VB 2008 invoice screen. Bound data grid view to invoice detail table.
The detail records maintain the taxable status (IsTaxableColNbr) of the line item so if the customer Tax Rate changes the totals can be recalculated.
The Tax Rate may be zero.
When I click on the check box column (IsTaxableColNbr) everything works perfectly.
But if I click too fast the second click doesn't work properly and results in incorrect taxable/non-taxable totals.
I've tried using
directly but that didn't work either.
Also tried EndEdit and CancelEdit in various places with no luck.
Also tried using a variable to indicate this process isn't complete.
Am I missing something here?
What do I need to do to make this work?
Detail grid is bound as follows to a binding source
Auguy
Sylvania/Toledo Ohio
The detail records maintain the taxable status (IsTaxableColNbr) of the line item so if the customer Tax Rate changes the totals can be recalculated.
The Tax Rate may be zero.
When I click on the check box column (IsTaxableColNbr) everything works perfectly.
But if I click too fast the second click doesn't work properly and results in incorrect taxable/non-taxable totals.
I've tried using
Code:
Convert.ToBoolean(dgvr.Cells(IsTaxableColNbr).EditedFormattedValue)
Also tried EndEdit and CancelEdit in various places with no luck.
Also tried using a variable to indicate this process isn't complete.
Am I missing something here?
What do I need to do to make this work?
Code:
Private Sub dgvDetail_CellContentClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles dgvDetail.CellContentClick
If e.ColumnIndex = IsTaxableColNbr And e.RowIndex >= 0 Then
Dim RowNbr As Integer = e.RowIndex
Dim CurrentExtValue As Decimal
Dim TaxRate As Decimal
TaxRate = CDec(dtInvoiceMaster.Rows(0).Item("TaxRate"))
Dim dgvr As DataGridViewRow
dgvr = dgvDetail.Rows(RowNbr)
dgvr.Cells(IsTaxableColNbr).Value = Convert.ToBoolean(dgvr.Cells(IsTaxableColNbr).EditedFormattedValue)
If dgvr.Cells(ExtPriceColNbr).Value Is DBNull.Value Then
CurrentExtValue = gDecimalZero
ElseIf CStr(dgvr.Cells(ExtPriceColNbr).Value).Trim = "" Then
CurrentExtValue = gDecimalZero
Else
CurrentExtValue = CDec(dgvr.Cells(ExtPriceColNbr).Value)
End If
If Not TaxRate = gDecimalZero Then
If Convert.ToBoolean(dgvr.Cells(IsTaxableColNbr).Value) = True Then
dtInvoiceMaster.Rows(0).Item("NonTaxableTotal") = CDec(dtInvoiceMaster.Rows(0).Item("NonTaxableTotal")) - CurrentExtValue
dtInvoiceMaster.Rows(0).Item("TaxableTotal") = CDec(dtInvoiceMaster.Rows(0).Item("TaxableTotal")) + CurrentExtValue
Else
dtInvoiceMaster.Rows(0).Item("NonTaxableTotal") = CDec(dtInvoiceMaster.Rows(0).Item("NonTaxableTotal")) + CurrentExtValue
dtInvoiceMaster.Rows(0).Item("TaxableTotal") = CDec(dtInvoiceMaster.Rows(0).Item("TaxableTotal")) - CurrentExtValue
End If
End If
ReCalcInvoice()
End If
End Sub
Code:
bsInvoiceDetail.DataSource = dtInvoiceDetail
dgvDetail.DataSource = bsInvoiceDetail
Auguy
Sylvania/Toledo Ohio