B4A=true Group=Default Group ModulesStructureVersion=1 Type=Activity Version=6.8 @EndOfDesignText@ #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 ruta As String Dim q_buscar As String 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. Dim skmt As SQL Dim c As Cursor Dim c2 As Cursor Dim ListView1 As ListView Dim entro As String Dim gest As Button Dim lfila As Label Dim marca As String Dim tipo As String Dim subtipo As String Private BUSCA As EditText Dim ya_entro 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("Layout1") Activity.LoadLayout("fila") 'Dim ruta As String ruta = File.DirInternal ' se crea o no el archivo de la base de ddatos de kmt 'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE 'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA 'SI SE REGRESA A ESTE ACTIVIDAD. If File.Exists(ruta, "kmt.db") = False Then File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db") End If skmt.Initialize(ruta,"kmt.db", True) End Sub Sub Activity_Resume 'If ya_entro <> "1" Then BUSCA.Text ="" skmt.Initialize(ruta,"kmt.db", True) entro ="1" ya_entro ="1" c=skmt.ExecQuery("select CAT_GP_CLASIF, count(*) as cuantos from cat_gunaprod where CAT_GP_ALMACEN > 0 group by CAT_GP_CLASIF order by CAT_GP_CLASIF asc") ListView1.Clear lfila.Text = "MARCA" If c.RowCount>0 Then For i=0 To c.RowCount -1 c.Position=i Dim label1 As Label label1 = ListView1.TwoLinesLayout.Label label1.TextSize = 10 label1.TextColor = Colors.White Dim label2 As Label label2 = ListView1.TwoLinesLayout.SecondLabel label2.TextSize = 10 label2.TextColor = Colors.White Dim label13 As Label label13 = ListView1.TwoLinesAndBitmap.Label label13.TextSize = 10 label13.TextColor = Colors.White Dim label14 As Label label14 = ListView1.TwoLinesAndBitmap.SecondLabel label14.TextSize = 10 label14.TextColor = Colors.White ListView1.AddTwoLines(c.GetString("CAT_GP_CLASIF"),c.GetString("cuantos")) Next End If 'End If End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub ListView1_ItemClick (Position As Int, Value As Object) 'Sub ListView1_ItemLongClick (Position As Int, Value As Object) 'que_colonia = Value 'StartActivity(fila) If Value = "PROMOS" Then entro = "3" marca = "PROMOS" tipo = "PROMOS" End If If entro = "1" Then marca = Value skmt.Initialize(ruta,"kmt.db", True) c2=skmt.ExecQuery2("select COUNT(*) AS CUANTOS, CAT_GP_TIPO from cat_gunaprod where CAT_GP_ALMACEN > 0 and CAT_GP_CLASIF = ? GROUP BY CAT_GP_TIPO ORDER BY CAT_GP_TIPO ASC", Array As String(Value)) ListView1.Clear lfila.text = "TIPO" If c2.RowCount>0 Then For i=0 To c2.RowCount -1 c2.Position=i ListView1.AddTwoLines(c2.GetString("CAT_GP_TIPO"),c2.GetString("CUANTOS")) Next End If entro = "2" Else If entro = "2" Then tipo = Value skmt.Initialize(ruta,"kmt.db", True) c2=skmt.ExecQuery2("select COUNT(*) AS CUANTOS, CAT_GP_SUBTIPO from cat_gunaprod where CAT_GP_ALMACEN > 0 and CAT_GP_CLASIF = ? and CAT_GP_TIPO = ? GROUP BY CAT_GP_SUBTIPO ORDER BY CAT_GP_SUBTIPO ASC ", Array As String(marca, Value)) ListView1.Clear lfila.text = "SUB-TIPO" If c2.RowCount>0 Then For i=0 To c2.RowCount -1 c2.Position=i ListView1.AddTwoLines(c2.GetString("CAT_GP_SUBTIPO"),c2.GetString("CUANTOS")) Next End If entro = "3" Else If entro = "3" Then skmt.Initialize(ruta,"kmt.db", True) c2=skmt.ExecQuery2("select CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from cat_gunaprod where CAT_GP_ALMACEN > 0 and CAT_GP_CLASIF = ? AND CAT_GP_TIPO = ? AND CAT_GP_SUBTIPO = ? ", Array As String(marca, tipo, Value)) ListView1.Clear lfila.text = "PRODUCTO" Dim ins As InputStream Dim bmp As Bitmap Dim jpeg() As Byte If c2.RowCount>0 Then For i=0 To c2.RowCount -1 c2.Position=i jpeg = c2.GetBlob("CAT_GP_IMG") ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length) bmp.Initialize2(ins) ListView1.AddTwoLinesAndBitmap(c2.GetString("CAT_GP_NOMBRE"),"# " & c2.GetString("CAT_GP_ALMACEN") & " $ " & c2.GetString("CAT_GP_PRECIO"),bmp) Next End If entro = "4" Else If entro = "4" Then skmt.ExecNonQuery("delete from PROID") skmt.ExecNonQuery2("INSERT INTO PROID VALUES (?)", Array As Object(Value)) StartActivity(pedidos) End If End Sub Sub Activity_KeyPress (key As Int) As Boolean ' BACK key pressed If key=KeyCodes.KEYCODE_BACK Then ya_entro ="0" If entro = "4" Then entro = "3" Activity_Resume Return True Else If entro = "3" Then entro = "2" Activity_Resume Return True Else If entro = "2" Then entro = "1" Activity_Resume Return True Else If entro = "1" Then ' I want to capture the key here so I return True StartActivity(fila) Return False End If End If ' Returning False signals the system to handle the key End Sub Sub BUSCA_TextChanged (Old As String, New As String) q_buscar = "%" & BUSCA.Text & "%" skmt.Initialize(ruta,"kmt.db", True) c=skmt.ExecQuery2("select CAT_GP_NOMBRE from cat_gunaprod where CAT_GP_ALMACEN > 0 and CAT_GP_NOMBRE like ? order by CAT_GP_NOMBRE asc", Array As String(q_buscar)) ListView1.Clear If c.RowCount>0 Then For i=0 To c.RowCount -1 c.Position=i Dim label1 As Label label1 = ListView1.SingleLineLayout.Label label1.TextSize = 10 ListView1.AddSingleLine(c.GetString("CAT_GP_NOMBRE")) Next End If c.Close entro= "4" End Sub