Hello..I am working on project based on Human resource Management system using vb6 as front end!..I want to know how to design a timesheet?..will it be possible using datagrid? :X

Dani AI

Generated

Practical design notes for a VB6 timesheet to record login/logout and compute pay totals. As requested a simple capture of login and logout times, and as noted, exact requirements drive the choice, the usual approach is to store full timestamps in the database and compute durations in VB6 when the logout is recorded.

Suggested minimal table (one row per work period):

  • TimesheetID (autonumber)
  • EmployeeID (integer)
  • WorkDate (date) ; date of the shift start
  • LoginTime (datetime)
  • LogoutTime (datetime)
  • BreakMinutes (integer)
  • HoursWorked (numeric/decimal)
  • Notes, CreatedAt, UpdatedAt

For display/editing: a DataGrid bound to an ADODB.Recordset works well for basic editing. MSFlexGrid is read-only and needs extra code to save edits. Always use parameterized ADODB commands to insert/update datetime values to avoid locale/format issues.

Example VB6 snippets (compute hours and insert a login):

Dim totalSeconds As Long
Dim totalHours As Double

totalSeconds = DateDiff("s", CDate(rs("LoginTime").Value), CDate(rs("LogoutTime").Value))
totalHours = totalSeconds / 3600
totalHours = Round(totalHours, 2) ' store two-decimal hours

Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandText = "INSERT INTO Timesheet (EmployeeID, WorkDate, LoginTime) VALUES (?, ?, ?)"
cmd.Prepared = True
cmd.Parameters.Append cmd.CreateParameter(, adInteger, adParamInput, , employeeID)
cmd.Parameters.Append cmd.CreateParameter(, adDate, adParamInput, , Date)
cmd.Parameters.Append cmd.CreateParameter(, adDate, adParamInput, , Now)
cmd.Execute

Cautions/troubleshooting: handle overnight shifts (logout next day), multiple clock-ins per day, breaks, daylight saving changes, and payroll rounding rules. Prefer storing UTC timestamps on the server and converting for display when local time matters. Validate for duplicate inserts (accidental double-click) and enforce database constraints for integrity.

Recommended Answers

All 2 Replies

It all depends on what you want the user to see. You need to give us much more information in order for us to help you.

Well I need it like if the user login, the time has to be noted and even the log out time.Then the calculation of hours for the summing up for the pay :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.