#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Private EdtTableNo As EditText
Private EdtKOT As EditText
Private EdtSession As EditText
Private EdtPax As EditText
Private BtnKot As Button
Private BtnBill As Button
Private ACEdtCode As AutoCompleteEditText
Private ACEdtItem As AutoCompleteEditText
Private BtnDown As Button
Private BtnTrnsfr As Button
Private BtnDisBill As Button
Private EdtRate As EditText
Private EdtQty As EditText
Private Pnl As Panel
Private Label1 As Label
Private Label2 As Label
Private Label5 As Label
Private Label6 As Label
Private Label7 As Label
Private Label8 As Label
Private Label4 As Label
Private Label3 As Label
Dim Grid As xnGrid
Dim k As Double
Dim valuesdata, valuesdata2 As List
Dim rows As List
Dim m As Map
Private BtnDlt As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("billing")
Activity.Title = "POS-KOT & Billing"
m.Initialize
Pnl.Height = 100%y
Pnl.Width = 100%x
Dim job_1, job_2, job_3 As HttpJob
job_1.Initialize("Billing", Me)
job_2.Initialize("job_4", Me)
job_3.Initialize("job_3", Me)
job_1.Download("http://192.168.1.4/posapi/result/getresultdata")
job_2.PostString("http://192.168.1.4/posapi/session/getsessiondata","close=false")
job_3.PostString("http://192.168.1.4/posapi/kotno/updatedata", "kotno=12, posarea=30")
Dim t As Int : t = 5dip
Dim h As Int : h = 45dip
t = t + h
If Grid.IsInitialized = False Then
Grid.Initialize("Grid")
Grid.RowHeight = 25dip
Grid.HeaderHeight = 33dip
Grid.HeaderTextSize = 12
Grid.RowTextSize = 12
Grid.HeaderTextColor = Colors.Black
Grid.RowTextColor = Colors.Black
Grid.HeaderTypeface = Typeface.DEFAULT_BOLD
Grid.RowEvenColor = Colors.Transparent
Grid.RowOddColor = Colors.Transparent
Grid.HeaderColor = Colors.Transparent
Grid.SelectedEvenColor = Colors.Blue
Grid.SelectedOddColor = Colors.Blue
Dim cc(6) As xnGridCol
cc(0).Initialize2 ("Item Code", ACEdtCode.Text, 50dip, Gravity.TOP + Gravity.LEFT)
Grid.ColAppend (cc(0))
cc(1).Initialize2 ("Item Name", ACEdtItem.Text, 105dip, Gravity.TOP + Gravity.CENTER_HORIZONTAL)
Grid.ColAppend (cc(1))
cc(2).Initialize2 ("Qty.", EdtQty.Text , 50dip , Gravity.TOP + Gravity.CENTER_HORIZONTAL)
Grid.ColAppend (cc(2))
cc(3).Initialize2 ("Rate", EdtRate.Text, 50dip, Gravity.TOP + Gravity.CENTER_HORIZONTAL)
Grid.ColAppend (cc(3))
cc(4).Initialize2 ("Amt.", "", 50dip, Gravity.TOP + Gravity.CENTER_HORIZONTAL)
Grid.ColAppend (cc(4))
cc(5).Initialize2 ("Item Category", m.Get("itemcat"), 105dip, Gravity.TOP + Gravity.CENTER_HORIZONTAL)
Grid.ColAppend (cc(5))
Pnl.AddView(Grid, 6dip, 185dip, 310dip, 130dip)
Grid.Multiselect = False
Grid.GridWidth = 1dip
Grid.GridColor = Colors.Black
Grid.PixelFix = False
Grid.Color = Colors.LightGray
Dim t0 As Long
Dim t1 As Long
Dim dd As Long
t0 = DateTime.Now
Grid.GridCreate2(False)
t1 = DateTime.Now
dd = t1 - t0
Log (dd)
End If
ACEdtCode.TextSize = 14
ACEdtItem.TextSize = 14
EdtQty.TextSize = 14
EdtRate.TextSize = 14
EdtTableNo.InputType = EdtTableNo.INPUT_TYPE_NUMBERS
EdtTableNo.TextColor = Colors.Black
EdtKOT.InputType = EdtKOT.INPUT_TYPE_NUMBERS
EdtKOT.TextColor = Colors.Black
EdtPax.InputType = EdtPax.INPUT_TYPE_NUMBERS
EdtPax.TextColor = Colors.Black
EdtSession.TextColor = Colors.Black
EdtQty.InputType = EdtQty.INPUT_TYPE_NUMBERS
ACEdtCode.InputType = ACEdtCode.INPUT_TYPE_TEXT
ACEdtItem.InputType = ACEdtItem.INPUT_TYPE_TEXT
EdtQty.Textcolor = Colors.Black
EdtRate.TextColor = Colors.Black
EdtTableNo.Text= Table.tablno1
Label1.TextColor = Colors.Black
Label2.TextColor = Colors.Black
Label3.TextColor = Colors.Black
Label4.TextColor = Colors.Black
Label5.TextColor = Colors.Black
Label6.TextColor = Colors.Black
Label7.TextColor = Colors.Black
Label8.TextColor = Colors.Black
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub BtnDisBill_Click
StartActivity(DiscountBill)
Activity.Finish
End Sub
Sub BtnBill_Click
End Sub
Sub BtnKot_Click
Dim job_5 As HttpJob
job_5.Initialize("job", Me)
Dim k1 As Double
Dim ic As String
ic = m.Get("itemcat")
For i = 0 To Grid.RowCount - 1
job_5.Download2("http://192.168.1.4/posapi/insertKot/addkot", _
Array As String("KoTNo",EdtKOT.Text,"itemcode",Grid.GetValue(i,0),"itemcategory",ic,"unqno",2,"reason","vcsdawre","rate",Grid.GetValue(i,3),"amount",Grid.GetValue(i,4),"quantity",Grid.GetValue(i,2),"taxrate",0,"preferencepckey",123,"kotdate",DateTime.Now,"status","A","itempckey",1234))
Next
k = EdtKOT.Text
k1 = k + 1
Wait For (job_5) JobDone(job_5 As HttpJob)
If job_5.Success Then
Log(job_5.GetString)
Else
ToastMessageShow(job_5.ErrorMessage,True)
Return
End If
job_5.Release
Dim http3 As HttpJob
http3.Initialize("Billing",Me)
http3.Download2("http://192.168.1.4/posapi/kotno/updatedata", _
Array As String("KotNo=" & k1, "posarea=" & Table.code))
EdtTableNo.Text = ""
EdtKOT.Text = ""
EdtPax.Text = ""
EdtKOT.Text = k1
End Sub
Sub ACEdtItem_ItemClick (Value As String)
For i = 0 To rows.Size - 1
m = rows.Get(i)
If ACEdtItem.text = m.Get("ItemName") And Table.code = m.Get("poscode") Then
ACEdtCode.Text = m.Get("Itemcode")
EdtRate.Text = m.Get("Rate")
EdtQty.RequestFocus
End If
Next
Log(m.Get("Rate"))
End Sub
Sub ACEdtCode_ItemClick (Value As String)
For i = 0 To rows.Size - 1
m = rows.Get(i)
If ACEdtCode.text = m.Get("Itemcode") And Table.code = m.Get("poscode") Then
ACEdtItem.Text = m.Get("ItemName")
EdtRate.Text = m.Get("Rate")
EdtQty.RequestFocus
End If
Next
Log(m.Get("Rate"))
End Sub
Sub job1()
Dim http1 As HttpJob
Dim d As Double
d = Table.code
http1.Initialize("Billing",Me)
http1.PostString("http://192.168.1.4/posapi/kot/selectdata","posarea=" & d)
wait for (http1) JobDone(http1 As HttpJob)
If http1.Success Then
Select http1.JobName
Case "Billing"
Dim parser1 As JSONParser
Dim response1 As String = http1.GetString
parser1.Initialize(response1)
Dim rows1 As List
rows1.Initialize
rows1 = parser1.NextArray
For i = 0 To rows1.Size - 1
Dim m1 As Map
m1 = rows1.Get(i)
If Table.code = m1.Get("posarea") Then
EdtKOT.Text = m1.Get("KotNo")
Log(m1)
End If
Next
End Select
Else
Log("Error:" & http1.ErrorMessage)
End If
End Sub
Sub job2()
Dim http2 As HttpJob
http2.Initialize("Billing",Me)
http2.PostString("http://192.168.1.4/posapi/session/getsessiondata","closed=false")
wait for (http2) JobDone(http2 As HttpJob)
If http2.Success Then
Select http2.JobName
Case "Billing"
Dim parser1 As JSONParser
Dim response1 As String = http2.GetString
parser1.Initialize(response1)
Dim rows2 As List
rows2.Initialize
rows2 = parser1.NextArray
For i = 0 To rows2.Size - 1
Dim m3 As Map
m3 = rows2.Get(i)
If Table.close = m3.Get("closed") Then
EdtSession.Text = m3.Get("SessionName")
End If
Next
End Select
End If
End Sub
Sub job4()
Dim http4 As HttpJob
http4.Initialize("Billing",Me)
http4.Download("http://192.168.1.4/posapi/result/getresultdata")
wait for (http4) JobDone(http4 As HttpJob)
If http4.Success Then
Select http4.JobName
Case "Billing"
Dim parser As JSONParser
Dim response As String = http4.GetString
parser.Initialize(response)
valuesdata.Initialize
valuesdata2.Initialize
Dim str As String
Dim val As Int
rows.Initialize
rows = parser.NextArray
str = rows.Size
val = str
For i = 0 To val - 1
m = rows.Get(i)
If Table.code = m.Get("poscode") Then
valuesdata.Add(m.Get("ItemName"))
valuesdata2.Add(m.Get("Itemcode"))
ACEdtCode.SetItems(valuesdata2)
ACEdtItem.SetItems(valuesdata)
End If
Next
End Select
End If
End Sub
Sub JobDone (job_6 As HttpJob)
job1
job2
job4
job_6.Release
End Sub
Sub BtnDown_Click
If ACEdtCode.Text = "" Or ACEdtItem.Text = "" Or EdtQty.Text = "" Or EdtRate.Text = "" Then
Msgbox("You have to enter all fields","Missed data field")
Else
Grid.RowAppend(Array As String(ACEdtCode.Text, ACEdtItem.Text, EdtQty.Text, EdtRate.Text, (EdtRate.Text) * (EdtQty.Text), m.Get("itemcat")))
ACEdtCode.Text = ""
ACEdtItem.Text = ""
EdtQty.Text = ""
ACEdtCode.RequestFocus
EdtRate.Text = ""
End If
End Sub
Sub BtnTrnsfr_Click
StartActivity(TableTransfer)
End Sub
Sub BtnDlt_Click
Msgbox2Async("Do you want to Delete this row?", "Warning", "Yes", "", "No", Null, False)
Wait For MsgBox_Result (Result As Int)
If Result = DialogResponse.POSITIVE Then
Grid.RowDelete(Grid.RowSelected)
Else
End If
End Sub