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 g As GPS
	Dim ruta As String
	Dim skmt As SQL
	Dim c As Cursor
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 CANCELA As Button
	Dim GUARDA As Button
	Dim cuenta As String
	Dim usuario As String
    Dim sDate,sTime As String
'	Dim lat_gps, lon_gps As String
	Dim no_cliente As String
	Dim no_ruta As String
	
	Dim r_4 As RadioButton
	Dim E_NOMBRE 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:
	If(FirstTime) Then
	 g.Initialize("GPS")
	End If
    
	Activity.LoadLayout("nuevocliente")
    
	' valido donde escribo el archivo de la base de datos de kmt
	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)
End Sub

Sub Activity_Resume
    E_NOMBRE.Text =  ""
    If g.GPSEnabled=False Then
	  ToastMessageShow("Habilitar el GPS", True)
	  StartActivity(g.LocationSettingsIntent)
	 Else
	  g.Start(0,0)
	 End If

End Sub

Sub Activity_Pause (UserClosed As Boolean)
	g.Start(0,0)

End Sub

Sub GPS_LocationChanged (Location1 As Location)
'lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
'lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
End Sub

Sub CANCELA_Click
	StartActivity(seleccion)
End Sub
Sub GUARDA_Click
If E_NOMBRE.Text =  "" Then
ToastMessageShow("Se tiene que nombrar la tienda para continuar" , True)
Else
		DateTime.DateFormat = "MM/dd/yyyy"
		sDate=DateTime.Date(DateTime.Now)
		sTime=DateTime.Time(DateTime.Now)
        c=skmt.ExecQuery("select CAT_CL_RUTA FROM kmt_info")
		c.Position=0
		no_ruta= c.GetString("CAT_CL_RUTA")
		no_cliente= "N" & sTime & no_ruta
		c.Close
		skmt.ExecNonQuery2("INSERT INTO kmt_info(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,CAT_CL_BCREDITO, gestion) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,0,0) ",Array As Object (no_cliente,no_ruta, E_NOMBRE.Text,"null","null","null","null","null","null","null","null","null","null","null","null","null","null","null"))
		skmt.ExecNonQuery("delete from CUENTAA")
	    skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(no_cliente))
	    StartActivity(fila)
End If
End Sub
