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
	Private p_cliente As Panel

	Dim g As GPS
	Dim ruta As String
	Dim skmt As SQL
	Dim clie_id As String
	Dim sDate,sTime As String
	Dim usuario As String
	Dim total_cliente As String
	Dim m_lat, m_lon As String
	Dim btAdmin As BluetoothAdmin
	Dim cmp20 As Serial
	Dim printer As TextWriter
	Dim PairedDevices As Map
	Dim L As List
	Dim TAMANO As Int
	Dim ESPACIO As Int
	Dim BLANCO As String
	Dim cuenta As String
	Dim tipo_venta As String = "VENTA"
	Dim MAC_IMPRESORA As String
	Dim btAdmin As BluetoothAdmin
	Dim Printer1 As EscPosPrinter
	
	Dim c As Cursor
	Dim s As Cursor
	Dim DD As Cursor
	Dim c2 As Cursor
	Dim ListView1 As ListView
	Dim la_cuenta As Label
	Dim La_nombre As Label
	Dim la_Calle As Label
	Dim la_numero As Label
	Dim la_nint As Label
	Dim la_edo As Label
	Dim la_pob As Label
	Dim la_col As Label
	Dim la_cp As Label
	Dim la_zona As Label
	Dim gest As Button
	Dim la_saldotot As Label
	Dim la_saldooper As Label
	
	Dim Tels As Button
	Dim Label10 As Label
	Dim Label11 As Label
	
	Dim Tar As Button
	
	Dim la_comm As Label
	Dim la_actdte As Label
	Dim la_usuario As Label
	Dim la_resultado As Label
	Dim l_entre1 As Label
	Dim l_entre2 As Label
	Dim l_atiende As Label
	Dim l_atiende2 As Label
	Dim DATOS As Button
	Dim Guardar As Button
	Dim NUEVO As Button
	'    Dim lat_gps, lon_gps As String

	Dim l_total As Label
	Dim c2 As Cursor
	Dim S2 As Cursor
	Private s As Cursor
	Dim res As String
	Private HIST As Button
	Private MONTO_COMPRA As String
	Private META As String
	Private META2 As String
	Private VERIFICA As String
	Private L_QR As Label
	Private BT_QR As Button
	'Private qr As QRCode
	Dim CODIGO As String

	Private b_mapa As Button
	Dim CUANTOS As String
	Private B_IMP As Button
	Dim Toggla As Toggle
	Dim tgl As Toggle
	Private Panel1 As Panel
	Private I_COMPRA As EditText
	Private B_GUARDA_C As Button
	Private b_venta As Button
	Dim ALMACEN As String
	Dim LA_GPS As Label
	Private B_E_NEXT As Button
	Private E_RES_E As EditText
	Private t_tenc As Label
	Private Panel2 As Panel
	Private CONTADOR_E As String
	Private HR_RES1 As String
	Private HR_RES2 As String
	Private HR_RES3 As String
	Private EXISTE As String
	Private TELEFONO As String
	
	
	Private RB1 As RadioButton
	Private RB2 As RadioButton
	Private RB3 As RadioButton
	Private RB4 As RadioButton
	Private RB5 As RadioButton
	
	Private stay_hh As String
	Private stay_mi As String
	Private stay_ss As String
	
	Private LA_GEO As Label
	Dim result As Int
	Private cercavalor As String
	Private LA_RUTA As String
	
	Private b_like As Button
	Private B_GPS As Button
	Dim sc As JhsIceZxing1
	Dim CODIGO As String
	Private SV_ENCUESTA As ScrollView
	Private RB1_E1 As RadioButton
	Private RB2_E1 As RadioButton
	Private RB3_E1 As RadioButton
	Private CHB1 As CheckBox
	Private CHB2 As CheckBox
	Private CHB3 As CheckBox
	Private Panel5 As Panel
	Private B_guardaencuesta As Button
	Private RadioButton1 As RadioButton
	Private RadioButton2 As RadioButton
	Private RadioButton3 As RadioButton
	Private RadioButton4 As RadioButton
	Private RadioButton5 As RadioButton
	Private RadioButton6 As RadioButton
	Private RadioButton7 As RadioButton
	Private RadioButton8 As RadioButton
	Private RadioButton9 As RadioButton
	Private RadioButton10 As RadioButton
	Private RadioButton11 As RadioButton
	Private RadioButton12 As RadioButton
	Private RadioButton13 As RadioButton
	Private RadioButton14 As RadioButton
	Private CheckBox1 As CheckBox
	Private CheckBox2 As CheckBox
	Private CheckBox3 As CheckBox
	Private CheckBox4 As CheckBox
	Private CheckBox5 As CheckBox
	Private CheckBox6 As CheckBox
	Private CheckBox7 As CheckBox
	Private CheckBox8 As CheckBox
	Dim encuentasmapa As Map
	Private p6 As EditText
	Private p7 As EditText
	Private p8 As EditText
	Private Panel7 As Panel
	Private RadioButton17 As RadioButton
	Private RadioButton16 As RadioButton
	Private RadioButton15 As RadioButton
	Private B_guardaencuesta_m2 As Button
	Private et_p1_m2 As EditText
	Private et_p2_m2 As EditText
	Private RB7_P6_M2 As RadioButton
	Private RB6_P6_M2 As RadioButton
	Private RB5_P6_M2 As RadioButton
	Private RB4_P6_M2 As RadioButton
	Private RB3_P6_M2 As RadioButton
	Private RB2_P6_M2 As RadioButton
	Private RB1_P6_M2 As RadioButton
	Private et_p5_m2 As EditText
	Private rd3_p4_m2 As RadioButton
	Private rd2_p4_m2 As RadioButton
	Private rd1_p4_m2 As RadioButton
	Private RB1_P3_M2 As RadioButton
	Private RB2_P3_M2 As RadioButton
	Private RB3_P3_M2 As RadioButton
	Private RB4_P3_M2 As RadioButton
	Private ET_P3_M2 As EditText
	Private Panel7_M2 As Panel
	Private P4_M2 As String
	Private P3_M2 As String
	Private P6_M2 As String
	
	Private CB1_P3_M2 As CheckBox
	Private CB2_P3_M2 As CheckBox
	Private CB3_P3_M2 As CheckBox
	Private CB4_P3_M2 As CheckBox
	Private CB5_P3_M2 As CheckBox
	Private CB6_P3_M2 As CheckBox
	Private EXISTE2 As String
	Private EXISTE3 As String
	Private EXISTE4 As String
	Private EXISTE5 As String
	Private et_p1_m3 As EditText
	Private et_p2_m3 As EditText
	Private CB1_P3_M3 As CheckBox
	Private CB2_P3_M3 As CheckBox
	Private CB3_P3_M3 As CheckBox
	Private CB4_P3_M3 As CheckBox
	Private CB5_P3_M3 As CheckBox
	Private CB1_P4_M3 As CheckBox
	Private CB2_P4_M3 As CheckBox
	Private CB3_P4_M3 As CheckBox
	Private CB4_P4_M3 As CheckBox
	Private CB5_P4_M3 As CheckBox
	Private rd1_p5_m3 As RadioButton
	Private rd2_p5_m3 As RadioButton
	Private CB1_P6_M3 As CheckBox
	Private CB2_P6_M3 As CheckBox
	Private CB3_P6_M3 As CheckBox
	Private CB4_P6_M3 As CheckBox
	Private CB5_P6_M3 As CheckBox
	Private CB6_P6_M3 As CheckBox
	Private ET_P6_M3 As EditText
	Private CB1_P7_M3 As CheckBox
	Private CB2_P7_M3 As CheckBox
	Private CB3_P7_M3 As CheckBox
	Private CB4_P7_M3 As CheckBox
	Private CB1_P8_M3 As CheckBox
	Private CB2_P8_M3 As CheckBox
	Private CB4_P8_M3 As CheckBox
	Private RB1_P9_M3 As RadioButton
	Private RB2_P9_M3 As RadioButton
	Private RB3_P9_M3 As RadioButton
	Private RB4_P9_M3 As RadioButton
	Private RB5_P9_M3 As RadioButton
	Private B_guardaencuesta_m3 As Button
	Private P_gallina As Panel
	Private b_acepta_gallina As Button
	Private B_CANCELA_GALLINA As Button
	Private B_GALLINA As Button
	Private la_cuenta_gallina As Label
	Private cb_pregunta As B4XComboBox
	Dim girotienda As String
	Private p_pregunta1 As Panel
	Private b_preguntag As Button
	Private EN_QUE_ENCUESTA As String
	Private ENCUESTA As String
	Private et_p1_m4 As EditText
	Private et_p2_m4 As EditText
	Private cb_p3_m4 As B4XComboBox
	Private cb_p4_1_m4 As B4XComboBox
	Private cb_p4_2_m4 As B4XComboBox
	Private cb_p4_3_m4 As B4XComboBox
	Private cb_p4_4_m4 As B4XComboBox
	Private cb_p4_5_m4 As B4XComboBox
	Dim itemselect2 As String
	Dim itemselect3 As String
	Dim itemselect4 As String
	Dim itemselect5 As String
	Dim itemselect6 As String
	Dim itemselect7 As String
	Private B_guardaencuesta_m4 As Button
	Private p_modulo5 As Panel
	Private cb_p1_m5 As B4XComboBox
	Private cb_p2_m5 As B4XComboBox
	Private cb_p3_m5 As B4XComboBox
	Private cb_p4_m5 As B4XComboBox
	Private cb_p5_m5 As B4XComboBox
	Private cb_p6_m5 As B4XComboBox
	Private cb_p7_m5 As B4XComboBox
	Private cb_p8_m5 As B4XComboBox
	Private cb_p9_m5 As B4XComboBox
	Dim itemselect8 As String
	Dim itemselect9 As String
	Dim itemselect10 As String
	Dim itemselect11 As String
	Dim itemselect12 As String
	Dim itemselect13 As String
	Dim itemselect14 As String
	Dim itemselect15 As String
	Dim itemselect16 As String
	Private B_guardaencuesta_m5 As Button
	Dim PASA As String
	Private RB1_P4_M2 As RadioButton
	Private RB2_P4_M2 As RadioButton
	Private panel7_p4_m2 As Panel
	Private CB1_P4_M2 As CheckBox
	Private CB2_P4_M2 As CheckBox
	Private CB3_P4_M2 As CheckBox
	Private CB4_P4_M2 As CheckBox
	Private Panel4 As Panel
	Private B_GUARDA_CE_PED As Button
	
	
	Private KP_01 As CheckBox
	Private KP_02 As CheckBox
	Private KP_03 As CheckBox
	Private KP_04 As CheckBox
	Private KP_05 As CheckBox
	Private KP_06 As CheckBox
	Private KP_07 As CheckBox
	Private KP_08 As CheckBox
	Private KP_09 As CheckBox
	Private KP_10 As CheckBox
	Private KP_11 As CheckBox
	Private KP_12 As CheckBox
	Private KP_13 As CheckBox
	Private KP_14 As CheckBox
	Private KP_15 As CheckBox
	Private KP_16 As CheckBox
	Private KP_17 As CheckBox
	Private KP_18 As CheckBox
	Private KP_19 As CheckBox
	Private KP_20 As CheckBox
	
	Private KG_01 As CheckBox
	Private KG_02 As CheckBox
	Private KG_03 As CheckBox
	Private KG_04 As CheckBox
	Private KG_05 As CheckBox
	Private KG_06 As CheckBox
	
	Private PK_01 As CheckBox
	Private PK_02 As CheckBox
	Private PK_03 As CheckBox
	Private PK_04 As CheckBox
	Private PK_05 As CheckBox
	Private PK_06 As CheckBox
	Private PK_07 As CheckBox
	Private PK_08 As CheckBox
	
	Private HPG_01 As CheckBox
	Private HPG_02 As CheckBox
	Private HPG_03 As CheckBox
	Private HPG_04 As CheckBox
	Private HPG_05 As CheckBox
	Private HPG_06 As CheckBox
	Private HPG_07 As CheckBox
	Private HPG_08 As CheckBox
	Private HPG_09 As CheckBox
	Private HPG_10 As CheckBox
	
	Private HC_01 As CheckBox
	Private HC_02 As CheckBox
	Private HC_03 As CheckBox
	Private HC_04 As CheckBox
	
	Private B_01 As CheckBox
	Private B_02 As CheckBox
	
	Private CH_FACTURA As CheckBox
	Private que_modulo As String
	Private CUENTA_MODULO As String
	Private rb1_m3_p1 As RadioButton
	Private RB2_M3_P1 As RadioButton
	Private RB3_M3_P1 As RadioButton
	Private RB4_M3_P1 As RadioButton
	Private RB1_M3_P2 As RadioButton
	Private RB2_M3_P2 As RadioButton
	Private RB3_M3_P2 As RadioButton
	Private RB4_M3_P2 As RadioButton
	Private et_p2_m3_1 As EditText
	Dim textemp2 As String =""
	Dim textemp3 As String =""
	Dim textemp4 As String =""
	Dim textemp5 As String =""
	Dim textemp6 As String =""
	Dim textemp7 As String =""
	Dim textemp8 As String =""
	Private CB3_P8_M3 As CheckBox
	Private CB7_P6_M3 As CheckBox
	Private p_m1 As Panel
	Private p_m2 As Panel
	Private p_m3 As Panel
	Private p_m4 As Panel
	Dim impresoraConectada As Boolean = False
	Dim errorImpresora As Int = 0
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
'	Activity.RemoveAllViews
	Root.LoadLayout("cliente")
	ruta = File.DirInternal
	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=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA  from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
	s=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
	s.Position=0
	If c.RowCount>0 Then
		c.Position=0
		la_cuenta.Text = c.GetString("CAT_CL_CODIGO")
		cuenta = c.GetString("CAT_CL_CODIGO")
		La_nombre.Text = c.GetString("CAT_CL_NOMBRE")
		la_Calle.Text = c.GetString("CAT_CL_CALLE") & c.GetString("CAT_CL_NOEXT")
		la_col.Text = c.GetString("CAT_CL_COLONIA")
		la_edo.Text = c.GetString("CAT_CL_EDO")
'			 la_cp.Text = c.GetString("CAT_CL_CP")
		l_entre1.Text = c.GetString("CAT_CL_CALLE1")
		l_entre2.Text = c.GetString("CAT_CL_CALLE2")
		l_atiende.Text = c.GetString("CAT_CL_ATIENDE1")
		l_atiende2.Text = c.GetString("CAT_CL_ATIENTE2")
		la_saldotot.Text = c.GetString("CAT_CL_TELEFONO")
		la_saldooper.Text = c.GetString("CAT_CL_EMAIL")
		l_total.Text = s.GetString("TOTAL_CLIE")
		total_cliente = s.GetString("TOTAL_CLIE")
		MONTO_COMPRA = c.GetString("CAT_CL_MTOCOMPRA")
	End If
	c.Close
	s.Close
	btAdmin.Initialize("BlueTeeth")
	cmp20.Initialize("Printer")
	SV_ENCUESTA.Height = Root.Height
	SV_ENCUESTA.Width = Root.Height
	p_pregunta1.Height = Root.Height
	p_pregunta1.Width = Root.Height
End Sub

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

Sub B4XPage_Appear
	que_modulo = 1
	B4XPages.MainPage.tipo_venta = tipo_venta
	encuentasmapa.Initialize
	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA)
	Wait For B4XPage_PermissionResult (Permission As String, resultC As Boolean)
	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
	Wait For B4XPage_PermissionResult (Permission As String, resultC As Boolean)

	LA_GPS.TextColor = Colors.Red
	LA_GPS.Text = "SIN UBICACION GPS"
	cercavalor = 0
	If Not(Starter.gps.GPSEnabled) Then
		ToastMessageShow("Es necesario tener el GPS encendido", True)
		StartActivity(Starter.gps.LocationSettingsIntent)
	End If
	skmt.Initialize(ruta,"kmt.db", True)
	c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO  from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
	s=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
	s.Position=0
	If c.RowCount > 0 Then
		c.Position=0
		la_cuenta.Text = c.GetString("CAT_CL_CODIGO")
		la_cuenta_gallina.Text = c.GetString("CAT_CL_CODIGO")
		La_nombre.Text = c.GetString("CAT_CL_NOMBRE")
		la_Calle.Text = c.GetString("CAT_CL_CALLE") & " " & c.GetString("CAT_CL_NOEXT")
		la_col.Text = c.GetString("CAT_CL_COLONIA")
		la_edo.Text = c.GetString("CAT_CL_EDO")
		l_entre1.Text = c.GetString("CAT_CL_CALLE1")
		l_entre2.Text = c.GetString("CAT_CL_CALLE2")
		l_atiende.Text = c.GetString("CAT_CL_ATIENDE1")
		l_atiende2.Text = c.GetString("CAT_CL_ATIENTE2")
		TELEFONO  = c.GetString("CAT_CL_TELEFONO")
		l_total.Text = s.GetString("TOTAL_CLIE")
		total_cliente = s.GetString("TOTAL_CLIE")
		m_lat = "0"
		If c.GetString("CAT_CL_LAT") <> "" Then m_lat =c.GetString("CAT_CL_LAT")
		If m_lat.Length < 5 Then m_lat = "0"
		m_lon = "0"
		If c.GetString("CAT_CL_LONG") <> "" Then m_lon =c.GetString("CAT_CL_LONG")
		If m_lon.Length < 5 Then m_lon = "0"
		LA_RUTA = c.GetString("CAT_CL_RUTA")
		' ESTO ES PARA FORZAR A PEDIR LA FOTO Y EL GPS
		If c.GetString("CAT_CL_NUM_SERIEFISICO") = "0"  Then
			L_QR.TEXT = "SIN CODIGO"
			L_QR.TextColor = Colors.Red
			gest.VISIBLE = True
			BT_QR.Visible = True
		Else
			L_QR.TEXT = c.GetString("CAT_CL_NUM_SERIEFISICO")
			L_QR.TextColor = Colors.Blue
			BT_QR.Visible = False
		End If
	End If
	c.Close
	s.Close
	
	S2=B4XPages.MainPage.skmt.ExecQuery("select count(*) AS CUANTOS from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa)")
	S2.Position =0
	CUANTOS = S2.GetString("CUANTOS")
	S2.Close
	If CUANTOS > 0 Then
		c2=B4XPages.MainPage.skmt.ExecQuery("select sum(HVD_COSTO_TOT) AS TOTAL from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa)")
		c2.Position =0
		MONTO_COMPRA = c2.GetString("TOTAL")
		c2.Close
	Else
		MONTO_COMPRA = "0"
	End If
			
	la_saldotot.Text = MONTO_COMPRA
	If MONTO_COMPRA <> "0" Then
		META2 = 300 -  MONTO_COMPRA
	Else
		META2 = 300
	End If
	If META2 < 1 Then
		META2 = "CUBIERTO"
	End If
	la_saldooper.Text = META2
	c=B4XPages.MainPage.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
	If c.RowCount>0 Then
		C.Position=0
		ALMACEN = C.GetString("ID_ALMACEN")
	End If
	c.Close
'	If ALMACEN = "1" Then
'		Tels.Visible = False
'		gest.Visible = True
'		B_GPS.Visible = False
'	End If
	If ALMACEN = "4"  Then
		b_like.Visible = False
		DD=B4XPages.MainPage.skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM HIST_VENTAS WHERE HVD_CLIENTE IN (Select cuenta from cuentaa) AND HVD_PRONOMBRE =?", Array As String("KNORR RINDE MAS 70 GR"))
		DD.Position =0
		If DD.GetString("CUANTOS")  = 0 Then
			c=B4XPages.MainPage.skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM PEDIDO  WHERE PE_CLIENTE  IN (Select cuenta from cuentaa) AND PE_PRONOMBRE =?", Array As String("KNORR RINDE MAS 70 GR"))
			c.Position =0
			If c.GetString("CUANTOS") = 0 Then
				b_like.Visible = False
			Else
				b_like.Visible = False
			End If
			c.Close
		Else
			b_like.Visible = False
		End If
		DD.Close
	Else
		b_like.Visible = False
	End If
	If ALMACEN = "16" Or ALMACEN = "13" Then
		Tels.Visible = True
		gest.Visible = True
	End If
	CallSubDelayed(Tracker, "Track")
	CallSubDelayed(Tracker, "StartFLPSmall")
	If Tracker.FLP.GetLastKnownLocation.IsInitialized Then 'Si tenemos "UltimaUbicaccionConocida" la usamos.
		B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
		B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
'		Log($"Tenemos UUC: ${Tracker.FLP.GetLastKnownLocation.Latitude},${Tracker.FLP.GetLastKnownLocation.Longitude}"$)
		GPS_LocationChanged(Tracker.FLP.GetLastKnownLocation)
	End If
	If ALMACEN = "1" Or ALMACEN = "2" Or ALMACEN = "4" Or ALMACEN = "5" Or ALMACEN = "25" Then
		DD=skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM HIST_VENTAS WHERE HVD_CLIENTE IN (Select cuenta from cuentaa) AND HVD_PRONOMBRE =?", Array As String("KNORR SUIZA GALLINA"))
		DD.Position =0
		If DD.GetString("CUANTOS")  = 0 Then
			c=skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM PEDIDO  WHERE PE_CLIENTE  IN (Select cuenta from cuentaa) AND PE_PRONOMBRE =?", Array As String("KNORR SUIZA GALLINA"))
			c.Position =0
			If c.GetString("CUANTOS") = 0 Then
				B_GALLINA.Visible = True
			Else
				B_GALLINA.Visible = False
			End If
			c.Close
		Else
			B_GALLINA.Visible = False
		End If
		DD.Close
	Else
		B_GALLINA.Visible = False
	End If
	P_gallina.Visible = False
	B_GALLINA.Visible = False
	que_modulo = 1
	If ALMACEN = "2" Or ALMACEN = "4" Or  ALMACEN = "5"  Or ALMACEN = "4" Or  ALMACEN = "53" Or  ALMACEN = "64" Or  ALMACEN = "25" Then
		b_like.Visible = True
	Else
		b_like.Visible = False
	End If
	c = skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MACIMP"))
	If c.RowCount > 0 Then
		c.Position = 0
		Starter.MAC_IMPRESORA = c.GetString("CAT_VA_VALOR")
	End If
	If Starter.MAC_IMPRESORA = "" Then Starter.MAC_IMPRESORA = "0"
	Log("|" & Starter.MAC_IMPRESORA & "|")
	Printer1.Initialize(Me, "Printer1")
	
	If Printer1.IsConnected = False Then
'		Printer1.Connect
		Log("1")
	Else
		Printer1.DisConnect
		Printer1.Connect
		Log("2")
	End If
	
	c = skmt.ExecQuery("SELECT HABILITADA FROM IMPRESORA")
	If c.RowCount >  0 Then
		c.Position = 0
		If c.GetString("HABILITADA") = 1 Then
			B_IMP.Visible = True
		Else If c.GetString("HABILITADA") = 0 Then
			B_IMP.Visible = False
		End If
	Else If c.RowCount =  0 Then
		B_IMP.Visible = False
	End If
End Sub

Sub GPS_LocationChanged (Location1 As Location)
'	LogColor($"Entrando a Cliente.GPS_LocationChanged"$, Colors.red)
	If Tracker.FLP.GetLastKnownLocation.IsInitialized And Tracker.FLP.GetLastKnownLocation.Latitude <> 0 Then
		B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
		B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
'		Log("Coords set to: " & B4XPages.MainPage.lat_gps & " and " & B4XPages.MainPage.lon_gps)
	End If
	
	Dim l1, l2 As Location
	l1.Initialize2(B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps)
'	Log($"Coordenadas de la tienda - lat:${m_lat}, lon:${m_lon}"$)
	l2.Initialize2(m_lat, m_lon)
	
	BT_QR.Enabled = True
	LA_GPS.TextColor = Colors.Blue
	LA_GPS.Text = "CON UBICACION GPS"
	B_GPS.Enabled = True
	'now we need the distance between our location and the target location
	Dim distance As Long
	distance =    l1.DistanceTo(l2)  'the result is in meter
	gest.Visible = True
	If distance < 100 Then
		LA_GEO.TextColor = Colors.Blue
		Tels.Visible = True
		gest.Visible = True
	Else
		LA_GEO.TextColor = Colors.Red
'		If ALMACEN = "1" Then
'			Tels.Visible = False
'			gest.Visible = True
'		End If
	End If
	LA_GEO.Text= $"$1.2{distance/1000} kms"$
	B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
	B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO  HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
	CallSubDelayed(Tracker, "CreateLocationRequest")
End Sub

Sub ListView1_ItemLongClick (Position As Int, Value As Object)
	
End Sub

Sub gest_Click

'	'If ALMACEN = "4" Or ALMACEN = "36" Then
'	Log(Subs.traeAlmacen)
'	Dim Items As List
'	Items.Initialize
'	Items.Add("Selecciona una opción")
'	Items.Add("Tienda de Abarrotes (Abarrotes, Misceláneas, Minisupers, Particulares con Venta y Cremerías)")
'	Items.Add("Recaudería (Frutas y Verduras)")
'	Items.Add("Vinos y Licores")
'	Items.Add("Carnicería o Pollería")
'	Items.Add("Farmacia")
'	Items.Add("Jarciería (Productos de Limpieza)")
'	Items.Add("Papelería y Regalos")
'	Items.Add("Tortillería")
'	Items.Add("Escuelas")
'	Items.Add("Estanquillos (Puestos Semifijos)")
'	Items.Add("Fonda, Cocina Económica, Cafetería)")
'	Items.Add("Tlapalería, Ferretería")
'	Items.Add("Dulcería, Materias Primas")
'	Items.Add("Semillas y Chiles Secos")
'	Items.Add("Cybercafé")
'	Items.Add("Hotel")
'	Items.Add("Veterinaria")
'	Items.Add("Tienda de Mascotas")
'	Items.Add("Otros")
'	cb_pregunta.SetItems(Items)
'
'	girotienda = "Selecciona una opcion"
'	
'	c=skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS FROM HIST_ENCUESTA_CLIENTE WHERE HEC_CLIENTE IN (Select CUENTA from cuentaa)")
'	c.Position=0
'	CUENTA_MODULO = c.GetString("CUANTOS")
'	c.Close
'	If CUENTA_MODULO > 0 Then
'		c=skmt.ExecQuery("SELECT HEC_MODULO FROM HIST_ENCUESTA_CLIENTE WHERE HEC_CLIENTE IN (Select CUENTA from cuentaa)")
'		c.Position=0
'		que_modulo = c.GetString("HEC_MODULO")
'		c.Close
'	End If
'	Log(Subs.traeAlmacen)
'	c=skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS FROM ENCUESTA_MODULO1 WHERE CLIENTE IN (Select CUENTA from cuentaa)")
'	c.Position=0
'	EXISTE  = c.GetString("CUANTOS")
'	c.Close
'	
'	c=skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS FROM ENCUESTA_MODULO2 WHERE CLIENTE IN (Select CUENTA from cuentaa)")
'	c.Position=0
'	EXISTE2  = c.GetString("CUANTOS")
'	c.Close
'	
'	c=skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS FROM ENCUESTA_MODULO3 WHERE CLIENTE IN (Select CUENTA from cuentaa)")
'	c.Position=0
'	EXISTE3  = c.GetString("CUANTOS")
'	c.Close
'	
'	c=skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS FROM ENCUESTA_MODULO4 WHERE CLIENTE IN (Select CUENTA from cuentaa)")
'	c.Position=0
'	EXISTE4  = c.GetString("CUANTOS")
'	c.Close
'	
'	c=skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS FROM ENCUESTA_MODULO5 WHERE CLIENTE IN (Select CUENTA from cuentaa)")
'	c.Position=0
'	EXISTE5  = c.GetString("CUANTOS")
'	c.Close
'	
'	'' esto para la primera encuesta m1
''	p_cliente.Visible = False
''	SV_ENCUESTA.Visible = True
''	SV_ENCUESTA.Panel.LoadLayout("ENCUESTA")
''	Panel5.Width = Root.Width * 0.94
''	SV_ENCUESTA.Panel.Height = Panel5.Height + 60
''	Panel7.Visible = False
'
'	'' para la m2
''	p_cliente.Visible = False
''	SV_ENCUESTA.Visible = True
''	SV_ENCUESTA.Panel.LoadLayout("ESNCUESTA_m2")
''	Panel5.Width = Root.Width * 0.94
''	SV_ENCUESTA.Panel.Height = Panel5.Height + 60
''	Panel7_M2.Visible = False
''	
'	'' para la m3
''	p_cliente.Visible = False
''	SV_ENCUESTA.Visible = True
''	SV_ENCUESTA.Panel.LoadLayout("ENCUESSTA_M3")
''	Panel5.Width = Root.Width * 0.94
''	SV_ENCUESTA.Panel.Height = Panel5.Height + 60
'
'	If EXISTE = 0 And EXISTE2 = 0 And EXISTE3 = 0 And EXISTE4 = 0 And EXISTE5 = 0 Then
'	
'	
'		S=skmt.ExecQuery2("SELECT CAT_VA_VALOR FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("CUESTIONARIO"))
'		S.Position=0
'	
'		If s.GetString("CAT_VA_VALOR") > "0" Then
'			''	If "3" > "0" Then
'			ENCUESTA =  s.GetString("CAT_VA_VALOR")
'			'	ENCUESTA =  "3"
'		
'	
''	c=skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS FROM HIST_ENCUESTA_PED_DIST_1 WHERE TIENDA IN (Select CUENTA from cuentaa)")
''	c.Position=0
''	EXISTE  = c.GetString("CUANTOS")
''	c.Close
''	If EXISTE = 0 Then
''			Dim result As Int= -3
''			Do While result=-3
''				result = 	Msgbox2("Entiendo, acepto y consiento que GUNA usará mis datos Personales y serán tratados acorde con lo establecido en la Ley Federal de Protección de Datos Personales en Posesión de los Particulares (en lo sucesivo la “Ley”), y su respectivo Reglamento; bajo lo manifestado en el Aviso de Privacidad – Texto Completo – que se encuentra en la página www.guna.com.mx", "AVISO DE PRIVACIDAD","ACEPTO","", "NO ACEPTO",LoadBitmap(File.DirAssets,"alert2.png"))
''				Select Case result
''					Case DialogResponse.POSITIVE
''						p_pregunta1.Visible = True
''					Case DialogResponse.NEGATIVE
''						''HIST_ENCUESTA_AVISO_GIRO (HEAV_CLIENTE TEXT, HEAV_MODULO TEXT, HEAV_AVISO TEXT, HEAV_GIRO TEXT)
''						skmt.ExecNonQuery2("INSERT INTO HIST_ENCUESTA_AVISO_GIRO(HEAV_CLIENTE , HEAV_MODULO , HEAV_AVISO   ) VALUES (?,?,?) ", Array As Object( clie_id, ENCUESTA, "NO ACEPTA"))
''
''						B4XPages.ShowPage("productos")
''				End Select
''	
''				
''			Loop
''			result = 	Msgbox2("Entiendo, acepto y consciento que GUNA usará mis datos Personales y serán tratados acorde con lo establecido en la Ley Federal de Protección de Datos Personales en Posesión de los Particulares (en lo sucesivo la “Ley”), y su respectivo Reglamento; bajo lo manifestado en el Aviso de Privacidad – Texto Completo – que se encuentra en la página www.guna.com.mx", "AVISO DE PRIVACIDAD","ACEPTO","", "NO ACEPTO",LoadBitmap(File.DirAssets,"alert2.png"))
''			If result = DialogResponse.Positive Then			
'			p_pregunta1.Visible = True
''				
''				
''			Else
''				''HIST_ENCUESTA_AVISO_GIRO (HEAV_CLIENTE TEXT, HEAV_MODULO TEXT, HEAV_AVISO TEXT, HEAV_GIRO TEXT)
''				skmt.ExecNonQuery2("INSERT INTO HIST_ENCUESTA_AVISO_GIRO(HEAV_CLIENTE , HEAV_MODULO , HEAV_AVISO   ) VALUES (?,?,?) ", Array As Object( clie_id, ENCUESTA, "NO ACEPTA"))
'			'
''				B4XPages.ShowPage("productos")
''		    End If
'			
'		
'		Else
'			B4XPages.ShowPage("productos")
'		End If
'	Else
'		B4XPages.ShowPage("productos")
'
'	End If

	B4XPages.ShowPage("productos")

	s.Close

	'Else
'		B4XPages.ShowPage("productos")
	'End If

End Sub


Private Sub cb_pregunta_SelectedIndexChanged (Index As Int)
	girotienda = Sender.As(B4XComboBox).SelectedItem
	Log(girotienda)
	Log(Index)
End Sub

Private Sub b_preguntag_Click
	B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE kmt_info SET CAT_CL_GIRO = ? WHERE CAT_CL_CODIGO = ? And CAT_CL_NOMBRE = ?", Array As Object (girotienda, la_cuenta.text,La_nombre.Text))

	skmt.ExecNonQuery2("INSERT INTO HIST_ENCUESTA_AVISO_GIRO(HEAV_CLIENTE , HEAV_MODULO , HEAV_AVISO ,HEAV_GIRO  ) VALUES (?,?,?,?) ", Array As Object( clie_id, ENCUESTA, "ACEPTA",girotienda))
	
	If girotienda <> "Selecciona una opcion" Then

		If girotienda = "Tienda de Abarrotes (Abarrotes, Misceláneas, Minisupers, Particulares con Venta y Cremerías)" Then
			
			Dim result As Int= -3
			Do While result=-3
				result = 	Msgbox2("Entiendo, acepto y consiento que GUNA usará mis datos Personales y serán tratados acorde con lo establecido en la Ley Federal de Protección de Datos Personales en Posesión de los Particulares (en lo sucesivo la “Ley”), y su respectivo Reglamento; bajo lo manifestado en el Aviso de Privacidad – Texto Completo – que se encuentra en la página www.guna.com.mx", "AVISO DE PRIVACIDAD","ACEPTO","", "NO ACEPTO",LoadBitmap(File.DirAssets,"alert2.png"))
				Select Case result
					Case DialogResponse.POSITIVE
						
					
						
					
		


'			If ALMACEN = "35" Or ALMACEN  = "43" Or ALMACEN = "54"  Or ALMACEN = "73" Or ALMACEN = "56" Then 'ALMACEN = "7" Then '
'				''Or ALMACEN = "56" ATIZAPAN PEDIGRI
'				p_pregunta1.Visible = False
'				SV_ENCUESTA.Visible = True
'				SV_ENCUESTA.Panel.LoadLayout("ENCUESTA_PED")
'				SV_ENCUESTA.Panel.Height = Panel4.Height
'				Panel4.Visible = True
'				b_like.Visible = False
'				BT_QR.Visible = False
'				B_GALLINA.Visible = False
'				Tar.Visible = False
'				Tels.Visible = False
'				gest.Visible = False
'				b_venta.Visible = False
'				Guardar.Visible = False
'				HIST.Visible = False
'	
'
'			Else
Log(que_modulo)
				If que_modulo = Null Or que_modulo = " " Then que_modulo = "1"
				'	Msgbox(que_modulo,"ALO")
				If que_modulo < =  ENCUESTA	Then
					If que_modulo = "1" Then
	
	
									If p_m2.IsInitialized And p_m2.Visible Then
										p_m2.Visible = False
									Else If p_m3.IsInitialized And p_m3.Visible Then
										p_m3.Visible = False
									Else If p_m4.IsInitialized And p_m4.Visible Then
										p_m4.Visible = False
									Else If p_modulo5.IsInitialized And p_modulo5.Visible Then
										p_modulo5.Visible = False
									Else 
									End If
						' esto para la primera encuesta m1
						p_pregunta1.Visible = False
						p_cliente.Visible = False
						SV_ENCUESTA.Visible = True
						SV_ENCUESTA.Panel.LoadLayout("ENCUESTA")
						p_m1.Width = Root.Width * 0.94
						SV_ENCUESTA.Panel.Height = p_m1.Height + 60
						Panel7.Visible = False
	
					else if que_modulo = "2" Then
	

						'' para la m2
						If p_m1.IsInitialized And p_m1.Visible Then
						p_m1.Visible = False
						Else
							
						End If
						p_pregunta1.Visible = False
						p_cliente.Visible = False
						SV_ENCUESTA.Visible = True
						SV_ENCUESTA.Panel.LoadLayout("ESNCUESTA_m2")
						p_m2.Width = Root.Width * 0.94
						SV_ENCUESTA.Panel.Height = p_m2.Height + 60
						Panel7_M2.Visible = False
					else if que_modulo = "3" Then
						'para la m3
									If p_m2.IsInitialized And p_m2.Visible Then
										p_m2.Visible = False
									Else
							
									End If
						p_pregunta1.Visible = False
						p_cliente.Visible = False
						SV_ENCUESTA.Visible = True
						SV_ENCUESTA.Panel.LoadLayout("ENCUESSTA_M3")
				
						p_m3.Width = Root.Width * 0.94
						SV_ENCUESTA.Panel.Height = p_m3.Height + 60
					else if que_modulo = "4" Then

						'' para la m4
						
									If p_m3.IsInitialized And p_m3.Visible Then
										
										p_m3.Visible = False
									Else
							
									End If
						p_pregunta1.Visible = False
						p_cliente.Visible = False
						SV_ENCUESTA.Visible = True
						p_pregunta1.Visible = False
						SV_ENCUESTA.Panel.LoadLayout("ENCUESTA_M4")
						p_m4.Width = Root.Width * 0.94
						SV_ENCUESTA.Panel.Height = p_m4.Height + 60
			
						Dim Items2 As List
						Items2.Initialize
						Items2.Add("Selecciona una opcion")
						Items2.Add("Propio")
						Items2.Add("Rentado")
						cb_p3_m4.SetItems(Items2)
						itemselect2 = "Selecciona una opcion"
	
	
						Dim Items3 As List
						Items3.Initialize
						Items3.Add("Selecciona una opcion")
						Items3.Add("Completamente Surtido")
						Items3.Add("Bien Surtido")
						Items3.Add("Poco Surtido")
						Items3.Add("Muy Poco Surtido")
						Items3.Add("Sin Existencias")
						cb_p4_1_m4.SetItems(Items3)
						itemselect3 = "Selecciona una opcion"
						cb_p4_2_m4.SetItems(Items3)
						itemselect4 = "Selecciona una opcion"
						cb_p4_3_m4.SetItems(Items3)
						itemselect5 = "Selecciona una opcion"
						cb_p4_4_m4.SetItems(Items3)
						itemselect6 = "Selecciona una opcion"
						cb_p4_5_m4.SetItems(Items3)
						itemselect7 = "Selecciona una opcion"
						'
					else if que_modulo = "5" Then
						''	'MODULO 5
									If p_m4.IsInitialized And p_m4.Visible Then
										p_m4.Visible = False
									Else
							
									End If
						p_cliente.Visible = False
						SV_ENCUESTA.Visible = True
						p_pregunta1.Visible = False
						SV_ENCUESTA.Panel.LoadLayout("ENCUESTA_M5")
						p_modulo5.Width = Root.Width * 0.94
						SV_ENCUESTA.Panel.Height = p_modulo5.Height + 30
	
						Dim Items8 As List
						Items8.Initialize
						Items8.Add("Selecciona una opcion")
						Items8.Add("Completamente Surtido")
						Items8.Add("Bien Surtido")
						Items8.Add("Poco Surtido")
						Items8.Add("Muy Poco Surtido")
						Items8.Add("Sin Existencias")
						cb_p1_m5.SetItems(Items8)
						itemselect8 = "Selecciona una opcion"
						cb_p2_m5.SetItems(Items8)
						itemselect9 = "Selecciona una opcion"
						cb_p3_m5.SetItems(Items8)
						itemselect10 = "Selecciona una opcion"
						cb_p4_m5.SetItems(Items8)
						itemselect11 = "Selecciona una opcion"
						cb_p5_m5.SetItems(Items8)
						itemselect12 = "Selecciona una opcion"
						cb_p6_m5.SetItems(Items8)
						itemselect13 = "Selecciona una opcion"
						cb_p7_m5.SetItems(Items8)
						itemselect14 = "Selecciona una opcion"
						cb_p8_m5.SetItems(Items8)
						itemselect15 = "Selecciona una opcion"
						cb_p9_m5.SetItems(Items8)
						itemselect16 = "Selecciona una opcion"
					End If
				Else
					p_pregunta1.Visible = False
		
					B4XPages.ShowPage("productos")

	
				End If
'			End IF
			
					Case DialogResponse.NEGATIVE
						
						B4XPages.ShowPage("productos")
				End Select
	
				
			Loop
			'fin modulos
'	If girotienda = "Tienda de Abarrotes (Abarrotes, Misceláneas, Minisupers, Particulares con Venta y Cremerías)"  Then
'		If  Subs.traeAlmacen = 36  And EXISTE4 = 0 Then
'			p_cliente.Visible = False
'			SV_ENCUESTA.Visible = True
'			p_pregunta1.Visible = False
'			SV_ENCUESTA.Panel.LoadLayout("ENCUESTA_M5")
'			p_modulo5.Width = Root.Width * 0.94
'			SV_ENCUESTA.Panel.Height = p_modulo5.Height + 60
'	
'			Dim Items8 As List
'			Items8.Initialize
'			Items8.Add("Selecciona una opcion")
'			Items8.Add("Completamente Surtido")
'			Items8.Add("Bien Surtido")
'			Items8.Add("Poco Surtido")
'			Items8.Add("Muy Poco Surtido")
'			Items8.Add("Sin Existencias")
'			cb_p1_m5.SetItems(Items8)
'			itemselect8 = "Selecciona una opcion"
'			cb_p2_m5.SetItems(Items8)
'			itemselect9 = "Selecciona una opcion"
'			cb_p3_m5.SetItems(Items8)
'			itemselect10 = "Selecciona una opcion"
'			cb_p4_m5.SetItems(Items8)
'			itemselect11 = "Selecciona una opcion"
'			cb_p5_m5.SetItems(Items8)
'			itemselect12 = "Selecciona una opcion"
'			cb_p6_m5.SetItems(Items8)
'			itemselect13 = "Selecciona una opcion"
'			cb_p7_m5.SetItems(Items8)
'			itemselect14 = "Selecciona una opcion"
'			cb_p8_m5.SetItems(Items8)
'			itemselect15 = "Selecciona una opcion"
'			cb_p9_m5.SetItems(Items8)
'			itemselect16 = "Selecciona una opcion"
'			
'		ELSE IF Subs.traeAlmacen = 56 And EXISTE4 = 0 Then
'			p_cliente.Visible = False
'			SV_ENCUESTA.Visible = True
'			p_pregunta1.Visible = False
'			SV_ENCUESTA.Panel.LoadLayout("ENCUESTA_M5")
'			p_modulo5.Width = Root.Width * 0.94
'			SV_ENCUESTA.Panel.Height = p_modulo5.Height + 60
'	
'			Dim Items8 As List
'			Items8.Initialize
'			Items8.Add("Selecciona una opcion")
'			Items8.Add("Completamente Surtido")
'			Items8.Add("Bien Surtido")
'			Items8.Add("Poco Surtido")
'			Items8.Add("Muy Poco Surtido")
'			Items8.Add("Sin Existencias")
'			cb_p1_m5.SetItems(Items8)
'			itemselect8 = "Selecciona una opcion"
'			cb_p2_m5.SetItems(Items8)
'			itemselect9 = "Selecciona una opcion"
'			cb_p3_m5.SetItems(Items8)
'			itemselect10 = "Selecciona una opcion"
'			cb_p4_m5.SetItems(Items8)
'			itemselect11 = "Selecciona una opcion"
'			cb_p5_m5.SetItems(Items8)
'			itemselect12 = "Selecciona una opcion"
'			cb_p6_m5.SetItems(Items8)
'			itemselect13 = "Selecciona una opcion"
'			cb_p7_m5.SetItems(Items8)
'			itemselect14 = "Selecciona una opcion"
'			cb_p8_m5.SetItems(Items8)
'			itemselect15 = "Selecciona una opcion"
'			cb_p9_m5.SetItems(Items8)
'			itemselect16 = "Selecciona una opcion"
			'
'		Else If Subs.traeAlmacen = 4  And EXISTE5 = 0 Then
'			p_cliente.Visible = False
'			SV_ENCUESTA.Visible = True
'			p_pregunta1.Visible = False
'			SV_ENCUESTA.Panel.LoadLayout("ENCUESTA_M5")
'			p_modulo5.Width = Root.Width * 0.94
'			SV_ENCUESTA.Panel.Height = p_modulo5.Height + 60
'	
'			Dim Items8 As List
'			Items8.Initialize
'			Items8.Add("Selecciona una opcion")
'			Items8.Add("Completamente Surtido")
'			Items8.Add("Bien Surtido")
'			Items8.Add("Poco Surtido")
'			Items8.Add("Muy Poco Surtido")
'			Items8.Add("Sin Existencias")
'			cb_p1_m5.SetItems(Items8)
'			itemselect8 = "Selecciona una opcion"
'			cb_p2_m5.SetItems(Items8)
'			itemselect9 = "Selecciona una opcion"
'			cb_p3_m5.SetItems(Items8)
'			itemselect10 = "Selecciona una opcion"
'			cb_p4_m5.SetItems(Items8)
'			itemselect11 = "Selecciona una opcion"
'			cb_p5_m5.SetItems(Items8)
'			itemselect12 = "Selecciona una opcion"
'			cb_p6_m5.SetItems(Items8)
'			itemselect13 = "Selecciona una opcion"
'			cb_p7_m5.SetItems(Items8)
'			itemselect14 = "Selecciona una opcion"
'			cb_p8_m5.SetItems(Items8)
'			itemselect15 = "Selecciona una opcion"
'			cb_p9_m5.SetItems(Items8)
'			itemselect16 = "Selecciona una opcion"
			' FIN MODULO 5


			' ESTOI ES PARA MODULO 4
'			p_cliente.Visible = False
'			SV_ENCUESTA.Visible = True
'			p_pregunta1.Visible = False
'			SV_ENCUESTA.Panel.LoadLayout("ENCUESTA_M4")
'			Panel5.Width = Root.Width * 0.94
'			SV_ENCUESTA.Panel.Height = Panel5.Height + 60
'			
'			Dim Items2 As List
'			Items2.Initialize
'			Items2.Add("Selecciona una opcion")
'			Items2.Add("Propio")
'			Items2.Add("Rentado")
'			cb_p3_m4.SetItems(Items2)
'			itemselect2 = "Selecciona una opcion"
'	
'			Dim Items3 As List
'			Items3.Initialize
'			Items3.Add("Selecciona una opcion")
'			Items3.Add("Completamente Surtido")
'			Items3.Add("Bien Surtido")
'			Items3.Add("Poco Surtido")
'			Items3.Add("Muy Poco Surtido")
'			Items3.Add("Sin Existencias")
'			cb_p4_1_m4.SetItems(Items3)
'			itemselect3 = "Selecciona una opcion"
'			cb_p4_2_m4.SetItems(Items3)
'			itemselect4 = "Selecciona una opcion"
'			cb_p4_3_m4.SetItems(Items3)
'			itemselect5 = "Selecciona una opcion"
'			cb_p4_4_m4.SetItems(Items3)
'			itemselect6 = "Selecciona una opcion"
'			cb_p4_5_m4.SetItems(Items3)
'			itemselect7 = "Selecciona una opcion"
'		End If
			' FIN MODULO 4

'	Else
'		B4XPages.ShowPage("productos")
'	End If
		Else
			p_pregunta1.Visible = False
		
			B4XPages.ShowPage("productos")

		End If
		
		
	Else
		Msgbox("Contesta la pregunta de favor","AVISO")
	End If
End Sub

Private Sub cb_p3_m4_SelectedIndexChanged (Index As Int)
	itemselect2 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect2)
	Log(Index)
End Sub

Private Sub cb_p4_1_m4_SelectedIndexChanged (Index As Int)
	itemselect3 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect3)
	Log(Index)
End Sub

Private Sub cb_p4_2_m4_SelectedIndexChanged (Index As Int)
	itemselect4 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect4)
	Log(Index)
End Sub

Private Sub cb_p4_3_m4_SelectedIndexChanged (Index As Int)
	itemselect5 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect5)
	Log(Index)
End Sub

Private Sub cb_p4_4_m4_SelectedIndexChanged (Index As Int)
	itemselect6 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect6)
	Log(Index)
End Sub

Private Sub cb_p4_5_m4_SelectedIndexChanged (Index As Int)
	itemselect7 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect7)
	Log(Index)
End Sub

Private Sub cb_p1_m5_SelectedIndexChanged (Index As Int)
	itemselect8 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect8)
	Log(Index)
End Sub

Private Sub cb_p2_m5_SelectedIndexChanged (Index As Int)
	itemselect9 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect9)
	Log(Index)
End Sub

Private Sub cb_p3_m5_SelectedIndexChanged (Index As Int)
	itemselect10 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect10)
	Log(Index)
End Sub

Private Sub cb_p4_m5_SelectedIndexChanged (Index As Int)
	itemselect11 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect11)
	Log(Index)
End Sub

Private Sub cb_p5_m5_SelectedIndexChanged (Index As Int)
	itemselect12 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect12)
	Log(Index)
End Sub

Private Sub cb_p6_m5_SelectedIndexChanged (Index As Int)
	itemselect13 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect13)
	Log(Index)
End Sub

Private Sub cb_p7_m5_SelectedIndexChanged (Index As Int)
	itemselect14 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect14)
	Log(Index)
End Sub

Private Sub cb_p8_m5_SelectedIndexChanged (Index As Int)
	itemselect15 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect15)
	Log(Index)
End Sub

Private Sub cb_p9_m5_SelectedIndexChanged (Index As Int)
	itemselect16 = Sender.As(B4XComboBox).SelectedItem
	Log(itemselect16)
	Log(Index)
End Sub


Sub B_guardaencuesta_Click
	Dim SI_GUARDAR As String
	SI_GUARDAR = 1
	
	If RB1_E1.Checked = False And RB2_E1.Checked = False And RB3_E1.Checked = False Then
		SI_GUARDAR = 0
	End If
	
	If Panel7.Visible = True Then
		If RadioButton15.Checked = False And RadioButton16.Checked = False And RadioButton17.Checked = False Then
			SI_GUARDAR = 0
		End If
	End If
	
	If RadioButton1.Checked = False And  RadioButton2.Checked = False And RadioButton3.Checked = False And RadioButton4.Checked = False Then
		SI_GUARDAR = 0
	End If
	
	If RadioButton5.Checked = False And  RadioButton6.Checked = False And RadioButton7.Checked = False And RadioButton8.Checked = False  And RadioButton9.Checked = False Then
		SI_GUARDAR = 0
	End If
	
	If RadioButton10.Checked = False And  RadioButton11.Checked = False And RadioButton12.Checked = False And RadioButton13.Checked = False  And RadioButton14.Checked = False Then
		SI_GUARDAR = 0
	End If
	
	If p6.Text = "" Then
		SI_GUARDAR = 0
	End If
	If p7.Text = "" Then
		SI_GUARDAR = 0
	End If
	If p8.Text = "" Then
		SI_GUARDAR = 0
	End If
	
	If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = False And CheckBox5.Checked = False And CheckBox6.Checked = False And CheckBox7.Checked = False And CheckBox8.Checked = False Then
		encuentasmapa.Put("P9", "")
		Log(encuentasmapa)
	End If
	
	If SI_GUARDAR = 1 Then
		skmt.ExecNonQuery2("INSERT INTO ENCUESTA_MODULO1 (CLIENTE, ALMACEN,P1, P2, P3, P4, P5, P6, P7, P8, P9) VALUES (?,?,?,?,?,?,?,?,?,?,?)", Array As Object(Subs.traeCliente, ALMACEN, encuentasmapa.Get("P3"),encuentasmapa.Get("P1"),encuentasmapa.Get("P2"),encuentasmapa.Get("P4"),encuentasmapa.Get("P5"),p6.Text,p7.Text,p8.Text,encuentasmapa.Get("P9")))
'	SV_ENCUESTA.Visible = False
'	p_cliente.Visible = True
'	B4XPages.MainPage.tipo_venta = "PREVENTA"
'	B4XPages.ShowPage("productos")
'	MsgboxAsync("Encuesta guardada","")
		RB1_E1.Checked = False
		RB2_E1.Checked = False
		RB3_E1.Checked = False
		RadioButton15.Checked = False
		RadioButton16.Checked = False
		RadioButton17.Checked = False
		RadioButton1.Checked = False
		RadioButton2.Checked = False
		RadioButton3.Checked = False
		RadioButton4.Checked = False
		RadioButton5.Checked = False
		RadioButton6.Checked = False
		RadioButton7.Checked = False
		RadioButton8.Checked = False
		RadioButton9.Checked = False
		RadioButton10.Checked = False
		RadioButton11.Checked = False
		RadioButton12.Checked = False
		RadioButton13.Checked = False
		RadioButton14.Checked = False
		p6.Text = ""
		p7.Text = ""
		p8.Text = ""
		CheckBox1.Checked = False
		CheckBox2.Checked = False
		CheckBox3.Checked = False
		CheckBox4.Checked = False
		CheckBox5.Checked = False
		CheckBox6.Checked = False
		CheckBox7.Checked = False
		CheckBox8.Checked = False
	
		If ENCUESTA > 1 Then
			' para la m2
			If p_m1.IsInitialized And p_m1.Visible Then
				p_m1.Visible = False
			Else
							
			End If
			p_pregunta1.Visible = False
			p_cliente.Visible = False
			SV_ENCUESTA.Visible = True
			SV_ENCUESTA.Panel.LoadLayout("ESNCUESTA_m2")
			p_m2.Width = Root.Width * 0.94
			SV_ENCUESTA.Panel.Height = p_m2.Height + 60
			Panel7_M2.Visible = False
		Else
			p_pregunta1.Visible = False
			SV_ENCUESTA.Visible = False
			p_cliente.Visible = True
			tipo_venta = "VENTA"
'	StartActivity(colonia2)
			B4XPages.ShowPage("productos")
	
		End If
	
	Else
		Msgbox("FALTAN DATOS DE CAPTURA FAVOR DE VALIDAR", "AVISO")
	End If
End Sub

Sub Tels_Click
	B4XPages.ShowPage("NoVenta")
End Sub

Private Sub B4XPage_CloseRequest As ResumableSub
'	BACK key pressed
'	Return True To close, False To cancel
	If p_pregunta1.Visible Then
		p_pregunta1.Visible = False
	Else if SV_ENCUESTA.Visible Then
		SV_ENCUESTA.visible = False
		p_cliente.Visible = True
	Else
		B4XPages.ShowPage("Clientes")
	End If
'	Return True
	Return False
End Sub

Sub Tar_Click
	B4XPages.ShowPage("Nota")
End Sub

Sub DATOS_Click
	B4XPages.ShowPage("telefonos")
End Sub

Sub Guardar_Click
	DateTime.DateFormat = "MM/dd/yyyy"
	sDate=DateTime.Date(DateTime.Now)
	sTime=DateTime.Time(DateTime.Now)
	c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
	c.Position=0
	clie_id = c.GetString("CUENTA")
	c.Close
	c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
	c.Position=0
	usuario = c.GetString("USUARIO")
	c.Close
	c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, COUNT(*) AS CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
	c.Position=0
	If c.GetString("CUANTOS") > 0 Then
		B4XPages.MainPage.skmt.ExecNonQuery("delete from NOVENTA where NV_CLIENTE In (select cuenta from cuentaa)")
		B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
		B4XPages.MainPage.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT) VALUES (?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps))
		B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2  where CAT_CL_CODIGO In (select cuenta from cuentaa)")
	End If
	c.Close
	DateTime.TimeFormat = "HHmmss"
	sTime=DateTime.Time(DateTime.Now)
	B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_OUT = ?  where HSS_OUT = 0 AND  HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(sTime))
	'  B4XPages.MainPage.skmt.ExecNonQuery("UPDATE HIST_STAY_STORE set HSS_TOT = HSS_OUT - HSS_IN where HSS_CODIGO In (select cuenta from cuentaa)")
	Try
		c=B4XPages.MainPage.skmt.ExecQuery(" Select (substr(HSS_OUT,1,2) - substr(HSS_IN,1,2)) - Case when  (substr(HSS_OUT,3,2) - substr(HSS_IN,3,2)) < 0 Then 1 Else 0 end HORAS_TOTALES, " & _
	"Case when  (substr(HSS_OUT,3,2) - substr(HSS_IN,3,2)) < 0 Then (substr(HSS_OUT,3,2) + 60 - substr(HSS_IN,3,2)) " & _
	"	Else (substr(HSS_OUT,3,2) - substr(HSS_IN,3,2)) End - Case when  (substr(HSS_OUT,5,2) - substr(HSS_IN,5,2)) < 0 Then 1 Else 0 end  MINUTOS_TOTALES, " & _
	"Case when  (substr(HSS_OUT,5,2) - substr(HSS_IN,5,2)) < 0 Then (substr(HSS_OUT,5,2) + 60 - substr(HSS_IN,5,2)) " & _
	"	Else (substr(HSS_OUT,5,2) - substr(HSS_IN,5,2)) end SEGUNDOS_TOTALES " & _
	"	from HIST_STAY_STORE where HSS_CODIGO In (Select cuenta from cuentaa) ")
		c.Position = 0
		stay_hh = c.GetString("HORAS_TOTALES") * 60 * 60
		stay_mi = c.GetString("MINUTOS_TOTALES") * 60
		stay_ss = c.GetString("SEGUNDOS_TOTALES")
		B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_TOT = ?  where HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(stay_hh + stay_mi + stay_ss))
		B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_OUT set HSO_FIN = ?  ", Array As Object(sTime))
		c.Close
	Catch
		ToastMessageShow(".",True)
	End Try
	DateTime.TimeFormat = "HH:mm:ss"
	B4XPages.ShowPage("Principal")
End Sub

Sub NUEVO_Click
	B4XPages.ShowPage("NuevoCliente")
End Sub

Sub HIST_Click
	B4XPages.ShowPage("Historico")
End Sub

Sub BT_QR_Click
	sc.isportrait = True
	sc.timeoutDuration = 45
	sc.theViewFinderXfactor = 0.7
	sc.theViewFinderYfactor = 0.5
	sc.theResultColor = Colors.Green
	sc.mustVibrate = True
	sc.BeginScan("sc")
End Sub

Sub sc_result(atype As String,Values As String, image As Bitmap)
	'Log("Type : " & atype)
	'Log("Value : " & Values)
	CODIGO = Values
	DD=B4XPages.MainPage.skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM kmt_info WHERE CAT_CL_NUM_SERIEFISICO = ?", Array As String(CODIGO))
	DD.Position =0
	If DD.GetString("CUANTOS") > 0 Then
		MsgboxAsync("Código ya asignado", "AVISO")
	Else
		If CODIGO.Length = 7 Then
			Msgbox2Async("El código "& CODIGO & " es correcto?" , "Title", "Yes", "Cancel", "No", Null, False)
			Wait For Msgbox_Result (resultado As Int)
			If resultado = DialogResponse.POSITIVE Then
				B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE kmt_info set CAT_CL_NUM_SERIEFISICO = ?, CAT_CL_LONG = ?, CAT_CL_LAT =? where CAT_CL_CODIGO In (select cuenta from cuentaa)", Array As Object(CODIGO, B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps))
				L_QR.TEXT =CODIGO
				L_QR.TextColor = Colors.Blue
				B4XPages.MainPage.skmt.ExecNonQuery2("insert into HIST_CODIGO_BARRAS(CODIGOKMTS, CODIGOB, LAT, LON) VALUES (?,?,?,?)", Array As Object(la_cuenta.Text,CODIGO, B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps))
			End If
		Else
			MsgboxAsync("Código No Valido", "AVISO")
		End If
	End If
	DD.Close
End Sub

Sub sc_timedout(timedOut As Boolean)
	Log("timedOut " & timedOut)
End Sub

Sub sc_usercancelled(userCancelled As Boolean)
	Log("userCancelled " & userCancelled)
End Sub

Sub calc_ean_checksum(number As String) As String           'this has now become redundant as I am only interested in QR Codes
	Dim i As Int
	Dim cO As Char
	Dim soma As Int
	Dim n As Int
	Dim digit As Float
	soma = 0
	For i=0 To number.Length - 1
		digit = number.SubString2(i,i+1)
		n= digit * ((i Mod 2) * 2 + 1)
		soma=soma+n
	Next
	Return number & ( ( 10 - ( soma Mod 10 )) Mod 10 )
End Sub

Sub b_mapa_Click
	B4XPages.ShowPage("mapas")
End Sub

Sub Printer1_Connected (Success As Boolean)
'	If Logger Then Log("Printer1_Connected")
	If Success Then
		ToastMessageShow("Impresora conectada", False)
		skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("MACIMP"))
		skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("MACIMP",Starter.mac_impresora))
		LogColor("Impresora conectada", Colors.Green)
'		B_IMP2.Enabled = True
		impresoraConectada = True
	Else
'		Msgbox(Printer1.ConnectedErrorMsg, "Error connecting.") 'ignore
'		ToastMessageShow("Error conectando la impresora", False)
		LogColor("Error conectando la impresora", Colors.Red)
		errorImpresora = errorImpresora + 1
		If errorImpresora > 1 Then
			Starter.MAC_IMPRESORA = "0"
			errorImpresora = 0
		End If
	End If
End Sub

Sub B_IMP_Click
'	Printer1.Connect2
'	c=Starter.skmt.ExecQuery2("select count(*) AS CUANTOS from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("PERFIL"))
'	c.Position =0
'	perfil = c.GetString("CUANTOS")
'	c.Close
	
'	If perfil > 0 Then
'	c=Starter.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("PERFIL"))
'	If c.RowCount > 0 Then
'		c.Position =0
'		perfil = c.GetString("CAT_VA_VALOR")
'		c.Close
'	End If
'	LogColor(perfil,Colors.Magenta)
'	End If
	
	
	
	c=skmt.ExecQuery("select USUARIO from usuarioa")
	c.Position=0
	usuario = c.GetString("USUARIO")
	DateTime.DateFormat = "MM/dd/yyyy"
	sDate=DateTime.Date(DateTime.Now)
	sTime=DateTime.Time(DateTime.Now)
	c.Close
'	c=Starter.skmt.ExecQuery2("SELECT CAT_VA_VALOR FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION =?", Array As String ("SUCURSAL"))
'	c.Position = 0
'	sucursal = c.GetString("CAT_VA_VALOR")
'	c.Close
	
	ProgressDialogShow("Imprimiendo, un momento ...")
	Printer1.DisConnect
	If Not(Printer1.IsConnected) Then
		Log("Conectando a impresora ...")
		Printer1.Connect
		Private cont As Int = 0
		Do While Not(impresoraConectada)
			Sleep(1000)
			Log("++++++  " & cont)
			cont = cont + 1
			If cont = 2 Then Printer1.Connect 'Tratamos de reconectar
			If cont > 3 Then impresoraConectada = True
		Loop
		Sleep(500)
		impresoraConectada = False
	Else
		Log("conectando 2")
		Printer1.Connect
		Private cont As Int = 0
		Do While Not(impresoraConectada) Or Not(Printer1.IsConnected)
			Sleep(1000)
			Log("******  " & cont)
			cont = cont + 1
			If cont = 2 Then Printer1.Connect
			If cont > 3 Then impresoraConectada = True
		Loop
		Sleep(500)
		impresoraConectada = False
	End If
	
	TAMANO = 0
	ESPACIO = 21
	BLANCO = " "
	Dim bmp As Bitmap
	bmp.InitializeResize(File.DirAssets, "guna.png", 192, 192, True) 'ignore
	Dim myimage As AnImage = Printer1.ImageToBWIMage(bmp)
	Printer1.Justify = 1
	myimage = Printer1.DitherImage2D(myimage, 128)
	myimage= Printer1.PackImage(myimage)
	Printer1.WriteString(CRLF) ' nudge the printer to show the user something is happening
	Printer1.WriteString(Printer1.REVERSE)
	
	Printer1.PrintImage(myimage)
	Printer1.WriteString(Printer1.UNREVERSE)

	Printer1.Justify = 0
	'printer.Initialize(cmp20.OutputStream)
	Printer1.WriteString("DISRUPTIVE" &  CRLF)
'	Printer1.WriteString("RFC: DRT-110316-9J1" &  CRLF)
'	Printer1.WriteString(sucursal &  CRLF)
	Printer1.WriteString(sDate & " " &sTime & CRLF)
	Printer1.WriteString("Vendedor:" & usuario &  CRLF)
	Printer1.WriteString("Tienda: " & La_nombre.Text &  CRLF)
	Printer1.WriteString("ID.Cliente: " &  la_cuenta.Text &  CRLF)
	Printer1.WriteString("Calle: " & la_Calle.Text &  CRLF)
	Printer1.WriteString("Colonia: " & la_col.Text &  CRLF)
'	Printer1.WriteString("C.P.: " & la_cp.Text &  CRLF)
	Printer1.WriteString("Entre c/1: " & l_entre1.Text &  CRLF)
	Printer1.WriteString("Entre c/2: " & l_entre2.Text &  CRLF)
	
	
	Printer1.WriteString("-------------VENTA------------" &  CRLF)
	' aqui es donde esta el pedo de julieta de los descuentos quitar el precio2 pero meter un if para saber si es ruta especial o es normal o que show.
	s=skmt.ExecQuery2("select PE_PRONOMBRE, PE_CANT, length(pe_cant) as L_CANT, PE_COSTOU, length(PE_COSTOU) as L_COSTOU,PE_CANT * PE_COSTOU AS  PE_COSTO_TOT, length(PE_CANT * PE_COSTOU) as L_COSTO_TOT,PE_PROID, PE_CEDIS  FROM PEDIDO WHERE PE_CEDIS <> ? AND LENGTH(PE_CEDIS) < 4 AND PE_CLIENTE IN (Select CUENTA from cuentaa)  order by  PE_PROID", Array As String("DUR"))
	If S.RowCount>0 Then
		For i=0 To S.RowCount -1
			S.Position=i
			If s.GetString("PE_CEDIS") = s.GetString("PE_PROID") Then
				Printer1.WriteString(s.GetString("PE_PRONOMBRE") &  CRLF)
				
			Else
				
				Printer1.WriteString(s.GetString("PE_CANT") & " " & s.GetString("PE_PRONOMBRE") &  CRLF)
				TAMANO = s.GetLong("L_CANT") + TAMANO
				TAMANO = s.GetLong("L_COSTOU") + TAMANO
				TAMANO = s.GetLong("L_COSTO_TOT") + TAMANO
	
				ESPACIO = ESPACIO - TAMANO
	
				For E=0 To ESPACIO -1
					BLANCO = " " & BLANCO
				Next
				Printer1.WriteString(BLANCO & s.GETSTRING("PE_CANT") & " X $" & s.GETSTRING("PE_COSTOU") & "   $" & s.GETSTRING("PE_COSTO_TOT") &  CRLF )
				TAMANO = 0
				ESPACIO = 21
				BLANCO = " "
			End If
		Next
	End If
	s.Close
	Printer1.WriteString(" " &  CRLF)
	s=skmt.ExecQuery("select PE_PRONOMBRE, PE_CANT, length(pe_cant) as L_CANT, PE_COSTOU, length(PE_COSTOU) as L_COSTOU,PE_CANT * PE_COSTOU AS  PE_COSTO_TOT, length(PE_CANT * PE_COSTOU) as L_COSTO_TOT,PE_PROID, PE_CEDIS  FROM PEDIDO WHERE LENGTH(PE_CEDIS) > 3 AND PE_PROID NOT IN (SELECT CAT_PA_ID FROM PROMOS_COMP ) AND PE_CLIENTE IN (Select CUENTA from cuentaa)  order by  PE_CEDIS, PE_COSTOU")
	If S.RowCount>0 Then
		Printer1.WriteString("------------PROMOS------------" &  CRLF)
		For i=0 To S.RowCount -1
			S.Position=i
			If s.GetString("PE_CEDIS") = s.GetString("PE_PROID") Then
				Printer1.WriteString(s.GetString("PE_PRONOMBRE") &  CRLF)
				
			Else
				
				Printer1.WriteString(s.GetString("PE_CANT") & " " & s.GetString("PE_PRONOMBRE") &  CRLF)
				TAMANO = s.GetLong("L_CANT") + TAMANO
				TAMANO = s.GetLong("L_COSTOU") + TAMANO
				TAMANO = s.GetLong("L_COSTO_TOT") + TAMANO
	
				ESPACIO = ESPACIO - TAMANO
	
				For E=0 To ESPACIO -1
					BLANCO = " " & BLANCO
				Next
				Printer1.WriteString(BLANCO & s.GETSTRING("PE_CANT") & " X $" & s.GETSTRING("PE_COSTOU") & "   $" & s.GETSTRING("PE_COSTO_TOT") &  CRLF )
				TAMANO = 0
				ESPACIO = 21
				BLANCO = " "
			End If
		Next
		Printer1.WriteString(" " &  CRLF)
	End If
	s.Close
		
'		Printer1.WriteString("-------------RMI..-----------" &  CRLF)
'		' aqui es donde esta el pedo de julieta de los descuentos quitar el precio2 pero meter un if para saber si es ruta especial o es normal o que show.
'		s=skmt.ExecQuery2("select PE_PRONOMBRE, PE_CANT, length(pe_cant) as L_CANT, PE_COSTOU, length(PE_COSTOU) as L_COSTOU,PE_CANT * PE_COSTOU AS  PE_COSTO_TOT, length(PE_CANT * PE_COSTOU) as L_COSTO_TOT,PE_PROID, PE_CEDIS  FROM PEDIDO WHERE PE_TIPO = ? AND PE_CEDIS = ? AND LENGTH(PE_CEDIS) < 4 AND PE_CLIENTE IN (Select CUENTA from cuentaa)  order by  PE_PROID", Array As String("PREVENTA","DUR"))
'		If S.RowCount>0 Then
'			For i=0 To S.RowCount -1
'				S.Position=i
'				If s.GetString("PE_CEDIS") = s.GetString("PE_PROID") Then
'					Printer1.WriteString(s.GetString("PE_PRONOMBRE") &  CRLF)
'				
'				Else
'				
'					Printer1.WriteString(s.GetString("PE_CANT") & " " & s.GetString("PE_PRONOMBRE") &  CRLF)
'					TAMANO = s.GetLong("L_CANT") + TAMANO
'					TAMANO = s.GetLong("L_COSTOU") + TAMANO
'					TAMANO = s.GetLong("L_COSTO_TOT") + TAMANO
'	
'					ESPACIO = ESPACIO - TAMANO
'	
'					For E=0 To ESPACIO -1
'						BLANCO = " " & BLANCO
'					Next
'					Printer1.WriteString(BLANCO & s.GETSTRING("PE_CANT") & " X $" & s.GETSTRING("PE_COSTOU") & "   $" & s.GETSTRING("PE_COSTO_TOT") &  CRLF )
'					TAMANO = 0
'					ESPACIO = 21
'					BLANCO = " "
'				End If
'			Next
'		End If
'		s.Close
		
	s=skmt.ExecQuery("select SUM(PE_COSTO_TOT) AS TOTAL FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
	s.Position =0
	'	If s.GetString("TOTAL") - s.GetString("TOTAL2") <> 0 Then
	'		Printer1.WriteString("Descuento:     $" & 	 (s.GetString("TOTAL2") -  s.GetString("TOTAL")))
	'	End If
	Printer1.WriteString("Total venta:   $" & s.GetString("TOTAL") &  CRLF)
	s.Close
	c= skmt.ExecQuery("select sum(PE_CANT) as PC_NOART from PEDIDO where PE_CLIENTE in (Select CUENTA from cuentaa) AND PE_PROID NOT IN (SELECT CAT_PA_ID FROM PROMOS_COMP )")
	C.Position=0
	Printer1.WriteString("Total articulos:   " & c.GetString("PC_NOART") &  CRLF)
	c.Close
	
	Printer1.WriteString(" " &  CRLF)
	Printer1.WriteString("------------------------------" &  CRLF)
	Printer1.WriteString("ENTREGA EN :" &  CRLF)
	Printer1.WriteString(la_Calle.Text &  CRLF)
	Printer1.WriteString("----ESTE TICKET NO ES UN -----" &  CRLF)
	Printer1.WriteString("--COMPROBANTE FISCAL, SOLO ES-" &  CRLF)
	Printer1.WriteString("--------INFORMATIVO-----------" &  CRLF)
	Printer1.WriteString("------------------------------" &  CRLF)
	Printer1.WriteString(" " &  CRLF)
	Printer1.WriteString(" " &  CRLF)
	Printer1.WriteString(" " &  CRLF)
	
	Sleep(1000)
	Printer1.DisConnect
	
	ProgressDialogHide
'	printer.Flush
	'	printer.Close
	
End Sub

'Sub B_IMP_Click
'	TAMANO = 0
'	ESPACIO = 21
'	BLANCO = " "
'	printer.Initialize(cmp20.OutputStream)
'	printer.WriteLine("DURAKELO S.A. de C.V.")
'	printer.WriteLine("RFC: DUR-011025-T12")
'	printer.WriteLine("Tel.: 618-826-0104")
'	printer.WriteLine("Vendedor: KMTS ")
'	printer.WriteLine("Tienda: " & La_nombre.Text)
'	printer.WriteLine("-----------PREVENTA-----------")
'	s=B4XPages.MainPage.skmt.ExecQuery("select PE_PRONOMBRE, PE_CANT, length(pe_cant) as L_CANT, PE_COSTOU, length(PE_COSTOU) as L_COSTOU, PE_COSTO_TOT, length(PE_COSTO_TOT) as L_COSTO_TOT FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
'	If S.RowCount>0 Then
'		For i=0 To S.RowCount -1
'			S.Position=i
'			printer.WriteLine(s.GetString("PE_CANT") & " " & s.GetString("PE_PRONOMBRE"))
'			TAMANO = s.GetLong("L_CANT") + TAMANO
'			TAMANO = s.GetLong("L_COSTOU") + TAMANO
'			TAMANO = s.GetLong("L_COSTO_TOT") + TAMANO
'			ESPACIO = ESPACIO - TAMANO
'			For E=0 To ESPACIO -1
'				BLANCO = " " & BLANCO
'			Next
'			printer.WriteLine(BLANCO & s.GETSTRING("PE_CANT") & " X $" & s.GETSTRING("PE_COSTOU") & "   $" & s.GETSTRING("PE_COSTO_TOT") )
'			TAMANO = 0
'			ESPACIO = 21
'			BLANCO = " "
'		Next
'	End If
'	s.Close
'	printer.WriteLine("Total Preventa:   $" & total_cliente)
'	printer.WriteLine("------------VENTA-------------")
'	printer.WriteLine(" ")
'	printer.WriteLine("TOTAL:   $" & total_cliente)
'	printer.WriteLine(" ")
'	printer.WriteLine("----ESTE TICKET NO ES UN -----")
'	printer.WriteLine("--COMPROBANTE FISCAL, SOLO ES-")
'	printer.WriteLine("--------INFORMATIVO-----------")
'	printer.WriteLine("------------------------------")
'	printer.WriteLine(" ")
'	printer.Flush
''	printer.Close
'End Sub

Sub Printer_Connected (Success As Boolean)
	If Success Then
		B_IMP.Enabled = True
	Else
		B_IMP.Enabled = False
		If Msgbox2("", "Printer Error","Reprint","Cancel","",Null) = DialogResponse.POSITIVE Then 'Ignore
			StartPrinter
		End If
	End If
End Sub

Sub StartPrinter
	Dim PairedDevices As Map
	Dim L As List
	Dim resimp As Int
	ToastMessageShow("Printing.....",True)
	PairedDevices.Initialize
	Try
		PairedDevices = cmp20.GetPairedDevices
	Catch
		Msgbox("Getting Paired Devices","Printer Error") 'Ignore
		printer.Close
		cmp20.Disconnect
	End Try
	If PairedDevices.Size = 0 Then
		Msgbox("Error Connecting to Printer - Printer Not Found","") 'Ignore
		Return
	End If
	If PairedDevices.Size = 1 Then
		Try
			cmp20.ConnectInsecure(btAdmin,PairedDevices.Get(PairedDevices.GetKeyAt(0)),1)
		Catch
			Msgbox("Connecting","Printer Error") 'Ignore
			printer.Close
			cmp20.Disconnect
		End Try
	Else
		L.Initialize
		For i = 0 To PairedDevices.Size - 1
			L.Add(PairedDevices.GetKeyAt(i))
		Next
		resimp = InputList(L, "Choose device", -1) 'Ignore
		If resimp <> DialogResponse.CANCEL Then
			cmp20.Connect(PairedDevices.Get(L.Get(resimp)))
		End If
	End If
End Sub

Sub B_GUARDA_C_Click
	DateTime.DateFormat = "MM/dd/yyyy"
	sDate=DateTime.Date(DateTime.Now)
	sTime=DateTime.Time(DateTime.Now)
	c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
	c.Position=0
	clie_id = c.GetString("CUENTA")
	c.Close
	c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
	c.Position=0
	usuario = c.GetString("USUARIO")
	c.Close
	B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO  PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA) VALUES(?,?,?,?,?,?,?,?,?,?) ", Array As Object ("4",.01 , .01, 2, "KNORR RINDE MAS 70 GR", "GUNA2",la_cuenta.TEXT, sDate & sTime, usuario,LA_RUTA))
	B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_FACE(HFCLIENTE, HFALIAS,HFRUTA,HFALMACEN) VALUES (?,?,?,?) ", Array As Object(la_cuenta.Text, I_COMPRA.Text,LA_RUTA,ALMACEN))
	Panel1.Visible = False
	b_like.Visible = True
	Tar.Visible = True
	Tels.Visible = True
	gest.Visible = True
	b_like.Visible = False
	Guardar.Visible = True
End Sub

Sub b_venta_Click
	DateTime.DateFormat = "MM/dd/yyyy"
	sDate=DateTime.Date(DateTime.Now)
	sTime=DateTime.Time(DateTime.Now)
'	s=B4XPages.MainPage.skmt.ExecQuery("select COUNT(*) AS CUANTOS from HIST_ENCUESTA where HE_CLIE In (Select cuenta from cuentaa)")
'	s.Position= 0
'	If s.GetString("CUANTOS") = 0 Then
'		c=B4XPages.MainPage.skmt.ExecQuery2("SELECT CAT_VA_VALOR FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String("CUESTIONARIO"))
'		c.Position =0
'		If c.GetString("CAT_VA_VALOR") = "2" Then
'			res =  Msgbox2("El cliente maneja CAZARES ?","CAZARES", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'Ignore
'			If res = DialogResponse.POSITIVE Then
'				B4XPages.MainPage.skmt.ExecNonQuery2("insert into HIST_ENCUESTA(HE_CLIE, HE_RES, HE_FECHA, HE_TIPO) VALUES (?,?,?,?)", Array As Object(la_cuenta.Text, "SI",sDate & sTime,"TIENE"))
'				Panel1.Visible =True
'				I_COMPRA.Text = ""
'				BT_QR.Visible= False
'			Else
'				B4XPages.MainPage.skmt.ExecNonQuery2("insert into HIST_ENCUESTA(HE_CLIE, HE_RES, HE_FECHA, HE_TIPO) VALUES (?,?,?,?)", Array As Object(la_cuenta.Text, "NO",sDate & sTime,"TIENE"))
'				B4XPages.MainPage.tipo_venta = "VENTA"
'				B4XPages.ShowPage("Productos")
'			End If
'		Else
'			B4XPages.MainPage.tipo_venta = "VENTA"
'			B4XPages.ShowPage("Productos")
'		End If
'		c.Close
'	Else
'		B4XPages.MainPage.tipo_venta = "VENTA"
'		B4XPages.ShowPage("Productos")
'	End If
'	s.Close
End Sub

Sub B_E_NEXT_Click
	If E_RES_E.Text <> "" Then
		B4XPages.MainPage.skmt.ExecNonQuery2("insert into HIST_ENCUESTA(HE_CLIE, HE_RES, HE_FECHA, HE_TIPO) VALUES (?,?,?,?)", Array As Object(la_cuenta.Text, E_RES_E.Text,sDate & sTime,"DONDE"))
		Panel2.Visible = False
		B4XPages.ShowPage("Productos")
	Else
		Msgbox("SIN RESPUESTA","AVISO") 'Ignore
	End If
End Sub

Sub RB1_CheckedChange(Checked As Boolean)
	If RB1.Checked = True Then
		E_RES_E.Text = "CENTRAL DE ABASTOS"
	End If
End Sub

Sub RB2_CheckedChange(Checked As Boolean)
	If RB2.Checked = True Then
		E_RES_E.Text = "AUTOSERVICIO"
	End If
End Sub

Sub RB3_CheckedChange(Checked As Boolean)
	If RB3.Checked = True Then
		E_RES_E.Text = "CLUB DE PRECIO"
	End If
End Sub

Sub RB4_CheckedChange(Checked As Boolean)
	If RB4.Checked = True Then
		E_RES_E.Text = "DIRECTO PEDEGREE"
	End If
End Sub

Sub b_like_Click
	Panel1.Visible = True
	b_like.Visible = False
	Tar.Visible = False
	Tels.Visible = False
	gest.Visible = False
	b_venta.Visible = False
	Guardar.Visible = False
End Sub

Sub B_GPS_Click
	Dim result As Int
	result = Msgbox2("Esta seguro de cambiar las coordenadas de este cliente", "Aviso GPS", "SI", "", "NO", LoadBitmap(File.DirAssets, "alerta.jpg")) 'Ignore
	If result = DialogResponse.Positive Then
		B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE  kmt_info SET CAT_CL_LAT = ?, CAT_CL_LONG = ? where CAT_CL_CODIGO In (Select cuenta from cuentaa)", Array As Object(B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
		B4XPage_Appear
	End If
End Sub

Private Sub p_cliente_Click
	'Nada aqui, solo esta para que los clics no se pasen hacia atras.
End Sub


Private Sub Panel5_Click
	
End Sub

' P2 M1

Private Sub RB1_E1_CheckedChange(Checked As Boolean)
	Log($"RB1 Clicked - chk:${Sender.As(RadioButton).Checked}"$)
	encuentasmapa.Put("P1", Sender.As(RadioButton).text)
	encuentasmapa.Remove("P2")
	Panel7.Visible = False
	RadioButton17.Checked = False
	RadioButton16.Checked = False
	RadioButton15.Checked = False
	encuentasmapa.Remove("P2")
	Log(encuentasmapa)
End Sub

Private Sub RB2_E1_CheckedChange(Checked As Boolean)
	Log($"RB2 Clicked - chk:${Sender.As(RadioButton).Checked}"$)
	encuentasmapa.Put("P1", Sender.As(RadioButton).text)
	RadioButton17.Checked = False
	encuentasmapa.Remove("P2")
	RadioButton17.Checked = False
	RadioButton16.Checked = False
	RadioButton15.Checked = False
	Panel7.Visible = False
	encuentasmapa.Remove("P2")
	Log(encuentasmapa)
End Sub

Private Sub RB3_E1_CheckedChange(Checked As Boolean)
	Log($"RB3 Clicked - chk:${Sender.As(RadioButton).Checked}"$)
	encuentasmapa.Put("P1", Sender.As(RadioButton).text)

	Panel7.Visible = True
	Log(encuentasmapa)
End Sub

' FIN P2 M1

' p2_1 m1
Private Sub RadioButton17_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P2", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton16_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P2", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton15_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P2", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub
' fin p2_1 m1


'PREGUNTA 1 MODULO 1

Private Sub RadioButton1_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P3", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton2_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P3", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton3_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P3", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton4_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P3", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

' FIN PREGUNTA 1 MODULO 1

' P3 M1
Private Sub RadioButton5_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P4", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton6_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P4", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton7_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P4", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton8_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P4", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton9_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P4", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

' FIN P3 M1

'P4 M1

Private Sub RadioButton10_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P5", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton11_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P5", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton12_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P5", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton13_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P5", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

Private Sub RadioButton14_CheckedChange(Checked As Boolean)
	encuentasmapa.Put("P5", Sender.As(RadioButton).text)
	Log(encuentasmapa)
End Sub

' FIN P4 M1

Private Sub CheckBox1_CheckedChange(Checked As Boolean)
	Dim textemp As String =""
	textemp = CheckBox1.Text
	If CheckBox2.Checked Then textemp = textemp & ", " & CheckBox2.Text
	If CheckBox3.Checked Then textemp = textemp & ", " & CheckBox3.Text
	If CheckBox4.Checked Then textemp = textemp & ", " & CheckBox4.Text
	If CheckBox5.Checked Then textemp = textemp & ", " & CheckBox5.Text
	If CheckBox6.Checked Then textemp = textemp & ", " & CheckBox6.Text
	If CheckBox7.Checked Then textemp = textemp & ", " & CheckBox7.Text
	If CheckBox8.Checked Then textemp = textemp & ", " & CheckBox8.Text
	encuentasmapa.Put("P9", textemp)
	Log(encuentasmapa)
End Sub

Private Sub CheckBox2_CheckedChange(Checked As Boolean)
	Dim textemp As String =""
	textemp = CheckBox2.Text
	If CheckBox1.Checked Then textemp = textemp & ", " & CheckBox1.Text
	If CheckBox3.Checked Then textemp = textemp & ", " & CheckBox3.Text
	If CheckBox4.Checked Then textemp = textemp & ", " & CheckBox4.Text
	If CheckBox5.Checked Then textemp = textemp & ", " & CheckBox5.Text
	If CheckBox6.Checked Then textemp = textemp & ", " & CheckBox6.Text
	If CheckBox7.Checked Then textemp = textemp & ", " & CheckBox7.Text
	If CheckBox8.Checked Then textemp = textemp & ", " & CheckBox8.Text
	encuentasmapa.Put("P9", textemp)
	Log(encuentasmapa)
End Sub

Private Sub CheckBox3_CheckedChange(Checked As Boolean)
	Dim textemp As String =""
	textemp = CheckBox3.Text
	If CheckBox1.Checked Then textemp = textemp & ", " & CheckBox1.Text
	If CheckBox2.Checked Then textemp = textemp & ", " & CheckBox2.Text
	If CheckBox4.Checked Then textemp = textemp & ", " & CheckBox4.Text
	If CheckBox5.Checked Then textemp = textemp & ", " & CheckBox5.Text
	If CheckBox6.Checked Then textemp = textemp & ", " & CheckBox6.Text
	If CheckBox7.Checked Then textemp = textemp & ", " & CheckBox7.Text
	If CheckBox8.Checked Then textemp = textemp & ", " & CheckBox8.Text
	encuentasmapa.Put("P9", textemp)
	Log(encuentasmapa)
End Sub

Private Sub CheckBox4_CheckedChange(Checked As Boolean)
	Dim textemp As String =""
	textemp = CheckBox4.Text
	If CheckBox1.Checked Then textemp = textemp & ", " & CheckBox1.Text
	If CheckBox2.Checked Then textemp = textemp & ", " & CheckBox2.Text
	If CheckBox3.Checked Then textemp = textemp & ", " & CheckBox3.Text
	If CheckBox5.Checked Then textemp = textemp & ", " & CheckBox5.Text
	If CheckBox6.Checked Then textemp = textemp & ", " & CheckBox6.Text
	If CheckBox7.Checked Then textemp = textemp & ", " & CheckBox7.Text
	If CheckBox8.Checked Then textemp = textemp & ", " & CheckBox8.Text
	encuentasmapa.Put("P9", textemp)
	Log(encuentasmapa)
End Sub

Private Sub CheckBox5_CheckedChange(Checked As Boolean)
	Dim textemp As String =""
	textemp = CheckBox5.Text
	If CheckBox1.Checked Then textemp = textemp & ", " & CheckBox1.Text
	If CheckBox2.Checked Then textemp = textemp & ", " & CheckBox2.Text
	If CheckBox3.Checked Then textemp = textemp & ", " & CheckBox3.Text
	If CheckBox4.Checked Then textemp = textemp & ", " & CheckBox4.Text
	If CheckBox6.Checked Then textemp = textemp & ", " & CheckBox6.Text
	If CheckBox7.Checked Then textemp = textemp & ", " & CheckBox7.Text
	If CheckBox8.Checked Then textemp = textemp & ", " & CheckBox8.Text
	encuentasmapa.Put("P9", textemp)
	Log(encuentasmapa)
End Sub

Private Sub CheckBox6_CheckedChange(Checked As Boolean)
	Dim textemp As String =""
	textemp = CheckBox6.Text
	If CheckBox1.Checked Then textemp = textemp & ", " & CheckBox1.Text
	If CheckBox2.Checked Then textemp = textemp & ", " & CheckBox2.Text
	If CheckBox3.Checked Then textemp = textemp & ", " & CheckBox3.Text
	If CheckBox4.Checked Then textemp = textemp & ", " & CheckBox4.Text
	If CheckBox5.Checked Then textemp = textemp & ", " & CheckBox5.Text
	If CheckBox7.Checked Then textemp = textemp & ", " & CheckBox7.Text
	If CheckBox8.Checked Then textemp = textemp & ", " & CheckBox8.Text
	encuentasmapa.Put("P9", textemp)
	Log(encuentasmapa)
End Sub

Private Sub CheckBox7_CheckedChange(Checked As Boolean)
	Dim textemp As String =""
	textemp = CheckBox7.Text
	If CheckBox1.Checked Then textemp = textemp & ", " & CheckBox1.Text
	If CheckBox2.Checked Then textemp = textemp & ", " & CheckBox2.Text
	If CheckBox3.Checked Then textemp = textemp & ", " & CheckBox3.Text
	If CheckBox4.Checked Then textemp = textemp & ", " & CheckBox4.Text
	If CheckBox5.Checked Then textemp = textemp & ", " & CheckBox5.Text
	If CheckBox6.Checked Then textemp = textemp & ", " & CheckBox6.Text
	If CheckBox8.Checked Then textemp = textemp & ", " & CheckBox8.Text
	encuentasmapa.Put("P9", textemp)
	Log(encuentasmapa)
End Sub

Private Sub CheckBox8_CheckedChange(Checked As Boolean)
	Dim textemp As String =""
	textemp = CheckBox8.Text
	If CheckBox1.Checked Then textemp = textemp & ", " & CheckBox1.Text
	If CheckBox2.Checked Then textemp = textemp & ", " & CheckBox2.Text
	If CheckBox3.Checked Then textemp = textemp & ", " & CheckBox3.Text
	If CheckBox4.Checked Then textemp = textemp & ", " & CheckBox4.Text
	If CheckBox5.Checked Then textemp = textemp & ", " & CheckBox5.Text
	If CheckBox6.Checked Then textemp = textemp & ", " & CheckBox6.Text
	If CheckBox7.Checked Then textemp = textemp & ", " & CheckBox7.Text
	encuentasmapa.Put("P9", textemp)
	Log(encuentasmapa)
End Sub

Private Sub B_guardaencuesta_m2_Click
	P3_M2 = ""
	P6_M2 = ""
	P4_M2 = ""
	
	PASA = "1"
	If et_p1_m2.Text = "" Then PASA = "0"
	If et_p2_m2.Text = "" Then PASA = "0"
	P4_M2 = ""
	If rd1_p4_m2.Checked Then P4_M2 = "ALTO"
	If rd2_p4_m2.Checked Then P4_M2 = "MEDIO"
	If rd3_p4_m2.Checked Then P4_M2 = "BAJO"
	
	If P4_M2 = "" Then PASA = "0"
	
	P6_M2 = ""
	If RB1_P6_M2.Checked Then P6_M2 = "LUNES"
	If RB2_P6_M2.Checked Then P6_M2 = "MARTES"
	If RB3_P6_M2.Checked Then P6_M2 = "MIERCOLES"
	If RB4_P6_M2.Checked Then P6_M2 = "JUEVES"
	If RB5_P6_M2.Checked Then P6_M2 = "VIERNES"
	If RB6_P6_M2.Checked Then P6_M2 = "SABADO"
	If RB7_P6_M2.Checked Then P6_M2 = "DOMINGO"
	
	If P6_M2 = "" Then PASA = "0"
	
'	P3_M2 = CB1_P3_M2.Checked & "," & CB2_P3_M2.Checked & "," & CB3_P3_M2.Checked & "," & CB4_P3_M2.Checked & "," & CB5_P3_M2.Checked & "," & CB6_P3_M2.Checked & "," & RB1_P3_M2.Checked & "," & RB2_P3_M2.Checked & "," & RB3_P3_M2.Checked& "," & ET_P3_M2.TEXT & "," & CB1_P4_M2.Checked  & "," & CB2_P4_M2.Checked  & "," & CB3_P4_M2.Checked  & "," & CB4_P4_M2.Checked
	If  CB1_P3_M2.Checked = False And  CB2_P3_M2.Checked = False And  CB3_P3_M2.Checked = False And CB4_P3_M2.Checked = False And  CB5_P3_M2.Checked = False And CB6_P3_M2.Checked = False And RB1_P3_M2.Checked = False And RB2_P3_M2.Checked = False And RB3_P3_M2.Checked = False And ET_P3_M2.TEXT = False And CB1_P4_M2.Checked  = False And CB2_P4_M2.Checked  = False And CB3_P4_M2.Checked  = False And CB4_P4_M2.Checked = False Then PASA = "0"
	If et_p5_m2.Text = "" Then PASA = "0"
	Log(textemp2)
	If textemp2 <> "" And textemp2.SubString2(0,2) = ", " Then textemp2 = textemp2.SubString(2)
	Log(textemp2)
	P3_M2 = textemp2
	If RB2_P4_M2.Checked  Then
		P3_M2 = P3_M2 &"|" & "NO"
		
	Else if RB1_P4_M2.Checked Then
		P3_M2 = P3_M2 &"|" & "SI"
		If ET_P3_M2.Text = "" Then
			If RB1_P3_M2.Checked Then P3_M2 = P3_M2 &"|" & "Rappi"
			If RB2_P3_M2.Checked Then P3_M2 = P3_M2 &"|" & "Coca Cola"
			If RB3_P3_M2.Checked Then P3_M2 = P3_M2 &"|" & "Modelo"
			If RB4_P3_M2.Checked Then P3_M2 = P3_M2 &"|" & "Rabbit"
		Else If ET_P3_M2.Text <> "" Then
			If RB1_P3_M2.Checked Then P3_M2 = P3_M2 &"|" & "Rappi"
			If RB2_P3_M2.Checked Then P3_M2 = P3_M2 &"|" & "Coca Cola"
			If RB3_P3_M2.Checked Then P3_M2 = P3_M2 &"|" & "Modelo"
			If RB4_P3_M2.Checked Then P3_M2 = P3_M2 &"|" & "Rabbit"
			P3_M2 = P3_M2 &", " & ET_P3_M2.Text
		End If
	End If
	If textemp3 <> "" And textemp3.SubString2(0,2) = ", " Then textemp3 = textemp3.SubString(2)
	
	P3_M2 = P3_M2 &"|" & textemp3
	
	If P3_M2 <> "" And P3_M2.SubString2(0,2) = ", " Then P3_M2 = P3_M2.SubString(2)
	LogColor(P3_M2,Colors.BlUE)
	If PASA = "1" Then
		skmt.ExecNonQuery2("INSERT INTO ENCUESTA_MODULO2 (CLIENTE, ALMACEN,P1, P2, P3, P4, P5, P6) VALUES (?,?,?,?,?,?,?,?)", Array As Object(Subs.traeCliente, ALMACEN,et_p1_m2.Text,et_p2_m2.Text,P3_M2,P4_M2,et_p5_m2.Text,P6_M2 ))
		SV_ENCUESTA.Visible = False
		p_cliente.Visible = True
		et_p1_m2.Text = ""
		et_p2_m2.TEXT = ""
		RB7_P6_M2.Checked = False
		RB6_P6_M2.Checked = False
		RB5_P6_M2.Checked = False
		RB4_P6_M2.Checked = False
		RB3_P6_M2.Checked = False
		RB2_P6_M2.Checked = False
		RB1_P6_M2.Checked = False
		et_p5_m2.Text = ""
		rd3_p4_m2.Checked = False
		rd2_p4_m2.Checked = False
		rd1_p4_m2.Checked = False
		RB1_P3_M2.Checked = False
		RB2_P3_M2.Checked = False
		RB3_P3_M2.Checked = False
		RB4_P3_M2.Checked = False
	
		CB1_P3_M2.Checked = False
		CB2_P3_M2.Checked = False
		CB3_P3_M2.Checked = False
		CB4_P3_M2.Checked = False
		CB5_P3_M2.Checked = False
		CB6_P3_M2.Checked = False
	
		ET_P3_M2.Text = ""
		P3_M2 = ""
		P4_M2 = ""
		P6_M2 = ""
	
		Panel7_M2.Visible = False
	
'	B4XPages.MainPage.tipo_venta = "PREVENTA"
'	B4XPages.ShowPage("productos")

		If ENCUESTA > 2 Then
			If p_m2.IsInitialized And p_m2.Visible Then
				p_m2.Visible = False
			Else
							
			End If
			p_pregunta1.Visible = False
			p_cliente.Visible = False
			SV_ENCUESTA.Visible = True
			SV_ENCUESTA.Panel.LoadLayout("ENCUESSTA_M3")
			p_m3.Width = Root.Width * 0.94
			SV_ENCUESTA.Panel.Height = p_m3.Height + 60
			'35,36,45,46,47,54,64,65,71,3,25,27,38
			If  Subs.traeAlmacen  = 1  Or  Subs.traeAlmacen  = 2  Or  Subs.traeAlmacen  = 4 Or  Subs.traeAlmacen  = 5  Or  Subs.traeAlmacen  =35  Or  Subs.traeAlmacen  =36  Or  Subs.traeAlmacen  =45  Or  Subs.traeAlmacen  =46  Or  Subs.traeAlmacen  =47  Or  Subs.traeAlmacen  =54  Or  Subs.traeAlmacen  =64  Or  Subs.traeAlmacen  =65  Or  Subs.traeAlmacen  =71  Or  Subs.traeAlmacen  =3  Or  Subs.traeAlmacen  =25  Or  Subs.traeAlmacen  =27  Or  Subs.traeAlmacen  =38 Then
				CB1_P6_M3.Text = "GARIS"
				CB2_P6_M3.Text = "SAHUAYO"
				CB3_P6_M3.Text = "ZORRO"
				CB4_P6_M3.Text = "ESCORPION"
				CB5_P6_M3.Text = "RABBIT"
				CB6_P6_M3.Text = "SAMS"
		
			else If  Subs.traeAlmacen = 12  Then '
				CB1_P6_M3.Text = "DECASA"
				CB2_P6_M3.Text = "ZETA"
				CB3_P6_M3.Text = "SAHUAYO"
				CB4_P6_M3.Text = "DUERO"
				CB5_P6_M3.Text = "HUGOSS"
				CB6_P6_M3.Text = "ZORRO"
			else If  Subs.traeAlmacen = 13  Then '
				CB1_P6_M3.Text = "DECASA"
				CB2_P6_M3.Text = "ZETA"
				CB3_P6_M3.Text = "SAHUAYO"
				CB4_P6_M3.Text = "SCORPION"
				CB5_P6_M3.Text = "ZORRO"
				CB6_P6_M3.Text = "GARIS"
			else If  Subs.traeAlmacen = 14   Or  Subs.traeAlmacen  =69  Or  Subs.traeAlmacen  =37 Then '69 -37
				CB1_P6_M3.Text = "DECASA"
				CB2_P6_M3.Text = "ZETA"
				CB3_P6_M3.Text = "SAHUAYO"
				CB4_P6_M3.Text = "DUERO"
				CB5_P6_M3.Text = "RIVERA/GRAN BODEGA"
				CB6_P6_M3.Text = "ZORRO"
			else If  Subs.traeAlmacen = 16  Or  Subs.traeAlmacen  =70 Then '70
				CB1_P6_M3.Text = "DECASA"
				CB2_P6_M3.Text = "ZETA"
				CB3_P6_M3.Text = "SAHUAYO"
				CB4_P6_M3.Text = "DUERO"
				CB5_P6_M3.Text = "RIVERA/GRAN BODEGA"
				CB6_P6_M3.Text = "SAMS"
			else If  Subs.traeAlmacen = 17  Then '
				CB1_P6_M3.Text = "DECASA"
				CB2_P6_M3.Text = "SAHUAYO"
				CB3_P6_M3.Text = ""
				CB4_P6_M3.Text = ""
				CB5_P6_M3.Text = ""
				CB6_P6_M3.Text = ""
			else If  Subs.traeAlmacen = 29  Or  Subs.traeAlmacen  =31 Then '31
				CB1_P6_M3.Text = "DECASA"
				CB2_P6_M3.Text = "ZETA"
				CB3_P6_M3.Text = "SAHUAYO"
				CB4_P6_M3.Text = "DUERO"
				CB5_P6_M3.Text = "SAMS"
				CB6_P6_M3.Text = "RIVERA/GRAN BODEGA"
			else If  Subs.traeAlmacen = 32  Or  Subs.traeAlmacen  =33 Then '33
				CB1_P6_M3.Text = "MAS BODEGA"
				CB2_P6_M3.Text = "SAHUAYO"
				CB3_P6_M3.Text = "TREVIÑO"
				CB4_P6_M3.Text = "HUGOSS"
				CB5_P6_M3.Text = "RABBIT"
				CB6_P6_M3.Text = "SAMS"
			else If  Subs.traeAlmacen = 66  Or  Subs.traeAlmacen  =67 Then '67
				CB1_P6_M3.Text = "DECASA"
				CB2_P6_M3.Text = "ZETA"
				CB3_P6_M3.Text = "SAHUAYO"
				CB4_P6_M3.Text = "DUERO"
				CB5_P6_M3.Text = "SCORPION"
				CB6_P6_M3.Text = "SAMS"
		
			else If  Subs.traeAlmacen = 22  Or  Subs.traeAlmacen  =34 Then '34
				CB1_P6_M3.Text = "DECASA"
				CB2_P6_M3.Text = "ZETA"
				CB3_P6_M3.Text = "SAHUAYO"
				CB4_P6_M3.Text = "MERZA/DUERO"
				CB5_P6_M3.Text = "HUGOSS"
	
			End If


		Else
			p_pregunta1.Visible = False
			SV_ENCUESTA.Visible = False
			p_cliente.Visible = True
			tipo_venta = "VENTA"
'	StartActivity(colonia2)
			B4XPages.ShowPage("productos")
			MsgboxAsync("Encuesta guardada","")
		End If
	Else
		Msgbox("FAVOR DE CONTESTAR LA ENCUESTA","AVISO")
	End If
End Sub

Private Sub CB6_P3_M2_CheckedChange(Checked As Boolean)
	If CB6_P3_M2.Checked = True Then
		Panel7_M2.Visible = True
	Else
		Panel7_M2.Visible = False
	End If
	
	
End Sub

Private Sub B_guardaencuesta_m3_Click
	
	PASA = "1"
'	textemp4 = ""
'	textemp5 = ""
'	textemp6 = ""
'	textemp7 = ""
'	textemp8 = ""
	Private P3_M3 As String = ""
	Private P4_M3 As String = ""
	Private P5_M3 As String = ""
	Private P6_M3 As String = ""
	Private P7_M3 As String = ""
	Private P8_M3 As String = ""
	Private P9_M3 As String = ""
	
	
'	If et_p1_m3.Text = "" Then PASA = "0"
'	If et_p2_m3.Text = "" Then PASA = "0"
	
	If rd1_p5_m3.Checked Then P5_M3 = "SI"
	If rd2_p5_m3.Checked Then P5_M3 = "NO"
	
	If RB1_P9_M3.Checked Then P9_M3 = "DIARIO"
	If RB2_P9_M3.Checked Then P9_M3 = "BISEMANAL"
	If RB3_P9_M3.Checked Then P9_M3 = "SEMANAL"
	If RB4_P9_M3.Checked Then P9_M3 = "QUINCENAL"
	If RB5_P9_M3.Checked Then P9_M3 = "MENSUAL"
	If P9_M3 = "" Then PASA = "0"
	If P5_M3 = "" Then PASA = "0"
	
'	P3_M3 = CB1_P3_M3.Checked & "," & CB2_P3_M3.Checked & "," & CB3_P3_M3.Checked & "," & CB4_P3_M3.Checked & "," & CB5_P3_M3.Checked
	If CB1_P3_M3.Checked = False And  CB2_P3_M3.Checked = False And CB3_P3_M3.Checked = False And CB4_P3_M3.Checked = False And CB5_P3_M3.Checked = False Then PASA = "0"
'	P4_M3 = CB1_P4_M3.Checked & "," & CB2_P4_M3.Checked & "," & CB3_P4_M3.Checked & "," & CB4_P4_M3.Checked & "," & CB5_P4_M3.Checked
	If  CB1_P4_M3.Checked  = False And  CB2_P4_M3.Checked  = False And  CB3_P4_M3.Checked  = False And  CB4_P4_M3.Checked  = False And  CB5_P4_M3.Checked = False Then PASA = "0"
	
'	P6_M3 = CB1_P6_M3.Checked & "," & CB2_P6_M3.Checked & "," & CB3_P6_M3.Checked & "," & CB4_P6_M3.Checked & "," & CB5_P6_M3.Checked & "," & CB6_P6_M3.Checked  & "," & ET_P6_M3.TEXT
	
'	P7_M3 = CB1_P7_M3.Checked & "," & CB2_P7_M3.Checked & "," & CB3_P7_M3.Checked & "," & CB4_P7_M3.Checked
	If CB1_P7_M3.Checked  = False And  CB2_P7_M3.Checked  = False And  CB3_P7_M3.Checked  = False And  CB4_P7_M3.Checked = False Then PASA = "0"
	
'	P8_M3 = CB1_P8_M3.Checked & "," & CB2_P8_M3.Checked & "," & CB3_P8_M3.Checked & "," & CB4_P8_M3.Checked
	If CB1_P8_M3.Checked = False And  CB2_P8_M3.Checked = False And  CB3_P8_M3.Checked = False And  CB4_P8_M3.Checked = False Then PASA = "0"
	If rb1_m3_p1.Checked Then P3_M3 = "7 A 9"
	If RB2_M3_P1.Checked Then P3_M3 = "9 A 11"
	If RB3_M3_P1.Checked Then P3_M3 = "11 A 13"
	If RB4_M3_P1.Checked Then P3_M3 = "13 +"
	
	If RB1_M3_P2.Checked Then P4_M3 = "2 A 4"
	If RB2_M3_P2.Checked Then P4_M3 = "4 A 6"
	If RB3_M3_P2.Checked Then P4_M3 = "6 A 8"
	If RB4_M3_P2.Checked Then P4_M3 = "8 +"
	
	If CB5_P4_M3.Checked  = True And ( CB2_P4_M3.Checked = True Or  CB3_P4_M3.Checked = True Or  CB4_P4_M3.Checked = True Or CB1_P4_M3.Checked = True ) Then
		PASA = "0"
		CB5_P4_M3.Checked = False
		CB2_P4_M3.Checked = False
		CB3_P4_M3.Checked = False
		CB4_P4_M3.Checked = False
		CB1_P4_M3.Checked = False
	End If
	
	
	If PASA = "1" Then
		If rb1_m3_p1.Checked Then P3_M3 = "7 A 9"
		If RB2_M3_P1.Checked Then P3_M3 = "9 A 11"
		If RB3_M3_P1.Checked Then P3_M3 = "11 A 13"
		If RB4_M3_P1.Checked Then P3_M3 = "13 +"
	
		If RB1_M3_P2.Checked Then P4_M3 = "2 A 4"
		If RB2_M3_P2.Checked Then P4_M3 = "4 A 6"
		If RB3_M3_P2.Checked Then P4_M3 = "6 A 8"
		If RB4_M3_P2.Checked Then P4_M3 = "8 +"
		
		If ET_P6_M3.Text <> "" Then
			textemp6 = textemp6 & ", " & ET_P6_M3.Text
		End If
		
		If textemp4 <> "" And textemp4.SubString2(0,2) = ", " Then textemp4 = textemp4.SubString(2)
		If textemp5 <> "" And textemp5.SubString2(0,2) = ", " Then textemp5 = textemp5.SubString(2)
		If textemp6 <> "" And textemp6.SubString2(0,2) = ", " Then textemp6 = textemp6.SubString(2)
		If textemp7 <> "" And textemp7.SubString2(0,2) = ", " Then textemp7 = textemp7.SubString(2)
		If textemp8 <> "" And textemp8.SubString2(0,2) = ", " Then textemp8 = textemp8.SubString(2)
'	skmt.ExecNonQuery2("INSERT INTO ENCUESTA_MODULO2 (CLIENTE, ALMACEN,P1, P2, P3, P4, P5, P6) VALUES (?,?,?,?,?,?,?,?)", Array As Object(Subs.traeCliente, ALMACEN,et_p1_m2.Text,et_p2_m2.Text,P3_M2,P4_M2,et_p5_m2.Text,"MODULO_3" ))
	
	
		skmt.ExecNonQuery2("INSERT INTO ENCUESTA_MODULO3 (CLIENTE, ALMACEN,P1, P2, P3, P4, P5, P6,P7,P8,P9,P10,P11) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", Array As Object(Subs.traeCliente, ALMACEN,"x","x",P3_M3,P4_M3,textemp4,textemp5,P5_M3,textemp6,textemp7, textemp8, P9_M3))
		SV_ENCUESTA.Visible = False
		p_cliente.Visible = True
'	B4XPages.MainPage.tipo_venta = "PREVENTA"
'	B4XPages.ShowPage("productos")
		If ENCUESTA > 3 Then
			If p_m3.IsInitialized And p_m3.Visible Then
				p_m3.Visible = False
			Else
							
			End If
			p_pregunta1.Visible = False
			p_cliente.Visible = False
			SV_ENCUESTA.Visible = True
			p_pregunta1.Visible = False
			SV_ENCUESTA.Panel.LoadLayout("ENCUESTA_M4")
			p_m4.Width = Root.Width * 0.94
			SV_ENCUESTA.Panel.Height = p_m4.Height + 60
			
			Dim Items2 As List
			Items2.Initialize
			Items2.Add("Selecciona una opcion")
			Items2.Add("Propio")
			Items2.Add("Rentado")
			cb_p3_m4.SetItems(Items2)
			itemselect2 = "Selecciona una opcion"
	
	
			Dim Items3 As List
			Items3.Initialize
			Items3.Add("Selecciona una opcion")
			Items3.Add("Completamente Surtido")
			Items3.Add("Bien Surtido")
			Items3.Add("Poco Surtido")
			Items3.Add("Muy Poco Surtido")
			Items3.Add("Sin Existencias")
			cb_p4_1_m4.SetItems(Items3)
			itemselect3 = "Selecciona una opcion"
			cb_p4_2_m4.SetItems(Items3)
			itemselect4 = "Selecciona una opcion"
			cb_p4_3_m4.SetItems(Items3)
			itemselect5 = "Selecciona una opcion"
			cb_p4_4_m4.SetItems(Items3)
			itemselect6 = "Selecciona una opcion"
			cb_p4_5_m4.SetItems(Items3)
			itemselect7 = "Selecciona una opcion"
		Else
			p_pregunta1.Visible = False
			SV_ENCUESTA.Visible = False
			p_cliente.Visible = True
			tipo_venta = "VENTA"
'	StartActivity(colonia2)
			B4XPages.ShowPage("productos")
	
			MsgboxAsync("Encuesta guardada","")
		End If
	Else
		Msgbox("FAVOR DE CONTESTAR LA ENCUESTA","AVISO")
	End If
End Sub

Private Sub B_guardaencuesta_m4_Click
	
	PASA = "1"
	
	If itemselect2 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect3 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect4 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect5 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect6 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect7 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If et_p1_m4.Text.Length  < 2 Then
		
		et_p1_m4.Text = ""
		PASA = "0"
	End If
	If PASA = "1" Then
		skmt.ExecNonQuery2("INSERT INTO ENCUESTA_MODULO4 (CLIENTE, ALMACEN,P1, P2, P3, P4, P5, P6, P7, P8) VALUES (?,?,?,?,?,?,?,?,?,?)", Array As Object(Subs.traeCliente, ALMACEN,et_p1_m4.Text,et_p2_m4.Text,itemselect2,itemselect3,itemselect4,itemselect5,itemselect6,itemselect7))
		SV_ENCUESTA.Visible = False
		p_cliente.Visible = True
'	
		If ENCUESTA > 4 Then
			If p_m4.IsInitialized And p_m4.Visible Then
				p_m4.Visible = False
			Else
							
			End If
			p_cliente.Visible = False
			SV_ENCUESTA.Visible = True
			p_pregunta1.Visible = False
			SV_ENCUESTA.Panel.LoadLayout("ENCUESTA_M5")
			p_modulo5.Width = Root.Width * 0.94
			SV_ENCUESTA.Panel.Height = p_modulo5.Height + 60
	
			Dim Items8 As List
			Items8.Initialize
			Items8.Add("Selecciona una opcion")
			Items8.Add("Completamente Surtido")
			Items8.Add("Bien Surtido")
			Items8.Add("Poco Surtido")
			Items8.Add("Muy Poco Surtido")
			Items8.Add("Sin Existencias")
			cb_p1_m5.SetItems(Items8)
			itemselect8 = "Selecciona una opcion"
			cb_p2_m5.SetItems(Items8)
			itemselect9 = "Selecciona una opcion"
			cb_p3_m5.SetItems(Items8)
			itemselect10 = "Selecciona una opcion"
			cb_p4_m5.SetItems(Items8)
			itemselect11 = "Selecciona una opcion"
			cb_p5_m5.SetItems(Items8)
			itemselect12 = "Selecciona una opcion"
			cb_p6_m5.SetItems(Items8)
			itemselect13 = "Selecciona una opcion"
			cb_p7_m5.SetItems(Items8)
			itemselect14 = "Selecciona una opcion"
			cb_p8_m5.SetItems(Items8)
			itemselect15 = "Selecciona una opcion"
			cb_p9_m5.SetItems(Items8)
			itemselect16 = "Selecciona una opcion"
			MsgboxAsync("Encuesta guardada","")
		Else
			B4XPages.MainPage.tipo_venta = "VENTA"
			'	B4XPages.ShowPage("productos")
			p_pregunta1.Visible = False
			SV_ENCUESTA.Visible = False
			p_cliente.Visible = True
			tipo_venta = "VENTA"
			B4XPages.ShowPage("productos")
			'	StartActivity(colonia2)
			B4XPages.ShowPage("productos")
		End If
	Else
		Msgbox("FAVOR DE CONTESTAR LA ENCUESTA","AVISO")
	End If
	
End Sub

Private Sub B_guardaencuesta_m5_Click
	
	PASA = "1"
	
	If itemselect8 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect9 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect10 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect11 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect12 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect13 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect14 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect15 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	If itemselect16 = "Selecciona una opcion" Then
		PASA = "0"
	End If
	
	If PASA = "1" Then
		skmt.ExecNonQuery2("INSERT INTO ENCUESTA_MODULO5 (CLIENTE, ALMACEN,P1, P2, P3, P4, P5, P6, P7, P8, P9) VALUES (?,?,?,?,?,?,?,?,?,?,?)", Array As Object(Subs.traeCliente, ALMACEN,itemselect8,itemselect9,itemselect10,itemselect11,itemselect12,itemselect13,itemselect14,itemselect15,itemselect16))
		SV_ENCUESTA.Visible = False
		p_cliente.Visible = True
		B4XPages.MainPage.tipo_venta = "VENTA"
		B4XPages.ShowPage("productos")
		MsgboxAsync("Encuesta guardada","")
	Else
		Msgbox("FAVOR DE CONTESTAR LA ENCUESTA","AVISO")
	End If
End Sub


Private Sub B_ACEPTA_GALLINA_Click
	
	
	DateTime.DateFormat = "MM/dd/yyyy"
	sDate=DateTime.Date(DateTime.Now)
	sTime=DateTime.Time(DateTime.Now)
	c=skmt.ExecQuery("Select CUENTA from cuentaa")
	c.Position=0
	clie_id = c.GetString("CUENTA")
	c.Close
	c=skmt.ExecQuery("select USUARIO from usuarioa")
	c.Position=0
	usuario = c.GetString("USUARIO")
	c.Close
	c=skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
	If c.RowCount>0 Then
		C.Position=0
		ALMACEN = C.GetString("ID_ALMACEN")
	End If
	c.Close
	skmt.ExecNonQuery2("INSERT INTO  PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA) VALUES(?,?,?,?,?,?,?,?,?,?) ", Array As Object ("PRO1771",0 , 0, 1, "1 KNORR SUIZA EXH C/50/22 GR +1 KNORR SUIZA GALLINA $279.00", "PRO1771",la_cuenta.TEXT, sDate & sTime, usuario,LA_RUTA))
	skmt.ExecNonQuery2("INSERT INTO  PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA) VALUES(?,?,?,?,?,?,?,?,?,?) ", Array As Object ("PRO1771",139.5 , 139.5, 1, "KNORR SUIZA EXH C/50/22 GR", "UNI047",la_cuenta.TEXT, sDate & sTime, usuario,LA_RUTA))
	skmt.ExecNonQuery2("INSERT INTO  PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA) VALUES(?,?,?,?,?,?,?,?,?,?) ", Array As Object ("PRO1771",139.5 , 139.5, 1, "KNORR SUIZA GALLINA", "UNI860",la_cuenta.TEXT, sDate & sTime, usuario,LA_RUTA))
	
	c=skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, SUM(PE_COSTO_SIN) AS TOTAL_CLIE_SIN FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
	c.Position=0
	skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
	skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT,PC_ALMACEN,PC_RUTA,PC_COSTO_SIN) VALUES (?,?,?,?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps,ALMACEN,LA_RUTA,c.GetString("TOTAL_CLIE_SIN")))
	skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2  where CAT_CL_CODIGO In (select cuenta from cuentaa)")

	
	'Panel5.Visible = False
	B_GALLINA.Visible = False
	b_like.Visible = True
	Tar.Visible = True
	Tels.Visible = True
	gest.Visible = True
	'b_venta.Visible = True
	b_like.Visible = False
	Guardar.Visible = True
	P_gallina.Visible = False
End Sub

Private Sub B_CANCELA_GALLINA_Click
	P_gallina.Visible = False
	'Panel5.Visible = False
	B_GALLINA.Visible = False
	b_like.Visible = True
	Tar.Visible = True
	Tels.Visible = True
	gest.Visible = True
	'b_venta.Visible = True
	b_like.Visible = False
	Guardar.Visible = True
'	tipo_venta = "PREVENTA"
'	StartActivity(colonia2)
End Sub

Private Sub B_GALLINA_Click
	P_gallina.Visible = True
	
	B_GALLINA.Visible = False
	b_like.Visible = False
	BT_QR.Visible = False
	'Panel5.Visible = True
	b_like.Visible = False
	Tar.Visible = False
	Tels.Visible = False
	gest.Visible = False
	b_venta.Visible = False
	Guardar.Visible = False
	HIST.Visible = False
End Sub



' P5 M1
Private Sub p6_TextChanged (Old As String, New As String)
	If p6.Text.Length  > 2 Then
		Msgbox("Valida tu respuesta, dato no valido1","Aviso")
		p6.Text = ""
	End If
End Sub
' FIN P5 M1

' P6 M1
Private Sub p7_TextChanged (Old As String, New As String)
	If p7.Text.Length  > 2 Then
		Msgbox("Valida tu respuesta, dato no valido2","Aviso")
		p7.Text = ""
	End If
End Sub
' FIN P6 M1

' P7 M1
Private Sub p8_TextChanged (Old As String, New As String)
	If p8.Text.Length  > 2 Then
		
		Msgbox("Valida tu respuesta, dato no valido3","Aviso")
		p8.Text = ""
	End If
End Sub

' FIN P7 M1
''aqui

'Private Sub et_p1_m3_TextChanged (Old As String, New As String)
'	If et_p1_m3.Text.Length  > 2 Or et_p1_m3.Text = 0 Then
'		
'		Msgbox("Valida tu respuesta, dato no valido","Aviso")
'		et_p1_m3.Text = ""
'	End If
'End Sub

'Private Sub et_p2_m3_TextChanged (Old As String, New As String)
'	If et_p2_m3.Text.Length  > 2 Or et_p2_m3.Text = 0 Then
'		
'		Msgbox("Valida tu respuesta, dato no valido","Aviso")
'		et_p2_m3.Text = ""
'		
'	End If
'End Sub

Private Sub et_p1_m2_TextChanged (Old As String, New As String)
	If et_p1_m2.Text.Length  > 2 Or et_p1_m2.Text = 0 Then
		
		Msgbox("Valida tu respuesta, dato no valido","Aviso")
		et_p1_m2.Text = ""
	End If
End Sub

Private Sub et_p2_m2_TextChanged (Old As String, New As String)
	If et_p2_m2.Text.Length  > 2 Or et_p2_m2.Text = 0 Then
		
		Msgbox("Valida tu respuesta, dato no valido","Aviso")
		et_p2_m2.Text = ""
		
	End If
End Sub

Private Sub et_p5_m2_TextChanged (Old As String, New As String)
	If et_p5_m2.Text.Length  > 4 Then
		
		Msgbox("Valida tu respuesta, dato no valido","Aviso")
		et_p5_m2.Text = ""
	End If
End Sub

Private Sub et_p1_m4_TextChanged (Old As String, New As String)
	If et_p1_m4.Text.Length  > 5 Then
		
		Msgbox("Valida tu respuesta, dato no valido","Aviso")
		et_p1_m4.Text = ""
	End If
End Sub


Private Sub RB1_P4_M2_CheckedChange(Checked As Boolean)
	If RB1_P4_M2.Checked = True Then
		Panel7_M2.Visible = True
		panel7_p4_m2.Visible = True
	Else
		Panel7_M2.Visible = False
		panel7_p4_m2.Visible = False
		
	End If
End Sub

Private Sub RB2_P4_M2_CheckedChange(Checked As Boolean)
	If RB2_P4_M2.Checked = True Then
		Panel7_M2.Visible = False
		panel7_p4_m2.Visible = False
		RB1_P3_M2.Checked = False
		RB2_P3_M2.Checked = False
		RB3_P3_M2.Checked = False
		RB4_P3_M2.Checked = False
		ET_P3_M2.Text = ""
		CB1_P4_M2.Checked = False
		CB2_P4_M2.Checked = False
		CB3_P4_M2.Checked = False
		CB4_P4_M2.Checked = False
		textemp3 = ""
	Else
		Panel7_M2.Visible = True
		panel7_p4_m2.Visible = True
		
	End If
End Sub

Private Sub B_GUARDA_CE_PED_Click
	
	DateTime.DateFormat = "MM/dd/yyyy"
	sDate=DateTime.Date(DateTime.Now)
	sTime=DateTime.Time(DateTime.Now)
	c=skmt.ExecQuery("Select CUENTA from cuentaa")
	c.Position=0
	clie_id = c.GetString("CUENTA")
	c.Close
	c=skmt.ExecQuery("select USUARIO from usuarioa")
	c.Position=0
	usuario = c.GetString("USUARIO")
	c.Close
	c=skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
	If c.RowCount>0 Then
		C.Position=0
		ALMACEN = C.GetString("ID_ALMACEN")
	End If
	c.Close
	
'	
'	If rdb_ch.Checked = True Then TAMANIO = "CHICA"
'	If rdb_gd.Checked = True Then TAMANIO = "GRANDE"
'	If rdb_md.Checked = True Then TAMANIO = "MEDIANA"
'	If rdb_vt.Checked = True Then TAMANIO = "VENTANITA"
'	
'	If RDB_SI.Checked = True Then ENTRADA = "SI"
'	
'	If RDB_NO.Checked = True Then 
'		ENTRADA = "NO"
'		TAMANIO = "VENTANITA"
'	End If
'	
	'la enecuesta actual
	
	skmt.ExecNonQuery2("INSERT INTO HIST_ENCUESTA_PED_DIST_1(ALMACEN , TIENDA , KP_01  , KP_02  , KP_03  , KP_04  , KP_05  , KP_06  , KP_07  , KP_08  , KP_09  , KP_10  , KP_11  , KP_12  , KP_13  , KP_14  , KP_15  , KP_16  , KP_17  , KP_18  , KP_19  , KP_20  , KG_01  , KG_02  , KG_03  , KG_04  , KG_05  , KG_06  , PK_01  , PK_02  , PK_03  , PK_04  , PK_05  , PK_06  , PK_07  , PK_08) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object(ALMACEN, clie_id,KP_01.Checked,KP_02.Checked,KP_03.Checked,KP_04.Checked,KP_05.Checked,KP_06.Checked,KP_07.Checked,KP_08.Checked,KP_09.Checked,KP_10.Checked,KP_11.Checked,KP_12.Checked,KP_13.Checked,KP_14.Checked,KP_15.Checked,KP_16.Checked,KP_17.Checked,KP_18.Checked,KP_19.Checked,KP_20.Checked,KG_01.Checked,KG_02.Checked,KG_03.Checked,KG_04.Checked,KG_05.Checked,KG_06.Checked,PK_01.Checked,PK_02.Checked,PK_03.Checked,PK_04.Checked,PK_05.Checked,PK_06.Checked,PK_07.Checked,PK_08.Checked ))
	
	skmt.ExecNonQuery2("INSERT INTO HIST_ENCUESTA_PED_DIST_2(ALMACEN , TIENDA , HPG_01  , HPG_02  , HPG_03  , HPG_04  , HPG_05  , HPG_06  , HPG_07  , HPG_08  , HPG_09  , HPG_10  , HC_01  , HC_02  , HC_03  , HC_04  , B_01  , B_02) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object(ALMACEN, clie_id, HPG_01.Checked,HPG_02.Checked,HPG_03.Checked,HPG_04.Checked,HPG_05.Checked,HPG_06.Checked,HPG_07.Checked,HPG_08.Checked,HPG_09.Checked,HPG_10.Checked,HC_01.Checked,HC_02.Checked,HC_03.Checked,HC_04.Checked,B_01.Checked,B_02.Checked))
	
	'la encuesta anterior
	
'	skmt.ExecNonQuery2("INSERT INTO HIST_ENCUESTA_PED_SEG(ALMACEN , TIENDA , TAMANIO , ENTRADA , BULTOSP , BULTOSG) VALUES (?,?,?,?,?,?) ", Array As Object(ALMACEN, clie_id, TAMANIO,ENTRADA, I_COMPRA2.TEXT, I_COMPRA.TEXT))
	
	
	
'	skmt.ExecNonQuery2("INSERT INTO  PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA) VALUES(?,?,?,?,?,?,?,?,?,?) ", Array As Object ("4",.01 , .01, 2, "KNORR RINDE MAS 70 GR", "GUNA2",la_cuenta.TEXT, sDate & sTime, usuario,LA_RUTA))
	
'	skmt.ExecNonQuery2("INSERT INTO HIST_FACE(HFCLIENTE, HFALIAS,HFRUTA,HFALMACEN) VALUES (?,?,?,?) ", Array As Object(la_cuenta.Text, I_COMPRA.Text,LA_RUTA,ALMACEN))
	
	'I_COMPRA2.TEXT = ""
	I_COMPRA.TEXT  = ""
	SV_ENCUESTA.Visible = False
	Panel1.Visible = False
'	Panel4.Visible = False
	b_like.Visible = True
	Tar.Visible = True
	Tels.Visible = True
	gest.Visible = True
	'b_venta.Visible = True
	b_like.Visible = False
	Guardar.Visible = True
	tipo_venta = "VENTA"
'	StartActivity(colonia2)
	B4XPages.ShowPage("productos")
	
End Sub


Private Sub p_modulo5_Click
	
End Sub

Private Sub Panel4_Click
	
End Sub

Private Sub CB1_P3_M2_CheckedChange(Checked As Boolean)
	textemp2 = ""
	If CB1_P3_M2.Checked Then
		textemp2 = CB1_P3_M2.Text
	Else
		textemp2 = ""
	End If
	If CB2_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB2_P3_M2.Text
	If CB3_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB3_P3_M2.Text
	If CB4_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB4_P3_M2.Text
	If CB5_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB5_P3_M2.Text
	Log(textemp2)
End Sub

Private Sub CB2_P3_M2_CheckedChange(Checked As Boolean)
	textemp2 = ""
	If CB2_P3_M2.Checked Then
		textemp2 = CB2_P3_M2.Text
	Else
		textemp2 = ""
	End If
	If CB1_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB1_P3_M2.Text
	If CB3_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB3_P3_M2.Text
	If CB4_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB4_P3_M2.Text
	If CB5_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB5_P3_M2.Text
	Log(textemp2)
End Sub

Private Sub CB3_P3_M2_CheckedChange(Checked As Boolean)
	textemp2 = ""
	If CB3_P3_M2.Checked Then
		textemp2 = CB3_P3_M2.Text
	Else
		textemp2 = ""
	End If
	If CB1_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB1_P3_M2.Text
	If CB2_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB2_P3_M2.Text
	If CB4_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB4_P3_M2.Text
	If CB5_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB5_P3_M2.Text
	Log(textemp2)
End Sub

Private Sub CB4_P3_M2_CheckedChange(Checked As Boolean)
	textemp2 = ""
	If CB4_P3_M2.Checked Then
		textemp2 = CB4_P3_M2.Text
	Else
		textemp2 = ""
	End If
	If CB1_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB1_P3_M2.Text
	If CB2_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB2_P3_M2.Text
	If CB3_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB3_P3_M2.Text
	If CB5_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB5_P3_M2.Text
	Log(textemp2)
End Sub

Private Sub CB5_P3_M2_CheckedChange(Checked As Boolean)
	textemp2 = ""
	If CB5_P3_M2.Checked Then
		textemp2 = CB5_P3_M2.Text
	Else
		textemp2 = ""
	End If
	If CB1_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB1_P3_M2.Text
	If CB2_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB2_P3_M2.Text
	If CB3_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB3_P3_M2.Text
	If CB4_P3_M2.Checked Then textemp2 = textemp2 & ", " & CB4_P3_M2.Text
	Log(textemp2)
End Sub



Private Sub CB1_P4_M2_CheckedChange(Checked As Boolean)
	textemp3 = ""
	If CB1_P4_M2.Checked Then
		textemp3 = CB1_P4_M2.Text
	Else
		textemp3 = ""
	End If
	If CB2_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB2_P4_M2.Text
	If CB3_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB3_P4_M2.Text
	If CB4_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB4_P4_M2.Text
	Log(textemp3)
End Sub

Private Sub CB2_P4_M2_CheckedChange(Checked As Boolean)
	textemp3 = ""
	If CB2_P4_M2.Checked Then
		textemp3 = CB2_P4_M2.Text
	Else
		textemp3 = ""
	End If
	If CB1_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB1_P4_M2.Text
	If CB3_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB3_P4_M2.Text
	If CB4_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB4_P4_M2.Text
	Log(textemp3)
End Sub

Private Sub CB3_P4_M2_CheckedChange(Checked As Boolean)
	textemp3 = ""
	If CB3_P4_M2.Checked Then
		textemp3 = CB3_P4_M2.Text
	Else
		textemp3 = ""
	End If
	If CB1_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB1_P4_M2.Text
	If CB2_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB2_P4_M2.Text
	If CB4_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB4_P4_M2.Text
	Log(textemp3)
End Sub

Private Sub CB4_P4_M2_CheckedChange(Checked As Boolean)
	textemp3 = ""
	If CB4_P4_M2.Checked Then
		textemp3 = CB4_P4_M2.Text
	Else
		textemp3 = ""
	End If
	If CB1_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB1_P4_M2.Text
	If CB2_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB2_P4_M2.Text
	If CB3_P4_M2.Checked Then textemp3 = textemp3 & ", " & CB3_P4_M2.Text
	Log(textemp3)
End Sub




Private Sub CB1_P3_M3_CheckedChange(Checked As Boolean)
	textemp4 = ""
	If CB1_P3_M3.Checked Then
		textemp4 = CB1_P3_M3.Text
	Else
		textemp4 = ""
	End If
	If CB2_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB2_P3_M3.Text
	If CB3_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB3_P3_M3.Text
	If CB4_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB4_P3_M3.Text
	If CB5_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB5_P3_M3.Text
	Log(textemp4)
End Sub

Private Sub CB2_P3_M3_CheckedChange(Checked As Boolean)
	textemp4 = ""
	If CB2_P3_M3.Checked Then
		textemp4 = CB2_P3_M3.Text
	Else
		textemp4 = ""
	End If
	If CB1_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB1_P3_M3.Text
	If CB3_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB3_P3_M3.Text
	If CB4_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB4_P3_M3.Text
	If CB5_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB5_P3_M3.Text
	Log(textemp4)
End Sub

Private Sub CB3_P3_M3_CheckedChange(Checked As Boolean)
	textemp4 = ""
	If CB3_P3_M3.Checked Then
		textemp4 = CB3_P3_M3.Text
	Else
		textemp4 = ""
	End If
	If CB1_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB1_P3_M3.Text
	If CB2_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB2_P3_M3.Text
	If CB4_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB4_P3_M3.Text
	If CB5_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB5_P3_M3.Text
	Log(textemp4)
End Sub

Private Sub CB4_P3_M3_CheckedChange(Checked As Boolean)
	textemp4 = ""
	If CB4_P3_M3.Checked Then
		textemp4 = CB4_P3_M3.Text
	Else
		textemp4 = ""
	End If
	If CB1_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB1_P3_M3.Text
	If CB2_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB2_P3_M3.Text
	If CB3_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB3_P3_M3.Text
	If CB5_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB5_P3_M3.Text
	Log(textemp4)
End Sub

Private Sub CB5_P3_M3_CheckedChange(Checked As Boolean)
	textemp4 = ""
	If CB5_P3_M3.Checked Then
		textemp4 = CB5_P3_M3.Text
	Else
		textemp4 = ""
	End If
	If CB1_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB1_P3_M3.Text
	If CB2_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB2_P3_M3.Text
	If CB3_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB3_P3_M3.Text
	If CB4_P3_M3.Checked Then textemp4 = textemp4 & ", " & CB4_P3_M3.Text
	Log(textemp4)
End Sub



Private Sub CB1_P4_M3_CheckedChange(Checked As Boolean)
	textemp5 = ""
	CB5_P4_M3.Checked = False
	If CB1_P4_M3.Checked Then
		textemp5 = CB1_P4_M3.Text
	Else
		textemp5 = ""
	End If
	If CB2_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB2_P4_M3.Text
	If CB3_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB3_P4_M3.Text
	If CB4_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB4_P4_M3.Text
	If CB5_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB5_P4_M3.Text
	Log(textemp5)
End Sub

Private Sub CB2_P4_M3_CheckedChange(Checked As Boolean)
	textemp5 = ""
	CB5_P4_M3.Checked = False
	If CB2_P4_M3.Checked Then
		textemp5 = CB2_P4_M3.Text
	Else
		textemp5 = ""
	End If
	If CB1_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB1_P4_M3.Text
	If CB3_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB3_P4_M3.Text
	If CB4_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB4_P4_M3.Text
	If CB5_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB5_P4_M3.Text
	Log(textemp5)
End Sub

Private Sub CB3_P4_M3_CheckedChange(Checked As Boolean)
	textemp5 = ""
	CB5_P4_M3.Checked = False
	If CB3_P4_M3.Checked Then
		textemp5 = CB3_P4_M3.Text
	Else
		textemp5 = ""
	End If
	If CB1_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB1_P4_M3.Text
	If CB2_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB2_P4_M3.Text
	If CB4_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB4_P4_M3.Text
	If CB5_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB5_P4_M3.Text
	Log(textemp5)
End Sub

Private Sub CB4_P4_M3_CheckedChange(Checked As Boolean)
	textemp5 = ""
	CB5_P4_M3.Checked = False
	If CB4_P4_M3.Checked Then
		textemp5 = CB4_P4_M3.Text
	Else
		textemp5 = ""
	End If
	If CB1_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB1_P4_M3.Text
	If CB2_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB2_P4_M3.Text
	If CB3_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB3_P4_M3.Text
	If CB5_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB5_P4_M3.Text
	Log(textemp5)
End Sub

Private Sub CB5_P4_M3_CheckedChange(Checked As Boolean)
	textemp5 = ""
	CB1_P4_M3.Checked = False
	CB2_P4_M3.Checked = False
	CB3_P4_M3.Checked = False
	CB4_P4_M3.Checked = False
	If CB5_P4_M3.Checked Then
		textemp5 = CB5_P4_M3.Text
	Else
		textemp5 = ""
	End If
	If CB1_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB1_P4_M3.Text
	If CB2_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB2_P4_M3.Text
	If CB3_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB3_P4_M3.Text
	If CB4_P4_M3.Checked Then textemp5 = textemp5 & ", " & CB4_P4_M3.Text
	Log(textemp5)
End Sub




Private Sub CB1_P6_M3_CheckedChange(Checked As Boolean)
	textemp6 = ""
	If CB1_P6_M3.Checked Then
		textemp6 = CB1_P6_M3.Text
	Else
		textemp6 = ""
	End If
	If CB2_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB2_P6_M3.Text
	If CB3_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB3_P6_M3.Text
	If CB4_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB4_P6_M3.Text
	If CB5_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB5_P6_M3.Text
	If CB6_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB6_P6_M3.Text
	If CB7_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB7_P6_M3.Text
	Log(textemp6)
End Sub

Private Sub CB2_P6_M3_CheckedChange(Checked As Boolean)
	textemp6 = ""
	If CB2_P6_M3.Checked Then
		textemp6 = CB2_P6_M3.Text
	Else
		textemp6 = ""
	End If
	If CB1_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB1_P6_M3.Text
	If CB3_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB3_P6_M3.Text
	If CB4_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB4_P6_M3.Text
	If CB5_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB5_P6_M3.Text
	If CB6_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB6_P6_M3.Text
	If CB7_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB7_P6_M3.Text
	Log(textemp6)
End Sub

Private Sub CB3_P6_M3_CheckedChange(Checked As Boolean)
	textemp6 = ""
	If CB3_P6_M3.Checked Then
		textemp6 = CB3_P6_M3.Text
	Else
		textemp6 = ""
	End If
	If CB1_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB1_P6_M3.Text
	If CB2_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB2_P6_M3.Text
	If CB4_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB4_P6_M3.Text
	If CB5_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB5_P6_M3.Text
	If CB6_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB6_P6_M3.Text
	If CB7_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB7_P6_M3.Text
	Log(textemp6)
End Sub

Private Sub CB4_P6_M3_CheckedChange(Checked As Boolean)
	textemp6 = ""
	If CB4_P6_M3.Checked Then
		textemp6 = CB4_P6_M3.Text
	Else
		textemp6 = ""
	End If
	If CB1_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB1_P6_M3.Text
	If CB2_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB2_P6_M3.Text
	If CB3_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB3_P6_M3.Text
	If CB5_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB5_P6_M3.Text
	If CB6_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB6_P6_M3.Text
	If CB7_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB7_P6_M3.Text
	Log(textemp6)
End Sub

Private Sub CB5_P6_M3_CheckedChange(Checked As Boolean)
	textemp6 = ""
	If CB5_P6_M3.Checked Then
		textemp6 = CB5_P6_M3.Text
	Else
		textemp6 = ""
	End If
	If CB1_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB1_P6_M3.Text
	If CB2_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB2_P6_M3.Text
	If CB3_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB3_P6_M3.Text
	If CB4_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB4_P6_M3.Text
	If CB6_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB6_P6_M3.Text
	If CB7_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB7_P6_M3.Text
	Log(textemp6)
End Sub

Private Sub CB6_P6_M3_CheckedChange(Checked As Boolean)
	textemp6 = ""
	If CB6_P6_M3.Checked Then
		textemp6 = CB6_P6_M3.Text
	Else
		textemp6 = ""
	End If
	If CB1_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB1_P6_M3.Text
	If CB2_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB2_P6_M3.Text
	If CB3_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB3_P6_M3.Text
	If CB4_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB4_P6_M3.Text
	If CB5_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB5_P6_M3.Text
	If CB7_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB7_P6_M3.Text
	Log(textemp6)
End Sub

Private Sub CB7_P6_M3_CheckedChange(Checked As Boolean)
	textemp6 = ""
	If CB7_P6_M3.Checked Then
		textemp6 = CB7_P6_M3.Text
	Else
		textemp6 = ""
	End If
	If CB1_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB1_P6_M3.Text
	If CB2_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB2_P6_M3.Text
	If CB3_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB3_P6_M3.Text
	If CB4_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB4_P6_M3.Text
	If CB5_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB5_P6_M3.Text
	If CB6_P6_M3.Checked Then textemp6 = textemp6 & ", " & CB6_P6_M3.Text
	Log(textemp6)
End Sub





Private Sub CB1_P7_M3_CheckedChange(Checked As Boolean)
	textemp7 = ""
	If CB1_P7_M3.Checked Then
		textemp7 = CB1_P7_M3.Text
	Else
		textemp7 = ""
	End If
	If CB2_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB2_P7_M3.Text
	If CB3_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB3_P7_M3.Text
	If CB4_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB4_P7_M3.Text
	Log(textemp7)
End Sub

Private Sub CB2_P7_M3_CheckedChange(Checked As Boolean)
	textemp7 = ""
	If CB2_P7_M3.Checked Then
		textemp7 = CB2_P7_M3.Text
	Else
		textemp7 = ""
	End If
	If CB1_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB1_P7_M3.Text
	If CB3_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB3_P7_M3.Text
	If CB4_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB4_P7_M3.Text
	Log(textemp7)
End Sub

Private Sub CB3_P7_M3_CheckedChange(Checked As Boolean)
	textemp7 = ""
	If CB3_P7_M3.Checked Then
		textemp7 = CB3_P7_M3.Text
	Else
		textemp7 = ""
	End If
	If CB1_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB1_P7_M3.Text
	If CB2_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB2_P7_M3.Text
	If CB4_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB4_P7_M3.Text
	Log(textemp7)
End Sub

Private Sub CB4_P7_M3_CheckedChange(Checked As Boolean)
	textemp7 = ""
	If CB4_P7_M3.Checked Then
		textemp7 = CB4_P7_M3.Text
	Else
		textemp7 = ""
	End If
	If CB1_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB1_P7_M3.Text
	If CB2_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB2_P7_M3.Text
	If CB3_P7_M3.Checked Then textemp7 = textemp7 & ", " & CB3_P7_M3.Text
	Log(textemp7)
End Sub






Private Sub CB1_P8_M3_CheckedChange(Checked As Boolean)
	textemp8 = ""
	textemp8 = CB1_P8_M3.Text
	If CB2_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB2_P8_M3.Text
	If CB3_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB3_P8_M3.Text
	If CB4_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB4_P8_M3.Text
	Log(textemp8)
End Sub

Private Sub CB2_P8_M3_CheckedChange(Checked As Boolean)
	textemp8 = ""
	textemp8 = CB2_P8_M3.Text
	If CB1_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB1_P8_M3.Text
	If CB3_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB3_P8_M3.Text
	If CB4_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB4_P8_M3.Text
	Log(textemp8)
End Sub

Private Sub CB3_P8_M3_CheckedChange(Checked As Boolean)
	textemp8 = ""
	textemp8 = CB3_P8_M3.Text
	If CB1_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB1_P8_M3.Text
	If CB2_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB2_P8_M3.Text
	If CB4_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB4_P8_M3.Text
	Log(textemp8)
End Sub

Private Sub CB4_P8_M3_CheckedChange(Checked As Boolean)
	textemp8 = ""
	textemp8 = CB4_P8_M3.Text
	If CB1_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB1_P8_M3.Text
	If CB2_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB2_P8_M3.Text
	If CB3_P8_M3.Checked Then textemp8 = textemp8 & ", " & CB3_P8_M3.Text
	Log(textemp8)
End Sub


