I have scoured the books I have, and hit every site online that even vaguely mentions anything close to my calculations. I have something working, what I want to know is if I have some hidden problem that I might not see. I don't want this thing mis-adding for some weird combination.
I got mixed results on the ExecuteScalar, and ended up going with straight calculations since my Tax, SubTotal and GrandTotal needed the ItemPrice and the LogoPrice to do their thing. ExecuteScalar tended to count my lines of items, which is ok, unless someone orders 2 of the same item, then it only counted it as 1.
Code:
Function GetItemTotal(extension as string) As Decimal
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Dim lblTotal As String
Dim decRunningTotal As Decimal = 0
Dim objRdr As SqlDataReader
Dim itemQu as integer = 0
objConn = new SqlConnection("server=(); User ID=();Password=();database=();connect timeout=30")
objCmd = new SqlCommand("SELECT ItemPrice, LogoPrice, ItemQuantity FROM Order WHERE Extension = '" & Extension & "'", objConn)
objConn.Open()
objRdr = objCmd.ExecuteReader()
While objRdr.Read
decRunningTotal += FormatCurrency(((objRdr.Item("ItemPrice") + objRdr.Item("LogoPrice")) * objRdr.Item("ItemQuantity")),2)
itemQu += Cint(ObjRdr.item("ItemQuantity"))
End While
taxlbl.text = FormatCurrency((decRunningTotal * .07),2)
Dim QoItems as Integer
QoItems = itemQu
if QoItems <4 then
shiplbl.text = FormatCurrency(("1"),2)
elseif QoItems >5 then
shiplbl.text = FormatCurrency(("3"),2)
else
shiplbl.text = FormatCurrency(("2"),2)
end if
GrandTotallbl.text = FormatCurrency((decRunningTotal + taxlbl.text + shiplbl.text),2)
Return decRunningTotal
objConn.Close()
End Function