commit 1d8d6def18d9941ca2638992a937c2c1aff0fdfb Author: cheveguerra Date: Sun Sep 24 00:55:14 2023 -0600 23/9/23 - Commit inicial. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af94e9d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +**/Objects +**/AutoBackups \ No newline at end of file diff --git a/B4A/B4XMainPage.bas b/B4A/B4XMainPage.bas new file mode 100644 index 0000000..a6699d2 --- /dev/null +++ b/B4A/B4XMainPage.bas @@ -0,0 +1,99 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=9.85 +@EndOfDesignText@ +#Region Shared Files +#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files" +'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True +#End Region + +'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip + +Sub Class_Globals + Private Root As B4XView + Private xui As XUI + Private Usuario As EditText + Private Contraseña As EditText + Private b_iniciar As Button + Dim reqManager As DBRequestManager + Dim user As String + Dim paso1 As String + + Dim seleccion As C_seleccion + Dim escaneo As C_escaneo + +End Sub + +Public Sub Initialize +' B4XPages.GetManager.LogEvents = True +End Sub + +'This event will be called once, before the page becomes visible. +Private Sub B4XPage_Created (Root1 As B4XView) + Root = Root1 + Root.LoadLayout("MainPage") + reqManager.Initialize(Me, Starter.DBReqServer) + seleccion.Initialize + B4XPages.AddPage("seleccion",seleccion) + escaneo.Initialize + B4XPages.AddPage("escaneo",escaneo) +End Sub + +Private Sub b_iniciar_Click + If Usuario.Text <> "" Then + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "select_usuario_almacen_SALMA" + cmd.Parameters = Array As Object(Usuario.Text, Contraseña.Text) + reqManager.ExecuteQuery(cmd , 0, "usuario") + + End If +End Sub + + +Sub JobDone(Job As HttpJob) + + If Job.Success = False Then + + ToastMessageShow("Error: " & Job.ErrorMessage, True) + + Else + + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "usuario" Then 'query tag + For Each records() As Object In result.Rows + Dim status As String = records(result.Columns.Get("STATUS")) + Starter.almacen = records(result.Columns.Get("CAT_LO_AGENCIA")) + user = records(result.Columns.Get("CAT_LO_USUARIO")) + Log(user) + Next + paso1 = 1 + End If + End If + + If paso1 = 1 Then + If status = "OKActivo" Then +' Starter.skmt.ExecNonQuery("delete from usuarioa") +' Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(Usuario.Text, Contraseña.Text)) +' Starter.skmt.ExecNonQuery("delete from cat_almacen") +' Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (ID_ALMACEN)) + B4XPages.ShowPage("seleccion") + Else If status = "OKExpirado" Then + Msgbox("Usuario Expirado llamar al administrador","") 'ignore + Else If status = "OKCancelado" Then + Msgbox("Usuario Cancelado llamar al administrador","") 'ignore + Else + Msgbox("Usuario o password No validos","") 'ignore + End If + paso1 = 0 + End If + + + + End If + +End Sub \ No newline at end of file diff --git a/B4A/C_escaneo.bas b/B4A/C_escaneo.bas new file mode 100644 index 0000000..7148917 --- /dev/null +++ b/B4A/C_escaneo.bas @@ -0,0 +1,1270 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=11.8 +@EndOfDesignText@ +Sub Class_Globals + Private Root As B4XView 'ignore + Private xui As XUI 'ignore + Private Dialog As B4XDialog + Private P_escan As Panel + Private e_cant As EditText + Private b_vreseumen As Button + Private B_borrar As Button + Private phn As PhoneVibrate + Private p_img As Panel + Private p_nums As Panel + Private e_prod As EditText + Private b_sig As Button + Private E_ESCANER As EditText + Private c As Cursor + Private codigo_escaner As String + Private piezas_escaner As String + Private P_escan As Panel + Private b_cad As Button + Private teclado As IME + Dim db As SQL + Private b_incidencia As Button + Private p_inci As Panel + Private B4XComboBox1 As B4XComboBox + Private B4XComboBox2 As B4XComboBox + Private d As Cursor + Private b_cadincidencia As Button + Private B_registrar As Button + Private et_cant_incidencia As EditText + Private ed_com As EditText + Private b_cancel As Button + Dim itemselect As String + Dim itemselect2 As String + Dim itemselect3 As String + Dim itemselect4 As String + Private b_limpiar As Button + Private p_calendario As Panel + Private ASWheelPicker1 As ASWheelPicker + Private ASWheelPicker2 As ASWheelPicker + Private ASWheelPicker3 As ASWheelPicker + Private l_fecha_caducidad As Label + Dim day As String = DateTime.GetDayOfMonth(DateTime.Now) + Dim month As String = DateTime.GetMonth(DateTime.Now) + Dim year2 As String = DateTime.GetYear(DateTime.Now) + Dim month2 As String + Private bgfecha As Button + Private SearchTemplate As B4XSearchTemplate + Private Base As B4XView + Private p_busqueda As Panel + + 'camara + + Private pnlPreview As B4XView + Private btnStartStop As Panel + Private rp As RuntimePermissions + Private detector As JavaObject + Private camEx As CameraExClass + Private camEx2 As CameraExClass2 + Private LastPreview As Long + Private IntervalBetweenPreviewsMs As Int = 100 + Private toast As BCToast + Private Capturing As Boolean + Private B_cerrar As Button + Private Panel6 As Panel + Private b_cadcancel As Button + Private b_cam_inci As Panel + + Private p_cam As Panel + Dim frontCamera As Boolean = False + Private p_camara As Panel + Private b_foto_inci As Button + Dim nombrefoto As String + Private e_cantpiezas As EditText + Private p_cant_cajas As Panel + Private p_cant_piezas As Panel + + Dim panelselect As String = 1 + + Private l_cajas As Label + Private l_piezas As Label + Dim foto As String = 0 + Private clv_producto As CustomListView + Private lb_prod As Label + Private lb_cantarchivo As Label + Private Label5 As Label + Private lb_entrada As Label + Private et_cant As EditText + Private p_prodnoencontrado As Panel + + Dim cadx As Button + Private c_prodn As B4XComboBox + Private c_entradan As B4XComboBox + Private et_cantn As EditText + Private lb_prodn As Label + Dim d As Cursor + + Private p_busquedainci As Panel +End Sub + +'You can add more parameters here. +Public Sub Initialize As Object + Return Me +End Sub + +'This event will be called once, before the page becomes visible. +Private Sub B4XPage_Created (Root1 As B4XView) + Root = Root1 + Base = Root + Dialog.Initialize (Base) + Root.LoadLayout("escaneo") + p_calendario.Width = Root.Width + p_calendario.Height= Root.Height + p_calendario.Visible = False + e_cant.Enabled = False + e_cantpiezas.Enabled = False + P_escan.Width = Root.Width + p_nums.Visible = True 'fl lo agregue + db.Initialize(Starter.rutaBD,"kmt.db",True) + p_inci.Visible = False + l_cajas.TextColor = Colors.Red + l_piezas.TextColor = Colors.Gray + p_cant_cajas.Color = Colors.Transparent + p_cant_piezas.Color = Colors.Transparent + Panel6.Width = Root.Width + Panel6.Height= Root.Height + e_prod.Enabled = False + + 'Se crea lista para incidencias + c = Starter.skmt.ExecQuery("SELECT CAT_INC_DESCRIPCION FROM CAT_INCIDENCIA") + Dim Items As List + Items.Initialize + If c.RowCount > 0 Then + Items.Add("SELECCIONA UNA OPCION") + For i = 0 To c.RowCount-1 + c.Position = i + Items.Add(c.GetString("CAT_INC_DESCRIPCION")) + Next + B4XComboBox1.SetItems(Items) + End If + c.Close + itemselect = "Selecciona una opcion" + + + + 'Se crean lista para producto que no este registrado + SearchTemplate.Initialize + Dialog.BackgroundColor = Colors.White + Dialog.ButtonsColor = Colors.Blue + Dialog.BorderColor = Colors.Blue + Dialog.ButtonsTextColor = Colors.White + Dialog.BorderCornersRadius = 30 + Dialog.ButtonsHeight = 70 + SearchTemplate.Resize(330dip,370dip) + SearchTemplate.ItemHightlightColor = Colors.Blue + SearchTemplate.CustomListView1.sv.ScrollViewInnerPanel.Color = Colors.Blue + SearchTemplate.CustomListView1.DefaultTextColor = Colors.Black + SearchTemplate.CustomListView1.DefaultTextBackgroundColor = Colors.White + SearchTemplate.TextHighlightColor = Colors.Black + SearchTemplate.SearchField.TextField.TextColor = Colors.Black + d = Starter.skmt.ExecQuery("SELECT CAT_GP_NOMBRE FROM CAT_PRODUCTOS_ALMACEN") + Dim Items2 As List + Items2.Initialize + If d.RowCount > 0 Then + + For i = 1 To d.RowCount-1 + d.Position = i + Items2.Add(d.GetString("CAT_GP_NOMBRE")) + Next + SearchTemplate.SetItems(Items2) + End If + d.Close + p_busqueda.Enabled = False + p_busquedainci.Enabled = False + + 'Creacion de spinners para caducidad + Dim dias As List : dias.Initialize + Log(month) + For i = 1 To 31 + Dim Item As ASWheelPicker_Item + Item.Initialize + Item.Text = i + Item.Value = i + Item.ItemTextProperties = ASWheelPicker1.ItemTextProperties + Item.ItemTextProperties.TextColor = (0x8FF000000) + dias.Add(Item) + Next + + ASWheelPicker1.AddItems(dias) + + Dim mes0 As List : mes0.Initialize + mes0 = Array As String("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre") + Dim mes As List + mes.Initialize + For Each o As Object In mes0 + Dim Item As ASWheelPicker_Item + Item.Initialize + Item.Text = o + Item.Value = o + Item.ItemTextProperties = ASWheelPicker2.ItemTextProperties + Item.ItemTextProperties.TextColor = (0x8FF000000) + mes.Add(Item) + Next + ASWheelPicker2.AddItems(mes) + + Dim year As List : year.Initialize + For i = DateTime.GetYear(DateTime.Now) To DateTime.GetYear(DateTime.Now) + 4 + Dim Item As ASWheelPicker_Item + Item.Initialize + Item.Text = i + Item.Value = i + Item.ItemTextProperties = ASWheelPicker3.ItemTextProperties + Item.ItemTextProperties.TextColor = (0x8FF000000) + year.Add(Item) + Next + ASWheelPicker3.AddItems(year) + + ASWheelPicker1.Refresh + ASWheelPicker2.Refresh + ASWheelPicker3.Refresh + + If (DateTime.GetMonth(DateTime.Now)= 1 Or DateTime.GetMonth(DateTime.Now)= 2 Or DateTime.GetMonth(DateTime.Now)= 3 Or DateTime.GetMonth(DateTime.Now)= 4 Or DateTime.GetMonth(DateTime.Now)= 5 Or DateTime.GetMonth(DateTime.Now)= 6 Or DateTime.GetMonth(DateTime.Now)= 7 Or DateTime.GetMonth(DateTime.Now)= 8 Or DateTime.GetMonth(DateTime.Now)= 9 ) Then + l_fecha_caducidad.Text = DateTime.GetDayOfMonth(DateTime.Now)&"/"&"0"&DateTime.GetMonth(DateTime.Now)&"/"&DateTime.GetYear(DateTime.Now) + End If + + 'camara + Panel6.Visible = False + p_camara.Height = Root.Height + p_camara.Width = Root.Width + p_camara.Visible = False' + toast.Initialize(Root) + StopCamera + B4XPages.SetTitle(Me, "Barcode Example") + CreateDetector (Array("AZTEC", "CODE_128", "CODE_39", "CODE_93", "CODABAR", "DATA_MATRIX", "EAN_13", "EAN_8", "ITF", "PDF417", "QR_CODE", "UPC_A", "UPC_E")) +End Sub + +Private Sub B4XPage_Appear + DateTime.DateFormat="dd/MM/yyyy" + E_ESCANER.RequestFocus + InitializeCamera2 + clv_producto.Clear + p_prodnoencontrado.Visible = False + p_inci.Visible = False + p_nums.Visible = True + P_escan.Visible = True + +End Sub +' +Private Sub B4XPage_Resume + Log("pausado") + p_nums.Visible = True + P_escan.Visible = True + InitializeCamera2 +End Sub + +'tomar foto + +Private Sub InitializeCamera2 + Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA) +' Wait For Activity_PermissionResult (Permission As String, Result As Boolean) +' If Result Then + camEx2.Initialize(p_cam, frontCamera, Me, "Camera1") + frontCamera = camEx2.Front + Log("inicializamos Camara") +' Else +' ToastMessageShow("No permission!!!", True) +' End If + Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE) +End Sub + +Sub Camera1_Ready (Success As Boolean) + Log("Camara ready") + If Success Then + camEx2.SetJpegQuality(90) + camEx2.SetContinuousAutoFocus + camEx2.CommitParameters + camEx2.StartPreview + Log(camEx2.GetPreviewSize) + Else + ToastMessageShow("Cannot open camera.", True) + Log("Cannot open camera") + End If +End Sub + +Private Sub b_cam_inci_Click + foto = 2 + DateTime.DateFormat="ddMMyyyyHHmmss" + InitializeCamera2 + p_camara.Visible = True + nombrefoto = DateTime.Now & "_foto.jpg" + teclado.HideKeyboard +End Sub + +Private Sub p_camara_Click + +End Sub + + +Private Sub b_foto_inci_Click + camEx2.TakePicture +' p_camara.Visible = False +' StopCamera +End Sub + +Sub Camera1_PictureTaken (Data()As Byte) + Log("tome foto") + Dim filename As String = nombrefoto + Dim Dirp As String = File.DirRootExternal + Dim Dir As String + Try + File.MakeDir(Dirp,"incidenciaskmts") + Dir = "/incidenciaskmts" + Catch + Dir = "" + End Try + + camEx2.SavePictureToFile(Data, Dirp&Dir, filename) + camEx2.StartPreview 'restart preview + ToastMessageShow("Picture saved." & CRLF & "File size: " & File.Size(Dir, filename) & Dir &"," & filename, True) + Log("Picture saved." & CRLF & "File size: " & File.Size(Dir, filename) & Dir &"," & filename) + p_camara.Visible = False + StopCamera2 +End Sub + +Private Sub StopCamera2 +' Capturing = False + If camEx2.IsInitialized Then + camEx2.Release + End If +End Sub + +'fin tomar foto + +'camara + +Private Sub B4XPage_Disappear + If p_camara.Visible = True Then + p_camara.Visible= False + StopCamera2 + Else if Panel6.Visible = True Then + Panel6.Visible = False + StopCamera + End If + +' StopCamera +' StopCamera2 +' Panel6.Visible = False +' p_calendario.Visible = False + + +End Sub + + +Sub btnStartStop_Click + foto = 1 + If Capturing = False Then + Panel6.Visible = True + StartCamera + phn.Vibrate(100) + Else + Panel6.Visible = False + StopCamera + phn.Vibrate(100) + End If +End Sub + +Private Sub B_cerrar_Click + If E_ESCANER.Text.Length = 0 Then + Panel6.Visible = False + StopCamera + StopCamera2 + phn.Vibrate(100) + Else + Panel6.Visible = False + StopCamera + StopCamera2 + E_ESCANER_EnterPressed + phn.Vibrate(100) + End If +End Sub + +Private Sub StopCamera +' E_ESCANER.Text = "" + Capturing = False + pnlPreview.Visible = False + If camEx.IsInitialized Then + camEx.Release + End If +End Sub + +Private Sub StartCameraShared + pnlPreview.Visible = True + Capturing = True +End Sub + +Private Sub FoundBarcode (msg As String) + E_ESCANER.Text = msg + toast.Show($"Found [Color=Red][b][plain]${msg}[/plain][/b][/Color]"$) + Log(msg) + If E_ESCANER.Text.Length > 1 Then + B_cerrar_Click + End If +End Sub + +Private Sub StartCamera + rp.CheckAndRequest(rp.PERMISSION_CAMERA) + Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean) + If Result = False Then + toast.Show("No permission!") + Return + End If + StartCameraShared + camEx.Initialize(pnlPreview, False, Me, "Camera1") + Wait For Camera1_Ready (Success As Boolean) + If Success Then + camEx.SetContinuousAutoFocus + camEx.CommitParameters + camEx.StartPreview + Else + toast.Show("Error opening camera") + StopCamera + End If +End Sub + +Private Sub CreateDetector (Codes As List) + Dim ctxt As JavaObject + ctxt.InitializeContext + Dim builder As JavaObject + builder.InitializeNewInstance("com/google/android/gms/vision/barcode/BarcodeDetector.Builder".Replace("/", "."), Array(ctxt)) + Dim barcodeClass As String = "com/google/android/gms/vision/barcode/Barcode".Replace("/", ".") + Dim barcodeStatic As JavaObject + barcodeStatic.InitializeStatic(barcodeClass) + Dim format As Int + For Each formatName As String In Codes + format = Bit.Or(format, barcodeStatic.GetField(formatName)) + Next + builder.RunMethod("setBarcodeFormats", Array(format)) + detector = builder.RunMethod("build", Null) + Dim operational As Boolean = detector.RunMethod("isOperational", Null) + If operational = False Then + toast.Show("Failed to create detector") + End If + btnStartStop.Enabled = operational +End Sub + +Private Sub Camera1_Preview (data() As Byte) + If DateTime.Now > LastPreview + IntervalBetweenPreviewsMs Then + 'Dim n As Long = DateTime.Now + Dim frameBuilder As JavaObject + Dim bb As JavaObject + bb = bb.InitializeStatic("java.nio.ByteBuffer").RunMethod("wrap", Array(data)) + frameBuilder.InitializeNewInstance("com/google/android/gms/vision/Frame.Builder".Replace("/", "."), Null) + + 'New Code + Dim In As InputStream + In.InitializeFromBytesArray(camEx.PreviewImageToJpeg(data, 100), 0, data.Length) + Dim bmp As Bitmap + 'Log(TestPnl.Top) +' TestPnl.Top = 40dip +' TestPnl.Width = pnlPreview.Width + bmp.Initialize2(In) + bmp = bmp.Rotate(90) + bmp = bmp.Crop(0, bmp.Height * .3, bmp.Width, bmp.Height * .3) + 'bmp = bmp.Resize(bmp.Width, bmp.Height * .8, True) + 'QrTestPnl.SetBitmap(bmp) + 'Dim B As Bitmap = camEx.PreviewImageToJpeg(data, 100) + 'bmp.Rotate(270) + + frameBuilder.RunMethod("setBitmap", Array(bmp)) 'instead of the setImageData line + 'frameBuilder.RunMethod("setBitmap", Array(TestPnl.GetBitmap)) 'instead of the setImageData line + 'End of new code + + + + + 'Old Code +' Dim cs As CameraSize = camEx.GetPreviewSize +' frameBuilder.RunMethod("setImageData", Array(bb, cs.Width, cs.Height, 842094169)) + + + Dim frame As JavaObject = frameBuilder.RunMethod("build", Null) + Dim SparseArray As JavaObject = detector.RunMethod("detect", Array(frame)) + LastPreview = DateTime.Now + Dim Matches As Int = SparseArray.RunMethod("size", Null) + If Matches > 0 Then + Dim barcode As JavaObject = SparseArray.RunMethod("valueAt", Array(0)) + Dim raw As String = barcode.GetField("rawValue") + FoundBarcode(raw) + End If + End If +End Sub + +'fin camara + +Private Sub E_ESCANER_EnterPressed + + c=Starter.skmt.ExecQuery2("select count(*) as CUANTOS from CAT_EQUIVALENCIAS where CAT_EQ_EQUIVALENCIA = ? ", Array As String(E_ESCANER.TEXT)) + c.Position = 0 + codigo_escaner = c.GetString("CUANTOS") + c.Close + If codigo_escaner > 0 Then + c=Starter.skmt.ExecQuery2("select CAT_EQ_CODIGO, CAT_EQ_EQUIVALENCIA from CAT_EQUIVALENCIAS where CAT_EQ_EQUIVALENCIA = ? ", Array As String(E_ESCANER.TEXT)) + c.Position = 0 + codigo_escaner = c.GetString("CAT_EQ_CODIGO") + c.Close + c=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(codigo_escaner)) + d=Starter.skmt.ExecQuery2("SELECT CAT_OC_FOLIO, RESTA, CAT_OC_UM FROM CAT_ORDENCOMPRA_SUMA WHERE CAT_OC_IDPROD = ?",Array As String (codigo_escaner)) + clv_producto.Clear + d.Position = 0 + c.Position = 0 + + If d.RowCount = 0 Then + Log("entre a registrar un producto escaneado") + + clv_producto.AsView.Visible = False + p_prodnoencontrado.Visible = True + +' c.Position = 0 + For i = 0 To c.RowCount - 1 + c.Position = i + lb_prodn.Text = (c.GetString("CAT_GP_NOMBRE")) + Next + c.Close + + d = Starter.skmt.ExecQuery("SELECT ORDEN FROM CAT_ORDENES_SELECCIONADAS") + Dim Items4 As List + Items4.Initialize + If d.RowCount > 0 Then + Items4.Add("Selecciona una opcion") + For i = 0 To d.RowCount-1 + d.Position = i + Items4.Add(d.GetString("ORDEN")) + Next + c_prodn.SetItems(Items4) + End If + d.Close + itemselect3 = "Selecciona una opcion" + + Dim items5 As List + items5.Initialize + items5.Add("Selecciona una opcion") + items5.Add("CS") + items5.Add("EA") + + c_entradan.SetItems(items5) + itemselect4 = "Selecciona una opcion" + + + Else If p_inci.Visible = True Then + + Log("encontre el codigo con incidencia") + + clv_producto.AsView.Visible = False + p_prodnoencontrado.Visible = False +' c.Position = 0 + For i = 0 To c.RowCount - 1 + c.Position = i + e_prod.Text = (c.GetString("CAT_GP_NOMBRE")) + Next + c.Close + + Else + Log("encontre el codigo") + clv_producto.AsView.Visible = True +' c.Position = 0 +' d.Position = 0 + For i = 0 To d.RowCount - 1 + d.Position = i + clv_producto.Add(CreateListItem(c.GetString("CAT_GP_NOMBRE"),d.GetString("CAT_OC_FOLIO"),d.GetString("RESTA"),d.GetString("CAT_OC_UM")),i) + Next + c.Close + d.Close + End If + + Else If E_ESCANER.Text.Length = 0 Then + Log("no hice nada ") + + Else + If p_inci.Visible Then + Log("entre a incidencia de producto no encontrado") + c=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(codigo_escaner)) + p_busquedainci_Click + p_prodnoencontrado.Visible = False + clv_producto.AsView.Visible = False + c.Position = 0 + For i = 0 To c.RowCount - 1 + c.Position = i + e_prod.Text = (c.GetString("CAT_GP_NOMBRE")) + Next + c.Close + Else + Log("entre aqui") + MsgboxAsync("CODIGO NO ENCONTRADO","AVISO") +' e_prod.Text = "Pendiente alta" + p_busqueda.Enabled = True + p_busquedainci.Enabled = True + p_busqueda_Click + p_prodnoencontrado.Visible = True + End If + End If + + + If E_ESCANER.Text.Length > 1 Then + teclado.HideKeyboard + End If + +End Sub + +Sub CreateListItem(mostrar As String, mostrar1 As String, mostrar2 As String, mostrar3 As String) As Panel + Dim p As B4XView = xui.CreatePanel("") + p.SetLayoutAnimated(0, 0, 0, 1, 115) + p.LoadLayout("detalle_folio") + p.Height= 195dip +' p.Width = clv_orden.GetBase.Width + lb_prod.Text = mostrar + Label5.Text = mostrar1 + lb_cantarchivo.Text = mostrar2 + lb_entrada.Text = mostrar3 + +' Log(p.Width) + Return p +End Sub + +Private Sub p_inci_Click + teclado.HideKeyboard +End Sub + +Private Sub p_nums_Click + teclado.HideKeyboard +End Sub + +Private Sub b_sig_Click + + If p_prodnoencontrado.Visible = False Then + + Dim r_guardado, continuar As Boolean = False + + For x= 0 To clv_producto.Size - 1 + Log(x & " y " & clv_producto.Size) + clv_producto.GetPanel(x) + Dim pnl0 As B4XView = clv_producto.GetPanel(x) + Dim pnl1 As B4XView = pnl0.GetView(0) + Dim b_fc As B4XView = pnl1.GetView(5) + Dim lb_oc As B4XView = pnl1.GetView(8) + + Dim pnl2 As B4XView = pnl1.GetView(4) + Dim et_escan As B4XView = pnl2.GetView(0) + Log("|" & b_fc.Text & "| y |" & et_escan.text &"| y " & lb_oc.Text) + If et_escan.Text <> "" And b_fc.Text = "Caducidad" Then + continuar = False + MsgboxAsync("Captura la fecha de caducidad de todos los productos","") + Log("no cumple") + Exit + Else + continuar = True + Log("si cumple") + End If + Log("continuar0 = "& continuar) + Next + + Log("Continuar =" & continuar) + If continuar Then + For x= 0 To clv_producto.Size - 1 + Log(x & " y " & clv_producto.Size) + clv_producto.GetPanel(x) + Dim pnl0 As B4XView = clv_producto.GetPanel(x) + Dim pnl1 As B4XView = pnl0.GetView(0) + Dim lb_np As B4XView = pnl1.GetView(3) + Dim lb_oc As B4XView = pnl1.GetView(8) + Dim lb_um As B4XView = pnl1.GetView(7) + Dim b_fc As B4XView = pnl1.GetView(5) + Dim lb_cant As B4XView = pnl1.GetView(10) + + Dim pnl2 As B4XView = pnl1.GetView(4) + Dim et_escan As B4XView = pnl2.GetView(0) + + If et_escan.Text <> "" And lb_um.Text = "EA" And b_fc.Text <> "Caducidad" Then + + DateTime.DateFormat="ddMMyyyyHHmmss" + Dim nuevaFecha As String = DateTime.DATE(DateTime.Now) + db.ExecNonQuery2("INSERT INTO CAT_ESCANEO (CAT_ID_USUARIO , CAT_ALMACEN, CAT_COD_BAR, CAT_NOM_PROD, CAT_CAJAS, CAT_PIEZAS, CAT_FEC_CAD, CAT_ORDEN_COMPRA, CAT_FECHA_CAPTURA, CAT_STATUS)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Array As Object (B4XPages.MainPage.user, Starter.almacen, E_ESCANER.Text, lb_np.text,0,et_escan.Text,b_fc.Text,lb_oc.Text,nuevaFecha,"0")) + Log("inserte " & et_escan.Text) + Dim rest = lb_cant.Text - et_escan.Text + Log(rest) + Starter.skmt.ExecNonQuery2("UPDATE CAT_ORDENCOMPRA_SUMA SET RESTA = ? WHERE CAT_OC_IDPROD = ? and CAT_OC_FOLIO = ?", Array As String (rest, codigo_escaner, lb_oc.Text)) + Log("actualice " & et_escan.Text) + r_guardado = True + LogColor("Se envio "& lb_oc.text,Colors.red) + + Else If et_escan.Text <> "" And lb_um.Text = "CS" And b_fc.Text <> "Caducidad" Then + + DateTime.DateFormat="ddMMyyyyHHmmss" + Dim nuevaFecha As String = DateTime.DATE(DateTime.Now) + db.ExecNonQuery2("INSERT INTO CAT_ESCANEO (CAT_ID_USUARIO , CAT_ALMACEN, CAT_COD_BAR, CAT_NOM_PROD, CAT_CAJAS, CAT_PIEZAS, CAT_FEC_CAD, CAT_ORDEN_COMPRA, CAT_FECHA_CAPTURA, CAT_STATUS)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Array As Object (B4XPages.MainPage.user, Starter.almacen, E_ESCANER.Text, lb_np.text,et_escan.Text, 0,b_fc.Text,lb_oc.Text,nuevaFecha,"0")) + Log("inserte " & et_escan.Text) + Dim rest = lb_cant.Text - et_escan.Text + Log(rest) + Starter.skmt.ExecNonQuery2("UPDATE CAT_ORDENCOMPRA_SUMA SET RESTA = ? WHERE CAT_OC_IDPROD = ? and CAT_OC_FOLIO = ?", Array As String (rest, codigo_escaner, lb_oc.Text)) + Log("actualice " & et_escan.Text) + r_guardado = True + LogColor("Se envio "& lb_oc.text,Colors.red) + + Else If et_escan.Text = "" And (lb_um.Text = "EA" Or lb_um.Text = "CS") And b_fc.Text = "Caducidad" Then + + Else + MsgboxAsync("Captura datos", "") + r_guardado = False + + End If + Next + If r_guardado Then + clv_producto.Clear + E_ESCANER.Text = "" + p_nums.Visible = True 'fl lo agregue + E_ESCANER.RequestFocus + b_cadincidencia.Text = "Caducidad" + DateTime.DateFormat="dd/MM/yyyy" + MsgboxAsync("Datos guardados","") + phn.Vibrate(100) + p_busqueda.Enabled = False + + + End If + End If + + Else If p_prodnoencontrado.Visible = True Then + + If et_cantn.Text <> "" And cadx.Text <> "Caducidad" Then + + If itemselect4 = "CS" Then + + DateTime.DateFormat="ddMMyyyyHHmmss" + Dim nuevaFecha As String = DateTime.DATE(DateTime.Now) + db.ExecNonQuery2("INSERT INTO CAT_ESCANEO (CAT_ID_USUARIO , CAT_ALMACEN, CAT_COD_BAR, CAT_NOM_PROD, CAT_CAJAS, CAT_PIEZAS, CAT_FEC_CAD, CAT_ORDEN_COMPRA, CAT_FECHA_CAPTURA, CAT_STATUS)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Array As Object (B4XPages.MainPage.user, Starter.almacen, E_ESCANER.Text, lb_prodn.text,et_cantn.text,0,b_cad.text,itemselect3,nuevaFecha,"0")) + E_ESCANER.Text = "" + p_nums.Visible = True 'fl lo agregue + p_prodnoencontrado.Visible = False + cadx.Text = "Caducidad" + E_ESCANER.RequestFocus + b_cadincidencia.Text = "Caducidad" + DateTime.DateFormat="dd/MM/yyyy" + MsgboxAsync("Datos guardados","") + phn.Vibrate(100) + p_busqueda.Enabled = False + c_entradan.SelectedIndex = 0 + c_prodn.SelectedIndex = 0 + et_cantn.Text = "" + clv_producto.AsView.Visible = True + + Else If itemselect4 = "EA" Then + + DateTime.DateFormat="ddMMyyyyHHmmss" + Dim nuevaFecha As String = DateTime.DATE(DateTime.Now) + db.ExecNonQuery2("INSERT INTO CAT_ESCANEO (CAT_ID_USUARIO , CAT_ALMACEN, CAT_COD_BAR, CAT_NOM_PROD, CAT_CAJAS, CAT_PIEZAS, CAT_FEC_CAD, CAT_ORDEN_COMPRA, CAT_FECHA_CAPTURA, CAT_STATUS)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Array As Object (B4XPages.MainPage.user, Starter.almacen, E_ESCANER.Text, lb_prodn.text,0,et_cantn.text,b_cad.text,itemselect3,nuevaFecha,"0")) + E_ESCANER.Text = "" + p_nums.Visible = True 'fl lo agregue + p_prodnoencontrado.Visible = False + cadx.Text = "Caducidad" + E_ESCANER.RequestFocus + b_cadincidencia.Text = "Caducidad" + DateTime.DateFormat="dd/MM/yyyy" + MsgboxAsync("Datos guardados","") + phn.Vibrate(100) + p_busqueda.Enabled = False + c_entradan.SelectedIndex = 0 + c_prodn.SelectedIndex = 0 + et_cantn.Text = "" + clv_producto.AsView.Visible = True + + End If + + Else If (et_cantn.Text <> "" And b_cad.Text = "Caducidad") Or (et_cantn.Text = "" And cadx.Text = "Caducidad") Then + + MsgboxAsync("Captura todos los datos","") + + End If + + End If + +End Sub + +Private Sub p_busqueda_Click + phn.Vibrate(100) + Wait For (Dialog.ShowTemplate(SearchTemplate, "", "", "Cancelar")) Complete (Result As Int) + If Result = xui.DialogResponse_Positive Then + clv_producto.AsView.Visible = False + lb_prodn.Text = SearchTemplate.SelectedItem +' e_prod.Text = SearchTemplate.SelectedItem + End If + phn.Vibrate(100) + + d = Starter.skmt.ExecQuery("SELECT ORDEN FROM CAT_ORDENES_SELECCIONADAS") + Dim Items4 As List + Items4.Initialize + If d.RowCount > 0 Then + Items4.Add("Selecciona una opcion") + For i = 0 To d.RowCount-1 + d.Position = i + Items4.Add(d.GetString("ORDEN")) + Next + c_prodn.SetItems(Items4) + End If + d.Close + itemselect3 = "Selecciona una opcion" + + Dim items5 As List + items5.Initialize + items5.Add("Selecciona una opcion") + items5.Add("CS") + items5.Add("EA") + + c_entradan.SetItems(items5) + itemselect4 = "Selecciona una opcion" + +End Sub + +Private Sub b_incidencia_Click + p_inci.Visible = True + P_escan.Visible = False + p_prodnoencontrado.Visible = False + phn.Vibrate(100) + + + c = Starter.skmt.ExecQuery("SELECT ORDEN FROM CAT_ORDENES_SELECCIONADAS") + Dim Items3 As List + Items3.Initialize + If c.RowCount > 0 Then + Items3.Add("SELECCIONA UNA OPCION") + For i = 0 To c.RowCount-1 + c.Position = i + Items3.Add(c.GetString("ORDEN")) + Next + B4XComboBox2.SetItems(Items3) + End If + c.Close + itemselect2 = "Selecciona una opcion" + +End Sub + +Private Sub c_entradan_SelectedIndexChanged (Index As Int) + itemselect4 = Sender.As(B4XComboBox).SelectedItem + Log(itemselect4) + Log(Index) +End Sub + +Private Sub c_prodn_SelectedIndexChanged (Index As Int) + itemselect3 = Sender.As(B4XComboBox).SelectedItem + Log(itemselect3) + Log(Index) +End Sub + +Private Sub B4XComboBox2_SelectedIndexChanged (Index As Int) + itemselect2 = Sender.As(B4XComboBox).SelectedItem + Log(itemselect2) + Log(Index) +End Sub + +Private Sub B4XComboBox1_SelectedIndexChanged (Index As Int) + itemselect = Sender.As(B4XComboBox).SelectedItem + Log(itemselect) + Log(Index) +End Sub + +Private Sub b_cadincidencia_Click + p_calendario.Visible = True + phn.Vibrate(100) +End Sub + +Private Sub b_limpiar_Click + + If p_prodnoencontrado.Visible Then + + p_busqueda.Enabled = False + p_prodnoencontrado.Visible = False + b_cad.Text = "Caducidad" + c_prodn.SelectedIndex = 0 + c_entradan.SelectedIndex = 0 + lb_prodn.Text = "" + et_cantn.Text = "" + E_ESCANER.Text = "" + + Else + + e_prod.Text = "" + E_ESCANER.Text = "" + b_cadincidencia.Text = "Caducidad" + E_ESCANER.RequestFocus +' b_cad.Text = "Caducidad" + phn.Vibrate(100) + p_busqueda.Enabled = False + clv_producto.Clear + + End If +End Sub + +Private Sub B_registrar_Click + If et_cant_incidencia.Text.Length > 0 And b_cadincidencia.Text <> "Caducidad" Then + If B4XComboBox1.SelectedIndex > 0 Then + DateTime.DateFormat="ddMMyyyyHHmmss" + Dim nuevaFecha As String=DateTime.Date(DateTime.Now) + db.ExecNonQuery2("INSERT INTO CAT_ESCAN_INCIDENCIA (CAT_ID_USUARIO, CAT_ALMACEN, CAT_COD_BAR, CAT_NOM_PROD, CAT_TIPO_INCIDENCIA, CAT_CANT, CAT_DETALLE_INCIDENCIA, CAT_FEC_CAD, CAT_ORDEN_COMPRA, CAT_FECHA_CAPTURA, CAT_FOTO, CAT_STATUS)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Array As Object (B4XPages.MainPage.user, Starter.almacen, E_ESCANER.Text,e_prod.Text,itemselect,et_cant_incidencia.Text,ed_com.Text,b_cadincidencia.Text,itemselect2, nuevaFecha,nombrefoto,"0")) + B4XComboBox1.SelectedIndex = 0 + e_prod.Text = "" + et_cant_incidencia.Text = "" + E_ESCANER.Text = "" + b_cadincidencia.Text = "Caducidad" + E_ESCANER.RequestFocus + ed_com.Text = "" + p_inci.Visible = False + P_escan.Visible = True + b_cad.Text = "Caducidad" + DateTime.DateFormat="dd/MM/yyyy" + MsgboxAsync("Datos guardados","") + phn.Vibrate(100) + p_busqueda.Enabled = False + p_busquedainci.Enabled = False + B4XComboBox1.SelectedIndex = 0 + Else + MsgboxAsync("Selecciona una opción valida", "") + End If + Else + MsgboxAsync("Captura todos los datos", "") + End If +End Sub + +Private Sub b_cancel_Click + e_prod.Text = "" + p_inci.Visible = False + P_escan.Visible = True + et_cant_incidencia.Text = "" + E_ESCANER.Text = "" + b_cadincidencia.Text = "Caducidad" + E_ESCANER.RequestFocus + ed_com.Text = "" + B4XComboBox1.SelectedIndex = 0 + B4XComboBox2.SelectedIndex = 0 + phn.Vibrate(100) + p_busquedainci.Enabled = False +End Sub + +Private Sub b_cad_Click + p_calendario.Visible = True + cadx = Sender + phn.Vibrate(100) + teclado.HideKeyboard +End Sub + +Private Sub b_cadcancel_Click + If b_cad.Text <> "Caducidad" Then + p_calendario.Visible = False + phn.Vibrate(100) + Else + p_calendario.Visible = False + phn.Vibrate(100) + b_cad.Text = "Caducidad" + End If +End Sub + +Private Sub p_calendario_Click + +End Sub + +Private Sub ASWheelPicker1_ItemChange(Column As Int,ListIndex As Int) + l_fecha_caducidad.Text = ASWheelPicker1.GetSelectedItem(Column).Text + day = ASWheelPicker1.GetSelectedItem(Column).Text + + If day = 1 Or day = "2" Or day = "3" Or day = "4" Or day = "5" Or day = "6" Or day = "7" Or day = "8" Or day = "9" Then + l_fecha_caducidad.Text = "0"&day&"/"&month2&"/"&year2 + Else + l_fecha_caducidad.Text = day&"/"&month2&"/"&year2 + End If + +End Sub + +Private Sub ASWheelPicker2_ItemChange(Column As Int,ListIndex As Int) + l_fecha_caducidad.Text = ASWheelPicker2.GetSelectedItem(Column).Text + month = ASWheelPicker2.GetSelectedItem(Column).Text + + If month = "Enero" Then + month2 = "01" + Else If month = "Febrero" Then + month2 = "02" + Else If month = "Marzo" Then + month2 = "03" + Else If month = "Abril" Then + month2 = "04" + Else If month = "Mayo" Then + month2 = "05" + Else If month = "Junio" Then + month2 = "06" + Else If month = "Julio" Then + month2 = "07" + Else If month = "Agosto" Then + month2 = "08" + Else If month = "Septiembre" Then + month2 = "09" + Else If month = "Octubre" Then + month2 = "10" + Else If month = "Noviembre" Then + month2 = "11" + Else If month = "Diciembre" Then + month2 = "12" + End If + + If day = 1 Or day = "2" Or day = "3" Or day = "4" Or day = "5" Or day = "6" Or day = "7" Or day = "8" Or day = "9" Then + l_fecha_caducidad.Text = "0"&day&"/"&month2&"/"&year2 + Else + l_fecha_caducidad.Text = day&"/"&month2&"/"&year2 + End If + +End Sub + +Private Sub ASWheelPicker3_ItemChange(Column As Int,ListIndex As Int) + l_fecha_caducidad.Text = ASWheelPicker3.GetSelectedItem(Column).Text + year2 = ASWheelPicker3.GetSelectedItem(Column).Text + + If day = 1 Or day = "2" Or day = "3" Or day = "4" Or day = "5" Or day = "6" Or day = "7" Or day = "8" Or day = "9" Then + l_fecha_caducidad.Text = "0"&day&"/"&month2&"/"&year2 + Else + l_fecha_caducidad.Text = day&"/"&month2&"/"&year2 + End If +End Sub + +Private Sub bgfecha_Click + + If l_fecha_caducidad.Text = "" Then + cadx.text = "Caducidad" + b_cadincidencia.Text = "Caducidad" + Else + If month = "Febrero" And (day = 31 Or day = 30) And (year2 Mod 4) = 0 Then + Log(year2 Mod 4) + cadx.Text = "29"&"/"&month2&"/"&year2 + b_cadincidencia.Text = "29"&"/"&month2&"/"&year2 + Else If month = "Febrero" And (day = 31 Or day = 30 Or day = 29) And (year2 Mod 4) > 1 Then + cadx.Text = "28"&"/"&month2&"/"&year2 + b_cadincidencia.Text = "28"&"/"&month2&"/"&year2 + Else If month = "Abril" And day = 31 Then + cadx.Text = "30"&"/"&month2&"/"&year2 + b_cadincidencia.Text = "30"&"/"&month2&"/"&year2 + Else If month = "Junio" And day = 31 Then + cadx.Text = "30"&"/"&month2&"/"&year2 + b_cadincidencia.Text = "30"&"/"&month2&"/"&year2 + Else If month = "Septiembre" And day = 31 Then + cadx.Text = "30"&"/"&month2&"/"&year2 + b_cadincidencia.Text = "30"&"/"&month2&"/"&year2 + Else If month = "Noviembre" And day = 31 Then + cadx.Text = "30"&"/"&month2&"/"&year2 + b_cadincidencia.Text = "30"&"/"&month2&"/"&year2 + Else + cadx.Text = l_fecha_caducidad.Text + b_cadincidencia.Text = l_fecha_caducidad.Text + End If + p_calendario.Visible = False + phn.Vibrate(100) + End If +End Sub + +Private Sub p_cant_cajas_Click + panelselect = 1 + phn.Vibrate(100) + l_cajas.TextColor = Colors.Red + l_piezas.TextColor = Colors.Gray +End Sub + +Private Sub p_cant_piezas_Click + panelselect = 2 + phn.Vibrate(100) + l_cajas.TextColor = Colors.Gray + l_piezas.TextColor = Colors.Red +End Sub + +Private Sub num_1_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "1" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "1" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub num_2_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "2" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "2" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub num_3_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "3" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "3" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub num_4_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "4" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "4" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub num_5_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "5" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "5" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub num_6_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "6" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "6" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub num_7_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "7" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "7" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub num_8_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "8" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "8" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub num_9_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "9" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "9" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub num_0_Click + If panelselect = 1 Then + e_cant.Text = e_cant.Text & "0" + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + phn.Vibrate(100) + Else + e_cantpiezas.Text = e_cantpiezas.Text & "0" + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + phn.Vibrate(100) + End If +End Sub + +Private Sub B_borrar_Click + If panelselect = 1 Then + If e_cant.Text.Length >= 2 Then + e_cant.Text = e_cant.Text.SubString2(0,e_cant.Text.Length-1) + e_cant.Text= NumberFormat(e_cant.Text.Replace(",",""),0,0) + Else + If e_cant.Text.Length <> 0 Then + e_cant.Text = e_cant.Text.SubString2(0,e_cant.Text.Length-1) + End If + End If + phn.Vibrate(80) + Else + If e_cantpiezas.Text.Length >= 2 Then + e_cantpiezas.Text = e_cantpiezas.Text.SubString2(0,e_cantpiezas.Text.Length-1) + e_cantpiezas.Text= NumberFormat(e_cantpiezas.Text.Replace(",",""),0,0) + Else + If e_cantpiezas.Text.Length <> 0 Then + e_cantpiezas.Text = e_cantpiezas.Text.SubString2(0,e_cantpiezas.Text.Length-1) + End If + End If + phn.Vibrate(80) + End If + +End Sub + +Private Sub b_vreseumen_Click + + B4XPages.ShowPage ("Resumen") + +End Sub + +Private Sub B_borrar_LongClick + + If panelselect = 1 Then + e_cant.Text = "" + Else + e_cantpiezas.Text = "" + End If +End Sub + +Private Sub B4XPage_CloseRequest As ResumableSub +' BACK key pressed +' Return True To close, False To cancel + If p_camara.Visible = True Then + p_camara.Visible= False + StopCamera2 + Else if Panel6.Visible = True Then + Panel6.Visible = False + StopCamera + Else If p_calendario.Visible = True Then + p_calendario.Visible = False + Else If p_inci.Visible = True Then + p_inci.Visible = False + P_escan.Visible = True + Else + B4XPages.ShowPage("Checarorden") + End If +' Return True + Return False +End Sub + +Private Sub p_busquedainci_Click + phn.Vibrate(100) + Wait For (Dialog.ShowTemplate(SearchTemplate, "", "", "Cancelar")) Complete (Result As Int) + If Result = xui.DialogResponse_Positive Then + clv_producto.AsView.Visible = False + p_prodnoencontrado.Visible = False +' lb_prodn.Text = SearchTemplate.SelectedItem + e_prod.Text = SearchTemplate.SelectedItem + End If + phn.Vibrate(100) +End Sub + +'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage. \ No newline at end of file diff --git a/B4A/C_seleccion.bas b/B4A/C_seleccion.bas new file mode 100644 index 0000000..7e4b7a2 --- /dev/null +++ b/B4A/C_seleccion.bas @@ -0,0 +1,155 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=11.8 +@EndOfDesignText@ +Sub Class_Globals + Private Root As B4XView 'ignore + Private xui As XUI 'ignore + Dim reqManager As DBRequestManager + Private b_cargar As Button + Private cl_folios As CustomListView + Private trabajos = 0 As Int + Dim c As Cursor + Private lb_num_folio As Label + Private contenido_folio As Panel + Private Panel1 As Panel + Dim folioactual As String +End Sub + +'You can add more parameters here. +Public Sub Initialize As Object + Return Me +End Sub + +'This event will be called once, before the page becomes visible. +Private Sub B4XPage_Created (Root1 As B4XView) + Root = Root1 + Root.LoadLayout("seleccion") + reqManager.Initialize(Me, Starter.DBReqServer) +End Sub + +'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage. + +Private Sub b_cargar_Click + + If trabajos > 1 Then + trabajos = 0 + End If + + cl_folios.Clear + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "selec_foliosalmacen_SALMA" + cmd.Parameters = Array As Object(Starter.almacen) + reqManager.ExecuteQuery(cmd , 0, "foliosalmacen") + trabajos = trabajos + 1 + + cmd.Name = "select_ALMACEN_CAT_CODIGOS_SALMA" + cmd.Parameters = Array As Object(Starter.almacen) + reqManager.ExecuteQuery(cmd , 0, "cat_productos") + trabajos = trabajos + 1 + + cmd.Name = "select_ALMACEN_CAT_EQUIVALENCIAS_SALMA" + cmd.Parameters = Array As Object(Starter.almacen) + reqManager.ExecuteQuery(cmd , 0, "cat_equivalencias") + trabajos = trabajos + 1 + + + + ProgressDialogShow ("Cargando") + +End Sub + +Sub CreateListItem(mostrar As String) As Panel + Dim p As B4XView = xui.CreatePanel("") + p.SetLayoutAnimated(0, 0, 0, 1, 115) + p.LoadLayout("cont_folio") + p.Height= 65dip +' p.Width = clv_orden.GetBase.Width + contenido_folio.Width = Panel1.Width + lb_num_folio.Height = p.Height *0.8 + lb_num_folio.Text = mostrar +' Log(p.Width) + Return p +End Sub + +Private Sub lb_num_folio_Click + folioactual = Sender.As(Label).Text + B4XPages.ShowPage ("escaneo") +End Sub + + +Sub JobDone(Job As HttpJob) + If Not(Job.Success) Then + + ToastMessageShow("Error: " & Job.ErrorMessage, True) + + Else + LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "foliosalmacen" Then 'query tag + Starter.skmt.ExecNonQuery("delete from CAT_FOLIOS_ALMACEN") + For Each records() As Object In result.Rows + + Dim FOLIO_ID As String = records(result.Columns.Get("HIST_EA_ID")) + Dim FOLIO_ENTREGA As String = records(result.Columns.Get("HIST_EA_FOLIO_ENTREGA")) + Dim FOLIO_REFERENCIA_FACTURA As String = records(result.Columns.Get("HIST_EA_REFERENCIA_FACTURA")) + + Starter.skmt.ExecNonQuery2("INSERT INTO CAT_FOLIOS_ALMACEN(FOLIO_ENTREGA, FOLIO_ID, FOLIO_REFERENCIA_FACTURA) VALUES (?,?,?)", Array As Object (FOLIO_ENTREGA,FOLIO_ID,FOLIO_REFERENCIA_FACTURA)) + + Next + + c = Starter.skmt.ExecQuery("SELECT FOLIO_REFERENCIA_FACTURA FROM CAT_FOLIOS_ALMACEN") + cl_folios.Clear + For i = 0 To c.RowCount - 1 + c.Position = i + cl_folios.Add(CreateListItem(c.GetString("FOLIO_REFERENCIA_FACTURA")),i) + Next + c.Close + + trabajos = trabajos - 1 + End If + End If + + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "cat_productos" Then 'query tag + Starter.skmt.ExecNonQuery("delete from CAT_PRODUCTOS_ALMACEN") + For Each records() As Object In result.Rows + + Dim id As String = records(result.Columns.Get("CAT_GP_ID")) + Dim nombre As String = records(result.Columns.Get("CAT_GP_NOMBRE")) + Dim cb As String = records(result.Columns.Get("CAT_GP_DUN14")) + + Starter.skmt.ExecNonQuery2("INSERT INTO CAT_PRODUCTOS_ALMACEN(CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_DUN14) VALUES (?,?,?)", Array As Object (id,nombre,cb)) + + Next + trabajos = trabajos - 1 + End If + End If + + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "cat_equivalencias" Then 'query tag + Starter.skmt.ExecNonQuery("delete from CAT_EQUIVALENCIAS_ALMACEN") + For Each records() As Object In result.Rows + + Dim codigo As String = records(result.Columns.Get("CAT_EQ_CODIGO")) + Dim equivalencia As String = records(result.Columns.Get("CAT_EQ_EQUIVALENCIA")) + + Starter.skmt.ExecNonQuery2("INSERT INTO CAT_EQUIVALENCIAS_ALMACEN(CAT_EQ_CODIGO, CAT_EQ_EQUIVALENCIA) VALUES (?,?)", Array As Object (codigo,equivalencia)) + + Next + trabajos = trabajos - 1 + End If + End If + + If trabajos = 0 Then + ProgressDialogHide + End If + + End If +End Sub \ No newline at end of file diff --git a/B4A/CameraExClass.bas b/B4A/CameraExClass.bas new file mode 100644 index 0000000..f090cea --- /dev/null +++ b/B4A/CameraExClass.bas @@ -0,0 +1,402 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=7.28 +@EndOfDesignText@ +'Class module +'version 1.30 +'See this page for the list of constants: +'http://developer.android.com/intl/fr/reference/android/hardware/Camera.Parameters.html +'Note that you should use the constant values instead of the names. +Sub Class_Globals + Private nativeCam As Object + Private cam As Camera + Private r As Reflector + Private target As Object + Private event As String + Public Front As Boolean + Private parameters As Object + + Public PreviewOrientation As Int +End Sub + +Public Sub Initialize (Panel1 As Panel, FrontCamera As Boolean, TargetModule As Object, EventName As String) + target = TargetModule + event = EventName + Front = FrontCamera + Dim id As Int + id = FindCamera(Front).id + If id = -1 Then + Front = Not(Front) 'try different camera + id = FindCamera(Front).id + If id = -1 Then + ToastMessageShow("No camera found.", True) + Return + End If + End If + cam.Initialize2(Panel1, "camera", id) +End Sub + +Private Sub FindCamera (frontCamera As Boolean) As CameraInfoAndId + Dim ci As CameraInfoAndId + Dim cameraInfo As Object + Dim cameraValue As Int + Log("findCamera") + If frontCamera Then cameraValue = 1 Else cameraValue = 0 + cameraInfo = r.CreateObject("android.hardware.Camera$CameraInfo") + Dim numberOfCameras As Int = r.RunStaticMethod("android.hardware.Camera", "getNumberOfCameras", Null, Null) + Log(r.target) + Log(numberOfCameras) + For i = 0 To numberOfCameras - 1 + r.RunStaticMethod("android.hardware.Camera", "getCameraInfo", Array As Object(i, cameraInfo), _ + Array As String("java.lang.int", "android.hardware.Camera$CameraInfo")) + r.target = cameraInfo + Log("facing: " & r.GetField("facing") & ", " & cameraValue) + If r.GetField("facing") = cameraValue Then 'ignore + ci.cameraInfo = r.target + ci.Id = i + Return ci + End If + Next + ci.id = -1 + Return ci +End Sub + +Private Sub SetDisplayOrientation + r.target = r.GetActivity + r.target = r.RunMethod("getWindowManager") + r.target = r.RunMethod("getDefaultDisplay") + r.target = r.RunMethod("getRotation") + Dim result, degrees As Int = r.target * 90 + Dim ci As CameraInfoAndId = FindCamera(Front) + r.target = ci.CameraInfo + Dim orientation As Int = r.GetField("orientation") + If Front Then + PreviewOrientation = (orientation + degrees) Mod 360 + result = PreviewOrientation + PreviewOrientation = (360 - PreviewOrientation) Mod 360 + Else + PreviewOrientation = (orientation - degrees + 360) Mod 360 + result = PreviewOrientation + Log("Preview Orientation: " & PreviewOrientation) + End If + r.target = nativeCam + r.RunMethod2("setDisplayOrientation", PreviewOrientation, "java.lang.int") + r.target = parameters + r.RunMethod2("setRotation", result, "java.lang.int") + CommitParameters +End Sub + +Private Sub Camera_Ready (Success As Boolean) + If Success Then + r.target = cam + nativeCam = r.GetField("camera") + r.target = nativeCam + parameters = r.RunMethod("getParameters") + SetDisplayOrientation + Else + Log("success = false, " & LastException) + End If + CallSub2(target, event & "_ready", Success) +End Sub +'Uncomment this sub if you need to handle the Preview event +Sub Camera_Preview (Data() As Byte) + If SubExists(target, event & "_preview") Then + CallSub2(target, event & "_preview", Data) + End If +End Sub + +Public Sub TakePicture + cam.TakePicture +End Sub + +Private Sub Camera_PictureTaken (Data() As Byte) + CallSub2(target, event & "_PictureTaken", Data) +End Sub + +Public Sub StartPreview + cam.StartPreview +End Sub + +Public Sub StopPreview + cam.StopPreview +End Sub + +Public Sub Release + cam.Release +End Sub + +'Saves the data received from PictureTaken event +Public Sub SavePictureToFile(Data() As Byte, Dir As String, FileName As String) + Dim out As OutputStream = File.OpenOutput(Dir, FileName, False) + out.WriteBytes(Data, 0, Data.Length) + out.Close +End Sub + +Public Sub SetParameter(Key As String, Value As String) + r.target = parameters + r.RunMethod3("set", Key, "java.lang.String", Value, "java.lang.String") +End Sub + +Public Sub GetParameter(Key As String) As String + r.target = parameters + Return r.RunMethod2("get", Key, "java.lang.String") +End Sub + +Public Sub CommitParameters + 'Try + r.target = nativeCam + r.RunMethod4("setParameters", Array As Object(parameters), Array As String("android.hardware.Camera$Parameters")) + 'Catch + ' ToastMessageShow("Error setting parameters.", True) + ' Log(LastException) + ' End Try +End Sub + +Public Sub GetColorEffect As String + Return GetParameter("effect") +End Sub + +Public Sub SetColorEffect(Effect As String) + SetParameter("effect", Effect) +End Sub + +Public Sub GetSupportedPreviewSizes As CameraSize() + r.target = parameters + Dim list1 As List = r.RunMethod("getSupportedPreviewSizes") + Dim cs(list1.Size) As CameraSize + For i = 0 To list1.Size - 1 + r.target = list1.get(i) + cs(i).Width = r.GetField("width") + cs(i).Height = r.GetField("height") + Next + Return cs +End Sub + +Public Sub SetPreviewSize(Width As Int, Height As Int) + r.target = parameters + r.RunMethod3("setPreviewSize", Width, "java.lang.int", Height, "java.lang.int") +End Sub +Public Sub GetSupportedPicturesSizes As CameraSize() + r.target = parameters + Dim list1 As List = r.RunMethod("getSupportedPictureSizes") + Dim cs(list1.Size) As CameraSize + For i = 0 To list1.Size - 1 + r.target = list1.get(i) + cs(i).Width = r.GetField("width") + cs(i).Height = r.GetField("height") + Next + Return cs +End Sub + +Public Sub SetPictureSize(Width As Int, Height As Int) + r.target = parameters + r.RunMethod3("setPictureSize", Width, "java.lang.int", Height, "java.lang.int") +End Sub + +Public Sub SetJpegQuality(Quality As Int) + r.target = parameters + r.RunMethod2("setJpegQuality", Quality, "java.lang.int") +End Sub + +Public Sub SetFlashMode(Mode As String) + r.target = parameters + r.RunMethod2("setFlashMode", Mode, "java.lang.String") +End Sub + +Public Sub GetFlashMode As String + r.target = parameters + Return r.RunMethod("getFlashMode") +End Sub + +Public Sub GetSupportedFlashModes As List + r.target = parameters + Return r.RunMethod("getSupportedFlashModes") +End Sub + +Public Sub GetSupportedColorEffects As List + r.target = parameters + Return r.RunMethod("getSupportedColorEffects") +End Sub + +'Returns a list with the supported preview fps. Each item in the list is an array of two ints (minimum value and maximum value). +Public Sub GetSupportedPreviewFpsRange As List + r.target = parameters + Return r.RunMethod("getSupportedPreviewFpsRange") +End Sub +'Returns the current preview fps range. +'Range is a two elements array. The minimum value and maximum value will be stored in this array. +Public Sub GetPreviewFpsRange(Range() As Int) + r.target = parameters + r.RunMethod4("getPreviewFpsRange", Array As Object(Range), Array As String("[I")) +End Sub + +Public Sub SetPreviewFpsRange(MinValue As Int, MaxValue As Int) + r.target = parameters + r.RunMethod4("setPreviewFpsRange", Array As Object(MinValue, MaxValue), _ + Array As String("java.lang.int", "java.lang.int")) +End Sub + +Public Sub GetPreviewSize As CameraSize + r.target = parameters + r.target = r.RunMethod("getPreviewSize") + Dim cs As CameraSize + cs.Width = r.GetField("width") + cs.Height = r.GetField("height") + Return cs +End Sub + +Public Sub GetPictureSize As CameraSize + r.target = parameters + r.target = r.RunMethod("getPictureSize") + Dim cs As CameraSize + cs.Width = r.GetField("width") + cs.Height = r.GetField("height") + Return cs +End Sub + +'Converts a preview image formatted in YUV format to JPEG. +'Note that you should not save every preview image as it will slow down the whole process. +Public Sub PreviewImageToJpeg(data() As Byte, quality As Int) As Byte() + Dim size, previewFormat As Object + r.target = parameters + size = r.RunMethod("getPreviewSize") + previewFormat = r.RunMethod("getPreviewFormat") + r.target = size + Dim width = r.GetField("width"), height = r.GetField("height") As Int + Dim yuvImage As Object = r.CreateObject2("android.graphics.YuvImage", _ + Array As Object(data, previewFormat, width, height, Null), _ + Array As String("[B", "java.lang.int", "java.lang.int", "java.lang.int", "[I")) + r.target = yuvImage + Dim rect1 As Rect + rect1.Initialize(0, 0, r.RunMethod("getWidth"), r.RunMethod("getHeight")) + Dim out As OutputStream + out.InitializeToBytesArray(100) + r.RunMethod4("compressToJpeg", Array As Object(rect1, quality, out), _ + Array As String("android.graphics.Rect", "java.lang.int", "java.io.OutputStream")) + + Return out.ToBytesArray +End Sub + +Public Sub GetSupportedFocusModes As List + r.target = parameters + Return r.RunMethod("getSupportedFocusModes") +End Sub + +Public Sub SetContinuousAutoFocus + Dim modes As List = GetSupportedFocusModes + If modes.IndexOf("continuous-picture") > -1 Then + SetFocusMode("continuous-picture") + Else If modes.IndexOf("continuous-video") > -1 Then + SetFocusMode("continuous-video") + Else + Log("Continuous focus mode is not available") + End If +End Sub + +Public Sub SetFocusMode(Mode As String) + r.target = parameters + r.RunMethod2("setFocusMode", Mode, "java.lang.String") +End Sub + +Public Sub GetFocusDistances As Float() + Dim F(3) As Float + r.target = parameters + r.RunMethod4("getFocusDistances", Array As Object(F), Array As String("[F")) + Return F +End Sub + +Public Sub GetSupportedPictureFormats As List + r.target = parameters + Return r.RunMethod("getSupportedPictureFormats") +End Sub +'This method should only be called if you need to immediately release the camera. +'For example if you need to start another application that depends on the camera. +Public Sub CloseNow + cam.Release + r.target = cam + r.RunMethod2("releaseCameras", True, "java.lang.boolean") +End Sub +'Calls AutoFocus and then takes the picture if focus was successfull. +Public Sub FocusAndTakePicture + cam.AutoFocus +End Sub + + +Private Sub Camera_FocusDone (Success As Boolean) + If Success Then + Sleep(100) + TakePicture + Else + Log("AutoFocus error.") + End If +End Sub + +Public Sub IsZoomSupported As Boolean + r.target = parameters + Return r.RunMethod("isZoomSupported") +End Sub + +Public Sub GetMaxZoom As Int + r.target = parameters + Return r.RunMethod("getMaxZoom") +End Sub + +Public Sub getZoom() As Int + r.target = parameters + Return r.RunMethod("getZoom") +End Sub + +Public Sub setZoom(ZoomValue As Int) + r.target = parameters + r.RunMethod2("setZoom", ZoomValue, "java.lang.int") +End Sub + +Public Sub getExposureCompensation As Int + r.target = parameters + Return r.RunMethod("getExposureCompensation") +End Sub + +Public Sub setExposureCompensation(v As Int) + r.target = parameters + r.RunMethod2("setExposureCompensation", v, "java.lang.int") +End Sub + +Public Sub getMinExposureCompensation As Int + r.target = parameters + Return r.RunMethod("getMinExposureCompensation") +End Sub + +Public Sub getMaxExposureCompensation As Int + r.target = parameters + Return r.RunMethod("getMaxExposureCompensation") +End Sub + +Public Sub SetFaceDetectionListener + Dim jo As JavaObject = nativeCam + Dim e As Object = jo.CreateEvent("android.hardware.Camera.FaceDetectionListener", "FaceDetection", Null) + jo.RunMethod("setFaceDetectionListener", Array(e)) +End Sub + +Private Sub FaceDetection_Event (MethodName As String, Args() As Object) As Object + Dim faces() As Object = Args(0) + For Each f As Object In faces + Dim jo As JavaObject = f + Dim faceRect As Rect = jo.GetField("rect") 'ignore + Next + Return Null +End Sub + + + +Public Sub StartFaceDetection + Dim jo As JavaObject = nativeCam + jo.RunMethod("startFaceDetection", Null) +End Sub + +Public Sub StopFaceDetection + Dim jo As JavaObject = nativeCam + jo.RunMethod("stopFaceDetection", Null) +End Sub + diff --git a/B4A/CameraExClass2.bas b/B4A/CameraExClass2.bas new file mode 100644 index 0000000..bc84bf4 --- /dev/null +++ b/B4A/CameraExClass2.bas @@ -0,0 +1,399 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=6 +@EndOfDesignText@ +'Class module +'version 1.30 +'See this page for the list of constants: +'http://developer.android.com/intl/fr/reference/android/hardware/Camera.Parameters.html +'Note that you should use the constant values instead of the names. +Sub Class_Globals + Private nativeCam As Object + Private cam As Camera + Private r As Reflector + Private target As Object + Private event As String + Public Front As Boolean + Private parameters As Object +End Sub + +Public Sub Initialize (Panel1 As Panel, FrontCamera As Boolean, TargetModule As Object, EventName As String) + target = TargetModule + event = EventName + Front = FrontCamera + Dim id As Int + id = FindCamera(Front).id + If id = -1 Then + Front = Not(Front) 'try different camera + id = FindCamera(Front).id + If id = -1 Then + ToastMessageShow("No camera found.", True) + Return + End If + End If + cam.Initialize2(Panel1, "camera", id) +End Sub + +Private Sub FindCamera (frontCamera As Boolean) As CameraInfoAndId + Dim ci As CameraInfoAndId + Dim cameraInfo As Object + Dim cameraValue As Int + Log("findCamera") + If frontCamera Then cameraValue = 1 Else cameraValue = 0 + cameraInfo = r.CreateObject("android.hardware.Camera$CameraInfo") + Dim numberOfCameras As Int = r.RunStaticMethod("android.hardware.Camera", "getNumberOfCameras", Null, Null) + Log(r.target) + Log(numberOfCameras) + For i = 0 To numberOfCameras - 1 + r.RunStaticMethod("android.hardware.Camera", "getCameraInfo", Array As Object(i, cameraInfo), _ + Array As String("java.lang.int", "android.hardware.Camera$CameraInfo")) + r.target = cameraInfo + Log("facing: " & r.GetField("facing") & ", " & cameraValue) + If r.GetField("facing") = cameraValue Then + ci.cameraInfo = r.target + ci.Id = i + Return ci + End If + Next + ci.id = -1 + Return ci +End Sub + +Private Sub SetDisplayOrientation + r.target = r.GetActivity + r.target = r.RunMethod("getWindowManager") + r.target = r.RunMethod("getDefaultDisplay") + r.target = r.RunMethod("getRotation") + Dim previewResult, result, degrees As Int = r.target * 90 + Dim ci As CameraInfoAndId = FindCamera(Front) + r.target = ci.CameraInfo + Dim orientation As Int = r.GetField("orientation") + If Front Then + previewResult = (orientation + degrees) Mod 360 + result = previewResult + previewResult = (360 - previewResult) Mod 360 + Else + previewResult = (orientation - degrees + 360) Mod 360 + result = previewResult + Log(previewResult) + End If + r.target = nativeCam + r.RunMethod2("setDisplayOrientation", previewResult, "java.lang.int") + r.target = parameters + r.RunMethod2("setRotation", result, "java.lang.int") + CommitParameters +End Sub + +Private Sub Camera_Ready (Success As Boolean) + If Success Then + r.target = cam + nativeCam = r.GetField("camera") + r.target = nativeCam + parameters = r.RunMethod("getParameters") + SetDisplayOrientation + Else + Log("success = false, " & LastException) + End If + CallSub2(target, event & "_ready", Success) +End Sub +'Uncomment this sub if you need to handle the Preview event +'Sub Camera_Preview (Data() As Byte) +' If SubExists(target, event & "_preview") Then +' CallSub2(target, event & "_preview", Data) +' End If +'End Sub + +Public Sub TakePicture + cam.TakePicture +End Sub + +Private Sub Camera_PictureTaken (Data() As Byte) + CallSub2(target, event & "_PictureTaken", Data) +End Sub + +Public Sub StartPreview + cam.StartPreview +End Sub + +Public Sub StopPreview + cam.StopPreview +End Sub + +Public Sub Release + cam.Release +End Sub + +'Saves the data received from PictureTaken event +Public Sub SavePictureToFile(Data() As Byte, Dir As String, FileName As String) + Dim out As OutputStream = File.OpenOutput(Dir, FileName, False) + out.WriteBytes(Data, 0, Data.Length) + out.Close +End Sub + +Public Sub SetParameter(Key As String, Value As String) + r.target = parameters + r.RunMethod3("set", Key, "java.lang.String", Value, "java.lang.String") +End Sub + +Public Sub GetParameter(Key As String) As String + r.target = parameters + Return r.RunMethod2("get", Key, "java.lang.String") +End Sub + +Public Sub CommitParameters + 'Try + r.target = nativeCam + r.RunMethod4("setParameters", Array As Object(parameters), Array As String("android.hardware.Camera$Parameters")) + 'Catch +' ToastMessageShow("Error setting parameters.", True) +' Log(LastException) +' End Try +End Sub + +Public Sub GetColorEffect As String + Return GetParameter("effect") +End Sub + +Public Sub SetColorEffect(Effect As String) + SetParameter("effect", Effect) +End Sub + +Public Sub GetSupportedPreviewSizes As CameraSize() + r.target = parameters + Dim list1 As List = r.RunMethod("getSupportedPreviewSizes") + Dim cs(list1.Size) As CameraSize + For i = 0 To list1.Size - 1 + r.target = list1.get(i) + cs(i).Width = r.GetField("width") + cs(i).Height = r.GetField("height") + Next + Return cs +End Sub + +Public Sub SetPreviewSize(Width As Int, Height As Int) + r.target = parameters + r.RunMethod3("setPreviewSize", Width, "java.lang.int", Height, "java.lang.int") +End Sub +Public Sub GetSupportedPicturesSizes As CameraSize() + r.target = parameters + Dim list1 As List = r.RunMethod("getSupportedPictureSizes") + Dim cs(list1.Size) As CameraSize + For i = 0 To list1.Size - 1 + r.target = list1.get(i) + cs(i).Width = r.GetField("width") + cs(i).Height = r.GetField("height") + Next + Return cs +End Sub + +Public Sub SetPictureSize(Width As Int, Height As Int) + r.target = parameters + r.RunMethod3("setPictureSize", Width, "java.lang.int", Height, "java.lang.int") +End Sub + +Public Sub SetJpegQuality(Quality As Int) + r.target = parameters + r.RunMethod2("setJpegQuality", Quality, "java.lang.int") +End Sub + +Public Sub SetFlashMode(Mode As String) + r.target = parameters + r.RunMethod2("setFlashMode", Mode, "java.lang.String") +End Sub + +Public Sub GetFlashMode As String + r.target = parameters + Return r.RunMethod("getFlashMode") +End Sub + +Public Sub GetSupportedFlashModes As List + r.target = parameters + Return r.RunMethod("getSupportedFlashModes") +End Sub + +Public Sub GetSupportedColorEffects As List + r.target = parameters + Return r.RunMethod("getSupportedColorEffects") +End Sub + +'Returns a list with the supported preview fps. Each item in the list is an array of two ints (minimum value and maximum value). +Public Sub GetSupportedPreviewFpsRange As List + r.target = parameters + Return r.RunMethod("getSupportedPreviewFpsRange") +End Sub +'Returns the current preview fps range. +'Range is a two elements array. The minimum value and maximum value will be stored in this array. +Public Sub GetPreviewFpsRange(Range() As Int) + r.target = parameters + r.RunMethod4("getPreviewFpsRange", Array As Object(Range), Array As String("[I")) +End Sub + +Public Sub SetPreviewFpsRange(MinValue As Int, MaxValue As Int) + r.target = parameters + r.RunMethod4("setPreviewFpsRange", Array As Object(MinValue, MaxValue), _ + Array As String("java.lang.int", "java.lang.int")) +End Sub + +Public Sub GetPreviewSize As CameraSize + r.target = parameters + r.target = r.RunMethod("getPreviewSize") + Dim cs As CameraSize + cs.Width = r.GetField("width") + cs.Height = r.GetField("height") + Return cs +End Sub + +Public Sub GetPictureSize As CameraSize + r.target = parameters + r.target = r.RunMethod("getPictureSize") + Dim cs As CameraSize + cs.Width = r.GetField("width") + cs.Height = r.GetField("height") + Return cs +End Sub + +'Converts a preview image formatted in YUV format to JPEG. +'Note that you should not save every preview image as it will slow down the whole process. +Public Sub PreviewImageToJpeg(data() As Byte, quality As Int) As Byte() + Dim size, previewFormat As Object + r.target = parameters + size = r.RunMethod("getPreviewSize") + previewFormat = r.RunMethod("getPreviewFormat") + r.target = size + Dim width = r.GetField("width"), height = r.GetField("height") As Int + Dim yuvImage As Object = r.CreateObject2("android.graphics.YuvImage", _ + Array As Object(data, previewFormat, width, height, Null), _ + Array As String("[B", "java.lang.int", "java.lang.int", "java.lang.int", "[I")) + r.target = yuvImage + Dim rect1 As Rect + rect1.Initialize(0, 0, r.RunMethod("getWidth"), r.RunMethod("getHeight")) + Dim out As OutputStream + out.InitializeToBytesArray(100) + r.RunMethod4("compressToJpeg", Array As Object(rect1, quality, out), _ + Array As String("android.graphics.Rect", "java.lang.int", "java.io.OutputStream")) + Return out.ToBytesArray +End Sub + +Public Sub GetSupportedFocusModes As List + r.target = parameters + Return r.RunMethod("getSupportedFocusModes") +End Sub + +Public Sub SetContinuousAutoFocus + Dim modes As List = GetSupportedFocusModes + If modes.IndexOf("continuous-picture") > -1 Then + SetFocusMode("continuous-picture") + Else If modes.IndexOf("continuous-video") > -1 Then + SetFocusMode("continuous-video") + Else + Log("Continuous focus mode is not available") + End If +End Sub + +Public Sub SetFocusMode(Mode As String) + r.target = parameters + r.RunMethod2("setFocusMode", Mode, "java.lang.String") +End Sub + +Public Sub GetFocusDistances As Float() + Dim F(3) As Float + r.target = parameters + r.RunMethod4("getFocusDistances", Array As Object(F), Array As String("[F")) + Return F +End Sub + +Public Sub GetSupportedPictureFormats As List + r.target = parameters + Return r.RunMethod("getSupportedPictureFormats") +End Sub +'This method should only be called if you need to immediately release the camera. +'For example if you need to start another application that depends on the camera. +Public Sub CloseNow + cam.Release + r.target = cam + r.RunMethod2("releaseCameras", True, "java.lang.boolean") +End Sub +'Calls AutoFocus and then takes the picture if focus was successfull. +Public Sub FocusAndTakePicture + cam.AutoFocus +End Sub + + +Private Sub Camera_FocusDone (Success As Boolean) + If Success Then + TakePicture + Else + Log("AutoFocus error.") + End If +End Sub + +Public Sub IsZoomSupported As Boolean + r.target = parameters + Return r.RunMethod("isZoomSupported") +End Sub + +Public Sub GetMaxZoom As Int + r.target = parameters + Return r.RunMethod("getMaxZoom") +End Sub + +Public Sub getZoom() As Int + r.target = parameters + Return r.RunMethod("getZoom") +End Sub + +Public Sub setZoom(ZoomValue As Int) + r.target = parameters + r.RunMethod2("setZoom", ZoomValue, "java.lang.int") +End Sub + +Public Sub getExposureCompensation As Int + r.target = parameters + Return r.RunMethod("getExposureCompensation") +End Sub + +Public Sub setExposureCompensation(v As Int) + r.target = parameters + r.RunMethod2("setExposureCompensation", v, "java.lang.int") +End Sub + +Public Sub getMinExposureCompensation As Int + r.target = parameters + Return r.RunMethod("getMinExposureCompensation") +End Sub + +Public Sub getMaxExposureCompensation As Int + r.target = parameters + Return r.RunMethod("getMaxExposureCompensation") +End Sub + +Public Sub SetFaceDetectionListener + Dim jo As JavaObject = nativeCam + Dim e As Object = jo.CreateEvent("android.hardware.Camera.FaceDetectionListener", "FaceDetection", Null) + jo.RunMethod("setFaceDetectionListener", Array(e)) +End Sub + +Private Sub FaceDetection_Event (MethodName As String, Args() As Object) As Object + Dim faces() As Object = Args(0) + For Each f As Object In faces + Dim jo As JavaObject = f + Dim faceRect As Rect = jo.GetField("rect") + Log(faceRect) + Next + Return Null +End Sub + + + +Public Sub StartFaceDetection + Dim jo As JavaObject = nativeCam + jo.RunMethod("startFaceDetection", Null) +End Sub + +Public Sub StopFaceDetection + Dim jo As JavaObject = nativeCam + jo.RunMethod("stopFaceDetection", Null) +End Sub + diff --git a/B4A/DBRequestManager.bas b/B4A/DBRequestManager.bas new file mode 100644 index 0000000..31298ba --- /dev/null +++ b/B4A/DBRequestManager.bas @@ -0,0 +1,272 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=6.8 +@EndOfDesignText@ +''Class module + +'' Requiere accesRandom File y requiere compressStrings, byte converter y okhhtputuils2 +Sub Class_Globals + Private mTarget As Object + Type DBResult (Tag As Object, Columns As Map, Rows As List) + Type DBCommand (Name As String, Parameters() As Object) + Private link As String + Private bc As ByteConverter + Private T_NULL = 0, T_STRING = 1, T_SHORT = 2, T_INT = 3, T_LONG = 4, T_FLOAT = 5 _ + ,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte + Private VERSION As Float = 0.9 + Private tempArray(1) As Object + Dim jobTagAnterior As String = "" 'Mod por CHV - 211109 +End Sub + +'Target - The module that handles JobDone (usually Me). +'ConnectorLink - URL of the Java server. +Public Sub Initialize (Target As Object, ConnectorLink As String) + mTarget = Target + link = ConnectorLink +End Sub + +'Sends a query request. +'Command - Query name and parameters. +'Limit - Maximum rows to return or 0 for no limit. +'Tag - An object that will be returned in the result. +Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object) + Dim j As HttpJob + Dim ms As OutputStream + Dim out2 As OutputStream = StartJob(j,ms, Tag) + + WriteObject(Command.Name, out2) + WriteInt(Limit, out2) + WriteList(Command.Parameters, out2) + out2.Close + j.PostBytes(link & "?method=query", ms.ToBytesArray) +End Sub + +'Executes a batch of (non-select) commands. +'ListOfCommands - List of the commands that will be executes. +'Tag - An object that will be returned in the result. +Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object) + Dim j As HttpJob + Dim ms As OutputStream + Dim out2 As OutputStream = StartJob(j,ms, Tag) + WriteInt(ListOfCommands.Size, out2) + For Each Command As DBCommand In ListOfCommands + WriteObject(Command.Name, out2) + WriteList(Command.Parameters, out2) + Next + out2.Close + j.PostBytes(link & "?method=batch", ms.ToBytesArray) +End Sub + +'Similar to ExecuteBatch. Sends a single command. +Public Sub ExecuteCommand(Command As DBCommand, Tag As Object) + ExecuteBatch(Array As DBCommand(Command), Tag) +End Sub + +Private Sub StartJob(j As HttpJob, MemoryStream As OutputStream, Tag As Object) As OutputStream + j.Initialize("DBRequest", mTarget) + j.Tag = Tag + MemoryStream.InitializeToBytesArray(0) + Dim compress As CompressedStreams + Dim out As OutputStream = compress.WrapOutputStream(MemoryStream, "gzip") + WriteObject(VERSION, out) + Return out +End Sub + +Private Sub WriteList(Parameters As List, out As OutputStream) + Dim data() As Byte + If Parameters = Null Or Parameters.IsInitialized = False Then + Dim Parameters As List + Parameters.Initialize + End If + data = bc.IntsToBytes(Array As Int(Parameters.Size)) + out.WriteBytes(data, 0, data.Length) + For Each o As Object In Parameters + WriteObject(o, out) + Next +End Sub + +Private Sub WriteObject(o As Object, out As OutputStream) + Dim data() As Byte + tempArray(0) = o + If tempArray(0) = Null Then + out.WriteBytes(Array As Byte(T_NULL), 0, 1) + Else If tempArray(0) Is Short Then + out.WriteBytes(Array As Byte(T_SHORT), 0, 1) + data = bc.ShortsToBytes(Array As Short(o)) + Else If tempArray(0) Is Int Then + out.WriteBytes(Array As Byte(T_INT), 0, 1) + data = bc.IntsToBytes(Array As Int(o)) + Else If tempArray(0) Is Float Then + out.WriteBytes(Array As Byte(T_FLOAT), 0, 1) + data = bc.FloatsToBytes(Array As Float(o)) + Else If tempArray(0) Is Double Then + out.WriteBytes(Array As Byte(T_DOUBLE), 0, 1) + data = bc.DoublesToBytes(Array As Double(o)) + Else If tempArray(0) Is Long Then + out.WriteBytes(Array As Byte(T_LONG), 0, 1) + data = bc.LongsToBytes(Array As Long(o)) + Else If tempArray(0) Is Boolean Then + out.WriteBytes(Array As Byte(T_BOOLEAN), 0, 1) + Dim b As Boolean = 0 + Dim data(1) As Byte + If b Then data(0) = 1 Else data(0) = 0 + Else If GetType(tempArray(0)) = "[B" Then + data = o + out.WriteBytes(Array As Byte(T_BLOB), 0, 1) + WriteInt(data.Length, out) + Else 'If o Is String Then (treat all other values as string) + out.WriteBytes(Array As Byte(T_STRING), 0, 1) + data = bc.StringToBytes(o, "UTF8") + WriteInt(data.Length, out) + End If + If data.Length > 0 Then out.WriteBytes(data, 0, data.Length) +End Sub + +Private Sub ReadObject(In As InputStream) As Object + Dim data(1) As Byte + In.ReadBytes(data, 0, 1) + Select data(0) + Case T_NULL + Return Null + Case T_SHORT + Dim data(2) As Byte + Return bc.ShortsFromBytes(ReadBytesFully(In, data, data.Length))(0) + Case T_INT + Dim data(4) As Byte + Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0) + Case T_LONG + Dim data(8) As Byte + Return bc.LongsFromBytes(ReadBytesFully(In, data, data.Length))(0) + Case T_FLOAT + Dim data(4) As Byte + Return bc.FloatsFromBytes(ReadBytesFully(In, data, data.Length))(0) + Case T_DOUBLE + Dim data(8) As Byte + Return bc.DoublesFromBytes(ReadBytesFully(In, data, data.Length))(0) + Case T_BOOLEAN + Dim b As Byte = ReadByte(In) + Return b = 1 + Case T_BLOB + Dim len As Int = ReadInt(In) + Dim data(len) As Byte + Return ReadBytesFully(In, data, data.Length) + Case Else + Dim len As Int = ReadInt(In) + Dim data(len) As Byte + ReadBytesFully(In, data, data.Length) + Return BytesToString(data, 0, data.Length, "UTF8") + End Select +End Sub + +Private Sub ReadBytesFully(In As InputStream, Data() As Byte, Len As Int) As Byte() + Dim count = 0, read As Int + Do While count < Len And read > -1 + read = In.ReadBytes(Data, count, Len - count) + count = count + read + Loop + Return Data +End Sub + +Private Sub WriteInt(i As Int, out As OutputStream) + Dim data() As Byte + data = bc.IntsToBytes(Array As Int(i)) + out.WriteBytes(data, 0, data.Length) +End Sub + +Private Sub ReadInt(In As InputStream) As Int + Dim data(4) As Byte + Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0) +End Sub + +Private Sub ReadByte(In As InputStream) As Byte + Dim data(1) As Byte + In.ReadBytes(data, 0, 1) + Return data(0) +End Sub + +'Handles the Job result and returns a DBResult. +Public Sub HandleJob(Job As HttpJob) As DBResult + Dim start As Long = DateTime.Now 'ignore + Dim In As InputStream = Job.GetInputStream + Dim cs As CompressedStreams + In = cs.WrapInputStream(In, "gzip") + Dim serverVersion As Float = ReadObject(In) 'ignore + Dim method As String = ReadObject(In) + Dim table As DBResult + table.Initialize + table.Columns.Initialize + table.rows.Initialize + table.Tag = Job.Tag + If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211109 + jobTagAnterior = Job.Tag 'Mod por CHV - 211109 + If method = "query" Then + Dim numberOfColumns As Int = ReadInt(In) + For i = 0 To numberOfColumns - 1 + table.Columns.Put(ReadObject(In), i) + Next + Do While ReadByte(In) = 1 + Dim rowObjects(numberOfColumns) As Object + table.rows.Add(rowObjects) + For col = 0 To numberOfColumns - 1 + Dim o As Object = ReadObject(In) + rowObjects(col) = o + Next + Loop + Else If method = "batch" Then + table.Columns.Put("AffectedRows", 0) + Dim rows As Int = ReadInt(In) + For i = 0 To rows - 1 + table.rows.Add(Array As Object(ReadInt(In))) + Next + End If + In.Close +' Log("HandleJob: " & (DateTime.Now - start))'Comentado por CHV - 211112 + Return table +End Sub +'Reads a file and returns the file as a bytes array. +Public Sub FileToBytes(Dir As String, FileName As String) As Byte() + Dim out As OutputStream + out.InitializeToBytesArray(0) + Dim In As InputStream = File.OpenInput(Dir, FileName) + File.Copy2(In, out) + out.Close + Return out.ToBytesArray +End Sub +'Converts an image to a bytes array (for BLOB fields). +Public Sub ImageToBytes(Image As Bitmap) As Byte() + Dim out As OutputStream + out.InitializeToBytesArray(0) + Image.WriteToStream(out, 100, "JPEG") + out.Close + Return out.ToBytesArray +End Sub +'Converts a bytes array to an image (for BLOB fields). +Public Sub BytesToImage(bytes() As Byte) As Bitmap + Dim In As InputStream + In.InitializeFromBytesArray(bytes, 0, bytes.Length) + Dim bmp As Bitmap + bmp.Initialize2(In) + Return bmp +End Sub +'Prints the table to the logs. +Public Sub PrintTable(Table As DBResult) + Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size) + Dim sb As StringBuilder + sb.Initialize + For Each col In Table.Columns.Keys + sb.Append(col).Append(TAB) + Next + Log(sb.ToString) + For Each row() As Object In Table.Rows + Dim sb As StringBuilder + sb.Initialize + For Each record As Object In row + sb.Append(record).Append(TAB) + Next + ToastMessageShow(sb.ToString, True) + Next +End Sub + + \ No newline at end of file diff --git a/B4A/Files/camara.png b/B4A/Files/camara.png new file mode 100644 index 0000000..be1ed84 Binary files /dev/null and b/B4A/Files/camara.png differ diff --git a/B4A/Files/cont_folio.bal b/B4A/Files/cont_folio.bal new file mode 100644 index 0000000..76b494c Binary files /dev/null and b/B4A/Files/cont_folio.bal differ diff --git a/B4A/Files/detalle_folio.bal b/B4A/Files/detalle_folio.bal new file mode 100644 index 0000000..06ec30a Binary files /dev/null and b/B4A/Files/detalle_folio.bal differ diff --git a/B4A/Files/escaneo.bal b/B4A/Files/escaneo.bal new file mode 100644 index 0000000..4e0781f Binary files /dev/null and b/B4A/Files/escaneo.bal differ diff --git a/B4A/Files/fondoalmancen2.png b/B4A/Files/fondoalmancen2.png new file mode 100644 index 0000000..bfecb37 Binary files /dev/null and b/B4A/Files/fondoalmancen2.png differ diff --git a/B4A/Files/kmt.db b/B4A/Files/kmt.db new file mode 100644 index 0000000..2cbbb8e Binary files /dev/null and b/B4A/Files/kmt.db differ diff --git a/B4A/Files/lector.png b/B4A/Files/lector.png new file mode 100644 index 0000000..c2549e4 Binary files /dev/null and b/B4A/Files/lector.png differ diff --git a/B4A/Files/logo-salma.png b/B4A/Files/logo-salma.png new file mode 100644 index 0000000..eebc6c6 Binary files /dev/null and b/B4A/Files/logo-salma.png differ diff --git a/B4A/Files/lupa.png b/B4A/Files/lupa.png new file mode 100644 index 0000000..16148bb Binary files /dev/null and b/B4A/Files/lupa.png differ diff --git a/B4A/Files/mainpage.bal b/B4A/Files/mainpage.bal new file mode 100644 index 0000000..c8537e8 Binary files /dev/null and b/B4A/Files/mainpage.bal differ diff --git a/B4A/Files/seleccion.bal b/B4A/Files/seleccion.bal new file mode 100644 index 0000000..4537e0b Binary files /dev/null and b/B4A/Files/seleccion.bal differ diff --git a/B4A/SALMA-ALMACEN.b4a b/B4A/SALMA-ALMACEN.b4a new file mode 100644 index 0000000..03a62f0 --- /dev/null +++ b/B4A/SALMA-ALMACEN.b4a @@ -0,0 +1,124 @@ +Build1=Default,b4a.example +File1=camara.png +File10=seleccion.bal +File2=cont_folio.bal +File3=detalle_folio.bal +File4=escaneo.bal +File5=fondoalmancen2.png +File6=lector.png +File7=logo-salma.png +File8=lupa.png +File9=MainPage.bal +FileGroup1=Default Group +FileGroup10=Default Group +FileGroup2=Default Group +FileGroup3=Default Group +FileGroup4=Default Group +FileGroup5=Default Group +FileGroup6=Default Group +FileGroup7=Default Group +FileGroup8=Default Group +FileGroup9=Default Group +Group=Default Group +Library1=accessibility +Library10=okhttputils2 +Library11=phone +Library12=randomaccessfile +Library13=reflection +Library14=runtimepermissions +Library15=sql +Library16=stringutils +Library17=xcustomlistview +Library18=xui views +Library19=xui +Library2=aswheelpicker +Library3=b4xpages +Library4=bctoast +Library5=byteconverter +Library6=camera +Library7=compressstrings +Library8=core +Library9=ime +ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~~\n~)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~CreateResourceFromFile(Macro, Themes.LightTheme)~\n~SetApplicationAttribute(android:usesCleartextTraffic, "true")~\n~'End of default text.~\n~AddApplicationText(~\n~~\n~ ~\n~)~\n~~\n~AddManifestText(~\n~~\n~)~\n~AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)~\n~~\n~AddManifestText(~\n~) +Module1=|relative|..\B4XMainPage +Module2=C_escaneo +Module3=C_seleccion +Module4=CameraExClass +Module5=CameraExClass2 +Module6=DBRequestManager +Module7=Starter +Module8=Subs +NumberOfFiles=10 +NumberOfLibraries=19 +NumberOfModules=8 +Version=11.8 +@EndOfDesignText@ +#Region Project Attributes + #ApplicationLabel: SALMA ALMACEN + #VersionCode: 1 + #VersionName: + 'SupportedOrientations possible values: unspecified, landscape or portrait. + #SupportedOrientations: portrait + #CanInstallToExternalStorage: False +#End Region + +#Region Activity Attributes + #FullScreen: False + #IncludeTitle: False +#End Region +#AdditionalJar: com.google.android.gms:play-services-vision +'#BridgeLogger: True + +Sub Process_Globals + Public ActionBarHomeClicked As Boolean +End Sub + +Sub Globals + Type CameraInfoAndId (CameraInfo As Object, Id As Int) + Type CameraSize (Width As Int, Height As Int) +End Sub + +Sub Activity_Create(FirstTime As Boolean) + Dim pm As B4XPagesManager + pm.Initialize(Activity) +End Sub + +'Template version: B4A-1.01 +#Region Delegates + +Sub Activity_ActionBarHomeClick + ActionBarHomeClicked = True + B4XPages.Delegate.Activity_ActionBarHomeClick + ActionBarHomeClicked = False +End Sub + +Sub Activity_KeyPress (KeyCode As Int) As Boolean + Return B4XPages.Delegate.Activity_KeyPress(KeyCode) +End Sub + +Sub Activity_Resume + B4XPages.Delegate.Activity_Resume +End Sub + +Sub Activity_Pause (UserClosed As Boolean) + B4XPages.Delegate.Activity_Pause +End Sub + +Sub Activity_PermissionResult (Permission As String, Result As Boolean) + B4XPages.Delegate.Activity_PermissionResult(Permission, Result) +End Sub + +Sub Create_Menu (Menu As Object) + B4XPages.Delegate.Create_Menu(Menu) +End Sub + +#if Java +public boolean _onCreateOptionsMenu(android.view.Menu menu) { + processBA.raiseEvent(null, "create_menu", menu); + return true; + +} +#End If +#End Region + +'Program code should go into B4XMainPage and other pages. \ No newline at end of file diff --git a/B4A/SALMA-ALMACEN.b4a.meta b/B4A/SALMA-ALMACEN.b4a.meta new file mode 100644 index 0000000..c597a4a --- /dev/null +++ b/B4A/SALMA-ALMACEN.b4a.meta @@ -0,0 +1,30 @@ +ModuleBookmarks0= +ModuleBookmarks1= +ModuleBookmarks2= +ModuleBookmarks3= +ModuleBookmarks4= +ModuleBookmarks5= +ModuleBookmarks6= +ModuleBookmarks7= +ModuleBookmarks8= +ModuleBreakpoints0= +ModuleBreakpoints1= +ModuleBreakpoints2= +ModuleBreakpoints3= +ModuleBreakpoints4= +ModuleBreakpoints5= +ModuleBreakpoints6= +ModuleBreakpoints7= +ModuleBreakpoints8= +ModuleClosedNodes0= +ModuleClosedNodes1= +ModuleClosedNodes2= +ModuleClosedNodes3= +ModuleClosedNodes4= +ModuleClosedNodes5= +ModuleClosedNodes6= +ModuleClosedNodes7= +ModuleClosedNodes8= +NavigationStack=C_escaneo,CreateListItem,621,0,C_seleccion,b_cargar_Click,52,0,C_seleccion,JobDone,84,0,Subs,revisaBD,12,0,C_escaneo,B4XPage_Appear,244,0,C_escaneo,B4XPage_CloseRequest,1251,0,C_escaneo,Class_Globals,49,0,Diseñador Visual,escaneo.bal,-100,6,Diseñador Visual,MainPage.bal,-100,1,C_escaneo,B4XPage_Created,228,6 +SelectedBuild=0 +VisibleModules=7,1,3,2,8,6,4,5 diff --git a/B4A/Starter.bas b/B4A/Starter.bas new file mode 100644 index 0000000..9ac1dd0 --- /dev/null +++ b/B4A/Starter.bas @@ -0,0 +1,50 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Service +Version=9.85 +@EndOfDesignText@ +#Region Service Attributes + #StartAtBoot: False + #ExcludeFromLibrary: 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. + + Public rp As RuntimePermissions + Dim reqManager As DBRequestManager + Dim DBReqServer As String = "http://11.0.0.179:1782" '"http://keymon.lat:1782" "http://10.0.0.205:1782" "http://keymon.lat:1783" "http://11.0.0.48:1783" ""' CAMBIAR HACIA AFUERA O DENTRO DE LA OFNA +' Dim server As String = "http://10.0.0.205:1782" + Dim rutaBD As String = File.DirInternal + Dim skmt As SQL + Dim almacen As String + +End Sub + +Sub Service_Create + 'This is the program entry point. + 'This is a good place to load resources that are not specific to a single activity. + +End Sub + +Sub Service_Start (StartingIntent As Intent) + Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases. + Subs.revisaBD + reqManager.Initialize(Me, DBReqServer) + If Not(skmt.IsInitialized) Then skmt.Initialize(rutaBD, "kmt.db", True) +End Sub + +Sub Service_TaskRemoved + 'This event will be raised when the user removes the app from the recent apps list. +End Sub + +'Return true to allow the OS default exceptions handler to handle the uncaught exception. +Sub Application_Error (Error As Exception, StackTrace As String) As Boolean + Return True +End Sub + +Sub Service_Destroy + +End Sub diff --git a/B4A/Subs.bas b/B4A/Subs.bas new file mode 100644 index 0000000..c29f01c --- /dev/null +++ b/B4A/Subs.bas @@ -0,0 +1,25 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=StaticCode +Version=11.5 +@EndOfDesignText@ +'Code module +'Subs in this code module will be accessible from all modules. +Sub Process_Globals + 'These global variables will be declared once when the application starts. + 'These variables can be accessed from all modules. +End Sub + +'Revisa que exista la BD y si es necesario crea algunas tablas dentro de ella +Sub revisaBD 'ignore + If Not(File.Exists(Starter.rutaBD, "kmt.db")) Then File.Copy(File.DirAssets, "kmt.db", Starter.rutaBD, "kmt.db") + If Not(Starter.skmt.IsInitialized) Then Starter.skmt.Initialize(Starter.rutaBD, "kmt.db", True) + Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_FOLIOS_ALMACEN(FOLIO_ENTREGA TEXT, FOLIO_ID TEXT, FOLIO_REFERENCIA_FACTURA TEXT)") + Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_PRODUCTOS_ALMACEN(CAT_GP_ID TEXT, CAT_GP_NOMBRE TEXT, CAT_GP_DUN14 TEXT)") + Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_EQUIVALENCIAS_ALMACEN(CAT_EQ_CODIGO TEXT, CAT_EQ_EQUIVALENCIA TEXT)") +' Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_DETALLEFOLIO(CAT_DF_ID TEXT, CAT_DF_NOMBRE TEXT,CAT_DF_RUTA TEXT, CAT_DF_CANTINICIAL TEXT, CAT_DF_CANTIDADESCRITA TEXT)") +' Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS PICKING (CODIGO TEXT, RUTA TEXT, CANTIDAD_INICIAL TEXT, CANTIDAD_FINAL TEXT,CANTIDAD_ESCRITA TEXT)") +' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS PICKING") +' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS CAT_DETALLEFOLIO") +End Sub \ No newline at end of file diff --git a/gitpull.bat b/gitpull.bat new file mode 100644 index 0000000..d0aed61 --- /dev/null +++ b/gitpull.bat @@ -0,0 +1 @@ +git pull diff --git a/lupa.png b/lupa.png new file mode 100644 index 0000000..16148bb Binary files /dev/null and b/lupa.png differ