kimprogrammer
Programmer
Hello
I'm want to update a database and am having problems with the datarowviews - I've tried a few things an am getting compile errors.
Thanks Again.
-----------------------------------------
'
'save Paycodes to database
'
Private Sub btnConfirm_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles btnConfirm.Click
'initialize variables
Dim Temptime As Decimal
Dim Hours As Decimal
Dim Minutes As Decimal
Dim StartDate As Date
Dim EndDate As Date
StartDate = DateTime.Parse(Me.cboPPStart.Text)
EndDate = StartDate.AddDays(14)
'TODO: This line of code loads data into the '_keyscan_payrollDataSet.SwipeAccumulativeHours' table. You can move, or remove it, as needed.
Me.SwipeAccumulativeHoursTableAdapter.FillByPayPeriodEmployee(Me._keyscan_payrollDataSet.SwipeAccumulativeHours, StartDate, EndDate, Employee)
'Dim newSwipeAccumulativeHoursRow As _keyscan_payrollDataSet.SwipeAccumulativeHoursRow
'newSwipeAccumulativeHoursRow = _keyscan_payrollDataSet.SwipeAccumulativeHours.newSwipeAccumulativeRow
Dim drvSwipeAccumulativeHoursRow As New DataRow()
'assign SwipeAccumulativeHours the employee number
newSwipeAccumulativeHoursRow.EmpNum = Me.cboEmployee.Text
'save supervisor Adjustment 1
Dim strReasoncode As String
Dim drReason As DataRow
For x As Integer = 1 To 14
If Me.txtAdjHour1(x).Text <> "" Or Val(Me.cboAdjMin1(x).Text) <> 0 Then
With drvSwipeAccumulativeHoursRow
.PPDay = CType(Me.lblPPDay(x).Text, Date)
strReasoncode = CStr(Me.cboAdjReason1(x).Text)
drReason = _keyscan_payrollDataSet.Supervisor_Reason_Xref.FindBySupReasonCode(strReasoncode)
.PayCode = (drReason("Paycode").ToString)
.SupReasonCode = Me.cboAdjReason1(x).Text
.InputType = "2"
Temptime = 0
Hours = CDec(Me.txtAdjHour1(x).Text)
Minutes = CDec(Me.cboAdjMin1(x).Text)
Select Case Minutes
Case 15
Minutes = CDec(0.25)
Case 30
Minutes = CDec(0.5)
Case 45
Minutes = CDec(0.75)
End Select
Temptime = Hours + Minutes
.Hours = Temptime
.Userid = Environment.UserName
.Timestamp = Now
_keyscan_payrollDataSet.SwipeAccumulativeHours.Rows.Add(newSwipeAccumulativeHoursRow)
End With
End If
Next
Try
Me.SwipeAccumulativeHoursBindingSource.EndEdit()
Me.SwipeAccumulativeHoursTableAdapter.Update(Me._keyscan_payrollDataSet.SwipeAccumulativeHours)
MessageBox.Show("Update successful", "", MessageBoxButtons.OK)
Catch ex As Exception
MessageBox.Show("Update failed - Try Again", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
'ClearForm()
End Sub
I'm want to update a database and am having problems with the datarowviews - I've tried a few things an am getting compile errors.
Thanks Again.
-----------------------------------------
'
'save Paycodes to database
'
Private Sub btnConfirm_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles btnConfirm.Click
'initialize variables
Dim Temptime As Decimal
Dim Hours As Decimal
Dim Minutes As Decimal
Dim StartDate As Date
Dim EndDate As Date
StartDate = DateTime.Parse(Me.cboPPStart.Text)
EndDate = StartDate.AddDays(14)
'TODO: This line of code loads data into the '_keyscan_payrollDataSet.SwipeAccumulativeHours' table. You can move, or remove it, as needed.
Me.SwipeAccumulativeHoursTableAdapter.FillByPayPeriodEmployee(Me._keyscan_payrollDataSet.SwipeAccumulativeHours, StartDate, EndDate, Employee)
'Dim newSwipeAccumulativeHoursRow As _keyscan_payrollDataSet.SwipeAccumulativeHoursRow
'newSwipeAccumulativeHoursRow = _keyscan_payrollDataSet.SwipeAccumulativeHours.newSwipeAccumulativeRow
Dim drvSwipeAccumulativeHoursRow As New DataRow()
'assign SwipeAccumulativeHours the employee number
newSwipeAccumulativeHoursRow.EmpNum = Me.cboEmployee.Text
'save supervisor Adjustment 1
Dim strReasoncode As String
Dim drReason As DataRow
For x As Integer = 1 To 14
If Me.txtAdjHour1(x).Text <> "" Or Val(Me.cboAdjMin1(x).Text) <> 0 Then
With drvSwipeAccumulativeHoursRow
.PPDay = CType(Me.lblPPDay(x).Text, Date)
strReasoncode = CStr(Me.cboAdjReason1(x).Text)
drReason = _keyscan_payrollDataSet.Supervisor_Reason_Xref.FindBySupReasonCode(strReasoncode)
.PayCode = (drReason("Paycode").ToString)
.SupReasonCode = Me.cboAdjReason1(x).Text
.InputType = "2"
Temptime = 0
Hours = CDec(Me.txtAdjHour1(x).Text)
Minutes = CDec(Me.cboAdjMin1(x).Text)
Select Case Minutes
Case 15
Minutes = CDec(0.25)
Case 30
Minutes = CDec(0.5)
Case 45
Minutes = CDec(0.75)
End Select
Temptime = Hours + Minutes
.Hours = Temptime
.Userid = Environment.UserName
.Timestamp = Now
_keyscan_payrollDataSet.SwipeAccumulativeHours.Rows.Add(newSwipeAccumulativeHoursRow)
End With
End If
Next
Try
Me.SwipeAccumulativeHoursBindingSource.EndEdit()
Me.SwipeAccumulativeHoursTableAdapter.Update(Me._keyscan_payrollDataSet.SwipeAccumulativeHours)
MessageBox.Show("Update successful", "", MessageBoxButtons.OK)
Catch ex As Exception
MessageBox.Show("Update failed - Try Again", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
'ClearForm()
End Sub