#Region Project Attributes
#ApplicationLabel: CameraBarcode
#VersionCode: 1
#VersionName: 18.0.0.1
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\ResourceBarcode
'#AdditionalRes: $AdditionalLibs$\b4a_appcompat, de.amberhome.objects.appcompat
'#AdditionalRes: $AndroidSDK$\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: $AndroidSDK$\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#Extends: android.support.v7.app.AppCompatActivity
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SpinnerMap As Map
Dim TableList As List
Dim StrTableCode As String
Dim intKeyBoardMode As Int
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Button1 As Button
Private TxtCutSlipNo As EditText
Private CboStage As Spinner
Private CmdExit As Button
Private CmdNext As Button
Private CmdPrev As Button
Private CmdSave As Button
Private TxtColor As EditText
Private TxtOrderNo As EditText
Private TxtPairs As EditText
Private TxtStyleNo As EditText
Dim p As Phone
Dim vib As PhoneVibrate
Dim objCurrentView As EditText
Dim btnShift As Button
Dim btnSpecChar As Button
Private CmdCancel As Button
Private LblStatus As Label
Dim StrSql As String
Dim Table1 As Table
Dim StrURLPath As String
Private TxtEmpCode As EditText
Private TxtOpeartions As EditText
Private TxtDeptName As EditText
Private TxtName As EditText
Dim StrEnCode As StringUtils
Dim StrDate As String
Dim StrStyleNo As String
Dim pnlKeyboard As Panel
Private CboTable As Spinner
Private CmdBack As Button
Private CmdCheckList As Button
Private Panel1 As Panel
Private TxtHours As EditText
Dim StrMode As String
Dim IntPairs As Int
Private CmdClear1 As Button
Private CmdClear2 As Button
Private CmdKeyBoard As Button
Private CmdOpClear As Button
Private CmdWIP As Button
Private ChkOT As CheckBox
Dim IntOT As Int
Private builder As BarcodeScannerBuilder
Private scanner As BarcodeScanner
Private CmdEScan As Button
Private CmdSCutSlip As Button
Dim StrScanTag As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("ProductionEntry")
Activity.Title = "Production Barcode : " & getVersion
If FirstTime = True Then
intKeyBoardMode = 1
StrURLPath = "http://192.168.1.6:85/"
builder.Initialize("Barcode").BleepEnabled(True).EnableAutoFocus(True).withBackfacingCamera
builder.setText("Glove Division")
builder.setTrackerColor(Colors.Red)
builder.FlashLightEnabledByDefault
DateTime.DateFormat = "yyyy-MM-dd"
StrDate = DateTime.Date(DateTime.Now)
SpinnerMap.Initialize
StrSql = StrEnCode.EncodeUrl("Select OperationTableCode,OperationTableName from GloveERP.Dbo.Common_Ref_OperationsTable ","UTF8")
ExecuteQuery("FrmGetQuery.aspx",StrSql,"TableList")
Else
For Each colroot As Map In TableList
CboTable.Add(colroot.Get("OperationTableName"))
SpinnerMap.Put(colroot.Get("OperationTableName"), colroot.Get("OperationTableCode"))
Next
End If
' For j = 0 To pnlKeyboard.NumberOfViews - 1
' If pnlKeyboard.GetView(j) Is Button Then
' Dim btnTemp As Button
' btnTemp = pnlKeyboard.GetView(j)
' ninePatch.SetNinePatchButton(btnTemp, "normal", "pressed")
' End If
' Next
End Sub
Sub getVersion As String
Dim PM As PackageManager
Return PM.GetVersionName(GetPackageName)
End Sub
Sub GetVersionCode As Int
Dim PM As PackageManager
Return PM.GetVersionCode(GetPackageName)
End Sub
Sub GetApplicationLabel As String
Dim PM As PackageManager
Return PM.GetApplicationLabel(GetPackageName)
End Sub
Sub GetPackageName As String
Dim r As Reflector
Return r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed = True Then
ExitApplication
End If
End Sub
Sub CmdSave_Click
If ChkOT.Checked = True Then
IntOT = 1
Else
IntOT = 0
End If
' If (TxtPairs.Text <>"") Then
' ExecuteQuery("FrmUpDateRecords.aspx","Arind.Dbo.SpProductionEntry '" & TxtCutSlipNo.Text & "','" & TxtOpeartions.Text & "', '" & TxtEmpCode.Text & "','" & TxtName.Text & "','" & StrStyleNo & "', " & TxtPairs.Text & "," & IntOT & ",'" & TxtHours.Text & "','" & StrTableCode & "' ","UpDateProduction")
' Else
' LblStatus.Text = "You can not Save this CutSlip"
' End If
Dim gen As JSONGenerator
'1
Dim m As Map
m.Initialize
m.Put("OpCode", TxtOpeartions.Text)
m.Put("EmpCode", TxtEmpCode.Text)
m.Put("EmpName", TxtName.Text)
m.Put("CutSlip", TxtCutSlipNo.Text)
m.Put("StyleNo", StrStyleNo)
m.Put("Pairs", TxtPairs.Text)
m.Put("OT", IntOT)
m.Put("Hours", TxtHours.Text)
m.Put("TableCode", StrTableCode)
m.Put("Message", "Test")
gen.Initialize(m)
'Msgbox(gen.ToPrettyString(4), "Example 1")
Dim Job As HttpJob
Job.Initialize("UpDateProduction", Me)
Dim StrPostURL As String
StrPostURL = "http://192.168.1.6:85/WebAPI/api/ProductionEntry/UpdateProduction"
Job.PatchString(StrPostURL,gen)
Job.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0")
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
Wait For (Job) JobDone(j As HttpJob)
If j.Success Then
'The result is a json string. We parse it and log the fields.
Log(j.GetString)
LblStatus.Text = j.GetString()
TxtCutSlipNo.Text = ""
TxtOrderNo.Text = ""
TxtPairs.Text = ""
TxtEmpCode.Text = ""
TxtName.Text = ""
'LblStatus.Text = ""
IntPairs = 0
TxtEmpCode.RequestFocus
'Dim jp As JSONParser
'jp.Initialize(j.GetString)
Else
'Log(j.ErrorMessage)
Msgbox(j.ErrorMessage,"")
End If
j.Release
End Sub
Sub CmdExit_Click
ExitApplication
End Sub
Sub ExecuteQuery(StrPage As String,Query As String,StrJobName As String)
Dim Job As HttpJob
Job.Initialize(StrJobName, Me)
Job.PostString(StrURLPath & "Android/" & StrPage &"?Query="&Query,"")
ProgressDialogShow("Calling KHARIND server...")
End Sub
Sub JobDone (Job As HttpJob)
Try
'Msgbox(Job.JobName,"")
'Msgbox(Job.GetString(),"")
If Job.Success Then
LblStatus.Text = ""
If (Job.JobName = "EmployeeDetails") Then
If Job.GetString() = "[]" Then
LblStatus.Text = "Please check Attendance"
Else
Dim parser As JSONParser
parser.Initialize(Job.GetString())
Dim root As List = parser.NextArray
For Each colroot As Map In root
TxtName.Text = colroot.Get("EmpName")
TxtOpeartions.Text = colroot.Get("OpCode")
TxtCutSlipNo.RequestFocus
Next
End If
Else if (Job.JobName = "CutSlipDetails") Then
If Job.GetString() = "[]" Then
LblStatus.Text = "Invalid Cut Slip"
Else
Dim parser As JSONParser
parser.Initialize(Job.GetString())
Dim root As List = parser.NextArray
For Each colroot As Map In root
If colroot.Get("Pairs")> 0 Then
TxtOrderNo.Text = colroot.Get("OrderNo") & " / " & colroot.Get("StyleNo") & " / " & colroot.Get("Color")
TxtPairs.Text = colroot.Get("Pairs")
StrStyleNo = colroot.Get("StyleNo")
IntPairs = TxtPairs.Text
Else
LblStatus.Text = "Production already finish for this Operations...."
End If
Next
End If
else if (Job.JobName = "TableList") Then
Dim parser As JSONParser
parser.Initialize(Job.GetString())
TableList = parser.NextArray
For Each colroot As Map In TableList
CboTable.Add(colroot.Get("OperationTableName"))
SpinnerMap.Put(colroot.Get("OperationTableName"), colroot.Get("OperationTableCode"))
Next
StrTableCode = SpinnerMap.Get(CboTable.SelectedItem)
else if (Job.JobName = "OperationDetails") Then
Dim parser As JSONParser
parser.Initialize(Job.GetString())
Dim root As List = parser.NextArray
For Each colroot As Map In root
TxtHours.Text = colroot.Get("Hours")
TxtCutSlipNo.RequestFocus
Next
End If
ProgressDialogHide
Else
Log(Job.ErrorMessage)
Msgbox("Failed","")
Msgbox(Job.ErrorMessage,"")
ProgressDialogHide
End If
Job.Release
Catch
Msgbox(LastException,"")
ProgressDialogHide
End Try
End Sub
Sub CmdCancel_Click
ClearAll
LblStatus.Text = ""
TxtCutSlipNo.Text = ""
TxtOrderNo.Text = ""
TxtPairs.Text = ""
TxtEmpCode.Text = ""
TxtName.Text = ""
TxtOpeartions.Text = ""
IntPairs=0
TxtEmpCode.RequestFocus
End Sub
Sub ClearAll()
TxtCutSlipNo.Text = ""
TxtOrderNo.Text = ""
TxtPairs.Text = ""
TxtEmpCode.Text = ""
TxtName.Text = ""
TxtEmpCode.RequestFocus
End Sub
Sub TxtOpeartions_EnterPressed
StrSql = StrEnCode.EncodeUrl("Select IsNull(Max(Hours),8)Hours from Arind.Dbo.ProdEntry Where (Entrydt = Convert(Char(10),GetDate(),120)) And (EmpCode = '" & TxtEmpCode.Text & "' ) And (OpCode = '" & TxtOpeartions.Text & "') ","UTF8")
ExecuteQuery("FrmGetQuery.aspx",StrSql,"OperationDetails")
End Sub
Sub TxtEmpCode_EnterPressed
StrSql = StrEnCode.EncodeUrl("Select M.EmpName,D.DeptName Department,IsNull(F.OpCode,'')OpCode,IsNull(F.Operations,'') Operations from Arind.Dbo.HrEmpMas M Join Arind.Dbo.Department D On D.DeptCode = M.deptcode Join (Select EmpCode,Count(*)Counts from Arind.Dbo.AttendanceLog Where (Convert(Char(10),LogDate,120) = Convert(Char(10),GetDate(),120)) Group by EmpCode Having Count(*)>0) E On (E.EmpCode = M.Empcode) Left Join Arind.Dbo.OperatorSkill F On (F.EmpCode = M.EmpCode) Where (M.EmpCode = '" & TxtEmpCode.Text & "') And (M.OnRolls = 'Y') ","UTF8")
ExecuteQuery("FrmGetQuery.aspx",StrSql,"EmployeeDetails")
End Sub
Sub TxtCutSlipNo_EnterPressed
StrSql = "Select C.OrdNo OrderNo, C.StyleNo,CC.coldesc Color,((C.S6 + C.S7 + C.S8 + C.S9 + C.S10 + C.S11 + C.S12)-IsNull((Select Sum(Pairs) from (Select IsNull(FlowProc.SlNo, 0) SlNo, (IsNull(B.Size06, 0) + IsNull(B.Size07, 0) + IsNull(B.Size08, 0) + IsNull(B.Size09, 0) + IsNull(B.Size10, 0) + IsNull(B.Size11, 0) + IsNull(B.Size12, 0)) Pairs from GloveErp.Dbo.Qa_Trn_BookingDetails B Join GloveErp.Dbo.Qa_Trn_BookingHeader H On H.BookingHeaderId = B.BookingHeaderId Join Arind.Dbo.CutSlipWip C On C.JcNo = H.CutSlip Left Join Arind.Dbo.FlowProc On (FlowProc.StyleNo = C.StyleNo)And(FlowProc.OpCode = H.Operation) Where (H.CutSlip = '" & TxtCutSlipNo.Text & "')And(H.BookedDate <= Convert(Char(10),GetDate(),120))) N "
StrSql = StrSql & "Where Convert(Int, N.SlNo) < Convert(Int, F.SlNo)), 0))- IsNull(P.Pairs, 0) Pairs from Arind.Dbo.CutSlipWip C Join Arind.Dbo.FlowProc F On (F.StyleNo = C.StyleNo)And(F.OpCode = '" & TxtOpeartions.Text & "') Left Join (Select JcNo, Sum(Qty) Pairs from Arind.Dbo.ProdEntry Where (JcNo = '" & TxtCutSlipNo.Text & "')And(OpCode = '" & TxtOpeartions.Text & "') Group by JcNo) P On P.JcNo = C.JcNo Join Arind.Dbo.Color CC On (CC.ColCode = C.ColCode) Where C.JcNo = '" & TxtCutSlipNo.Text & "' "
'StrSql = StrEnCode.EncodeUrl("Select C.OrdNo OrderNo, C.StyleNo,CC.coldesc Color,((C.S6 + C.S7 + C.S8 + C.S9 + C.S10 + C.S11 + C.S12)-IsNull((Select Sum(Pairs) from (Select IsNull(FlowProc.SlNo, 0) SlNo, (IsNull(B.Size06, 0) + IsNull(B.Size07, 0) + IsNull(B.Size08, 0) + IsNull(B.Size09, 0) + IsNull(B.Size10, 0) + IsNull(B.Size11, 0) + IsNull(B.Size12, 0)) Pairs from GloveErp.Dbo.Qa_Trn_BookingDetails B Join GloveErp.Dbo.Qa_Trn_BookingHeader H On H.BookingHeaderId = B.BookingHeaderId Join Arind.Dbo.CutSlipWip C On C.JcNo = H.CutSlip Left Join Arind.Dbo.FlowProc On (FlowProc.StyleNo = C.StyleNo)And(FlowProc.OpCode = H.Operation) Where (H.CutSlip = '" & TxtCutSlipNo.Text & "')And(H.BookedDate <= Convert(Char(10),GetDate(),120))) N Where Convert(Int, N.SlNo) < Convert(Int, F.SlNo)), 0))- IsNull(P.Pairs, 0) Pairs from Arind.Dbo.CutSlipWip C Join Arind.Dbo.FlowProc F On (F.StyleNo = C.StyleNo)And(F.OpCode = '" & TxtOpeartions.Text & "') Left Join (Select JcNo, Sum(Qty) Pairs from Arind.Dbo.ProdEntry Where (JcNo = '" & TxtCutSlipNo.Text & "')And(OpCode = '" & TxtOpeartions.Text & "') Group by JcNo) P On P.JcNo = C.JcNo Join Arind.Dbo.Color CC On (CC.ColCode = C.ColCode) Where C.JcNo = '" & TxtCutSlipNo.Text & "' ","UTF8")
StrSql = StrEnCode.EncodeUrl(StrSql,"UTF8")
ExecuteQuery("FrmGetQuery.aspx",StrSql,"CutSlipDetails")
End Sub
Sub CboTable_ItemClick (Position As Int, Value As Object)
StrTableCode = SpinnerMap.Get(Value)
End Sub
Sub CmdBack_Click
Panel1.Visible = False
End Sub
Sub CmdCheckList_Click
If CboTable.SelectedItem <> "" Then
CallSubDelayed2(FrmCheckList, "LoadGrid", StrTableCode )
Else
Msgbox("Please Enter Operation Code","BarCode")
End If
End Sub
Sub TxtHours_FocusChanged (HasFocus As Boolean)
End Sub
Sub CmdClear2_Click
TxtPairs.Text = ""
End Sub
Sub CmdClear1_Click
TxtHours.Text = ""
End Sub
Sub CmdOpClear_Click
TxtOpeartions.Text = ""
TxtOpeartions.RequestFocus
End Sub
Sub CmdWIP_Click
If TxtCutSlipNo.Text <> "" Then
CallSubDelayed2(FrmCheckList, "LoadGrid2", TxtCutSlipNo.Text)
Else
Msgbox("Please Enter CutSlip","BarCode")
End If
End Sub
Sub CmdEScan_Click
StrScanTag = "E"
LblStatus.Text = ""
scanner = builder.Initialize("Barcode").BleepEnabled(True).EnableAutoFocus(True).withBackfacingCamera.setText("DonManfred presents").setTrackerColor(Colors.Red).build
builder.setText("Glove Division")
builder.setTrackerColor(Colors.Red)
builder.FlashLightEnabledByDefault
scanner.startScan
End Sub
Sub CmdSCutSlip_Click
StrScanTag = "C"
LblStatus.Text = ""
scanner = builder.Initialize("Barcode").BleepEnabled(True).EnableAutoFocus(True).withBackfacingCamera.setText("DonManfred presents").setTrackerColor(Colors.Red).build
builder.setText("Glove Division")
builder.setTrackerColor(Colors.Red)
builder.FlashLightEnabledByDefault
scanner.startScan
End Sub
Sub Barcode_onResult(barcode As String)
If (StrScanTag="E") Then
TxtEmpCode.Text = barcode
TxtEmpCode_EnterPressed
else if (StrScanTag="C") Then
TxtCutSlipNo.Text = barcode
TxtCutSlipNo_EnterPressed
End If
End Sub