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 skmt As SQL
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 c As Cursor
	Dim S As Cursor
	Dim ruta As String
	Dim ListView1 As ListView
	Dim b_noventa As Button
	Dim nombre_boton As String
	Dim STIME As String
	End Sub

Sub Activity_Create(FirstTime As Boolean)
'	If File.ExternalWritable Then
'	   ruta = File.DirDefaultExternal
'	Else
'	   ruta = File.DirInternal
'	End If
	    Activity.LoadLayout("buscar")

	' 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)
	   
	c=Starter.skmt.ExecQuery("select PC_CLIENTE,PC_MONTO,PC_NOART FROM PEDIDO_CLIENTE ORDER BY PC_FECHA asc")
	   ListView1.Clear
	  
	   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.Black
			 Dim label2 As Label
			 label2 = ListView1.TwoLinesLayout.SecondLabel
			 label2.TextSize = 15
			 label2.TextColor = Colors.Blue
			 ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),"Cantidad #"& c.GetString("PC_NOART")& " SubTotal $"& c.GetString("PC_MONTO"))
	      Next
	   End If
		 'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
		
			 
			 'ListView1.AddTwoLines(c.GetString("pr_cd_nombre"),c.GetString("pr_cd_colonia"))
	    '  Next
	   'End If

End Sub

Sub Activity_Resume
nombre_boton = "NOVENTA"
    
	
	c=starter.skmt.ExecQuery("select PC_CLIENTE,PC_MONTO,PC_NOART,(select CAT_CL_NOMBRE from kmt_info where cat_cl_codigo = pc_cliente ) as NOMBRE FROM PEDIDO_CLIENTE ORDER BY PC_FECHA asc")
	   ListView1.Clear
	  
	   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 = 15
			 label1.TextColor = Colors.Black
			 Dim label2 As Label
			 label2 = ListView1.TwoLinesLayout.SecondLabel
			 label2.TextSize = 10
			 label2.TextColor = Colors.Blue
			 ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &"   Cantidad #"& c.GetString("PC_NOART")& " SubTotal $"& c.GetString("PC_MONTO"))
	      Next
	   End If
		c.Close
			 'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
		

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub



Sub Regresar_Click
	StartActivity(fila)
End Sub
Sub Activity_KeyPress (key As Int) As Boolean
    ' BACK key pressed
    If key=KeyCodes.KEYCODE_BACK Then
            ' I want to capture the key here so I return True
			StartActivity(seleccion)
            'Return True
    End If
    ' Returning False signals the system to handle the key
    Return False
End Sub
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
	Starter.skmt.ExecNonQuery("delete from CUENTAA")
	Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(Value))
	DateTime.TimeFormat = "HHmmss"
	STIME=DateTime.Time(DateTime.Now)
	s=Starter.skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS FROM HIST_STAY_STORE WHERE HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)")
	s.Position = 0
	If s.GetString("CUANTOS") = 1 Then
		Starter.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_IN = ?  where HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(STIME))
	Else
		Starter.skmt.ExecNonQuery2("INSERT INTO HIST_STAY_STORE(HSS_CODIGO,  HSS_IN , HSS_OUT , HSS_TOT) VALUES (?,0,0,0)", Array As Object (Value))
		Starter.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_IN = ?  where HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(STIME))
	End If
	DateTime.TimeFormat = "HH:mm:ss"
	StartActivity(fila)
End Sub
Sub b_noventa_Click

If nombre_boton = "NOVENTA" Then
nombre_boton = "VENTA"
b_noventa.Text ="VENTA"

		c=starter.skmt.ExecQuery("select NV_CLIENTE,NV_MOTIVO,NV_COMM, (select CAT_CL_NOMBRE from kmt_info where cat_cl_codigo = NV_CLIENTE ) as NOMBRE FROM NOVENTA ORDER BY NV_CLIENTE asc")
	   ListView1.Clear
	  
	   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 = 15
			 label1.TextColor = Colors.Black
			 Dim label2 As Label
			 label2 = ListView1.TwoLinesLayout.SecondLabel
			 label2.TextSize = 10
			 label2.TextColor = Colors.Blue
				ListView1.AddTwoLines(c.GetString("NV_CLIENTE"),c.GetString("NOMBRE") &"  Motivo #"& c.GetString("NV_MOTIVO")& " Comentario $"& c.GetString("NV_COMM"))
	      Next
	   End If
Else
nombre_boton = "NOVENTA"
b_noventa.Text ="NO VENTA"
		c=starter.skmt.ExecQuery("select PC_CLIENTE,PC_MONTO,PC_NOART,(select CAT_CL_NOMBRE from kmt_info where cat_cl_codigo = pc_cliente ) as NOMBRE FROM PEDIDO_CLIENTE ORDER BY PC_FECHA asc")
	   ListView1.Clear
	  
	   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 = 15
			 label1.TextColor = Colors.Black
			 Dim label2 As Label
			 label2 = ListView1.TwoLinesLayout.SecondLabel
			 label2.TextSize = 10
			 label2.TextColor = Colors.Blue
			 ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &"   Cantidad #"& c.GetString("PC_NOART")& " SubTotal $"& c.GetString("PC_MONTO"))
	      Next
	   End If
		c.Close


End If


	

End Sub