Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a standard_user table which has these fields: id, name, year, user_id, course, monday, tuesday, wednesday, thursday, friday, and saturday.

I want monday, tuesday, wednesday, thursday, friday, and saturday to have (each of them):

table:
[(store_time)]
login_one
logout_one
login_two
logout_two
login_three
logout_three
login_four
logout_four


Most of the tutorials only uses console which has no database so it gets really confusing on how to create. Please help me...

What I have tried:

i have only tried something like this, since one-to-many relationship in windows form has no tutorials or something :(

SqlCommand cmd = new SqlCommand("insert into standard_user values (@name, @year, @standard_user_id, @course, @user_role, @login_time_one, @logout_time_one, @login_time_two, @logout_time_two, @login_time_three, @logout_time_three, @login_time_four, @logout_time_four)", con);
            cmd.Parameters.AddWithValue("@name", NameTextBox.Text);
            cmd.Parameters.AddWithValue("@year", ComboBoxYear.Text.ToString());
            cmd.Parameters.AddWithValue("@standard_user_id", IDTextBox.Text);
            cmd.Parameters.AddWithValue("@course", CourseTextBox.Text);
            cmd.Parameters.AddWithValue("@user_role", "Standard User");
Posted
Updated 8-Dec-19 9:44am

Quote:
I have a standard_user table which has these fields: id, name, year, user_id, course, monday, tuesday, wednesday, thursday, friday, and saturday.

I want monday, tuesday, wednesday, thursday, friday, and saturday to have (each of them):

table:
[(store_time)]
login_one
logout_one
login_two
logout_two
login_three
logout_three
login_four
logout_four


Well... I'd say it's NOT proper design.

You have to have only one table for storing log-in and log-out entries. For example:
[loginout]
entry_id --primary key
user_id --foreign key
course_id --foreign key
entrydatetime --date and time of entry; you'll be able to 'recognize' a weekday based on date!!!
entrytype -- text: {'IN', 'OUT'}


So, your standard_user table have to be changed accordingly...
 
Share this answer
 
Comments
Member 14561189 9-Dec-19 8:00am    
I am trying to "insert" the login and logout time for users in a specific date, for example, monday login_one: 7:30 am, logout_one: 9:30 am... and so on, a user can have up to 4 sets og login and logout time
It can be hard to find a good tutorial on relational databases, which is what you need in my opinion before proceeding to make a Windows forms application that uses a database.
Here are some suggestions:
what-are-best-resources-to-learn-database-fundamentals[^]
online-resources-to-learn-relational-database-design[^]

You might also be interested in a database design tool: relational-database-design-and-modelling-tools[^]

If you find relational databases too difficult and time consuming (especially SQL Server), and your needs are simple, take a look at: best-databases-for-a-small-net-application~litedb[^]

Here is an example on CodeProject that has login / logout tracking: Employee Attendance Tracking[^]
 
Share this answer
 
v3
Comments
Member 14561189 8-Dec-19 4:53am    
I am trying to implement a user that has many schedules sir :D
RickZeeland 8-Dec-19 6:29am    
See the updated solution, good luck !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900