I could do with a new pair of eyes going over this code for me to see where i have gone wrong as I can not seem to find it
First of I am using this to add item(s) to the DataGridView
Dim iInd As Integer = 0
Dim ItemToadd As String
Dim ItemToadd1 As String
Dim ItemFound As Integer = 0
ItemToAdd = "Pepsi Max Lime 500ml"
ItemToadd1 = "£1.80"
ListCurrentSale.Add(ListCurrentSale.Count, String.Padright(ItemToadd, 65) & String.PadLeft(ItemToadd1, 10))
'Find Item in Grid
For iInd = 0 To ProductGrid.Rows.Count - 1 ' Loop thoug the Product groop and add the offer codes to it
If ProductGrid[iInd, 1].Text = "4060800306982" Then
ItemFound = 1
Else
ItemFound = 0
Endif
Next
If iInd > 0 Then
iInd = iInd - 1
Else
iInd = 0
End If
If ItemFound = 0 Then
ProductGrid.Rows.Count += 1
ProductGrid[ProductGrid.Rows.Count - 1, 1].Text = "4060800306982"
ProductGrid[ProductGrid.Rows.Count - 1, 2].Text = 1
ProductGrid[ProductGrid.Rows.Count - 1, 3].Text = 180
Else
ProductGrid[iInd, 2].Text = (CInt(ProductGrid[iInd, 2].Text) + 1)
ProductGrid[iInd, 3].Text = (CInt(ProductGrid[iInd, 3].Text) + 180)
End If
and it works fine but if I add another item and then try to add the item again it does not update the existing row it adds a new row
Exanple say I have
4060800306982 2 360
then add
404010011 1 189
and then add another 4060800306982 in stead of showing
4060800306982 3 540
it shows
4060800306982 1 180
second Error I seem to get is when i press my "Total" key It calls SubTotalFunction and it works if I have the correct number in the System but it does not work if i have say 3 (example the Pepsi Offer 4060800306982 is 2 for £2.50 so If I had 3 in the scanned Qty field it errors out
this shows how the Promotions should work
If anyone has any recommendations as well as any whys to fix the code and improve it I am all Ears (as we say in the UK)
I have attached the Full Zip of the Mutilsaver project I am working on (I am still using 3.15.2)
' Gambas module file
Public Sub SubTotalFunction()
Dim SubTotal As Integer = 0
Dim iInd As Integer = 0
'get the total from the Product grid (grid1)
If FMain.ProductGrid.Rows.Count > 0 Then
For iInd = 0 To FMain.ProductGrid.Rows.Count - 1
'Dim TempStore As Integer =
SubTotal += CInteger(FMain.ProductGrid[iInd, 3].Text)
Next
Dim TotalToShow As String = Format((SubTotal / 100), "£0.00")
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, "")
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, String.Padright(" SUB TOTAL", 65) & String.PadLeft(TotalToShow, 10))
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, String(75, "-"))
ProcessOffers
' AddMSListTOscreen(SubTotal)
End If
End
Private Sub ProcessOffers()
Dim iInd As Integer = 0
Dim ScannedQty As Integer = 0
Dim OfferQty As Integer = 0
Dim ProductGot As Integer = 0
Dim OfferValue As Integer = 0
Dim OfferTotal As Integer = 0
For iInd = 0 To FMain.ProductGrid.Rows.Count - 1 ' Loop thoug the Product groop and add the offer codes to it
Select Case FMain.ProductGrid[iInd, 1].Text
Case "4060800306982"
FMain.ProductGrid[iInd, 0].Text = "00001"
Case "404010011"
FMain.ProductGrid[iInd, 0].Text = "00002"
Case "404010022"
FMain.ProductGrid[iInd, 0].Text = "00002"
End Select
Next
AddAllScannedItemsTogether
'apply offer
For iInd = 0 To FMain.OfferGrid.Rows.Count - 1 '
' This will loop though the Scanned products and work out the Got value for each Item
If FMain.ProductGrid.Rows.Count = 1 Then
If FMain.ProductGrid[0, 0].Text = FMain.OfferGrid[iInd, 0].Text Then
ScannedQty = CInt(FMain.ProductGrid[0, 2].Text)
OfferQty = CInt(FMain.OfferGrid[iInd, 2].Text)
FMain.OfferGrid[iInd, 4].Text = Format((ScannedQty / OfferQty), "0")
ProductGot = CInt(FMain.OfferGrid[iInd, 4].Text)
OfferValue = CInt(FMain.OfferGrid[iInd, 3].Text)
OfferTotal = (ProductGot * OfferValue)
FMain.OfferGrid[iInd, 6].Text = OfferTotal
End If
Else
If FMain.ProductGrid[iInd, 0].Text = FMain.OfferGrid[iInd, 0].Text Then
ScannedQty = CInt(FMain.OfferGrid[iInd, 5].Text)
OfferQty = CInt(FMain.OfferGrid[iInd, 2].Text)
FMain.OfferGrid[iInd, 4].Text = Format((ScannedQty / OfferQty), "0")
ProductGot = CInt(FMain.OfferGrid[iInd, 4].Text)
OfferValue = CInt(FMain.OfferGrid[iInd, 3].Text)
OfferTotal = (ProductGot * OfferValue)
FMain.OfferGrid[iInd, 6].Text = OfferTotal
End If
End If
Next
End
Private Sub AddAllScannedItemsTogether()
Dim iInd As Integer = 0
Dim iLoc As Integer = 0
Dim ScannedQty As Integer = 0
Dim OfferQty As Integer = 0
' Add all items togther to make a summary
For iInd = 0 To FMain.ProductGrid.Rows.Count - 1 ' Loop thoug the Product groop and add the offer codes to it
If FMain.ProductGrid[iInd, 0].Text = FMain.OfferGrid[iInd, 0].Text Then
iLoc = 0
If FMain.OfferGrid[iInd, 5].Text = "" Then ' Add New Value the table
FMain.OfferGrid[iInd, 5].Text = FMain.ProductGrid[iLoc, 2].Text
iInd = 0
Else
ScannedQty = CInt(FMain.OfferGrid[iInd, 5].Text)
ScannedQty += CInt(FMain.ProductGrid[0, 2].Text)
FMain.OfferGrid[iInd, 5].Text = ScannedQty
End If
End If
Next
End
Private Sub AddMSListTOscreen(TotalDue As Integer)
Dim iInd As Integer = 0
Dim TotalToShow As String
Dim NewSubTotal As Integer = TotalDue
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, " Mutilsavers")
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, " -----------")
For iInd = 0 To FMain.OfferGrid.Rows.Count - 1 ' Loop thoug the Promtion table and show all offers to the PoS
If FMain.OfferGrid[iInd, 4].Text <> "" Then ' A offer has been processed here
If CInt(FMain.OfferGrid[iInd, 4].Text) = 1 Then
TotalToShow = Format(CInt(FMain.OfferGrid[iInd, 6].Text) / 100, "£0.00")
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, String.Padright(FMain.OfferGrid[iInd, 1].Text, 65) & String.PadLeft(TotalToShow, 10))
Else
Dim QtyOfferBrack As String = Null
Dim OfferValue As String = Format(CInt(FMain.OfferGrid[iInd, 3].Text) / 100, "£0.00")
TotalToShow = Format(CInt(FMain.OfferGrid[iInd, 6].Text) / 100, "£0.00")
QtyOfferBrack = " " & FMain.OfferGrid[iInd, 4].Text & " @ " & OfferValue
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, FMain.OfferGrid[iInd, 1].Text)
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, String.Padright(QtyOfferBrack, 65) & String.PadLeft(TotalToShow, 10))
End If
NewSubTotal -= (CInt(FMain.OfferGrid[iInd, 5].Text))
End If
Next
TotalToShow = Format(NewSubTotal / 100, "£0.00")
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, String(75, "-"))
FMain.ListCurrentSale.Add(FMain.ListCurrentSale.Count, String.Padright(" TOTAL TO PAY", 65) & String.PadLeft(TotalToShow, 10))
End