D
Derek
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
SqlSelectCommand12.Parameters("@userid").Value =
CType(lbluserid.Text, Integer)
SqlDataAdapter12.Fill(Dsmaxtrxid1)
lblmaxtrxid.DataBind()
lastid = CType(lblmaxtrxid.Text, Integer)
'set details information and save
txtItem1.Visible = True
txtqty1.Visible = True
txtunit1.Visible = True
Dim qty1 As Decimal
Dim unit1 As Decimal
qty1 = CType(txtqty1.Text, 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.Text, Decimal)
txtEC.Text = ectext + EUC
End If
Dim ec As Decimal
ec = CType(lbleucost.Text, Decimal)
SqlUpdateCommand2.Parameters("@trxid").Value =
lastid
SqlUpdateCommand2.Parameters("@desc").Value =
txtItem1.Text
SqlUpdateCommand2.Parameters("@qty").Value = qty1
SqlUpdateCommand2.Parameters("@uc").Value = unit1
SqlUpdateCommand2.Parameters("@ec").Value = ec
SqlConnection1.Open()
SqlUpdateCommand2.ExecuteNonQuery()
SqlConnection1.Close()
txtEC.Visible = True
ShowFields()
txtItem1.Text = ""
txtqty1.Text = ""
txtunit1.Text = ""
lbleucost.Text = ""
txtItem1.TabIndex = 1
txtqty1.TabIndex = 2
txtunit1.TabIndex = 3
Button1.TabIndex = 4
resetTabs()
BindDetails()
' Updates the main table with the total estimated charges
Dim inttrx As Integer
inttrx = CType(lblmaxtrxid.Text, Integer)
SqlUpdateCommand5.Parameters("@ec").Value =
txtEC.Text
SqlUpdateCommand5.Parameters("@tid").Value =
inttrx
SqlConnection1.Open()
SqlUpdateCommand5.ExecuteNonQuery()
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
SqlSelectCommand12.Parameters("@userid").Value =
CType(lbluserid.Text, Integer)
SqlDataAdapter12.Fill(Dsmaxtrxid1)
lblmaxtrxid.DataBind()
lastid = CType(lblmaxtrxid.Text, Integer)
'set details information and save
txtItem1.Visible = True
txtqty1.Visible = True
txtunit1.Visible = True
Dim qty1 As Decimal
Dim unit1 As Decimal
qty1 = CType(txtqty1.Text, 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.Text, Decimal)
txtEC.Text = ectext + EUC
End If
Dim ec As Decimal
ec = CType(lbleucost.Text, Decimal)
SqlUpdateCommand2.Parameters("@trxid").Value =
lastid
SqlUpdateCommand2.Parameters("@desc").Value =
txtItem1.Text
SqlUpdateCommand2.Parameters("@qty").Value = qty1
SqlUpdateCommand2.Parameters("@uc").Value = unit1
SqlUpdateCommand2.Parameters("@ec").Value = ec
SqlConnection1.Open()
SqlUpdateCommand2.ExecuteNonQuery()
SqlConnection1.Close()
txtEC.Visible = True
ShowFields()
txtItem1.Text = ""
txtqty1.Text = ""
txtunit1.Text = ""
lbleucost.Text = ""
txtItem1.TabIndex = 1
txtqty1.TabIndex = 2
txtunit1.TabIndex = 3
Button1.TabIndex = 4
resetTabs()
BindDetails()
' Updates the main table with the total estimated charges
Dim inttrx As Integer
inttrx = CType(lblmaxtrxid.Text, Integer)
SqlUpdateCommand5.Parameters("@ec").Value =
txtEC.Text
SqlUpdateCommand5.Parameters("@tid").Value =
inttrx
SqlConnection1.Open()
SqlUpdateCommand5.ExecuteNonQuery()
SqlConnection1.Close()