B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Activity
Version=6.8
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.
    Dim skmt As SQL
End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.
    
	Dim c As Cursor
	Dim ruta As String
	
	Dim Regresa As Button
	
	Dim Agrega As Button
	Dim e_atiende1 As EditText
	Dim e_atiende2 As EditText
	Dim e_tel As EditText
	Dim e_email As EditText
	Dim e_edo As EditText
	Dim e_mpo As EditText
	Dim e_cp As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
	'Do not forget to load the layout file created with the visual designer. For example:
	'Activity.LoadLayout("Layout1")
	ruta = File.DirInternal
	Activity.LoadLayout("telefonos")
    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=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  from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
	  ' ListView1.Clear
	   
	   'If c.RowCount>0 Then
	    '  For i=0 To c.RowCount -1
		     c.Position=0
			 e_edo.Text = c.GetString("CAT_CL_EDO")
			 If e_edo.Text <> "" Or e_edo.text <> "null" Then
			 e_edo.Enabled = False
			 End If
			 e_cp.Text = c.GetString("CAT_CL_CP")
			 If e_cp.Text <> "" Then
			 e_cp.Enabled = False
			 End If
			 e_mpo.Text = c.GetString("CAT_CL_MUNI")
			 If e_mpo.Text <> "" Then
			 e_mpo.Enabled = False
			 End If
			 e_email.Text = c.GetString("CAT_CL_EMAIL")
			 e_tel.Text = c.GetString("CAT_CL_TELEFONO")
			 e_atiende1.Text = c.GetString("CAT_CL_ATIENDE1")
			 e_atiende2.Text = c.GetString("CAT_CL_ATIENTE2")
			 
	' se crea o no el archivo de la base de ddatos de kmt
	'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE 
	'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
	'SI SE REGRESA A ESTE ACTIVIDAD.
	

End Sub

Sub Activity_Resume
		skmt.Initialize(ruta,"kmt.db", True)
		c=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  from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
	  ' ListView1.Clear
	   
	   'If c.RowCount>0 Then
	    '  For i=0 To c.RowCount -1
		     c.Position=0
			 e_edo.Text = c.GetString("CAT_CL_EDO")
			 If e_edo.Text <> "" Or e_edo.text <> "null" Then
			 e_edo.Enabled = False
			 End If
			 e_cp.Text = c.GetString("CAT_CL_CP")
			 If e_cp.Text <> "" Then
			 e_cp.Enabled = False
			 End If
			 e_mpo.Text = c.GetString("CAT_CL_MUNI")
			 If e_mpo.Text <> "" Then
			 e_mpo.Enabled = False
			 End If
			 e_email.Text = c.GetString("CAT_CL_EMAIL")
			 e_tel.Text = c.GetString("CAT_CL_TELEFONO")
			 e_atiende1.Text = c.GetString("CAT_CL_ATIENDE1")
			 e_atiende2.Text = c.GetString("CAT_CL_ATIENTE2")
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub



Sub Regresa_Click
	StartActivity(fila)
End Sub
Sub Activity_KeyPress (key As Int) As Boolean
    ' BACK key pressed
    If key=KeyCodes.KEYCODE_BACK Then
            ' I want to capture the key here so I return True
			StartActivity(seleccion)
            'Return True
    End If
    ' Returning False signals the system to handle the key
    Return False
End Sub
Sub Agrega_Click
     c=skmt.ExecQuery("Select CUENTA from cuentaa")
     C.Position =0
    	skmt.ExecNonQuery2("insert into CLIE_ACT(CLIENTE,ATIENDE1, ATIENDE2,TEL,EMAIL,EDO,CP, MPO) VALUES (?,?,?,?,?,?,?,?)", Array As Object(c.GetString("CUENTA"),e_atiende1.Text ,e_atiende2.Text,e_tel.text,e_email.Text,e_edo.Text,e_cp.Text,e_mpo.Text))
    c.Close
	StartActivity(seleccion)
End Sub