I am creating a POS system and on the subtotal page I have various labels such as 'cash', 'card', 'voucher' etc. Say for example a customers total comes to £20 and they want to pay £10 of it in cash and the other £10 with their card, I am having problems getting the labels to total up as they should. The 'total tendered' label displays 0.000 even though it should say £20.00 and the balance and change labels always display 0.00 even if they should say other. I know this is very basic but I have tried to figure this other for ages now and im getting nowhere. I have also tried calling values in from the database but have had no joy with that either. Thanks.
(I only included one payment button click event as they are all the same except for the labels name changing e.g. lblcash.text would say lblcard.text in the card click event.)
Code:Private Sub btnCash_Click(sender As Object, e As EventArgs) Handles btnCash.Click 'Payment methods...........?? '2 cash entries 'cash and card 'gift voucher and cash 'gift voucher and card 'HAVING PROBLEMS GETTING CARD AND GIFT VOUCHERS TOGETHER WITH OTHER METHODS If txtCash.Text = "" Then MessageBox.Show("Please enter amount") ElseIf txtCash.Text >= "0.00" Then lblCash.Text = txtCash.Text lblCash.Text = FormatCurrency(lblCash.Text, 2) lblTotTend.Text = (lblCash.Text) + (lblCredit.Text) + (lblVoucher.Text) + (lblOther.Text) lblTotTend.Text = FormatCurrency(lblTotTend.Text, 2) 'DISPLAYING AS £0.00 lblBALANCE.Text = (lblTOTALDUE.Text) - (lblTotTend.Text) lblBALANCE.Text = FormatCurrency(lblBALANCE.Text, 2) If lblBALANCE.Text < "0.00" Then lblBALANCE.Text = "£0.00" End If lblChange.Text = (lblTotTend.Text) - (lblTOTALDUE.Text) lblChange.Text = FormatCurrency(lblChange.Text, 2) If lblChange.Text <= "£0.00" Then lblChange.Text = "£0.00" End If txtCash.Text = "" SqlStr = "UPDATE Subtotal SET CASH = '" & lblCash.Text & "'" With CMD .Connection = CN .CommandType = CommandType.Text .CommandText = SqlStr End With DataP = CMD.ExecuteScalar SqlStr = "UPDATE Subtotal SET CHANGE = '" & lblChange.Text & "'" With CMD .Connection = CN .CommandType = CommandType.Text .CommandText = SqlStr End With DataP = CMD.ExecuteScalar SqlStr = "UPDATE Subtotal SET BalanceRemain = '" & lblBALANCE.Text & "'" With CMD .Connection = CN .CommandType = CommandType.Text .CommandText = SqlStr End With DataP = CMD.ExecuteScalar SqlStr = "UPDATE Subtotal SET TotalTendered = '" & lblTotTend.Text & "'" With CMD .Connection = CN .CommandType = CommandType.Text .CommandText = SqlStr End With DataP = CMD.ExecuteScalar End If SqlStr = "INSERT INTO SalesLog(ReceiptID) SELECT Id FROM Subtotal" With CMD .Connection = CN .CommandType = CommandType.Text .CommandText = SqlStr End With DataP = CMD.ExecuteNonQuery SqlStr = "INSERT INTO TransactionLog(ReceiptID) SELECT Id FROM Subtotal" With CMD .Connection = CN .CommandType = CommandType.Text .CommandText = SqlStr End With DataP = CMD.ExecuteNonQuery ' Added this statement to try solve problem with totaltendered label SqlStr = "SELECT SUM(TotalTendered) FROM Subtotal" With CMD .Connection = CN .CommandType = CommandType.Text .CommandText = SqlStr End With lblTotTend.Text = CMD.ExecuteScalar lblTotTend.Text = FormatCurrency(lblTotTend.Text, 2) 'UPDATES THE PRICE LABEL TEXTBOX WITH THE LATEST PRICE TOTAL WITHIN THE ACTIVE TABLE!! SqlStr = Nothing SqlStr = "SELECT SUM(Price) FROM Active" With CMD .Connection = CN .CommandType = CommandType.Text .CommandText = SqlStr End With lblTOTALDUE.Text = CMD.ExecuteScalar ' lblTOTALDUE.Text = FormatCurrency(lblTOTALDUE.Text, 2) If lblBALANCE.Text = "£0.00" Then Reset() Application.DoEvents() 'TILL DRAWER OPEN Threading.Thread.Sleep(5000) Me.Close() Login.Show() End If




Reply With Quote
