If Main.SQL1.ExecQuerySingleResult("SELECT COUNT('Item_Name') FROM Cart WHERE Item_Barcode='" & Barcode_TXT & "'") > 0 Then
'ToastMessageShow("Item Exist in Cart",False)
'Msgbox2Async("The item is in the cart Do you want to modify the quantity?", Barcode_TXT, "Yes", "", "No", Null, False)
Msgbox2Async("The item is already in the cart Do you want to modify the quantity?", Barcode_TXT, "Yes", "", "No", Null, False)
Wait For Msgbox_Result (Result As Int)
If Result = DialogResponse.POSITIVE Then
'The Error Start From Here
Dim xui2 As XUI
Dim dialog2 As B4XDialog
If dialog2.IsInitialized = False Then
dialog2.Initialize(Activity)
End If
Dim input As B4XInputTemplate
If input.IsInitialized = False Then
input.Initialize
End If
input.lblTitle.Text = "Enter the required quantity:"
input.lblTitle.SetTextAlignment("CENTER","RIGHT")
input.TextField1.Text=Main.SQL1.ExecQuerySingleResult("SELECT QTY FROM Cart WHERE Item_Barcode='" & Barcode_TXT & "'")
input.ConfigureForNumbers(False, False) 'AllowDecimals, AllowNegative
'Wait For (dialog2.ShowTemplate(input, "OK", "", "Cancel")) Complete (Result2 As Int)
Dim rs2 As ResumableSub = dialog2.ShowTemplate(input, "OK", "", "CANCEL")
'thewifidialog.GetButton(xui.DialogResponse_Positive).Enabled = False
Wait For (rs2) Complete (Result2 As Int)
If Result2 = xui2.DialogResponse_Positive Then
Dim res2 As Int = input.Text 'no need to check with IsNumber
'Log(res)
Main.SQL1.ExecNonQuery("UPDATE Cart SET QTY='" & res2 & "' WHERE Item_Barcode='" & Barcode_TXT & "'")
Load_Cart_Data
End If
End If
Else
Dim QTY_Dialog As InputDialog
QTY_Dialog.Input = 1
QTY_Dialog.InputType = QTY_Dialog.INPUT_TYPE_INTEGER
Dim sf As Object = QTY_Dialog.ShowAsync("", "QTY", "OK", "", "Cancel", Null, False)
Wait For (sf) Dialog_Result(Result As Int)
If Result = DialogResponse.POSITIVE Then
'Log(QTY_Dialog.Input)
If QTY_Dialog.Input > 0 Then
Module1.Insert_Into_Cart(QTY_Dialog.Input,Barcode_TXT)
Load_Cart_Data
'Sleep(0)
'Log(Cart_Items_CustomListView1.Size -1)
'ToastMessageShow(CustomListView1.Size -1,False)
Else
Msgbox("The quantity must be greater than zero",True)
End If
End If
End If