Dim timeSummary As TimeSpan
Dim workedCount As Integer = 0
Dim workedCount1 As Integer = 0
Dim workdalivery As Integer = 0
For Each row As DataGridViewRow In dgvTimework.Rows
If row.Cells("statustime").Value = "เข้าสาย" Then
Dim timeString As String = Convert.ToString(row.Cells("timelad").Value)
Dim time As TimeSpan = TimeSpan.Parse(timeString)
timeSummary = timeSummary.Add(time)
workedCount += 1
End If
If row.Cells("statusleave").Value = "ทำงาน" Then
workedCount1 += 1
End If
If row.Cells("statusleave").Value = "ลากิจ" Or "ลาป่วย" Or "ลาพักร้อน" Or "ลาบวช" Or "ลาคลอด" Then
workdalivery += 1
End If
If row.Cells("statusleave").Value = "ลากิจ" Or row.Cells("statusleave").Value = "ลาป่วย" Or row.Cells("statusleave").Value = "ลาพักร้อน" Or row.Cells("statusleave").Value = "ลาบวช" Or row.Cells("statusleave").Value = "ลาคลอด" Then
workdalivery += 1
End If
ผมเขียนไว้แบบนี้ แล้ว errer ครับ
Dim timeot As TimeSpan
Dim workedot As Integer = 0
For Each row As DataGridViewRow In dgvTimework.Rows
If row.Cells("statusleave").Value = "ทำงาน" Then
Dim worktimeot As String = Convert.ToString(row.Cells("ot").Value)
Dim workot As TimeSpan = TimeSpan.Parse(worktimeot)
timeot = timeot.Add(workot)
workedot += 1
End If
Next
Private Sub sumtotaltime()
Dim jamkerja As Short
Dim timespan As new TimeSpan(0, 0, 0, 0, 0)
jamkerja = 0
For t As Integer = 0 To DGVexcel.Rows.Count - 1
'jamkerja = jamkerja + Val(DGVexcel.Rows(t).Cells(7).Value)
Dim value = Val(DGVexcel.Rows(t).Cells(7).Value)
Dim interval As TimeSpan
If Not TimeSpan.TryParse(value, interval)
timespan.Add(interval)
End If
Next
txtjamkerja.Text = timespan.ToString()
End Sub
Private Sub sumtotaltime()
Try
Dim jamkerja As Short
Dim timespan As New TimeSpan(0, 0, 0, 0, 0)
jamkerja = 0
For t As Integer = 0 To dgvTimework.Rows.Count - 1
'jamkerja = jamkerja + Val(DGVexcel.Rows(t).Cells(7).Value)
Dim value = Val(dgvTimework.Rows(t).Cells("ot").Value)
Dim interval As TimeSpan
If Not TimeSpan.TryParse(value, interval) Then
timespan.Add(interval)
End If
Next
txtOt.Text = timespan.ToString("hh\:mm\:ss")
Catch ex As Exception
Dim timeot As TimeSpan
Dim workedot As Integer = 0
For Each row1 As DataGridViewRow In dgvTimework.Rows
If row1.Cells("ot").Value > "00:00:00" Then
Dim worktimeot As String = Convert.ToString(row1.Cells("ot").Value)
Dim workot As TimeSpan = TimeSpan.Parse(worktimeot)
timeot = timeot.Add(workot)
workedot += 1
End If
Next
For Each row1 As DataGridViewRow In dgvTimework.Rows
If row1.Cells("ot").Value.ToString <> String.Empty Then
timeot = timeot.Add(TimeSpan.Parse(row1.Cells("ot").Value.ToString()))
'workedot += 1
End If
Next
Dim timeot As TimeSpan
Dim workedot As Integer = 0
For Each row1 As DataGridViewRow In dgvTimework.Rows
If row1.Cells("ot").Value.ToString <> String.Empty Then
timeot = timeot.Add(TimeSpan.Parse(row1.Cells("ot").Value.ToString()))
End If
Dim OTCount Integer = 0
For Each row1 As DataGridViewRow In dgvTimework.Rows
If row1.Cells("ot").Value.ToString <> String.Empty AND TimeSpan.Parse(row1.Cells("ot").Value.ToString()) >0Then
timeot = timeot.Add(TimeSpan.Parse(row1.Cells("ot").Value.ToString()))
OTCount +=1
End If
Next
Dim timeot As TimeSpan
'Dim workedot As Integer = 0
Dim OTCount As Integer = 0
For Each row1 As DataGridViewRow In dgvTimework.Rows
If row1.Cells("ot").Value.ToString <> String.Empty And TimeSpan.Parse(row1.Cells("ot").Value.ToString()) > 0 Then
timeot = timeot.Add(TimeSpan.Parse(row1.Cells("ot").Value.ToString()))
OTCount += 1
End If