B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=11.5
@EndOfDesignText@
Sub Class_Globals
	Private Root As B4XView 'ignore
	Private xui As XUI 'ignore
	Dim c As Cursor
	Dim ruta As String
	Dim ListView1 As ListView
	Dim b_noventa As Button
	Dim nombre_boton As String
	Private l_titulo As Label
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
	'load the layout to Root
	ruta = File.DirInternal
	Root.LoadLayout("ticketsDia")
	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 = 15
			label1.TextColor = Colors.Black
			Dim label2 As Label
			label2 = ListView1.TwoLinesLayout.SecondLabel
			label2.TextSize = 13
			label2.TextColor = Colors.Black
			ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),"Cantidad #"& c.GetString("PC_NOART")& " SubTotal $"& NumberFormat2(Subs.traeTotalCliente, 1, 2, 2, True))
		Next
	End If
	Subs.centraEtiqueta(l_titulo, Root.Width)
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Sub B4XPage_Appear
	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 = 13
			label2.TextColor = Colors.Black
			ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &"   Cant. #"& c.GetString("PC_NOART")& " SubTotal $"& NumberFormat2(c.GetString("PC_MONTO"), 1, 2, 2, True))
		Next
	End If
	c.Close
End Sub

Sub Regresar_Click
	Subs.iniciaActividad("Cliente")
'	B4XPages.ShowPage("Cliente")
End Sub

Private Sub B4XPage_CloseRequest As ResumableSub
	' BACK key pressed
	Subs.iniciaActividad("Principal")
'	B4XPages.ShowPage("Principal")
	Return True
End Sub

Sub Activity_KeyPress (key As Int) As Boolean
'	' BACK key pressed
'	If key=KeyCodes.KEYCODE_BACK Then
'		Subs.iniciaActividad("Principal")
'	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))
	Subs.iniciaActividad("Cliente")
End Sub

Sub b_noventa_Click
	If nombre_boton = "NOVENTA" Then
		l_titulo.Text = "TICKETS NO VENTA"
		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.Black
				ListView1.AddTwoLines(c.GetString("NV_CLIENTE"),c.GetString("NOMBRE") &"  Motivo #"& c.GetString("NV_MOTIVO")& " Comentario $"& c.GetString("NV_COMM"))
			Next
		End If
	Else
		l_titulo.Text = "TICKETS VENTA"
		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.Black
				ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &"   Cantidad #"& c.GetString("PC_NOART")& " SubTotal $"& NumberFormat2(c.GetString("PC_MONTO"), 1, 2, 2, True))
			Next
		End If
		c.Close
	End If
End Sub