Click here to Skip to main content
16,016,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i need help ASAP ....i created an payroll system with automatic counted of total hours from 03/22/2018 to 03/25/2018

i have a MySQL database column No,Name,date,Position,time_IN and time_OUT
the DataGridView has 3 column, header date,time_IN and time_OUT

i have button "Fill", that once i click all the total time_IN and time_OUT of one employee from 03/22/2018 to 03/30/2018 show in textbox(total) and all the date, time_IN and time_OUT information must show in datagridview


i have time information here: (one employee)
date=22/03/2018,time_IN=7:00,time_OUT=17:30
date=23/03/2018,time_IN=6:30,time_OUT=17:20
date=24/03/2018,time_IN=6:45,time_OUT=17:05
date=25/03/2018,time_IN=6:10,time_OUT=17:10


note:any time and minute that is less than 7:00 will start her/his time at 7:00 and once it greater than 7:00 counted as 1 hour late

note: any time that is greater than 17:00 still counted as 17:00 then less than 16:30 counted as undertime

any comment and suggestion......

What I have tried:

i have try this code this is incomplete because from mysql query, the value i need to see to datagridview doesn't appear

VB
<pre> Try
             
                conn.Open()
                query = New MySqlCommand("SELECT No, Name, date,position,time_IN ,time_OUT From cash_table WHERE No=" & txtID.Text & " AND (date BETWEEN '" & DateTimePicker2.Value.Date & "' AND '" & DateTimePicker3.Value.Date & "')", conn)
                dr = query.ExecuteReader()
                If dr.HasRows Then
                    Do While dr.Read()
                        txtName.Text = dr.GetString("Name")
                        txtPosition.Text = dr.GetString("position")

                        arr(0) = dr.Item("date")
                        arr(1) = dr.Item("time_IN")
                        arr(2) = dr.Item("time_OUT")
                        DataGridView1.Rows.Add(arr)

                        time1 = dr.Item("time_IN")
                        time2 = dr.Item("time_OUT")

                 
                dr.Dispose()

            Catch ex As Exception
                MsgBox(ex.Message)

            Finally
                dr.Dispose()
                conn.Close()

            End Try

            If txtID.Text = "" Then
                DataGridView1.Rows.Clear()
                txtName.Clear()
                txtPosition.Clear()
            End If

        End If
Posted
Updated 23-Mar-18 20:51pm

1 solution

Repost: And if you don't listen to what we told you yesterday: What is the right computation for getting the total hours of time in and time out[^]
Then what is the point of telling you anything?

I will reiterate:
Quote:
Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use parameterized queries instead.
You will find the full reason why in yesterday's question and it's answers.
 
Share this answer
 

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