I am having a problem updating the main table (2nd set of
code) based on the total of all details entered (1st set
of code). It seems to be off by less than a dollar. I
thought it was a decimal issue but all my ctypes are set
to decimal. I am resetting all my textfields to "" after
adding the detail information. Any help would be
appreciated.
Here's the code:
'this updates the details table with the amounts
Dim lastid As Integer
SqlSelectComman d12.Parameters( "@userid").Valu e =
CType(lbluserid .Text, Integer)
SqlDataAdapter1 2.Fill(Dsmaxtrx id1)
lblmaxtrxid.Dat aBind()
lastid = CType(lblmaxtrx id.Text, Integer)
'set details information and save
txtItem1.Visibl e = True
txtqty1.Visible = True
txtunit1.Visibl e = True
Dim qty1 As Decimal
Dim unit1 As Decimal
qty1 = CType(txtqty1.T ext, Decimal)
unit1 = CType(txtunit1. Text, Decimal)
lbleucost.Text = qty1 * unit1
Dim EUC As Decimal
EUC = CType(lbleucost .Text, Decimal)
If txtEC.Text = "" Then
txtEC.Text = lbleucost.Text
Else
Dim ectext As Decimal
ectext = CType(txtEC.Tex t, Decimal)
txtEC.Text = ectext + EUC
End If
Dim ec As Decimal
ec = CType(lbleucost .Text, Decimal)
SqlUpdateComman d2.Parameters(" @trxid").Value =
lastid
SqlUpdateComman d2.Parameters(" @desc").Value =
txtItem1.Text
SqlUpdateComman d2.Parameters(" @qty").Value = qty1
SqlUpdateComman d2.Parameters(" @uc").Value = unit1
SqlUpdateComman d2.Parameters(" @ec").Value = ec
SqlConnection1. Open()
SqlUpdateComman d2.ExecuteNonQu ery()
SqlConnection1. Close()
txtEC.Visible = True
ShowFields()
txtItem1.Text = ""
txtqty1.Text = ""
txtunit1.Text = ""
lbleucost.Text = ""
txtItem1.TabInd ex = 1
txtqty1.TabInde x = 2
txtunit1.TabInd ex = 3
Button1.TabInde x = 4
resetTabs()
BindDetails()
' Updates the main table with the total estimated charges
Dim inttrx As Integer
inttrx = CType(lblmaxtrx id.Text, Integer)
SqlUpdateComman d5.Parameters(" @ec").Value =
txtEC.Text
SqlUpdateComman d5.Parameters(" @tid").Value =
inttrx
SqlConnection1. Open()
SqlUpdateComman d5.ExecuteNonQu ery()
SqlConnection1. Close()
code) based on the total of all details entered (1st set
of code). It seems to be off by less than a dollar. I
thought it was a decimal issue but all my ctypes are set
to decimal. I am resetting all my textfields to "" after
adding the detail information. Any help would be
appreciated.
Here's the code:
'this updates the details table with the amounts
Dim lastid As Integer
SqlSelectComman d12.Parameters( "@userid").Valu e =
CType(lbluserid .Text, Integer)
SqlDataAdapter1 2.Fill(Dsmaxtrx id1)
lblmaxtrxid.Dat aBind()
lastid = CType(lblmaxtrx id.Text, Integer)
'set details information and save
txtItem1.Visibl e = True
txtqty1.Visible = True
txtunit1.Visibl e = True
Dim qty1 As Decimal
Dim unit1 As Decimal
qty1 = CType(txtqty1.T ext, Decimal)
unit1 = CType(txtunit1. Text, Decimal)
lbleucost.Text = qty1 * unit1
Dim EUC As Decimal
EUC = CType(lbleucost .Text, Decimal)
If txtEC.Text = "" Then
txtEC.Text = lbleucost.Text
Else
Dim ectext As Decimal
ectext = CType(txtEC.Tex t, Decimal)
txtEC.Text = ectext + EUC
End If
Dim ec As Decimal
ec = CType(lbleucost .Text, Decimal)
SqlUpdateComman d2.Parameters(" @trxid").Value =
lastid
SqlUpdateComman d2.Parameters(" @desc").Value =
txtItem1.Text
SqlUpdateComman d2.Parameters(" @qty").Value = qty1
SqlUpdateComman d2.Parameters(" @uc").Value = unit1
SqlUpdateComman d2.Parameters(" @ec").Value = ec
SqlConnection1. Open()
SqlUpdateComman d2.ExecuteNonQu ery()
SqlConnection1. Close()
txtEC.Visible = True
ShowFields()
txtItem1.Text = ""
txtqty1.Text = ""
txtunit1.Text = ""
lbleucost.Text = ""
txtItem1.TabInd ex = 1
txtqty1.TabInde x = 2
txtunit1.TabInd ex = 3
Button1.TabInde x = 4
resetTabs()
BindDetails()
' Updates the main table with the total estimated charges
Dim inttrx As Integer
inttrx = CType(lblmaxtrx id.Text, Integer)
SqlUpdateComman d5.Parameters(" @ec").Value =
txtEC.Text
SqlUpdateComman d5.Parameters(" @tid").Value =
inttrx
SqlConnection1. Open()
SqlUpdateComman d5.ExecuteNonQu ery()
SqlConnection1. Close()
Comment