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 C3 As Cursor
	Dim s 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
	Dim TIENE_PROMOS As String
	Dim RES As String
	Dim S1 As Cursor
	Dim bmp As Bitmap
	Dim ciclo As String
	Private b_qr As Button
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.RemoveAllViews
    Activity.LoadLayout("fila")
	'Dim ruta As String
	' valido donde escribo el archivo de la base de datos de kmt
'	If File.ExternalWritable Then
'	   ruta = File.DirDefaultExternal
'	Else
'	   ruta = File.DirInternal
'	End If
	
	' 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)
	ciclo = 1
End Sub

Sub Activity_Resume
	
	Starter.skmt.execNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("PRIORITARIO","1"))
	Starter.skmt.execNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("ESTRATEGICO","2"))
	Starter.skmt.execNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("COMPLEMETARIO","3"))
	Starter.skmt.execNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("CATALOGO REGULAR","0"))
	Starter.skmt.execNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_CLASIF = (?) ",Array As Object("PROMOS","PROMOS"))
	
	If ya_entro <> "1" Then

		BUSCA.Text =""
'		skmt.Initialize(ruta,"kmt.db", True)
		entro ="3"
		ya_entro ="1"
		
'' esto es para la secuencia de los productos,
		'' 		c=starter.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")
		If ciclo = 1 Then
			c=Starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and CAT_GP_TIPOPROD = (?)  group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("PRIORITARIO") )
			'c=starter.skmt.execQuery2("select (?) AS CAT_GP_TIPOPROD, count(*) as cuantos from CAT_NEXTBESTSKU where CAT_TIENDA IN (SELECT CUENTA FROM CUENTAA) ", Array As String("RECOMENDACIONES") )

		else if ciclo = 2 Then
			c=Starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and (CAT_GP_TIPOPROD = (?) ) group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("ESTRATEGICO") )

'			c=starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and CAT_GP_TIPOPROD = (?)  group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("INICIATIVAS") )

			'c=starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and (CAT_GP_TIPOPROD = (?) or CAT_GP_TIPOPROD = (?)) group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("INICIATIVAS","PAQUETES") )

			'	Else IF ciclo = 3 Then
			'c=starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and (CAT_GP_TIPOPROD = (?) or CAT_GP_TIPOPROD = (?) or CAT_GP_TIPOPROD = (?)) group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("PROMOCIONAL","PAQUETES CLIENTE") )

			'		c=starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and (CAT_GP_TIPOPROD = (?) or CAT_GP_TIPOPROD = (?) or CAT_GP_TIPOPROD = (?)) group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("PROMOCIONAL","PAQUETES CLIENTE") )

		else if ciclo = 3 Then
			c=Starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and (CAT_GP_TIPOPROD = (?) ) group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("COMPLEMETARIO") )

		else if ciclo = 4 Then
			c=Starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and (CAT_GP_TIPOPROD = (?) ) group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("CATALOGO REGULAR") )
	

		Else
			'c=starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and (CAT_GP_TIPOPROD = (?) ) group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("CATALOGO REGULAR") )
			c=Starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and (CAT_GP_TIPOPROD = (?) or CAT_GP_TIPOPROD = (?)) group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("PROMOS","PAQUETES CLIENTE") )
			'c=starter.skmt.execQuery2("select (?) AS CAT_GP_TIPOPROD, count(*) as cuantos from CAT_NEXTBESTSKU where CAT_TIENDA IN (SELECT CUENTA FROM CUENTAA) ", Array As String("RECOMENDACIONES") )

			'c=starter.skmt.execQuery2("select CAT_GP_TIPOPROD, count(*) as cuantos from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0  and (CAT_GP_TIPOPROD = (?) ) group by CAT_GP_TIPOPROD order by CAT_GP_CLASIF asc", Array As String("PAQUETES CLIENTE") )
			
		End If

		'ESTO ES PARA NO VER PROCTER
		'c=starter.skmt.execQuery2("select CAT_GP_CLASIF, count(*) as cuantos from cat_gunaprod where CAT_GP_ALMACEN > 0 and cat_gp_clasif NOT IN (?,?,?,?,?,?,?,?,?,?) group by CAT_GP_CLASIF order by CAT_GP_CLASIF asc", Array As String("PROCTER","PROMOS","TRES MONTES","CAMPARI","CAMPARI-PRO","CLOROX DE MEXICO","MARS","CONAGRA","VERDE VALLE","MEAD JOHNSON"))
'		ListView1.Clear
'		lfila.Text = "MARCA"
'		Dim label1 As Label
'		label1 = ListView1.TwoLinesLayout.Label
'		label1.TextSize = 13
'		label1.TextColor = Colors.Black
'		Dim label2 As Label
'		label2 = ListView1.TwoLinesLayout.SecondLabel
'		label2.TextSize = 10
'		label2.TextColor = Colors.Black
'		Dim label13 As Label
'		label13 = ListView1.TwoLinesAndBitmap.Label
'		label13.TextSize = 13
'		label13.TextColor = Colors.Black
'		Dim label14 As Label
'		label14 = ListView1.TwoLinesAndBitmap.SecondLabel
'		label14.TextSize = 10
'		label14.TextColor = Colors.Black
'			
'		If c.RowCount>0 Then
'			For i=0 To c.RowCount -1
'				c.Position=i
'				bmp = LoadBitmap(File.DirAssets, "palomita_verde.png")
'
'				ListView1.AddTwoLinesAndBitmap(c.GetString("CAT_GP_CLASIF"),c.GetString("cuantos"), bmp)

		ListView1.Clear
		lfila.Text = "CATALOGOS"
		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 = 13
				label1.TextColor = Colors.Black
				Dim label2 As Label
				label2 = ListView1.TwoLinesLayout.SecondLabel
				label2.TextSize = 13
				label2.TextColor = Colors.Black
				Dim label13 As Label
				label13 = ListView1.TwoLinesAndBitmap.Label
				label13.TextSize = 13
				label13.TextColor = Colors.Black
				Dim label14 As Label
				label14 = ListView1.TwoLinesAndBitmap.SecondLabel
				label14.TextSize = 13
				label14.TextColor = Colors.Black
				' If c.GetString("CAT_GP_TIPOPROD") = "PROMOS" Then
				'	 ListView1.AddTwoLines(c.GetString("CAT_GP_CLASIF")," ")
				'Else
				ListView1.AddTwoLines(c.GetString("CAT_GP_TIPOPROD"),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)
	b_qr.Visible = True
	b_qr.Text = "SIGUIENTE"
	
	If Value = "PROMOS" And fila.cuenta <> "N" Then
		entro = "3"
		marca = "PROMOS"
		tipo = "PROMOS"
	Else if Value = "PROMOS"  And fila.cuenta = "N"  Then
		entro = "5"
		StartActivity(fila)
	End If
'	If entro = "1" Then
'		marca = Value
'		skmt.Initialize(ruta,"kmt.db", True)
'		c2=starter.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=starter.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"
'	   
	If entro = "3" Then
		If marca = "PROMOS" Then
			c2=Starter.skmt.execQuery2("select  CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from cat_gunaprod where CAT_GP_PRECIO > 0 AND  CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD = ? AND CAT_GP_TIPO = ? AND CAT_GP_SUBTIPO = ?  AND CAT_GP_ID NOT IN (SELECT PE_PROID FROM PEDIDO WHERE PE_CLIENTE IN (Select cuenta from cuentaa) )", Array As String(Value,marca, tipo))
    
		Else
			c2=Starter.skmt.execQuery2("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG, CAT_GP_INICIATIVA from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD = ? ", Array As String(Value))
			'c2=starter.skmt.execQuery2("select  CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD = ? AND CAT_GP_TIPO = ? AND CAT_GP_SUBTIPO = ?  ", Array As String(marca, tipo, Value))
		End If

		'' antes del por categoria
	
		If Value = "PRIORITARIO" Then
			ListView1.Clear
			lfila.text = "PRIORITARIO"
			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 = LoadBitmap(File.DirAssets, "ROJO.png")
					'c2.GetBlob("CAT_GP_IMG")
					'ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
					'bmp.Initialize2(ins)
					S1=Starter.skmt.execQuery2("select COUNT(*) AS CUANTOS from HIST_VENTAS where HVD_PRONOMBRE =? and HVD_CLIENTE IN (Select cuenta from cuentaa)", Array As String(c2.GetString("CAT_GP_NOMBRE")))
					S1.Position =0
					If S1.GetString("CUANTOS") > 0 Then
						s=Starter.skmt.execQuery2("select sum(HVD_CANT) AS SUMA from HIST_VENTAS where HVD_PRONOMBRE =? and HVD_CLIENTE IN (Select cuenta from cuentaa)", Array As String(c2.GetString("CAT_GP_NOMBRE")))
						s.Position =0
			 
						'Msgbox(s.GetString("SUMA"),"DATO")
						If s.GetString("SUMA") >=  c2.GetString("CAT_GP_INICIATIVA") Then
							bmp = LoadBitmap(File.DirAssets, "VERDE.png")
						Else  If s.GetString("SUMA") < c2.GetString("CAT_GP_INICIATIVA") And  s.GetString("SUMA") > 0 Then
							bmp = LoadBitmap(File.DirAssets, "AMARILLO.png")
						Else
							bmp = LoadBitmap(File.DirAssets, "ROJO.png")
				
						End If
						s.Close
					Else
						bmp = LoadBitmap(File.DirAssets, "ROJO.png")
				
					End If
					ListView1.AddTwoLinesAndBitmap(c2.GetString("CAT_GP_NOMBRE"),"# " & c2.GetString("CAT_GP_ALMACEN") & " $ " & c2.GetString("CAT_GP_PRECIO"),bmp)
				Next
			End If
			c2.Close
	  
		Else if  Value = "ESTRATEGICO" Then
			ListView1.Clear
			lfila.text = "ESTRATEGICO"
			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
			c2.Close
		
		Else
				
			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
			c2.Close
		End If
	
'		skmt.Initialize(ruta,"kmt.db", True)
'		c2=starter.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 = ?  AND CAT_GP_TIPOPROD <> ? ", Array As String(marca, tipo, Value,"7"))
'		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
'		
'		C3=starter.skmt.execQuery("select count(*) as CUANTOS FROM HIST_PROMOS WHERE HP_CLIENTE IN (Select CUENTA from cuentaa)")
'		C3.Position =0
'		If C3.GetString("CUANTOS") > 0 Then
'			c2=starter.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_TIPOPROD = ?  ", Array As String("7"))
'			
'			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
'			c2=starter.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_ID = ?  ", Array As String("PRO524"))
'			
'			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
'		End If
'		C3.Close
'		
		entro = "4"
	Else If entro = "4" Then
	  
		Starter.skmt.execNonQuery("delete from PROID")
		Starter.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
		Else
			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=starter.skmt.execQuery2("select CAT_GP_NOMBRE from cat_gunaprod where CAT_GP_ALMACEN > 0 and CAT_GP_NOMBRE like ? AND cat_gp_clasif NOT IN (?,?,?,?,?,?,?,?,?,?)  order by CAT_GP_NOMBRE asc", Array As String(q_buscar, "PROCTER","PROMOS","TRES MONTES","CAMPARI","CAMPARI-PRO","CLOROX DE MEXICO","MARS","CONAGRA","VERDE VALLE","MEAD JOHNSON"))
	c=Starter.skmt.execQuery2("select CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO,CAT_GP_IMG from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_NOMBRE like ? and CAT_GP_CLASIF <>  ?  order by CAT_GP_NOMBRE asc", Array As String(q_buscar,"PROMOS"))
	'and CAT_GP_CLASIF <>  ? group by CAT_GP_CLASIF order by CAT_GP_CLASIF asc", Array As String("PROMOS") )
	
	   ListView1.Clear
	 
	  Dim ins As InputStream
             Dim bmp As Bitmap
             Dim jpeg() As Byte
	   If c.RowCount>0 Then
	      For i=0 To c.RowCount -1
		     c.Position=i
	         jpeg = c.GetBlob("CAT_GP_IMG")
             ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
             bmp.Initialize2(ins)

			 ListView1.AddTwoLinesAndBitmap(c.GetString("CAT_GP_NOMBRE"),"Existencia " & c.GetString("CAT_GP_ALMACEN") & " Precio $" & c.GetString("CAT_GP_PRECIO"),bmp)
	      Next
	   End If

	 
	 
'	   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 = 13
'			 ListView1.AddSingleLine(c.GetString("CAT_GP_NOMBRE"))
'	      Next
'	   End If
	c.Close
	entro= "4"
End Sub



Sub b_QR_Click
	If ciclo = 1 Then
		ciclo = 2
		b_qr.Visible = False
		ya_entro  = "0"
		'entro = 3
		Activity_Resume
	else if ciclo = 2 Then
		ciclo = 3
		'	ya_entro  = 0
		ya_entro  = "0"

		Activity_Resume
		b_qr.Visible = False

	else if ciclo = 3 Then
		ciclo = 4
		'	ya_entro  = 0
		ya_entro  = "0"

		Activity_Resume
		b_qr.Visible = False
	else if ciclo = 4 Then
		ciclo = 5
		'	ya_entro  = 0
		ya_entro  = "0"

		Activity_Resume
		b_qr.Visible = False
	else if ciclo = 5 Then
		ciclo = 1
		'	ya_entro  = 0
		ya_entro  = "0"

		Activity_Resume
		b_qr.Visible = False
	End If
End Sub

