Commit inicial, cambio de puerto al 1781
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
**/Objects
|
||||
**/AutoBackups
|
||||
*/AutoBackups
|
||||
138
BUSCAR.bas
Normal file
@@ -0,0 +1,138 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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 ListView1 As ListView
|
||||
Dim b_noventa As Button
|
||||
Private p_principal As Panel
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
' ruta = Main.ruta
|
||||
Activity.LoadLayout("buscar")
|
||||
|
||||
' se crea o no el archivo de la base de ddatos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.skmt.ExecQuery("select REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT FROM REPARTO")
|
||||
ListView1.Clear
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("REP_CLIENTE"),c.GetString("REP_PRONOMBRE") &" Cantidad #"& c.GetString("REP_CANT")& " SubTotal $"& c.GetString("REP_COSTO_TOT"))
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
|
||||
|
||||
'ListView1.AddTwoLines(c.GetString("pr_cd_nombre"),c.GetString("pr_cd_colonia"))
|
||||
' Next
|
||||
'End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
p_principal.Width = Activity.Width
|
||||
p_principal.Height = Activity.Height
|
||||
Subs.centraPanel(p_principal, Activity.Width)
|
||||
|
||||
c=Starter.skmt.ExecQuery("select REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT FROM REPARTO")
|
||||
ListView1.Clear
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("REP_CLIENTE"),c.GetString("REP_PRONOMBRE") &" Cantidad #"& c.GetString("REP_CANT")& " SubTotal $"& c.GetString("REP_COSTO_TOT"))
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub Regresar_Click
|
||||
StartActivity(fila)
|
||||
End Sub
|
||||
Sub Activity_KeyPress (key As Int) As Boolean
|
||||
' BACK key pressed
|
||||
If key=KeyCodes.KEYCODE_BACK Then
|
||||
' I want to capture the key here so I return True
|
||||
StartActivity(seleccion)
|
||||
'Return True
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(Value))
|
||||
StartActivity(fila)
|
||||
End Sub
|
||||
Sub b_noventa_Click
|
||||
c=Starter.skmt.ExecQuery("select NV_CLIENTE,NV_MOTIVO,NV_COMM FROM NOVENTA ORDER BY NV_CLIENTE asc")
|
||||
ListView1.Clear
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("NV_CLIENTE"),"Motivo #"& c.GetString("NV_MOTIVO")& " Comentario $"& c.GetString("NV_COMM"))
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
126
BatteryUtilities.bas
Normal file
@@ -0,0 +1,126 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=9.95
|
||||
@EndOfDesignText@
|
||||
'Class module
|
||||
Sub Class_Globals
|
||||
Private nativeMe As JavaObject
|
||||
|
||||
End Sub
|
||||
'Initializes the object.
|
||||
Public Sub Initialize
|
||||
nativeMe = Me
|
||||
End Sub
|
||||
'Return information about the battery status. It returns the following 11 values in an integer Array:
|
||||
'EXTRA_LEVEL = current battery level, from 0 To EXTRA_SCALE.
|
||||
'EXTRA_SCALE = the maximum battery level possible.
|
||||
'EXTRA_HEALTH = the current health constant.
|
||||
'EXTRA_ICON_SMALL = the resource ID of a small status bar icon indicating the current battery state.
|
||||
'EXTRA_PLUGGED = whether the device is plugged into a Power source; 0 means it is on battery, other constants are different types of Power sources.
|
||||
'EXTRA_STATUS = the current status constant.
|
||||
'EXTRA_TEMPERATURE = the current battery temperature.
|
||||
'EXTRA_VOLTAGE = the current battery voltage level.
|
||||
'A value indicating if the battery is being charged or fully charged (If neither it returns 0 Else it returns 1)
|
||||
'A value indicating if it is charging via USB (0 = Not USB, 2 = USB)
|
||||
'A value indicating if it is charging via AC (0 = Not AC, 1 = AC)
|
||||
Public Sub getBatteryInformation () As Int()
|
||||
|
||||
Dim batteryInfo(11) As Int
|
||||
batteryInfo = nativeMe.RunMethod("getBatteryInformation",Null)
|
||||
Return batteryInfo
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub getBatteryTechnolgy() As String
|
||||
|
||||
Dim batterytech As String
|
||||
batterytech = nativeMe.RunMethod("getBatteryTechnology",Null)
|
||||
Return batterytech
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
#If Java
|
||||
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
public int[] getBatteryInformation() {
|
||||
|
||||
int[] mybat = new int[11];
|
||||
|
||||
Intent batteryIntent = ba.context.getApplicationContext().registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
|
||||
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
mybat[0] = level;
|
||||
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
|
||||
mybat[1] = scale;
|
||||
int health = batteryIntent.getIntExtra(BatteryManager.EXTRA_HEALTH,-1);
|
||||
mybat[2] = health;
|
||||
int icon_small = batteryIntent.getIntExtra(BatteryManager.EXTRA_ICON_SMALL,-1);
|
||||
mybat[3] = icon_small;
|
||||
int plugged = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED,-1);
|
||||
mybat[4] = plugged;
|
||||
// boolean present = batteryIntent.getExtras().getBoolean(BatteryManager.EXTRA_PRESENT);
|
||||
int status = batteryIntent.getIntExtra(BatteryManager.EXTRA_STATUS,-1);
|
||||
mybat[5] = status;
|
||||
// String technology = batteryIntent.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY);
|
||||
// BA.Log("Technology = " + technology);
|
||||
int temperature = batteryIntent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,-1);
|
||||
mybat[6] = temperature;
|
||||
int voltage = batteryIntent.getIntExtra(BatteryManager.EXTRA_VOLTAGE,-1);
|
||||
mybat[7] = voltage;
|
||||
// int ac = batteryIntent.getIntExtra("plugged",BatteryManager.BATTERY_PLUGGED_AC);
|
||||
// mybat[8] = ac;
|
||||
// int usb = batteryIntent.getIntExtra("plugged",BatteryManager.BATTERY_PLUGGED_USB);
|
||||
// mybat[9] = usb;
|
||||
|
||||
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
|
||||
status == BatteryManager.BATTERY_STATUS_FULL;
|
||||
mybat[8] = 0;
|
||||
if (isCharging == true) {
|
||||
mybat[8] = 1;
|
||||
}
|
||||
|
||||
// How are we charging?
|
||||
mybat[9] = 0;
|
||||
mybat[10] = 0;
|
||||
int chargePlug = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;
|
||||
if (usbCharge == true) {
|
||||
mybat[9] = 2;
|
||||
}
|
||||
|
||||
boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;
|
||||
if (acCharge == true) {
|
||||
mybat[10] = 1;
|
||||
}
|
||||
|
||||
return mybat;
|
||||
}
|
||||
|
||||
|
||||
public String getBatteryTechnology() {
|
||||
|
||||
Intent batteryIntent = ba.context.getApplicationContext().registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
|
||||
String technology = batteryIntent.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY);
|
||||
|
||||
return technology;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#End If
|
||||
290
CameraExClass.bas
Normal file
@@ -0,0 +1,290 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=7.01
|
||||
@EndOfDesignText@
|
||||
|
||||
'Class module
|
||||
'version 1.20
|
||||
'See this page for the list of constants:
|
||||
'http://developer.android.com/intl/fr/reference/android/hardware/Camera.Parameters.html
|
||||
'Note that you should use the constant values instead of the names.
|
||||
Sub Class_Globals
|
||||
Private nativeCam As Object
|
||||
Private cam As Camera
|
||||
Private r As Reflector
|
||||
Private target As Object
|
||||
Private event As String
|
||||
Public Front As Boolean
|
||||
Type CameraInfoAndId (CameraInfo As Object, Id As Int)
|
||||
Type CameraSize (Width As Int, Height As Int)
|
||||
Private parameters As Object
|
||||
End Sub
|
||||
|
||||
Public Sub Initialize (Panel1 As Panel, FrontCamera As Boolean, TargetModule As Object, EventName As String)
|
||||
target = TargetModule
|
||||
event = EventName
|
||||
Front = FrontCamera
|
||||
Dim id As Int
|
||||
id = FindCamera(Front).id
|
||||
If id = -1 Then
|
||||
Front = Not(Front) 'try different camera
|
||||
id = FindCamera(Front).id
|
||||
If id = -1 Then
|
||||
ToastMessageShow("No camera found.", True)
|
||||
Return
|
||||
End If
|
||||
End If
|
||||
cam.Initialize2(Panel1, "camera", id)
|
||||
End Sub
|
||||
|
||||
Private Sub FindCamera (frontCamera As Boolean) As CameraInfoAndId
|
||||
Dim ci As CameraInfoAndId
|
||||
Dim cameraInfo As Object
|
||||
Dim cameraValue As Int
|
||||
If frontCamera Then cameraValue = 1 Else cameraValue = 0
|
||||
cameraInfo = r.CreateObject("android.hardware.Camera$CameraInfo")
|
||||
Dim numberOfCameras As Int = r.RunStaticMethod("android.hardware.Camera", "getNumberOfCameras", Null, Null)
|
||||
For i = 0 To numberOfCameras - 1
|
||||
r.RunStaticMethod("android.hardware.Camera", "getCameraInfo", Array As Object(i, cameraInfo), _
|
||||
Array As String("java.lang.int", "android.hardware.Camera$CameraInfo"))
|
||||
r.target = cameraInfo
|
||||
If r.GetField("facing") = cameraValue Then
|
||||
ci.cameraInfo = r.target
|
||||
ci.Id = i
|
||||
Return ci
|
||||
End If
|
||||
Next
|
||||
ci.id = -1
|
||||
Return ci
|
||||
End Sub
|
||||
|
||||
Private Sub SetDisplayOrientation
|
||||
r.target = r.GetActivity
|
||||
r.target = r.RunMethod("getWindowManager")
|
||||
r.target = r.RunMethod("getDefaultDisplay")
|
||||
r.target = r.RunMethod("getRotation")
|
||||
Dim previewResult, result, degrees As Int = r.target * 90
|
||||
Dim ci As CameraInfoAndId = FindCamera(Front)
|
||||
r.target = ci.CameraInfo
|
||||
Dim orientation As Int = r.GetField("orientation")
|
||||
If Front Then
|
||||
previewResult = (orientation + degrees) Mod 360
|
||||
result = previewResult
|
||||
previewResult = (360 - previewResult) Mod 360
|
||||
Else
|
||||
previewResult = (orientation - degrees + 360) Mod 360
|
||||
result = previewResult
|
||||
Log(previewResult)
|
||||
End If
|
||||
r.target = nativeCam
|
||||
r.RunMethod2("setDisplayOrientation", previewResult, "java.lang.int")
|
||||
r.target = parameters
|
||||
r.RunMethod2("setRotation", result, "java.lang.int")
|
||||
CommitParameters
|
||||
End Sub
|
||||
|
||||
Private Sub Camera_Ready (Success As Boolean)
|
||||
If Success Then
|
||||
r.target = cam
|
||||
nativeCam = r.GetField("camera")
|
||||
r.target = nativeCam
|
||||
parameters = r.RunMethod("getParameters")
|
||||
SetDisplayOrientation
|
||||
Else
|
||||
Log("success = false, " & LastException)
|
||||
End If
|
||||
CallSub2(target, event & "_ready", Success)
|
||||
End Sub
|
||||
|
||||
Sub Camera_Preview (Data() As Byte)
|
||||
If SubExists(target, event & "_preview") Then
|
||||
CallSub2(target, event & "_preview", Data)
|
||||
End If
|
||||
End Sub
|
||||
Public Sub TakePicture
|
||||
cam.TakePicture
|
||||
End Sub
|
||||
|
||||
Private Sub Camera_PictureTaken (Data() As Byte)
|
||||
CallSub2(target, event & "_PictureTaken", Data)
|
||||
End Sub
|
||||
|
||||
Public Sub StartPreview
|
||||
cam.StartPreview
|
||||
End Sub
|
||||
|
||||
Public Sub StopPreview
|
||||
cam.StopPreview
|
||||
End Sub
|
||||
|
||||
Public Sub Release
|
||||
cam.Release
|
||||
End Sub
|
||||
|
||||
'Saves the data received from PictureTaken event
|
||||
Public Sub SavePictureToFile(Data() As Byte, Dir As String, FileName As String)
|
||||
Dim out As OutputStream = File.OpenOutput(Dir, FileName, False)
|
||||
out.WriteBytes(Data, 0, Data.Length)
|
||||
out.Close
|
||||
End Sub
|
||||
|
||||
Public Sub SetParameter(Key As String, Value As String)
|
||||
r.target = parameters
|
||||
r.RunMethod3("set", Key, "java.lang.String", Value, "java.lang.String")
|
||||
End Sub
|
||||
|
||||
Public Sub GetParameter(Key As String) As String
|
||||
r.target = parameters
|
||||
Return r.RunMethod2("get", Key, "java.lang.String")
|
||||
End Sub
|
||||
|
||||
Public Sub CommitParameters
|
||||
Try
|
||||
r.target = nativeCam
|
||||
r.RunMethod4("setParameters", Array As Object(parameters), Array As String("android.hardware.Camera$Parameters"))
|
||||
Catch
|
||||
ToastMessageShow("Error setting parameters.", True)
|
||||
Log(LastException)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub GetColorEffect As String
|
||||
Return GetParameter("effect")
|
||||
End Sub
|
||||
|
||||
Public Sub SetColorEffect(Effect As String)
|
||||
SetParameter("effect", Effect)
|
||||
End Sub
|
||||
|
||||
Public Sub GetSupportedPicturesSizes As CameraSize()
|
||||
r.target = parameters
|
||||
Dim list1 As List = r.RunMethod("getSupportedPictureSizes")
|
||||
Dim cs(list1.Size) As CameraSize
|
||||
For i = 0 To list1.Size - 1
|
||||
r.target = list1.Get(i)
|
||||
cs(i).Width = r.GetField("width")
|
||||
cs(i).Height = r.GetField("height")
|
||||
Next
|
||||
Return cs
|
||||
End Sub
|
||||
|
||||
Public Sub SetPictureSize(Width As Int, Height As Int)
|
||||
r.target = parameters
|
||||
r.RunMethod3("setPictureSize", Width, "java.lang.int", Height, "java.lang.int")
|
||||
End Sub
|
||||
|
||||
Public Sub SetJpegQuality(Quality As Int)
|
||||
r.target = parameters
|
||||
r.RunMethod2("setJpegQuality", Quality, "java.lang.int")
|
||||
End Sub
|
||||
|
||||
Public Sub SetFlashMode(Mode As String)
|
||||
r.target = parameters
|
||||
r.RunMethod2("setFlashMode", Mode, "java.lang.String")
|
||||
End Sub
|
||||
|
||||
Public Sub GetFlashMode As String
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getFlashMode")
|
||||
End Sub
|
||||
|
||||
Public Sub GetSupportedFlashModes As List
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getSupportedFlashModes")
|
||||
End Sub
|
||||
|
||||
Public Sub GetSupportedColorEffects As List
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getSupportedColorEffects")
|
||||
End Sub
|
||||
|
||||
Public Sub GetPreviewSize As CameraSize
|
||||
r.target = parameters
|
||||
r.target = r.RunMethod("getPreviewSize")
|
||||
Dim cs As CameraSize
|
||||
cs.Width = r.GetField("width")
|
||||
cs.Height = r.GetField("height")
|
||||
Return cs
|
||||
End Sub
|
||||
|
||||
Public Sub GetPictureSize As CameraSize
|
||||
r.target = parameters
|
||||
r.target = r.RunMethod("getPictureSize")
|
||||
Dim cs As CameraSize
|
||||
cs.Width = r.GetField("width")
|
||||
cs.Height = r.GetField("height")
|
||||
Return cs
|
||||
End Sub
|
||||
|
||||
'Converts a preview image formatted in YUV format to JPEG.
|
||||
'Note that you should not save every preview image as it will slow down the whole process.
|
||||
Public Sub PreviewImageToJpeg(data() As Byte, quality As Int) As Byte()
|
||||
Dim size, previewFormat As Object
|
||||
r.target = parameters
|
||||
size = r.RunMethod("getPreviewSize")
|
||||
previewFormat = r.RunMethod("getPreviewFormat")
|
||||
r.target = size
|
||||
Dim width = r.GetField("width"), height = r.GetField("height") As Int
|
||||
Dim yuvImage As Object = r.CreateObject2("android.graphics.YuvImage", _
|
||||
Array As Object(data, previewFormat, width, height, Null), _
|
||||
Array As String("[B", "java.lang.int", "java.lang.int", "java.lang.int", "[I"))
|
||||
r.target = yuvImage
|
||||
Dim rect1 As Rect
|
||||
rect1.Initialize(0, 0, r.RunMethod("getWidth"), r.RunMethod("getHeight"))
|
||||
Dim out As OutputStream
|
||||
out.InitializeToBytesArray(100)
|
||||
r.RunMethod4("compressToJpeg", Array As Object(rect1, quality, out), _
|
||||
Array As String("android.graphics.Rect", "java.lang.int", "java.io.OutputStream"))
|
||||
Return out.ToBytesArray
|
||||
End Sub
|
||||
|
||||
Public Sub GetSupportedFocusModes As List
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getSupportedFocusModes")
|
||||
End Sub
|
||||
|
||||
Public Sub SetContinuousAutoFocus
|
||||
Dim modes As List = GetSupportedFocusModes
|
||||
If modes.IndexOf("continuous-picture") > -1 Then
|
||||
SetFocusMode("continuous-picture")
|
||||
Else If modes.IndexOf("continuous-video") > -1 Then
|
||||
SetFocusMode("continuous-video")
|
||||
Else
|
||||
Log("Continuous focus mode is not available")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub SetFocusMode(Mode As String)
|
||||
r.target = parameters
|
||||
r.RunMethod2("setFocusMode", Mode, "java.lang.String")
|
||||
End Sub
|
||||
|
||||
Public Sub GetFocusDistances As Float()
|
||||
Dim F(3) As Float
|
||||
r.target = parameters
|
||||
r.RunMethod4("getFocusDistances", Array As Object(F), Array As String("[F"))
|
||||
Return F
|
||||
End Sub
|
||||
'This method should only be called if you need to immediately release the camera.
|
||||
'For example if you need to start another application that depends on the camera.
|
||||
Public Sub CloseNow
|
||||
cam.Release
|
||||
r.target = cam
|
||||
r.RunMethod2("releaseCameras", True, "java.lang.boolean")
|
||||
End Sub
|
||||
'Calls AutoFocus and then takes the picture if focus was successfull.
|
||||
Public Sub FocusAndTakePicture
|
||||
cam.AutoFocus
|
||||
End Sub
|
||||
Private Sub Camera_FocusDone (Success As Boolean)
|
||||
If Success Then
|
||||
TakePicture
|
||||
Else
|
||||
Log("AutoFocus error.")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
271
DBRequestManager.bas
Normal file
@@ -0,0 +1,271 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=7.01
|
||||
@EndOfDesignText@
|
||||
'Class module
|
||||
Sub Class_Globals
|
||||
Private mTarget As Object
|
||||
Type DBResult (Tag As Object, Columns As Map, Rows As List)
|
||||
Type DBCommand (Name As String, Parameters() As Object)
|
||||
Private link As String
|
||||
Private bc As ByteConverter
|
||||
Private T_NULL = 0, T_STRING = 1, T_SHORT = 2, T_INT = 3, T_LONG = 4, T_FLOAT = 5 _
|
||||
,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte
|
||||
Private VERSION As Float = 0.9
|
||||
Private tempArray(1) As Object
|
||||
Dim jobTagAnterior As String = "" 'Mod por CHV - 211023
|
||||
End Sub
|
||||
|
||||
'Target - The module that handles JobDone (usually Me).
|
||||
'ConnectorLink - URL of the Java server.
|
||||
Public Sub Initialize (Target As Object, ConnectorLink As String)
|
||||
mTarget = Target
|
||||
link = ConnectorLink
|
||||
End Sub
|
||||
|
||||
'Sends a query request.
|
||||
'Command - Query name and parameters.
|
||||
'Limit - Maximum rows to return or 0 for no limit.
|
||||
'Tag - An object that will be returned in the result.
|
||||
Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object)
|
||||
Dim j As HttpJob
|
||||
Dim ms As OutputStream
|
||||
Dim out2 As OutputStream = StartJob(j,ms, Tag)
|
||||
|
||||
WriteObject(Command.Name, out2)
|
||||
WriteInt(Limit, out2)
|
||||
WriteList(Command.Parameters, out2)
|
||||
out2.Close
|
||||
j.PostBytes(link & "?method=query", ms.ToBytesArray)
|
||||
End Sub
|
||||
|
||||
'Executes a batch of (non-select) commands.
|
||||
'ListOfCommands - List of the commands that will be executes.
|
||||
'Tag - An object that will be returned in the result.
|
||||
Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object)
|
||||
Dim j As HttpJob
|
||||
Dim ms As OutputStream
|
||||
Dim out2 As OutputStream = StartJob(j,ms, Tag)
|
||||
WriteInt(ListOfCommands.Size, out2)
|
||||
For Each Command As DBCommand In ListOfCommands
|
||||
WriteObject(Command.Name, out2)
|
||||
WriteList(Command.Parameters, out2)
|
||||
Next
|
||||
out2.Close
|
||||
j.PostBytes(link & "?method=batch", ms.ToBytesArray)
|
||||
End Sub
|
||||
|
||||
'Similar to ExecuteBatch. Sends a single command.
|
||||
Public Sub ExecuteCommand(Command As DBCommand, Tag As Object)
|
||||
ExecuteBatch(Array As DBCommand(Command), Tag)
|
||||
End Sub
|
||||
|
||||
Private Sub StartJob(j As HttpJob, MemoryStream As OutputStream, Tag As Object) As OutputStream
|
||||
j.Initialize("DBRequest", mTarget)
|
||||
j.Tag = Tag
|
||||
MemoryStream.InitializeToBytesArray(0)
|
||||
Dim compress As CompressedStreams
|
||||
Dim out As OutputStream = compress.WrapOutputStream(MemoryStream, "gzip")
|
||||
WriteObject(VERSION, out)
|
||||
Return out
|
||||
End Sub
|
||||
|
||||
Private Sub WriteList(Parameters As List, out As OutputStream)
|
||||
Dim data() As Byte
|
||||
If Parameters = Null Or Parameters.IsInitialized = False Then
|
||||
Dim Parameters As List
|
||||
Parameters.Initialize
|
||||
End If
|
||||
data = bc.IntsToBytes(Array As Int(Parameters.Size))
|
||||
out.WriteBytes(data, 0, data.Length)
|
||||
For Each o As Object In Parameters
|
||||
WriteObject(o, out)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub WriteObject(o As Object, out As OutputStream)
|
||||
Dim data() As Byte
|
||||
tempArray(0) = o
|
||||
If tempArray(0) = Null Then
|
||||
out.WriteBytes(Array As Byte(T_NULL), 0, 1)
|
||||
Else If tempArray(0) Is Short Then
|
||||
out.WriteBytes(Array As Byte(T_SHORT), 0, 1)
|
||||
data = bc.ShortsToBytes(Array As Short(o))
|
||||
Else If tempArray(0) Is Int Then
|
||||
out.WriteBytes(Array As Byte(T_INT), 0, 1)
|
||||
data = bc.IntsToBytes(Array As Int(o))
|
||||
Else If tempArray(0) Is Float Then
|
||||
out.WriteBytes(Array As Byte(T_FLOAT), 0, 1)
|
||||
data = bc.FloatsToBytes(Array As Float(o))
|
||||
Else If tempArray(0) Is Double Then
|
||||
out.WriteBytes(Array As Byte(T_DOUBLE), 0, 1)
|
||||
data = bc.DoublesToBytes(Array As Double(o))
|
||||
Else If tempArray(0) Is Long Then
|
||||
out.WriteBytes(Array As Byte(T_LONG), 0, 1)
|
||||
data = bc.LongsToBytes(Array As Long(o))
|
||||
Else If tempArray(0) Is Boolean Then
|
||||
out.WriteBytes(Array As Byte(T_BOOLEAN), 0, 1)
|
||||
Dim b As Boolean = 0
|
||||
Dim data(1) As Byte
|
||||
If b Then data(0) = 1 Else data(0) = 0
|
||||
Else If GetType(tempArray(0)) = "[B" Then
|
||||
data = o
|
||||
out.WriteBytes(Array As Byte(T_BLOB), 0, 1)
|
||||
WriteInt(data.Length, out)
|
||||
Else 'If o Is String Then (treat all other values as string)
|
||||
out.WriteBytes(Array As Byte(T_STRING), 0, 1)
|
||||
data = bc.StringToBytes(o, "UTF8")
|
||||
WriteInt(data.Length, out)
|
||||
End If
|
||||
If data.Length > 0 Then out.WriteBytes(data, 0, data.Length)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadObject(In As InputStream) As Object
|
||||
Dim data(1) As Byte
|
||||
In.ReadBytes(data, 0, 1)
|
||||
Select data(0)
|
||||
Case T_NULL
|
||||
Return Null
|
||||
Case T_SHORT
|
||||
Dim data(2) As Byte
|
||||
Return bc.ShortsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_INT
|
||||
Dim data(4) As Byte
|
||||
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_LONG
|
||||
Dim data(8) As Byte
|
||||
Return bc.LongsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_FLOAT
|
||||
Dim data(4) As Byte
|
||||
Return bc.FloatsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_DOUBLE
|
||||
Dim data(8) As Byte
|
||||
Return bc.DoublesFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_BOOLEAN
|
||||
Dim b As Byte = ReadByte(In)
|
||||
Return b = 1
|
||||
Case T_BLOB
|
||||
Dim len As Int = ReadInt(In)
|
||||
Dim data(len) As Byte
|
||||
Return ReadBytesFully(In, data, data.Length)
|
||||
Case Else
|
||||
Dim len As Int = ReadInt(In)
|
||||
Dim data(len) As Byte
|
||||
ReadBytesFully(In, data, data.Length)
|
||||
Return BytesToString(data, 0, data.Length, "UTF8")
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub ReadBytesFully(In As InputStream, Data() As Byte, Len As Int) As Byte()
|
||||
Dim count = 0, read As Int
|
||||
Do While count < Len And read > -1
|
||||
read = In.ReadBytes(Data, count, Len - count)
|
||||
count = count + read
|
||||
Loop
|
||||
Return Data
|
||||
End Sub
|
||||
|
||||
Private Sub WriteInt(i As Int, out As OutputStream)
|
||||
Dim data() As Byte
|
||||
data = bc.IntsToBytes(Array As Int(i))
|
||||
out.WriteBytes(data, 0, data.Length)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadInt(In As InputStream) As Int
|
||||
Dim data(4) As Byte
|
||||
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadByte(In As InputStream) As Byte
|
||||
Dim data(1) As Byte
|
||||
In.ReadBytes(data, 0, 1)
|
||||
Return data(0)
|
||||
End Sub
|
||||
|
||||
'Handles the Job result and returns a DBResult.
|
||||
Public Sub HandleJob(Job As HttpJob) As DBResult
|
||||
' Dim start As Long = DateTime.Now
|
||||
Dim In As InputStream = Job.GetInputStream
|
||||
Dim cs As CompressedStreams
|
||||
In = cs.WrapInputStream(In, "gzip")
|
||||
Dim serverVersion As Float = ReadObject(In) 'ignore
|
||||
Dim method As String = ReadObject(In)
|
||||
Dim table As DBResult
|
||||
table.Initialize
|
||||
table.Columns.Initialize
|
||||
table.rows.Initialize
|
||||
table.Tag = Job.Tag
|
||||
If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211023
|
||||
jobTagAnterior = Job.Tag 'Mod por CHV - 211023
|
||||
If method = "query" Then
|
||||
Dim numberOfColumns As Int = ReadInt(In)
|
||||
For i = 0 To numberOfColumns - 1
|
||||
table.Columns.Put(ReadObject(In), i)
|
||||
Next
|
||||
Do While ReadByte(In) = 1
|
||||
Dim rowObjects(numberOfColumns) As Object
|
||||
table.rows.Add(rowObjects)
|
||||
For col = 0 To numberOfColumns - 1
|
||||
Dim o As Object = ReadObject(In)
|
||||
rowObjects(col) = o
|
||||
Next
|
||||
Loop
|
||||
Else If method = "batch" Then
|
||||
table.Columns.Put("AffectedRows", 0)
|
||||
Dim rows As Int = ReadInt(In)
|
||||
For i = 0 To rows - 1
|
||||
table.rows.Add(Array As Object(ReadInt(In)))
|
||||
Next
|
||||
End If
|
||||
In.Close
|
||||
Return table
|
||||
End Sub
|
||||
|
||||
'Reads a file and returns the file as a bytes array.
|
||||
Public Sub FileToBytes(Dir As String, FileName As String) As Byte()
|
||||
Dim out As OutputStream
|
||||
out.InitializeToBytesArray(0)
|
||||
Dim In As InputStream = File.OpenInput(Dir, FileName)
|
||||
File.Copy2(In, out)
|
||||
out.Close
|
||||
Return out.ToBytesArray
|
||||
End Sub
|
||||
|
||||
'Converts an image to a bytes array (for BLOB fields).
|
||||
Public Sub ImageToBytes(Image As Bitmap) As Byte()
|
||||
Dim out As OutputStream
|
||||
out.InitializeToBytesArray(0)
|
||||
Image.WriteToStream(out, 100, "JPEG")
|
||||
out.Close
|
||||
Return out.ToBytesArray
|
||||
End Sub
|
||||
'Converts a bytes array to an image (for BLOB fields).
|
||||
Public Sub BytesToImage(bytes() As Byte) As Bitmap
|
||||
Dim In As InputStream
|
||||
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
|
||||
Dim bmp As Bitmap
|
||||
bmp.Initialize2(In)
|
||||
Return bmp
|
||||
End Sub
|
||||
'Prints the table to the logs.
|
||||
Public Sub PrintTable(Table As DBResult)
|
||||
Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size)
|
||||
Dim sb As StringBuilder
|
||||
sb.Initialize
|
||||
For Each col In Table.Columns.Keys
|
||||
sb.Append(col).Append(TAB)
|
||||
Next
|
||||
Log(sb.ToString)
|
||||
For Each row() As Object In Table.Rows
|
||||
Dim sb As StringBuilder
|
||||
sb.Initialize
|
||||
For Each record As Object In row
|
||||
sb.Append(record).Append(TAB)
|
||||
Next
|
||||
ToastMessageShow(sb.ToString, True)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
56
Durakelo_reparto.b4a.meta
Normal file
@@ -0,0 +1,56 @@
|
||||
VisibleModules=1,2,3,4,5,6,7,8,9,10
|
||||
ModuleBreakpoints0=
|
||||
ModuleBookmarks0=
|
||||
ModuleClosedNodes0=
|
||||
ModuleBreakpoints1=
|
||||
ModuleBookmarks1=
|
||||
ModuleClosedNodes1=3,5,6,7,8,9,10,12,14,15,16,17,18,19
|
||||
ModuleBreakpoints2=
|
||||
ModuleBookmarks2=
|
||||
ModuleClosedNodes2=
|
||||
ModuleBreakpoints3=
|
||||
ModuleBookmarks3=
|
||||
ModuleClosedNodes3=
|
||||
ModuleBreakpoints4=
|
||||
ModuleBookmarks4=
|
||||
ModuleClosedNodes4=
|
||||
ModuleBreakpoints5=
|
||||
ModuleBookmarks5=
|
||||
ModuleClosedNodes5=
|
||||
ModuleBreakpoints6=
|
||||
ModuleBookmarks6=
|
||||
ModuleClosedNodes6=
|
||||
ModuleBreakpoints7=
|
||||
ModuleBookmarks7=
|
||||
ModuleClosedNodes7=
|
||||
ModuleBreakpoints8=
|
||||
ModuleBookmarks8=
|
||||
ModuleClosedNodes8=
|
||||
ModuleBreakpoints9=
|
||||
ModuleBookmarks9=
|
||||
ModuleClosedNodes9=9
|
||||
ModuleBreakpoints10=
|
||||
ModuleBookmarks10=
|
||||
ModuleClosedNodes10=3,4,6,8,17,18,19
|
||||
ModuleBreakpoints11=
|
||||
ModuleBookmarks11=
|
||||
ModuleClosedNodes11=
|
||||
ModuleBreakpoints12=
|
||||
ModuleBookmarks12=
|
||||
ModuleClosedNodes12=
|
||||
ModuleBreakpoints13=
|
||||
ModuleBookmarks13=
|
||||
ModuleClosedNodes13=
|
||||
ModuleBreakpoints14=
|
||||
ModuleBookmarks14=
|
||||
ModuleClosedNodes14=
|
||||
ModuleBreakpoints15=
|
||||
ModuleBookmarks15=
|
||||
ModuleClosedNodes15=
|
||||
ModuleBreakpoints16=
|
||||
ModuleBookmarks16=
|
||||
ModuleClosedNodes16=
|
||||
ModuleBreakpoints17=
|
||||
ModuleBookmarks17=
|
||||
ModuleClosedNodes17=
|
||||
SelectedBuild=0
|
||||
BIN
Files/alert2.png
Normal file
|
After Width: | Height: | Size: 632 B |
BIN
Files/alerta.jpg
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Files/buscar.bal
Normal file
BIN
Files/dbc.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
Files/detalle_promo.bal
Normal file
BIN
Files/durakelo1.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
Files/fila.bal
Normal file
BIN
Files/fondo_kmt.jpg
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
Files/foto.bal
Normal file
BIN
Files/guardagestion.bal
Normal file
BIN
Files/guna_viejo.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
Files/guna_viejo2.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
Files/info_gral.bal
Normal file
BIN
Files/infonavit1.jpg
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
Files/itembuttonblue.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
Files/kelloggs.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
Files/keymon_logo.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
Files/kmt.db
Normal file
BIN
Files/login.bal
Normal file
BIN
Files/logo sanfer.jpg
Normal file
|
After Width: | Height: | Size: 7.8 KiB |
BIN
Files/logo.jpg
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
Files/logo0.jpg
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
Files/logo01.jpg
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
Files/logo1.jpg
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
Files/logo_192x192.jpg
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
Files/logo_exitus1.jpg
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
Files/malo.jpg
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
Files/mapa.bal
Normal file
BIN
Files/mapa_cliente.bal
Normal file
BIN
Files/mapa_rutas.bal
Normal file
BIN
Files/nopago.bal
Normal file
BIN
Files/nuevocliente.bal
Normal file
BIN
Files/pedido.bal
Normal file
BIN
Files/planfia_logo.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
Files/planfia_logo_old.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
Files/planfia_logo_old2.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
Files/productos.bal
Normal file
BIN
Files/profina.jpg
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
Files/profina.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
Files/seleccion.bal
Normal file
BIN
Files/sync.png
Normal file
|
After Width: | Height: | Size: 763 B |
BIN
Files/tarjeta.bal
Normal file
BIN
Files/telefonos.bal
Normal file
278
FirebaseMessaging.bas
Normal file
@@ -0,0 +1,278 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
'///////////////////////////////////////////////////////////////////////////////////////
|
||||
'/// Agregar estas lineas al editor de manifiestos
|
||||
'
|
||||
' CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
|
||||
' CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
|
||||
' CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
|
||||
' CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
|
||||
'
|
||||
'/// Agregar modulo de servicio nuevo FirebaseMessaging y copiar este modulo
|
||||
'
|
||||
'/// Bajar el archivo google-services.json de la consola de Firebase (https://console.firebase.google.com/)
|
||||
'/// El nombre de la app en el archivo json tiene que ser el mismo que el nombre del paquete (Proyecto/Conf de Compilacion/Paquete)
|
||||
'
|
||||
'/// En Starter agregar esta linea
|
||||
'
|
||||
' Sub Service_Create
|
||||
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
|
||||
' End Sub
|
||||
'
|
||||
'/// En Main en Sub Process_Globals agregar esta linea
|
||||
'
|
||||
' Private const API_KEY As String = "AAAAv__xxxxxxxxxxxxx-xxxxxxxxxxxxxx-xxxxxxxxxxxx"
|
||||
'
|
||||
'/// Esta llave se consigue igualmente en la consola de Firebase, configuracion de proyecto, Cloud Messaging,
|
||||
'/// es la clave de servidor.
|
||||
'///
|
||||
'/// Se necesitan agregar las librerías: FirebaseAnalitics, FirebaseNotifications, JSON y OkHttpUtils2
|
||||
'/// ... JSON es necesario si se van a enviar mensajes, si solo se van a recibir, no es necesario.
|
||||
'
|
||||
'///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Sub Process_Globals
|
||||
Private fm As FirebaseMessaging
|
||||
Private const API_KEY As String = "AAAAv1qt3Lk:APA91bECIR-pHn6ul53eYyoVlpPuOo85RO-0zcAgEXwE7vqw8DFSbBtCaCINiqWQAkBBZXxHtQMdpU6B-jHIqgFKVL196UgwHv0Gw6_IgmipfV_NiItjzlH9d2QNpGLp9y_JUKVjUEhP"
|
||||
' Dim phn As Phone
|
||||
' Dim devModel As String
|
||||
Dim pe As PhoneEvents
|
||||
Dim c As Cursor
|
||||
Public GZip As GZipStrings 'Requiere la libreria CompressStrings
|
||||
Dim Subscrito As String = ""
|
||||
Dim au As String
|
||||
Dim puntosRuta As Int = 380
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
fm.Initialize("fm") 'Inicializamos FirebaseMessaging
|
||||
pe.Initialize("pe") 'Para obtener la bateria
|
||||
End Sub
|
||||
|
||||
Public Sub SubscribeToTopics
|
||||
fm.SubscribeToTopic("Trckr") 'Global (you can subscribe to more topics)
|
||||
fm.SubscribeToTopic("Trckr-GunaReparto") 'Global (you can subscribe to more topics)
|
||||
If Main.usuario <> Subscrito Then
|
||||
fm.SubscribeToTopic(Main.usuario) 'Propio (you can subscribe to more topics)
|
||||
fm.UnsubscribeFromTopic(Subscrito) 'Unsubscribe from topic
|
||||
End If
|
||||
If Main.logger Then Log("Subscrito a FM "&Main.usuario)
|
||||
Subscrito = Main.usuario
|
||||
' Log(fm.token)
|
||||
' fm.UnsubscribeFromTopic("Sprvsr") 'Unsubscribe from topic
|
||||
' fm.UnsubscribeFromTopic("Trckr") 'Unsubscribe from topic
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
LogColor("Iniciamos FirebaseMessaging", Colors.Green)
|
||||
If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
|
||||
Sleep(0)
|
||||
Service.StopAutomaticForeground 'remove if not using B4A v8+.
|
||||
StartServiceAt(Me, DateTime.Now + 15 * DateTime.TicksPerMinute, True) 'Iniciamos servicio cada XX minutos
|
||||
End Sub
|
||||
|
||||
Sub fm_MessageArrived (Message As RemoteMessage)
|
||||
If Main.logger Then Log("Message arrived")
|
||||
If Main.logger Then Log($"Message data: ${Message.GetData}"$)
|
||||
' getPhnId
|
||||
If Message.GetData.ContainsKey("t") Then
|
||||
Dim tipos As List = Regex.Split(",",Message.GetData.Get("t"))
|
||||
If tipos.IndexOf("pu") <> -1 Or tipos.IndexOf("au") <> -1 Then 'Si es una peticion de ubicacion
|
||||
If Main.logger Then Log("Es una peticion de ubicacion")
|
||||
Tracker.locRequest="Activa"
|
||||
If Main.logger Then Log("Llamamos StartFLP")
|
||||
' CallSubDelayed(Tracker, "StartFLP")
|
||||
CallSubDelayed(Tracker, "StartFLP")
|
||||
End If
|
||||
If tipos.IndexOf("au") <> -1 Then 'Si es una actualizacion de ubicacion
|
||||
au = 1
|
||||
End If
|
||||
If tipos.IndexOf("ping") <> -1 Then 'Si es un ping
|
||||
If Main.logger Then Log("Es un ping")
|
||||
If Main.logger Then Log("Mandamos pong")
|
||||
Dim params As Map = CreateMap("topic":"Sprv-GunaReparto","title":"pong", "body":Main.usuario&" - Recibi mensaje "&Message.GetData.Get("title"), "t":"pong")
|
||||
SendMessage(params)
|
||||
End If
|
||||
If tipos.IndexOf("bgps") <> -1 Then 'Si es una instruccion de borrar archivo gps
|
||||
If Main.logger Then Log("Es una instruccion de borrar archivo gps")
|
||||
If Main.logger Then Log("Borramos archivo gps")
|
||||
borramosArchivoGPS
|
||||
End If
|
||||
If tipos.IndexOf("dr") <> -1 Then 'Si es una peticion de ruta gps
|
||||
If Main.logger Then Log("Es una peticion de Ruta GPS")
|
||||
Dim rutaGpsCmp As String = dameRuta
|
||||
Dim params As Map = CreateMap("topic":"Sprv-GunaReparto","title":"ruta", "body":Main.usuario&" - Recibi mensaje "&Message.GetData.Get("title"), "t":"ruta", "r":rutaGpsCmp)
|
||||
SendMessage(params)
|
||||
End If
|
||||
If tipos.IndexOf("bgps2") <> -1 Then 'Si es una instruccion de borrar DB gps
|
||||
If Main.logger Then Log("Es una instruccion de borrar BD gps")
|
||||
If Main.logger Then Log("Borramos BD gps")
|
||||
borraGPSHist
|
||||
End If
|
||||
If tipos.IndexOf("pu") = -1 And tipos.IndexOf("au") = -1 And tipos.IndexOf("ping") = -1 And tipos.IndexOf("dr") = -1 Then
|
||||
If Main.logger Then Log("No es ping ni solicitud de ubicacion o ruta, entonces no hacemos nada")
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
|
||||
End Sub
|
||||
|
||||
Sub SendMessage(params As Map)
|
||||
Dim topic As String= params.Get("topic")
|
||||
Dim title As String= params.Get("title")
|
||||
Dim body As String= params.Get("body")
|
||||
Dim tipo As String= params.Get("t")
|
||||
If params.ContainsKey("r") Then
|
||||
If Main.logger Then Log("Con ruta")
|
||||
Dim rutaGpsCmp As String= params.Get("r")
|
||||
Else
|
||||
If Main.logger Then Log("Sin ruta")
|
||||
Dim rutaGpsCmp As String = ""
|
||||
End If
|
||||
Dim Job As HttpJob
|
||||
Job.Initialize("fcm", Me)
|
||||
Dim m As Map = CreateMap("to": $"/topics/${topic}"$)
|
||||
Dim data As Map = CreateMap("title":title, "body":body, "d":Main.usuario, "t":tipo, "b":Main.batt, "mt":Main.montoActual, "r":rutaGpsCmp, "v":Application.VersionName)
|
||||
m.Put("data", data)
|
||||
Dim jg As JSONGenerator
|
||||
jg.Initialize(m)
|
||||
Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
|
||||
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
|
||||
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
|
||||
If Main.logger Then Log(m)
|
||||
End Sub
|
||||
|
||||
Sub mandamosLoc(coords As String)
|
||||
If Main.logger Then Log("Iniciamos mandamosLoc "&coords)
|
||||
' If Main.logger Then Log("Tracker.locRequest="&Tracker.locRequest)
|
||||
Dim t As String
|
||||
If Tracker.locRequest="Activa" Then 'Si hay solicitud de ubicacion, entonces la mandamos ...
|
||||
If au = 1 Then
|
||||
t = "au" ' es una actualizacion
|
||||
Else
|
||||
t = "u" ' es una peticion
|
||||
End If
|
||||
Dim params As Map = CreateMap("topic":"Sprv-GunaReparto","title":"ubicacionRecibida", "body":coords, "t":t)
|
||||
SendMessage(params)
|
||||
Tracker.locRequest="Enviada"
|
||||
CallSubDelayed(Tracker,"CreateLocationRequest")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub guardaInfoEnArchivo(coords As String) 'Escribimos coordenadas y fecha a un archivo de texto 'ignore
|
||||
'' Cambiamos el formato de la hora
|
||||
' Dim OrigFormat As String=DateTime.DateFormat 'save orig date format
|
||||
' DateTime.DateFormat="MMM-dd HH:mm:ss"
|
||||
' Dim lastUpdate As String=DateTime.Date(DateTime.Now)
|
||||
' DateTime.DateFormat=OrigFormat 'return to orig date format
|
||||
|
||||
If Main.logger Then Log("Guardamos ubicacion en db")
|
||||
Dim latlon() As String = Regex.Split(",", coords)
|
||||
Try
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO RUTA_GPS(fecha, lat, lon) VALUES (?,?,?)", Array As Object (latlon(2),latlon(0),latlon(1)))
|
||||
Catch
|
||||
If Main.logger Then Log("Error guardando ubicacion") 'Si la horaMinSeg es el mismo no lo guarda
|
||||
End Try
|
||||
' c=Main.skmt.ExecQuery("select * from RUTA_GPS")
|
||||
' c.Position =0
|
||||
' Log(c.GetString("lat")&","&c.GetString("lon")&","&c.GetString("fecha"))
|
||||
|
||||
' Dim ubic As String = coords&","&lastUpdate
|
||||
' Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "gps.txt", True)
|
||||
' Dim s As String = ubic & CRLF
|
||||
' Dim t() As Byte = s.GetBytes("UTF-8")
|
||||
' out.WriteBytes(t, 0, t.Length)
|
||||
' out.Close
|
||||
End Sub
|
||||
|
||||
Sub borramosArchivoGPS
|
||||
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "gps.txt", False)
|
||||
Dim s As String = ""
|
||||
Dim t() As Byte = s.GetBytes("UTF-8")
|
||||
out.WriteBytes(t, 0, t.Length)
|
||||
out.Close
|
||||
End Sub
|
||||
|
||||
'Sub getPhnId 'Pone el valor de phn.Model en la variable global "devModel"
|
||||
' devModel = phn.Model
|
||||
' If devModel.Length <= 3 Then 'Si phn.Model esta en blanco ...
|
||||
' Dim t As String = phn.GetSettings("android_id") 'Intentamos con "android_id"
|
||||
' devModel = t
|
||||
' End If
|
||||
' If devModel.Length >= 3 Then 'Si tenemos valor para phn.Model
|
||||
' File.WriteString(File.DirInternal, "phnId.txt", devModel) 'Sobreescribimos archivo phnId.txt with deviceId
|
||||
' Log("Tenemos phnId: "&devModel&" "&File.DirInternal&"/phn.txt sobreescrito")
|
||||
' Else If devModel.Length < 2 Then ' Si no tenemos valor, lo leemos de phnId.txt
|
||||
' Dim s As String = File.ReadString(File.DirInternal, "phnId.txt")
|
||||
' devModel = s
|
||||
' Log("Leemos id de "&File.DirInternal&"/phnId.txt")
|
||||
' Log(devModel)
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
Sub pe_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
|
||||
Main.batt=Level
|
||||
End Sub
|
||||
|
||||
Sub compress(str As String) As String
|
||||
' Compression
|
||||
Private su As StringUtils
|
||||
Dim compressed() As Byte = GZip.compress(str)
|
||||
If Main.logger Then Log($"CompressedBytesLength: ${compressed.Length}"$)
|
||||
Dim base64 As String = su.EncodeBase64(compressed)
|
||||
If Main.logger Then Log($"CompressedBytes converted to base64 Length: ${base64.Length}"$)
|
||||
If Main.logger Then Log($"CompressedBytes converted to base64: ${base64}"$)
|
||||
Return base64
|
||||
End Sub
|
||||
|
||||
Sub decompress(base64 As String) As String 'ignore
|
||||
' Decompression
|
||||
Private su As StringUtils
|
||||
Dim decompressedbytes() As Byte = su.DecodeBase64(base64)
|
||||
If Main.logger Then Log($"decompressedbytesLength: ${decompressedbytes.Length}"$)
|
||||
Dim bc As ByteConverter
|
||||
Dim uncompressed As String = bc.StringFromBytes(decompressedbytes,"UTF8")
|
||||
If Main.logger Then Log($"uncompressedLength: ${uncompressed.Length}"$) ' 6163 Bytes
|
||||
If Main.logger Then Log($"Decompressed String = ${uncompressed}"$)
|
||||
Return uncompressed
|
||||
End Sub
|
||||
|
||||
Sub dameRuta As String
|
||||
If Main.logger Then Log("dameRuta")
|
||||
Dim OrigFormat As String = DateTime.DateFormat 'save orig date format
|
||||
DateTime.DateFormat="yyMMdd"
|
||||
' Dim lastUpdate As String=DateTime.Date(fecha)
|
||||
Dim hoy As String = DateTime.Date(DateTime.Now)&"000000"
|
||||
DateTime.DateFormat=OrigFormat 'return to orig date format
|
||||
If Main.logger Then Log(hoy)
|
||||
Dim c As Cursor
|
||||
c = Starter.skmt.ExecQuery("select LAT, LON from RUTA_GPS where fecha > "& hoy &" order by fecha desc limit "&puntosRuta)
|
||||
c.Position = 0
|
||||
Dim ruta2 As String = ""
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
ruta2=ruta2&CRLF&c.GetString("LAT")&","&c.GetString("LON")
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
Return compress(ruta2)
|
||||
End Sub
|
||||
|
||||
Sub borraGPSHist
|
||||
c=Starter.skmt.ExecQuery("select count(*) as cuantos FROM RUTA_GPS")
|
||||
c.Position=0
|
||||
If Main.logger Then Log("Habia "&c.GetInt("cuantos"))
|
||||
Starter.skmt.ExecNonQuery("delete from RUTA_GPS")
|
||||
c=Starter.skmt.ExecQuery("select count(*) as cuantos FROM RUTA_GPS")
|
||||
c.Position=0
|
||||
Log("Quedaron " & c.GetInt("cuantos"))
|
||||
Log("Borramos RUTA_GPS")
|
||||
c.Close
|
||||
End Sub
|
||||
282
Historico.bas
Normal file
@@ -0,0 +1,282 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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
|
||||
Dim g As GPS
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
|
||||
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 Regresar As Button
|
||||
|
||||
|
||||
Dim ListView1 As ListView
|
||||
Dim L_CANT As Label
|
||||
Dim L_TOTAL As Label
|
||||
Dim borra As Button
|
||||
Dim Existe As String
|
||||
Dim result As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
Dim cuantos As String
|
||||
Dim nombre_prod As String
|
||||
Dim cuantos_pedido As String
|
||||
|
||||
|
||||
Private Titulo As Label
|
||||
Private P1 As Panel
|
||||
Private lv2 As ListView
|
||||
Private p_principal As Panel
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
If(FirstTime) Then
|
||||
g.Initialize("GPS")
|
||||
End If
|
||||
|
||||
' ruta = Main.ruta
|
||||
Activity.LoadLayout("tarjeta")
|
||||
borra.Visible = False
|
||||
Titulo.Text = "Pedido"
|
||||
|
||||
' se crea o no el archivo de la base de ddatos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
|
||||
|
||||
'ListView1.AddTwoLines(c.GetString("pr_cd_nombre"),c.GetString("pr_cd_colonia"))
|
||||
' Next
|
||||
'End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
' If g.GPSEnabled=False Then
|
||||
' ToastMessageShow("Habilitar el GPS", True)
|
||||
' StartActivity(g.LocationSettingsIntent)
|
||||
' Else
|
||||
' g.Start(0,0)
|
||||
' End If
|
||||
Subs.centraPanel(p_principal, Activity.Width)
|
||||
' Titulo.Left = Round(p_principal.Width/2)-(Titulo.Width/2)
|
||||
L_CANT.Text =""
|
||||
L_TOTAL.Text=""
|
||||
c=Starter.skmt.ExecQuery("select count(*) as EXISTE from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 ")
|
||||
C.Position=0
|
||||
Existe = C.GetString("EXISTE")
|
||||
C.Close
|
||||
c=Starter.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 order by HVD_PRONOMBRE asc")
|
||||
ListView1.Clear
|
||||
Subs.SetDivider(ListView1, Colors.LightGray, 2)
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 12
|
||||
label1.TextColor = Colors.black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 12
|
||||
label2.TextColor = Colors.black
|
||||
ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT"))
|
||||
Next
|
||||
End If
|
||||
If Existe <> 0 Then
|
||||
c=Starter.skmt.ExecQuery("select SUM(HVD_CANT) AS PC_NOART, SUM(HVD_COSTO_TOT) AS PC_MONTO from HIST_VENTAS where HVD_CLIENTE in (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 ")
|
||||
C.Position=0
|
||||
L_CANT.Text = c.GetString("PC_NOART")
|
||||
L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||
End If
|
||||
|
||||
|
||||
c=Starter.skmt.ExecQuery("select count(*) as EXISTE from PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
Existe = C.GetString("EXISTE")
|
||||
C.Close
|
||||
c=Starter.skmt.ExecQuery("select PE_PRONOMBRE,PE_COSTO_TOT, PE_CANT FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_PRONOMBRE asc")
|
||||
'ListView1.Clear
|
||||
Subs.SetDivider(ListView1, Colors.LightGray, 2)
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 12
|
||||
label1.TextColor = Colors.White
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 12
|
||||
label2.TextColor = Colors.White
|
||||
ListView1.AddTwoLines("VENTA" & c.GetString("PE_PRONOMBRE"),"Cantidad #"& c.GetString("PE_CANT")& " SubTotal $"& c.GetString("PE_COSTO_TOT"))
|
||||
'folio = c.GetString("PE_FOLIO")
|
||||
Next
|
||||
End If
|
||||
If Existe <> 0 Then
|
||||
c=Starter.skmt.ExecQuery("select SUM(PE_CANT) AS PE_CANT, SUM(PE_COSTO_TOT) AS PE_COSTO_TOT FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
L_CANT.Text = L_CANT.Text + c.GetString("PE_CANT")
|
||||
L_TOTAL.Text = L_TOTAL.Text + c.GetString("PE_COSTO_TOT")
|
||||
End If
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
' lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
' lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
Sub Regresar_Click
|
||||
StartActivity(fila)
|
||||
End Sub
|
||||
|
||||
Sub Activity_KeyPress (key As Int) As Boolean
|
||||
' BACK key pressed
|
||||
If key=KeyCodes.KEYCODE_BACK Then
|
||||
' I want to capture the key here so I return True
|
||||
StartActivity(seleccion)
|
||||
'Return True
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
nombre_prod = Value
|
||||
result = Msgbox2("Seguro que desa borrar este articulo?","Borrar Articulo", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
c=Starter.skmt.ExecQuery2("select HVD_CANT FROM hist_ventas where HVD_pronombre = ? and HVD_cliente in (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 ", Array As String(Value))
|
||||
c.Position=0
|
||||
If c.GetString("HVD_CANT") > 1 Then
|
||||
Regresar.Visible =False
|
||||
borra.Visible=False
|
||||
P1.Visible =True
|
||||
cuantos_pedido = c.GetString("HVD_CANT")
|
||||
lv2.Clear
|
||||
lv2.SingleLineLayout.Label.TextColor = Colors.Black
|
||||
For i=1 To c.GetString("HVD_CANT")
|
||||
lv2.AddSingleLine(i)
|
||||
Next
|
||||
Else
|
||||
' skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?", Array As Object(c.GetString("HVD_CANT"),Value))
|
||||
c.Close
|
||||
Starter.skmt.ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT,REP_FECHA) select HVD_CLIENTE, HVD_PRONOMBRE, HVD_CANT, HVD_COSTO_TOT, HVD_FECHA from hist_ventas where HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
||||
|
||||
c=Starter.skmt.ExecQuery2("select HVD_CANT FROM hist_ventas where HVD_pronombre = ? and HVD_cliente in (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 ", Array As String(Value))
|
||||
c.Position=0
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?", Array As Object(c.GetString("HVD_CANT"),Value))
|
||||
c.Close
|
||||
|
||||
'skmt.ExecNonQuery2("delete FROM HIST_VENTAS WHERE HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
||||
' se cambia por update para no borrarlo y tener todos los registros.
|
||||
Starter.skmt.ExecNonQuery2("update HIST_VENTAS set HVD_RECHAZO = 1 WHERE HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
||||
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'quitar esta mamada no es ahi
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 3 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Activity_Resume
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub lv2_ItemClick (Position As Int, Value As Object)
|
||||
' If Value = "Todos" Then
|
||||
' cuantos = c.GetString("HVD_CANT")
|
||||
'Else
|
||||
cuantos = Value
|
||||
' End If
|
||||
If cuantos = cuantos_pedido Then
|
||||
'Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?", Array As Object(c.GetString("HVD_CANT"),nombre_prod))
|
||||
c.Close
|
||||
Starter.skmt.ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT,REP_FECHA) select HVD_CLIENTE, HVD_PRONOMBRE, HVD_CANT, HVD_COSTO_TOT, HVD_FECHA from hist_ventas where HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(nombre_prod))
|
||||
c=Starter.skmt.ExecQuery2("select HVD_CANT FROM hist_ventas where HVD_pronombre = ? and HVD_cliente in (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 ", Array As String(nombre_prod))
|
||||
c.Position=0
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?", Array As Object(c.GetString("HVD_CANT"),nombre_prod))
|
||||
c.Close
|
||||
'Starter.skmt.ExecNonQuery2("delete FROM HIST_VENTAS WHERE HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
||||
' se cambia por update para no borrarlo y tener todos los registros.
|
||||
Starter.skmt.ExecNonQuery2("update HIST_VENTAS set HVD_RECHAZO = 1 WHERE HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 ", Array As String(Value))
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'quitar esta m*m*d* no es ahi
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 3 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Starter.skmt.ExecNonQuery2("update hist_Ventas set HVD_RECHAZO = 1, HVD_PARCIAL = 0, HVD_CANT = HVD_CANT - ? where HVD_pronombre = ? and HVD_cliente in (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 ", Array As Object(cuantos, nombre_prod))
|
||||
Regresar.Visible =True
|
||||
borra.Visible=True
|
||||
P1.Visible =False
|
||||
Activity_Resume
|
||||
Else
|
||||
' skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?", Array As Object(cuantos,nombre_prod))
|
||||
c.Close
|
||||
|
||||
'modificar tambien esto
|
||||
'Modificaciones para que solo quite una parte.
|
||||
Starter.skmt.ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT, REP_FECHA ) select HVD_CLIENTE, HVD_PRONOMBRE, ?, ? * (HVD_COSTO_TOT/?), HVD_FECHA from hist_ventas where HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As Object(cuantos,cuantos,cuantos_pedido, nombre_prod))
|
||||
Starter.skmt.ExecNonQuery2("insert into hist_ventas(HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT, HVD_FECHA, HVD_CODPROMO, HVD_PROID,HVD_NUM_TICKET, HVD_NUM_REGISTRO, HVD_RECHAZO, HVD_ESTATUS, HVD_PARCIAL) select HVD_CLIENTE,HVD_PRONOMBRE,?,HVD_COSTO_TOT, HVD_FECHA, HVD_CODPROMO, HVD_PROID,HVD_NUM_TICKET, HVD_NUM_REGISTRO, 1, HVD_ESTATUS, 1 from hist_ventas where HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As Object(cuantos, nombre_prod))
|
||||
Starter.skmt.ExecNonQuery2("update hist_Ventas set HVD_RECHAZO = 0, HVD_PARCIAL = 1, HVD_CANT = HVD_CANT - ? where HVD_pronombre = ? and HVD_cliente in (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 ", Array As Object(cuantos, nombre_prod))
|
||||
Starter.skmt.ExecNonQuery2("update hist_Ventas set HVD_COSTO_TOT = HVD_CANT * (HVD_COSTO_TOT/?) where HVD_pronombre = ? and HVD_cliente in (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 ", Array As Object(cuantos_pedido, nombre_prod))
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?", Array As Object(cuantos,nombre_prod))
|
||||
'crear nueva tabla para que guarde el resto.
|
||||
' skmt.ExecNonQuery2("delete FROM HIST_VENTAS WHERE HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 3 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Activity_Resume
|
||||
Regresar.Visible =True
|
||||
borra.Visible=True
|
||||
P1.Visible =False
|
||||
End If
|
||||
End Sub
|
||||
128
MAPA_CLIENTE.bas
Normal file
@@ -0,0 +1,128 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=9.95
|
||||
@EndOfDesignText@
|
||||
#Region Activity Attributes
|
||||
#FullScreen: False
|
||||
#IncludeTitle: FALSE
|
||||
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
Dim GPS As GPS
|
||||
Dim rp As RuntimePermissions
|
||||
Dim ruta As String
|
||||
Dim skmt As SQL
|
||||
End Sub
|
||||
|
||||
Sub Globals
|
||||
Private gmap As GoogleMap
|
||||
Private MapFragment1 As MapFragment
|
||||
Dim Latitud As Double = 0
|
||||
Dim Longitud As Double = 0
|
||||
Dim Lat2 As Double = 0
|
||||
Dim Lon2 As Double = 0
|
||||
Dim p1, p2 As Location
|
||||
Dim Distance As Float
|
||||
Dim boton1 As Button
|
||||
Dim c As Cursor
|
||||
Dim latmarker As String
|
||||
Dim longmarker As String
|
||||
Private l_long As Label
|
||||
Private l_lat As Label
|
||||
Private NOMBRE_TIENDA As String
|
||||
Private p_principal As Panel
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
Activity.LoadLayout("mapa_cliente")
|
||||
If MapFragment1.IsGooglePlayServicesAvailable = False Then
|
||||
ToastMessageShow("Please install Google Play Services.", True)
|
||||
End If
|
||||
' Boton velocidad'
|
||||
' boton1.Initialize(0)
|
||||
' boton1.Text = 0 &" "&"km/h"
|
||||
' boton1.TextColor = Colors.Red
|
||||
' boton1.TextSize = 15
|
||||
' boton1.Visible=False
|
||||
' Activity.AddView(boton1, 40%x, 5dip, 25%x, 40dip)
|
||||
'Fin Boton velocidad'
|
||||
'GPS.Start(0, 0)
|
||||
End Sub
|
||||
|
||||
Sub MapFragment1_Ready
|
||||
gmap = MapFragment1.GetMap
|
||||
'permisos
|
||||
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
gmap.MyLocationEnabled = Result
|
||||
'fin de permisos
|
||||
Dim JavaMapsObject As JavaObject
|
||||
JavaMapsObject = gmap.GetUiSettings
|
||||
JavaMapsObject.RunMethod("setMapToolbarEnabled", Array As Object(True))
|
||||
|
||||
' Log($"AltoPanel: ${p_principal.Height}"$)
|
||||
' Private altoMapa As Int = DipToCurrent(p_principal.Height*0.5o)
|
||||
' Private anchoMapa As Int = DipToCurrent(p_principal.Width*0.6)
|
||||
'' p_principal.GetView(0).SetLayout(15dip, 15dip, anchoMapa, altoMapa)
|
||||
' p_principal.GetView(0).Height = altoMapa
|
||||
|
||||
'marcadores
|
||||
' Dim latmarker As Double =19.3931867
|
||||
' Dim longmarker As Double =-99.1439178
|
||||
Dim marcador1 As Marker = gmap.AddMarker (latmarker,longmarker, "TIENDA")
|
||||
marcador1.Snippet = fila.NOMBRE
|
||||
'"Tienda 1"
|
||||
|
||||
|
||||
'posicion inicial
|
||||
Dim aa As CameraPosition
|
||||
aa.Initialize(latmarker,longmarker,15)''' RECOMENDABLE CAMBIAR A 10 SI ES MAS DE 1 MARCADOR
|
||||
gmap.AnimateCamera(aa)
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Parametro As Location)
|
||||
' GPS.Start(0, 0)
|
||||
' Dim sp As Int
|
||||
' sp = Ceil(Parametro.Speed * 3.6)
|
||||
' boton1.Text = sp &" "&"km/h"
|
||||
' Latitud = Parametro.Latitude
|
||||
' Longitud = Parametro.Longitude
|
||||
' p2.Initialize2(Latitud,Longitud)
|
||||
' p1.Initialize2(Lat2, Lon2)
|
||||
' Distance = p1.DistanceTo(p2)
|
||||
' If Latitud <> 0 And Longitud <> 0 Then
|
||||
' If Distance > 10 Then
|
||||
' Lat2 = Latitud
|
||||
' Lon2 = Longitud
|
||||
' Dim cp As CameraPosition
|
||||
' cp.Initialize2(Parametro.Latitude, Parametro.Longitude, gmap.CameraPosition.Zoom, Parametro.Bearing, 0)
|
||||
' gmap.AnimateCamera(cp)
|
||||
' End If
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
GPS.Initialize("GPS")
|
||||
If GPS.GPSEnabled = False Then
|
||||
ToastMessageShow("Debe Activar el GPS del Equipo.", True)
|
||||
StartActivity(GPS.LocationSettingsIntent)
|
||||
Else
|
||||
GPS.Start(0, 0)
|
||||
End If
|
||||
Subs.centraPanel(p_principal, Activity.Width)
|
||||
p_principal.Height = Activity.Height * 0.95
|
||||
latmarker = fila.LATITUD
|
||||
longmarker = fila.LONGITUD
|
||||
NOMBRE_TIENDA = fila.NOMBRE
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
GPS.Stop
|
||||
End Sub
|
||||
|
||||
Sub reg_Click
|
||||
StartActivity(fila)
|
||||
End Sub
|
||||
326
MAPA_RUTAS.bas
Normal file
@@ -0,0 +1,326 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=9.3
|
||||
@EndOfDesignText@
|
||||
#Region Activity Attributes
|
||||
#FullScreen: False
|
||||
#IncludeTitle: False
|
||||
#End Region
|
||||
|
||||
'Activity module
|
||||
Sub Process_Globals
|
||||
Dim GPS As GPS
|
||||
Dim rp As RuntimePermissions
|
||||
' Dim skmt As SQL
|
||||
Dim c As Cursor
|
||||
Dim c2 As Cursor
|
||||
Dim c22 As Cursor
|
||||
Dim c3 As Cursor
|
||||
End Sub
|
||||
|
||||
Sub Globals
|
||||
Private gmap As GoogleMap
|
||||
Private MapFragment1 As MapFragment
|
||||
Dim Latitud As Double = 0
|
||||
Dim Longitud As Double = 0
|
||||
Dim Lat2 As Double = 0
|
||||
Dim Lon2 As Double = 0
|
||||
Dim p1, p2 As Location
|
||||
Dim Distance As Float
|
||||
Dim boton1 As Button
|
||||
Dim HUE_BLUE As Float
|
||||
Dim HUE_RED As Float
|
||||
Dim HUE_GREEN As Float
|
||||
Private B_AZUL As Button
|
||||
Private B_ROJO As Button
|
||||
Private B_VERDE As Button
|
||||
Private B_TODOS As Button
|
||||
Dim Tienda As String
|
||||
Dim ruta, rutaAnt As String
|
||||
Dim LatitudRu As Double
|
||||
Dim LongitudRU As Double
|
||||
Dim LIST_AZUL As List
|
||||
Dim LIST_ROJO As List
|
||||
Dim LIST_VERDE As List
|
||||
Dim MARK_AZUL As Marker
|
||||
Dim MARK_ROJO As Marker
|
||||
Dim MARK_VERDE As Marker
|
||||
Dim MARK_CEDIS As Marker
|
||||
Dim rojo As String
|
||||
Dim azul As String
|
||||
Dim verde As String
|
||||
Dim todos As String
|
||||
Dim NumSerie As Int
|
||||
Dim OnInfoWindowClickListener1 As OnInfoWindowClickListener
|
||||
Dim GoogleMapEXTRA As GoogleMapsExtras
|
||||
Dim CODIGO As String
|
||||
Private SEMANA As String
|
||||
' Dim ruta As String
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
' Msgbox("0","AVISO")
|
||||
Activity.LoadLayout("MAPA_RUTAS")
|
||||
' ruta = Main.ruta
|
||||
' If File.Exists(RUTA, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", RUTA, "kmt.db")
|
||||
' End If
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
'GPS
|
||||
' If(FirstTime) Then
|
||||
' GPS.Initialize("GPS")
|
||||
' End If
|
||||
' Msgbox("0.0","AVISO")
|
||||
If MapFragment1.IsGooglePlayServicesAvailable = False Then
|
||||
ToastMessageShow("Please install Google Play Services.", True)
|
||||
End If
|
||||
' Msgbox("0.1","AVISO")
|
||||
'Boton velocidad'
|
||||
' boton1.Initialize(0)
|
||||
' boton1.Text = 0 &" "&"km/h"
|
||||
' boton1.TextColor = Colors.Red
|
||||
' boton1.TextSize = 15
|
||||
' Activity.AddView(boton1, 40%x, 5dip, 25%x, 40dip)
|
||||
'Fin Boton velocidad'
|
||||
'MARK_CEDIS.IsInitialized
|
||||
MARK_AZUL.IsInitialized
|
||||
MARK_ROJO.IsInitialized
|
||||
MARK_VERDE.IsInitialized
|
||||
|
||||
LIST_AZUL.Initialize
|
||||
LIST_ROJO.Initialize
|
||||
LIST_VERDE.Initialize
|
||||
|
||||
verde = 0
|
||||
azul = 0
|
||||
rojo = 0
|
||||
todos = 1
|
||||
' c=skmt.ExecQuery2("select count(*) AS CUANTOS from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA"))
|
||||
' c.Position =0
|
||||
' SEMANA = c.GetString("CUANTOS")
|
||||
' c.Close
|
||||
'
|
||||
' If SEMANA > 0 Then
|
||||
' c=skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA"))
|
||||
' c.Position =0
|
||||
' SEMANA = c.GetString("CAT_VA_VALOR")
|
||||
' c.Close
|
||||
' End If
|
||||
|
||||
' Msgbox("0.2","AVISO")
|
||||
End Sub
|
||||
|
||||
Sub MapFragment1_Ready
|
||||
' Msgbox("111","AVISO")
|
||||
gmap = MapFragment1.GetMap
|
||||
gmap.IsInitialized
|
||||
|
||||
'todos= 1
|
||||
'permisos
|
||||
' Msgbox("11","AVISO")
|
||||
|
||||
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
gmap.MyLocationEnabled = Result
|
||||
|
||||
Dim JavaMapsObject As JavaObject
|
||||
JavaMapsObject = gmap.GetUiSettings
|
||||
JavaMapsObject.RunMethod("setMapToolbarEnabled", Array As Object(True))
|
||||
|
||||
' Msgbox("12","AVISO")
|
||||
|
||||
'''''''----------------------------MARKER AZUL - POR ENTREGAR
|
||||
Private esteAzul As Int = 0
|
||||
Private esteAzul2 As Float
|
||||
If azul = 1 Or todos = 1 Then
|
||||
c.IsInitialized
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE, CAT_CL_LAT, CAT_CL_LONG, CAT_CL_RUTA from kmt_info where gestion = 0 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 order by CAT_CL_RUTA")
|
||||
' Msgbox("2","AVISO")
|
||||
rutaAnt = ""
|
||||
For i = 0 To c.RowCount -1
|
||||
c.Position = i
|
||||
LatitudRu = c.GetString("CAT_CL_LAT")
|
||||
LongitudRU = c.GetString("CAT_CL_LONG")
|
||||
CODIGO=c.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c.GetString("CAT_CL_NOMBRE")
|
||||
ruta = c.GetString("CAT_CL_RUTA")
|
||||
If rutaAnt <> ruta Then esteAzul = esteAzul + 1
|
||||
If esteAzul = 1 Then esteAzul2=gmap.HUE_AZURE-25
|
||||
If esteAzul = 2 Then esteAzul2=gmap.HUE_AZURE
|
||||
If esteAzul = 3 Then esteAzul2=gmap.HUE_AZURE+25
|
||||
If esteAzul = 4 Then esteAzul2=gmap.HUE_AZURE+50
|
||||
If esteAzul = 5 Then esteAzul2=gmap.HUE_AZURE+75
|
||||
' Log(ruta & "|" & esteAzul & "|" & esteAzul2)
|
||||
MARK_AZUL = gmap.AddMarker2(LatitudRu,LongitudRU, CODIGO, esteAzul2)
|
||||
MARK_AZUL.Snippet = "R: " & ruta & " - " & Tienda
|
||||
rutaAnt = ruta
|
||||
Next
|
||||
c .Close
|
||||
If MARK_AZUL.IsInitialized Then LIST_AZUL.Add(MARK_AZUL)
|
||||
End If
|
||||
' Msgbox("3","AVISO")
|
||||
'''''''----------------------------MARKER VERDE- ENTREGADO
|
||||
If verde = 1 Or todos = 1 Then
|
||||
rutaAnt = ""
|
||||
c2.IsInitialized
|
||||
c2=Starter.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE, CAT_CL_LONG, CAT_CL_LAT, CAT_CL_RUTA from kmt_info where gestion = 2 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 order by CAT_CL_RUTA")
|
||||
For i = 0 To c2.RowCount -1
|
||||
c2.Position = i
|
||||
LongitudRU = c2.GetString("CAT_CL_LONG")
|
||||
LatitudRu = c2.GetString("CAT_CL_LAT")
|
||||
CODIGO=c2.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c2.GetString("CAT_CL_NOMBRE")
|
||||
ruta = c2.GetString("CAT_CL_RUTA")
|
||||
MARK_VERDE = gmap.AddMarker2(LatitudRu,LongitudRU, CODIGO,gmap.HUE_GREEN)
|
||||
MARK_VERDE.Snippet = "R:" & ruta & ", " & Tienda
|
||||
Next
|
||||
Else
|
||||
If verde = 1 Or todos = 1 Then
|
||||
rutaAnt = ""
|
||||
c2.IsInitialized
|
||||
c2=Starter.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE, CAT_CL_LONG, CAT_CL_LAT, CAT_CL_RUTA from kmt_info where gestion = 2 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 order by CAT_CL_RUTA")
|
||||
For i = 0 To c2.RowCount -1
|
||||
c2.Position = i
|
||||
LongitudRU = c2.GetString("CAT_CL_LONG")
|
||||
LatitudRu = c2.GetString("CAT_CL_LAT")
|
||||
CODIGO=c2.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c2.GetString("CAT_CL_NOMBRE")
|
||||
ruta = c2.GetString("CAT_CL_RUTA")
|
||||
MARK_VERDE = gmap.AddMarker2(LatitudRu,LongitudRU, CODIGO,gmap.HUE_GREEN)
|
||||
MARK_VERDE.Snippet = "R:" & ruta & ", " & Tienda
|
||||
Next
|
||||
c2 .Close
|
||||
If MARK_VERDE.IsInitialized Then LIST_VERDE.Add(MARK_VERDE)
|
||||
End If
|
||||
End If
|
||||
|
||||
' '''''''----------------------------MARKER ROJO - NO ENTREGADO
|
||||
|
||||
If rojo = 1 Or todos = 1 Then
|
||||
rutaAnt = ""
|
||||
c3.IsInitialized
|
||||
c3=Starter.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE, CAT_CL_LONG, CAT_CL_LAT, CAT_CL_RUTA from kmt_info where gestion = 3 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 order by CAT_CL_RUTA")
|
||||
For i = 0 To c3.RowCount -1
|
||||
c3.Position = i
|
||||
LongitudRU = c3.GetDouble("CAT_CL_LONG")
|
||||
LatitudRu = c3.GetDouble("CAT_CL_LAT")
|
||||
Tienda= c3.GetString("CAT_CL_NOMBRE")
|
||||
ruta = c3.GetString("CAT_CL_RUTA")
|
||||
CODIGO=c3.GetString("CAT_CL_CODIGO")
|
||||
MARK_ROJO = gmap.AddMarker2(LatitudRu,LongitudRU, CODIGO,gmap.HUE_RED)
|
||||
MARK_ROJO.Snippet= "R:" & ruta & ", " & Tienda
|
||||
Next
|
||||
Else
|
||||
If rojo = 1 Or todos = 1 Then
|
||||
rutaAnt = ""
|
||||
c3.IsInitialized
|
||||
c3=Starter.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE, CAT_CL_LONG, CAT_CL_LAT, CAT_CL_RUTA from kmt_info where gestion = 3 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 order by CAT_CL_RUTA")
|
||||
For i = 0 To c3.RowCount -1
|
||||
c3.Position = i
|
||||
LongitudRU = c3.GetDouble("CAT_CL_LONG")
|
||||
LatitudRu = c3.GetDouble("CAT_CL_LAT")
|
||||
Tienda= c3.GetString("CAT_CL_NOMBRE")
|
||||
ruta = c2.GetString("CAT_CL_RUTA")
|
||||
CODIGO=c3.GetString("CAT_CL_CODIGO")
|
||||
MARK_ROJO = gmap.AddMarker2(LatitudRu,LongitudRU, CODIGO,gmap.HUE_RED)
|
||||
MARK_ROJO.Snippet= "R:" & ruta & ", " & Tienda
|
||||
Next
|
||||
If MARK_ROJO.IsInitialized Then LIST_ROJO.Add(MARK_ROJO)
|
||||
c3.Close
|
||||
End If
|
||||
End If
|
||||
''------------------------------
|
||||
' MARK_CEDIS = gmap.AddMarker3("19.3961802","-99.0784293","CEDIS", LoadBitmap(File.DirAssets, "marker-azul-0.png"))
|
||||
' If MARK_VERDE.Visible Or MARK_ROJO.Visible Then
|
||||
' MARK_CEDIS.Remove
|
||||
' End If
|
||||
Dim aa As CameraPosition
|
||||
aa.Initialize(LatitudRu,LongitudRU,15)''' RECOMENDABLE CAMBIAR A 10 PARA QUE SE VEAN MAS MARCADORES
|
||||
gmap.AnimateCamera(aa)
|
||||
|
||||
'''''---------------------- ESTO ES PARA LOS CLICK EN LAS VENTANAS D INFORMACION-----------
|
||||
Dim OnInfoWindowClickListener1 As OnInfoWindowClickListener
|
||||
OnInfoWindowClickListener1.Initialize("OnInfoWindowClickListener1")
|
||||
GoogleMapEXTRA.SetOnInfoWindowClickListener(gmap, OnInfoWindowClickListener1)
|
||||
End Sub
|
||||
|
||||
''''-------------------------- PRUEBA CON MARKER _CLICK
|
||||
|
||||
Sub OnInfoWindowClickListener1_click(Marker1 As Marker)
|
||||
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?) ", Array As Object(Marker1.Title))
|
||||
StartActivity(fila)
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Parametro As Location)
|
||||
'MARK_CEDIS.IsInitialized
|
||||
' Dim sp As Int
|
||||
' sp = Ceil(Parametro.Speed * 3.6)
|
||||
' boton1.Text = sp &" "&"km/h"
|
||||
' Latitud = Parametro.Latitude
|
||||
' Longitud = Parametro.Longitude
|
||||
' p2.Initialize2(Latitud,Longitud)
|
||||
' p1.Initialize2(Lat2, Lon2)
|
||||
' Distance = p1.DistanceTo(p2)
|
||||
' If Latitud <> 0 And Longitud <> 0 Then
|
||||
' If Distance > 10 Then
|
||||
' Lat2 = Latitud
|
||||
' Lon2 = Longitud
|
||||
' Dim cp As CameraPosition
|
||||
' cp.Initialize2(Parametro.Latitude, Parametro.Longitude, gmap.CameraPosition.Zoom, Parametro.Bearing, 0)
|
||||
' gmap.AnimateCamera(cp)
|
||||
' End If
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
' If GPS.GPSEnabled = False Then
|
||||
' ToastMessageShow("Debe Activar el GPS del Equipo.", True)
|
||||
' StartActivity(GPS.LocationSettingsIntent)
|
||||
' Else
|
||||
' GPS.Start(0, 0)
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
GPS.Stop
|
||||
End Sub
|
||||
|
||||
Sub B_TODOS_Click
|
||||
todos =1
|
||||
verde = 0
|
||||
azul = 0
|
||||
rojo = 0
|
||||
MapFragment1_Ready
|
||||
End Sub
|
||||
|
||||
Sub B_VERDE_Click
|
||||
verde = 1
|
||||
azul = 0
|
||||
rojo = 0
|
||||
todos = 0
|
||||
gmap.Clear
|
||||
MapFragment1_Ready
|
||||
End Sub
|
||||
|
||||
Sub B_ROJO_Click
|
||||
rojo = 1
|
||||
verde = 0
|
||||
azul = 0
|
||||
todos = 0
|
||||
gmap.Clear
|
||||
MapFragment1_Ready
|
||||
End Sub
|
||||
|
||||
Sub B_AZUL_Click
|
||||
azul = 1
|
||||
verde = 0
|
||||
rojo = 0
|
||||
todos = 0
|
||||
gmap.Clear
|
||||
MapFragment1_Ready
|
||||
End Sub
|
||||
|
||||
|
||||
128
Starter.bas
Normal file
@@ -0,0 +1,128 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
#Region Service Attributes
|
||||
#StartAtBoot: False
|
||||
#ExcludeFromLibrary: 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.
|
||||
Public rp As RuntimePermissions
|
||||
Dim skmt As SQL
|
||||
Dim ruta As String
|
||||
Private BTAdmin As BluetoothAdmin
|
||||
Public BluetoothState As Boolean
|
||||
Public rp As RuntimePermissions
|
||||
Public FLP As FusedLocationProvider
|
||||
Dim Timer1 As Timer
|
||||
Dim Interval As Int = 30
|
||||
'Para WebSockets
|
||||
' Dim monitor As Timer 'Lo usamos para monitorear los servicios Tracker y PushService
|
||||
' Dim monitorTicks As Int = 0
|
||||
Dim trackerActividad As String = "501231235959"
|
||||
Dim pushServiceActividad As String = "501231235959"
|
||||
'Para los Logs
|
||||
Private logs As StringBuilder
|
||||
Private logcat As LogCat
|
||||
Public SharedFolder As String 'Para actualizar apk
|
||||
Dim cedisLocation As Location
|
||||
Dim reqManager As DBRequestManager
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
'This is the program entry point.
|
||||
'This is a good place to load resources that are not specific to a single activity.
|
||||
ruta = File.DirInternal 'Ruta de la base de datos por defecto.
|
||||
' If File.ExternalWritable Then ruta = rp.GetSafeDirDefaultExternal("") 'Si podemos escribir a la tarjeta, cambiamos la ruta.
|
||||
If Not(File.Exists(ruta, "kmt.db")) Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db") 'Si no existe el archivo de la base de datos, lo copiamos.
|
||||
Log("db copiada a " & ruta & "kmt.db")
|
||||
End If
|
||||
Log(ruta)
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
' CallSubDelayed(PushService, "SubscribeToTopics")
|
||||
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
|
||||
' BTAdmin.Initialize("admin")
|
||||
' If BTAdmin.IsEnabled = False Then
|
||||
' If BTAdmin.Enable = False Then
|
||||
' ToastMessageShow("Error enabling Bluetooth adapter.", True)
|
||||
' Else
|
||||
' ToastMessageShow("Enabling Bluetooth adapter...", False)
|
||||
' End If
|
||||
' Else
|
||||
' BluetoothState = True
|
||||
' End If
|
||||
' reqManager.Initialize(Me, Main.server)
|
||||
Timer1.Initialize("Timer1", Interval * 1000)
|
||||
Timer1.Enabled = True
|
||||
SharedFolder = rp.GetSafeDirDefaultExternal("")
|
||||
cedisLocation.Initialize
|
||||
cedisLocation.Latitude = "20.529047064198483"
|
||||
cedisLocation.Longitude = "-103.25068553885922"
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||
' StartService(PushService)
|
||||
' monitor.Initialize("monitor", 30000)
|
||||
' monitor.Enabled = True
|
||||
Subs.revisaBD
|
||||
End Sub
|
||||
|
||||
Sub Service_TaskRemoved
|
||||
'This event will be raised when the user removes the app from the recent apps list.
|
||||
End Sub
|
||||
|
||||
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
|
||||
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
|
||||
Return True
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Timer1_Tick
|
||||
' ToastMessageShow("Timer",False)
|
||||
LogColor("Siguiente actualizacion " & DateTime.Time(DateTime.Now + Interval * 1000),Colors.Blue)
|
||||
ENVIA_ULTIMA_GPS
|
||||
End Sub
|
||||
|
||||
Sub ENVIA_ULTIMA_GPS
|
||||
Dim skmt As SQL
|
||||
Dim cmd As DBCommand
|
||||
Dim reqManager As DBRequestManager
|
||||
reqManager.Initialize(Me, Main.server)
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
' Log("server: "&Main.server)
|
||||
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
|
||||
If Main.logger Then Log("Iniciamos ENVIA_ULTIMA_GPS")
|
||||
DateTime.TimeFormat = "HHmmss"
|
||||
Main.ultimaActualizacionGPS = DateTime.Time(DateTime.Now)
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_fechat"
|
||||
reqManager.ExecuteQuery(cmd , 0, "fechat")
|
||||
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "UPDATE_INTMEX_ACTUALR3_GPS"
|
||||
cmd.Parameters = Array As Object(Main.montoActual,Main.clientestotal, Main.clientesventa,Main.clientesvisitados,Main.lat_gps,Main.lon_gps,Main.batt,0, 0, Main.ALMACEN,Main.rutapreventa )
|
||||
Log($"montoActual: ${Main.montoActual}, cTotal: ${Main.clientestotal}, cVenta: ${Main.clientesventa}, cVisitados: ${Main.clientesvisitados}, ${Main.lat_gps}, ${Main.lon_gps}, Batt: ${Main.batt}, 0, 0, 0, Almacen: ${Main.ALMACEN}, Ruta: ${Main.rutapreventa}"$)
|
||||
|
||||
reqManager.ExecuteCommand(cmd, "inst_visitas")
|
||||
'' If Main.logger Then Log("ubic_tiempo_real")
|
||||
skmt.ExecNonQuery2("Update cat_variables set CAT_VA_VALOR = ? WHERE CAT_VA_DESCRIPCION = ?" , Array As String(DateTime.Time(DateTime.Now),"HoraIngreso"))
|
||||
|
||||
'Reiniciamos el timer para cuando llamamos el Sub desde otra actividad
|
||||
Timer1.Enabled = False
|
||||
Timer1.Interval = Interval * 1000
|
||||
Timer1.Enabled = True
|
||||
End Sub
|
||||
617
Subs.bas
Normal file
@@ -0,0 +1,617 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=StaticCode
|
||||
Version=11
|
||||
@EndOfDesignText@
|
||||
'Code module
|
||||
'Subs in this code module will be accessible from all modules.
|
||||
Sub Process_Globals
|
||||
'These global variables will be declared once when the application starts.
|
||||
'These variables can be accessed from all modules.
|
||||
Public GZip As GZipStrings
|
||||
Private su As StringUtils
|
||||
Dim phn As Phone
|
||||
Dim devModel As String
|
||||
Dim kmt, errorLog As SQL 'Requiere la libreria "SQL"
|
||||
' Dim wifi As MLwifi
|
||||
Dim ssid As String 'ignore
|
||||
Dim rutaMaxPoints As Int = 3000
|
||||
Dim rutaHrsAtras As Int = 48
|
||||
' Dim rutaInicioHoy As String = ""
|
||||
End Sub
|
||||
|
||||
'Pone el valor de phn.Model en la variable global "devModel"
|
||||
Sub getPhnId As String 'ignore
|
||||
'Requiere la libreria "Phone"
|
||||
devModel = phn.Model
|
||||
If devModel.Length <= 3 Then 'Si phn.Model esta en blanco ...
|
||||
Dim t As String = phn.GetSettings("android_id") 'Intentamos con "android_id"
|
||||
devModel = t
|
||||
End If
|
||||
If devModel.Length >= 3 Then 'Si tenemos valor para phn.Model
|
||||
File.WriteString(File.DirInternal, "phnId.txt", devModel) 'Sobreescribimos archivo phnId.txt with deviceId
|
||||
' Log("Tenemos phnId: "&devModel&" "&File.DirInternal&"/phn.txt sobreescrito")
|
||||
Else If devModel.Length < 3 Then ' Si no tenemos valor, lo leemos de phnId.txt
|
||||
Dim s As String = File.ReadString(File.DirInternal, "phnId.txt")
|
||||
devModel = s
|
||||
' Log("Leemos id de "&File.DirInternal&"/phnId.txt")
|
||||
' Log(devModel)
|
||||
End If
|
||||
Return devModel
|
||||
End Sub
|
||||
|
||||
'Comprime y regresa un texto (str) en base64
|
||||
Sub compress(str As String) As String 'ignore
|
||||
'Requiere la libreria "CompressStrings"
|
||||
Dim compressed() As Byte = GZip.compress(str)
|
||||
' Log($"UncompressedBytesLength: ${str.Length}"$)
|
||||
' Log($"CompressedBytesLength: ${compressed.Length}"$)
|
||||
Dim base64 As String = su.EncodeBase64(compressed)
|
||||
Log($"Comprimido: ${base64.Length}"$)
|
||||
' Log($"CompressedBytes converted to base64: ${base64}"$)
|
||||
Return base64
|
||||
End Sub
|
||||
|
||||
'Descomprime y regresa un texto en base64
|
||||
Sub decompress(base64 As String) As String 'ignore
|
||||
Dim decompressedbytes() As Byte = su.DecodeBase64(base64)
|
||||
' Log($"decompressedbytesLength: ${decompressedbytes.Length}"$)
|
||||
Dim bc As ByteConverter
|
||||
Dim uncompressed As String = bc.StringFromBytes(decompressedbytes,"UTF8")
|
||||
Log($"Descomprimido: ${uncompressed.Length}"$)
|
||||
' Log($"Decompressed String = ${uncompressed}"$)
|
||||
Return uncompressed
|
||||
End Sub
|
||||
|
||||
'Convierte una fecha al formato yyMMddHHmmss
|
||||
Sub fechaKMT(fecha As String) As String 'ignore
|
||||
' Log(fecha)
|
||||
Dim OrigFormat As String = DateTime.DateFormat 'save orig date format
|
||||
DateTime.DateFormat="yyMMddHHmmss"
|
||||
Dim nuevaFecha As String=DateTime.Date(fecha)
|
||||
DateTime.DateFormat=OrigFormat 'return to orig date format
|
||||
' Log(nuevaFecha)
|
||||
Return nuevaFecha
|
||||
End Sub
|
||||
|
||||
'Genera una notificacion con importancia alta
|
||||
Sub notiHigh(title As String, body As String, activity As Object) 'ignore
|
||||
Private notif As Notification
|
||||
notif.Initialize2(notif.IMPORTANCE_HIGH)
|
||||
notif.Icon = "icon"
|
||||
notif.Vibrate = False
|
||||
notif.Sound = False
|
||||
notif.AutoCancel = True
|
||||
Log("notiHigh: "&title)
|
||||
notif.SetInfo(title, body, activity)
|
||||
' Log("notiHigh SetInfo")
|
||||
notif.Notify(777)
|
||||
End Sub
|
||||
|
||||
'Regresa el objeto de una notificacion con importancia baja
|
||||
Sub notiLowReturn(title As String, Body As String, id As Int) As Notification 'ignore
|
||||
Private notification As Notification
|
||||
notification.Initialize2(notification.IMPORTANCE_LOW)
|
||||
Log("notiLowReturn: "&title)
|
||||
notification.Icon = "icon"
|
||||
notification.Sound = False
|
||||
notification.Vibrate = False
|
||||
notification.SetInfo(title, Body, Main)
|
||||
notification.Notify(id)
|
||||
' Log("notiLowReturn SetInfo")
|
||||
Return notification
|
||||
End Sub
|
||||
|
||||
'Escribimos las coordenadas y fecha a un archivo de texto
|
||||
Sub guardaInfoEnArchivo(coords As String) 'ignore
|
||||
' Cambiamos el formato de la hora
|
||||
Dim OrigFormat As String=DateTime.DateFormat 'save orig date format
|
||||
DateTime.DateFormat="MMM-dd HH:mm:ss"
|
||||
Dim lastUpdate As String=DateTime.Date(DateTime.Now)
|
||||
DateTime.DateFormat=OrigFormat 'return to orig date format
|
||||
|
||||
Dim ubic As String = coords&","&lastUpdate
|
||||
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "gps.txt", True)
|
||||
Dim s As String = ubic & CRLF
|
||||
Dim t() As Byte = s.GetBytes("UTF-8")
|
||||
out.WriteBytes(t, 0, t.Length)
|
||||
out.Close
|
||||
End Sub
|
||||
|
||||
'Escribimos las coordenadas (latitud, longitud, fecha) y fecha a una BD
|
||||
Sub guardaInfoEnBD(coords As String) 'ignore
|
||||
Log("Guardamos ubicacion en BD - "&coords)
|
||||
Try
|
||||
Dim latlon() As String = Regex.Split("\|", coords)
|
||||
If latlon.Length < 2 Then latlon = Regex.Split(",", coords) 'Si son menos de 2, entonces estan separadas por comas y no por "|"
|
||||
' If Main.Logger Then Log("LatLon="&latlon)
|
||||
If Not(kmt.IsInitialized) Then revisaBD
|
||||
kmt.ExecNonQuery2("INSERT INTO RUTA_GPS(fecha, lat, lon) VALUES (?,?,?)", Array As Object (latlon(2),latlon(0),latlon(1)))
|
||||
Catch
|
||||
Log(LastException)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Regresa la ruta solicitada comprimida y en base64
|
||||
Sub dameRuta(inicioRuta As String, origenRuta As String) As String 'ignore
|
||||
'Requiere la libreria "SQL"
|
||||
Dim fechaInicio As String
|
||||
Try 'incioRuta es numero
|
||||
inicioRuta = inicioRuta * 1
|
||||
' Log("fechaInicio numerica="&fechaInicio)
|
||||
fechaInicio = fechaKMT(DateTime.Now - (DateTime.TicksPerHour * inicioRuta))
|
||||
Catch 'inicioRuta es string
|
||||
fechaInicio = fechaInicioHoy
|
||||
' Log("fechaInicio string="&fechaInicio)
|
||||
End Try
|
||||
If Main.logger Then Log("fechaInicio: "&fechaInicio&" | rutaHrsAtras="&rutaHrsAtras) 'fechaKMT(DateTime.Now)
|
||||
Dim c As Cursor
|
||||
If kmt.IsInitialized = False Then kmt.Initialize(Starter.ruta, "kmt.db", True)
|
||||
If Main.logger Then Log("select FECHA, LAT, LON from "& origenRuta &" where FECHA > " & fechaInicio & " order by FECHA desc limit " & rutaMaxPoints)
|
||||
c = kmt.ExecQuery("select FECHA, LAT, LON from "& origenRuta &" where FECHA > " & fechaInicio & " order by FECHA desc limit " & rutaMaxPoints)
|
||||
c.Position = 0
|
||||
Dim ruta2 As String = ""
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
ruta2=ruta2&CRLF&c.GetString("LAT")&","&c.GetString("LON")&","&c.GetString("FECHA")
|
||||
Main.fechaRuta = c.GetString("FECHA")
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
Return compress(ruta2)
|
||||
End Sub
|
||||
|
||||
'Limpiamos la tabla RUTA_GPS de la BD
|
||||
Sub deleteGPS_DB 'ignore
|
||||
kmt.ExecNonQuery("delete from RUTA_GPS")
|
||||
kmt.ExecNonQuery("vacuum;")
|
||||
End Sub
|
||||
|
||||
'Limpiamos la tabla errorLog de la BD
|
||||
Sub deleteErrorLog_DB 'ignore
|
||||
If Not(errorLog.IsInitialized) Then revisaBD
|
||||
errorLog.ExecNonQuery("delete from errores")
|
||||
errorLog.ExecNonQuery("vacuum;")
|
||||
ToastMessageShow("Borrada", False)
|
||||
End Sub
|
||||
|
||||
'Borramos el archio "gps.txt"
|
||||
Sub borramosArchivoGPS 'ignore
|
||||
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "gps.txt", False)
|
||||
Dim s As String = ""
|
||||
Dim t() As Byte = s.GetBytes("UTF-8")
|
||||
out.WriteBytes(t, 0, t.Length)
|
||||
out.Close
|
||||
End Sub
|
||||
|
||||
'Revisa que exista la BD y si es necesario crea algunas tablas dentro de ella
|
||||
Sub revisaBD 'ignore
|
||||
If Not(File.Exists(Starter.ruta, "kmt.db")) Then
|
||||
File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
Log("db copiada a " & Starter.ruta & "kmt.db")
|
||||
End If
|
||||
If Not(kmt.IsInitialized) Then kmt.Initialize(Starter.ruta, "kmt.db", True)
|
||||
kmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS RUTA_GPS(FECHA INTEGER, LAT TEXT, LON TEXT)")
|
||||
' kmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS UUC(fecha INTEGER, lat TEXT, lon TEXT)") 'LastKnownLocation
|
||||
kmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS bitacora(fecha INTEGER, texto TEXT)") 'Bitacora
|
||||
'Tabla para la bitacora de errores
|
||||
If Not(errorLog.IsInitialized) Then errorLog.Initialize(Starter.ruta, "errorLog.db", True)
|
||||
errorLog.ExecNonQuery("CREATE TABLE IF NOT EXISTS errores(fecha INTEGER, error TEXT)")
|
||||
Try 'Intentamos usar "pragma_table_info" para revisar si existe la columna "reprogramar" en la tabla
|
||||
Dim c As Cursor=kmt.ExecQuery("SELECT COUNT(*) AS fCol FROM pragma_table_info('noventa') WHERE name='NV_REPROGRAMAR'")
|
||||
c.Position = 0
|
||||
If c.GetString("fCol") = 0 Then 'Si no esta la columna REPROGRAMAR la agregamos
|
||||
kmt.ExecNonQuery("ALTER TABLE noventa ADD COLUMN NV_REPROGRAMAR TEXT")
|
||||
End If
|
||||
Catch 'Si no funciona "pragma_table_info" lo hacemos con try/catch
|
||||
Try
|
||||
kmt.ExecNonQuery("ALTER TABLE noventa ADD COLUMN NV_REPROGRAMAR TEXT")
|
||||
Catch
|
||||
Log(LastException)
|
||||
End Try
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Obtiene el ssid al que esta conectado el telefono
|
||||
Sub getSSID 'ignore
|
||||
' 'Requiere la libreria "MLWifi400"
|
||||
' If wifi.isWifiConnected Then
|
||||
' ssid = wifi.WifiSSID
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
'Convierte un texto en formato JSON a un objeto "Map"
|
||||
Sub JSON2Map(theJson As String) As Map 'ignore
|
||||
'Requiere la libreria "JSON"
|
||||
Try
|
||||
Private json As JSONParser
|
||||
json.Initialize(theJson)
|
||||
Return json.NextObject
|
||||
Catch
|
||||
Log(LastException)
|
||||
log2DB("JSON2Map: "&LastException)
|
||||
Private m As Map = CreateMap("title":"Error generating JSON", "t":"Error", "Message":LastException, "text" : LastException)
|
||||
Return m
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Convierte un mapa a formato JSON
|
||||
Sub map2JSON(m As Map) As String 'ignore
|
||||
'Requiere la libreria "JSON"
|
||||
'Convierte un objecto "Map" a JSON
|
||||
Dim jg As JSONGenerator
|
||||
jg.Initialize(m)
|
||||
Dim t As String = jg.ToString
|
||||
Return t
|
||||
End Sub
|
||||
|
||||
'Mandamos "coords" en un mensaje a "Sprvsr"
|
||||
Sub mandamosLoc(coords As String) 'ignore
|
||||
'' Log("Iniciamos mandamosLoc "&coords)
|
||||
'' Log("locRequest="&Tracker.locRequest)
|
||||
' guardaInfoEnBD(coords)'Escribimos coordenadas y fecha a una bd
|
||||
' Dim t As String
|
||||
' If Tracker.locRequest="Activa" Then
|
||||
' If PushService.au = 1 Then
|
||||
' t = "au" ' es una actualizacion
|
||||
' Else
|
||||
' t = "u" ' es una peticion
|
||||
' End If
|
||||
' Dim params As Map = CreateMap("topic":"Sprvsr", "coords":coords, "t":t, "b":PushService.battery)
|
||||
' CallSub2(PushService, "mandaMensaje",params)
|
||||
' Tracker.locRequest="Enviada"
|
||||
' CallSubDelayed(Tracker,"CreateLocationRequest")
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
'Regresa la fecha y hora de hoy a las 00:00 en el formato "yyMMddHHMMSS"
|
||||
Sub fechaInicioHoy As String 'ignore
|
||||
Dim OrigFormat As String = DateTime.DateFormat 'save orig date format
|
||||
DateTime.DateFormat="yyMMdd"
|
||||
Private h As String = DateTime.Date(DateTime.Now)&"000000"
|
||||
DateTime.DateFormat=OrigFormat 'return to orig date format
|
||||
Log("Hoy="&h)
|
||||
Return h
|
||||
End Sub
|
||||
|
||||
'Guardamos "texto" a la bitacora
|
||||
Sub log2DB(texto As String) 'ignore
|
||||
LogColor(fechaKMT(DateTime.Now)&" - log2BD: '"&texto&"'", Colors.Magenta)
|
||||
If kmt.IsInitialized Then kmt.ExecNonQuery2("INSERT INTO bitacora(fecha, texto) VALUES (?,?)", Array As Object (fechaKMT(DateTime.now), texto))
|
||||
End Sub
|
||||
|
||||
'Regresa verdadero si ya pasaron XX minutos de la fecha dada
|
||||
Sub masDeXXMins(hora As Int, mins As Int) As Boolean 'ignore
|
||||
If (hora + mins * DateTime.TicksPerMinute) < DateTime.Now Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Regresa verdadero si ya pasaron XX minutos de la fechaKMT dada
|
||||
Sub masDeXXMinsKMT(hora As String, mins As Int) As Boolean 'ignore
|
||||
Try
|
||||
' LogColor($"Hora=${fechaKMT(fechaKMT2Ticks(hora) + mins * DateTime.TicksPerMinute)}, Mins=${mins}, Actual=${fechaKMT(DateTime.Now)}"$,Colors.red)
|
||||
If fechaKMT2Ticks(hora) + mins * DateTime.TicksPerMinute < DateTime.Now Then
|
||||
' Log("+++ +++ "&fechaKMT(fechaKMT2Ticks(hora) + mins * DateTime.TicksPerMinute) & " < " & fechaKMT(DateTime.Now))
|
||||
Return True
|
||||
Else
|
||||
' Log("+++ +++ "&fechaKMT(fechaKMT2Ticks(hora) + mins * DateTime.TicksPerMinute) & " > " & fechaKMT(DateTime.Now))
|
||||
Return False
|
||||
End If
|
||||
Catch
|
||||
Log(LastException)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Limpiamos la tabla "bitacora" de la BD
|
||||
Sub borraLogDB 'ignore
|
||||
LogColor("Borramos BD de log", Colors.Magenta)
|
||||
kmt.ExecNonQuery("delete from bitacora")
|
||||
kmt.ExecNonQuery("vacuum;")
|
||||
End Sub
|
||||
|
||||
'Monitoreamos los servicios para ver si estan activos (No pausados), y si no, los reniciamos
|
||||
Sub Monitor 'ignore
|
||||
' Private monitorStatus As Boolean = True
|
||||
' LogColor("Corriendo Subs.Monitor", Colors.RGB(161,150,0))
|
||||
' If IsPaused(Tracker) Then
|
||||
' log2DB("Reiniciando 'Tracker Pausado' desde Subs.Monitor")
|
||||
' StartService(Tracker)
|
||||
' monitorStatus = False
|
||||
' Else
|
||||
' revisaFLP
|
||||
' End If
|
||||
' If IsPaused(PushService) Then
|
||||
' log2DB("Reiniciando 'PushService Pausado' desde Subs.Monitor")
|
||||
' StartService(PushService)
|
||||
' monitorStatus = False
|
||||
' Else
|
||||
' revisaPushService
|
||||
' End If
|
||||
' If monitorStatus Then LogColor(" +++ +++ Servicios Activos", Colors.Green)
|
||||
End Sub
|
||||
|
||||
'Compara la UUG (Ultima Ubicacion Guardada) con FLP.LastKnowLocation y si
|
||||
'cumple con los requisitos de distancia y precision la guardamos en la BD.
|
||||
Sub revisaUUG 'ignore
|
||||
revisaFLP
|
||||
If Tracker.FLP.GetLastKnownLocation.IsInitialized Then
|
||||
Dim daa As Int = Tracker.UUGCoords.DistanceTo(Tracker.FLP.GetLastKnownLocation) 'Distancia de la UUG a la actual de Tracker.FLP.GetLastKnownLocation
|
||||
If Main.Logger Then LogColor($"**** UUC "${fechaKMT(Tracker.FLP.GetLastKnownLocation.Time)}|$0.2{Tracker.FLP.GetLastKnownLocation.Accuracy}|$0.8{Tracker.FLP.GetLastKnownLocation.Latitude}|$0.8{Tracker.FLP.GetLastKnownLocation.Longitude}|$0.2{Tracker.FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
|
||||
If daa > 40 And Tracker.FLP.GetLastKnownLocation.Accuracy < 35 Then 'Si la distancia de la ubicacion anterior es mayor de XX y la precision es menor de XX, la guardamos ...
|
||||
kmt.ExecNonQuery2("INSERT INTO RUTA_GPS(fecha, lat, lon) VALUES (?,?,?)", Array As Object (fechaKMT(Tracker.FLP.GetLastKnownLocation.Time),Tracker.FLP.GetLastKnownLocation.Latitude,Tracker.FLP.GetLastKnownLocation.Longitude))
|
||||
If Main.Logger Then Log("++++ Distancia a anterior="&daa&"|"&"Precision="&Tracker.FLP.GetLastKnownLocation.Accuracy)
|
||||
End If
|
||||
Tracker.UUGCoords = Tracker.FLP.GetLastKnownLocation
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Revisamos que el FLP (FusedLocationProvider) este inicializado y activo
|
||||
Sub revisaFLP 'ignore
|
||||
LogColor($"**** **** Revisamos FLP - ${fechaKMT(DateTime.Now)}**** ****"$, Colors.RGB(78,0,227))
|
||||
Private todoBienFLP As Boolean = True
|
||||
If Not(Tracker.FLP.IsInitialized) Then
|
||||
log2DB("revisaFLP: No esta inicializado ... 'Reinicializando FLP'")
|
||||
Tracker.FLP.Initialize("flp")
|
||||
todoBienFLP = False
|
||||
End If
|
||||
If Tracker.FLP.IsInitialized Then
|
||||
If Not(Tracker.FLP.IsConnected) Then
|
||||
log2DB("revisaFLP: No esta conectado ... 'Reconectando FLP'")
|
||||
' Tracker.FLP.Connect
|
||||
CallSubDelayed(Tracker,"StartFLP")
|
||||
todoBienFLP = False
|
||||
End If
|
||||
If Tracker.FLP.IsConnected And _
|
||||
Tracker.FLP.GetLastKnownLocation.IsInitialized And _
|
||||
Tracker.FLP.GetLastKnownLocation.DistanceTo(Tracker.UUGCoords) > 500 Then
|
||||
log2DB("revisaFLP: 'No se esta actualizando, lo reiniciamos ...'")
|
||||
StartService(Tracker)
|
||||
todoBienFLP = False
|
||||
End If
|
||||
End If
|
||||
If todoBienFLP Then LogColor(" +++ +++ Sin errores en FLP", Colors.Green)
|
||||
' revisar hora de lastKnownlocation y si es mayor de 10 minutos llamar StartFLP
|
||||
End Sub
|
||||
|
||||
'Revisamos que el servicio "PushService" este inicializado y activo
|
||||
Sub revisaPushService 'ignore
|
||||
' Private todoBienPS As Boolean = True
|
||||
'' LogColor("**** **** Revisamos PushService **** ****", Colors.RGB(78,0,227))
|
||||
' Try
|
||||
' If Not(PushService.wsh.IsInitialized) Then 'Si no esta inicializado ...
|
||||
' log2DB("revisaPushService: No esta inicializado ... 'Reinicializando PushService'")
|
||||
' CallSubDelayed(PushService, "Connect")
|
||||
' todoBienPS = False
|
||||
' End If
|
||||
' Catch
|
||||
' Log(LastException)
|
||||
' insertaEnErrores("Subs.revisaPushService: Reiniciando - "&LastException)
|
||||
' End Try
|
||||
' Try
|
||||
' If Not(PushService.wsh.ws.Connected) Then 'Si no esta conectado ...
|
||||
' log2DB("revisaPushService: No esta conectado ... 'Reconectando PushService'")
|
||||
' CallSubDelayed(PushService, "Connect")
|
||||
' todoBienPS = False
|
||||
' End If
|
||||
' Catch
|
||||
' Log(LastException)
|
||||
' insertaEnErrores("Subs.revisaPushService: Reconectando - "&LastException)
|
||||
' End Try
|
||||
' Try
|
||||
' If masDeXXMinsKMT(Starter.pushServiceActividad, 5) Then 'Si mas de xx minutos de la ultima actividad entonces ...
|
||||
' PushService.wsh.Close
|
||||
' CallSubDelayed(PushService, "Connect")
|
||||
' ' StartService(PushService)
|
||||
' ' If Main.Logger Then Log("Ultima act: "&Starter.pushServiceActividad)
|
||||
' log2DB("revisaPushService: 'Reconectamos 'PushService' por inactividad")
|
||||
' Starter.pushServiceActividad = fechaKMT(DateTime.Now)
|
||||
' todoBienPS = False
|
||||
' End If
|
||||
' Catch
|
||||
' Log(LastException)
|
||||
' insertaEnErrores("Subs.revisaPushService: Reconectando por inactividad - "&LastException)
|
||||
' End Try
|
||||
' If todoBienPS Then LogColor(" +++ +++ Sin errores en PushService", Colors.Green)
|
||||
End Sub
|
||||
|
||||
'Borramos renglones extra de la tabla de errores
|
||||
Sub borraArribaDe100Errores 'ignore
|
||||
If Not(errorLog.IsInitialized) Then revisaBD
|
||||
LogColor("Recortamos la tabla de Errores, limite de 100", Colors.Magenta)
|
||||
errorLog.ExecNonQuery("DELETE FROM errores WHERE fecha NOT in (SELECT fecha FROM errores ORDER BY fecha desc LIMIT 99 )")
|
||||
errorLog.ExecNonQuery("vacuum;")
|
||||
' Log("Borramos mas de 100 de errorLog")
|
||||
End Sub
|
||||
|
||||
'Borramos renglones extra de la tabla de bitacora
|
||||
Sub borraArribaDe600RenglonesBitacora 'ignore
|
||||
revisaBD
|
||||
LogColor("Recortamos la tabla de la Bitacora, limite de 600", Colors.Magenta)
|
||||
Private c As Cursor
|
||||
c = kmt.ExecQuery("select fecha from bitacora")
|
||||
c.Position = 0
|
||||
If c.RowCount > 650 Then
|
||||
kmt.ExecNonQuery("DELETE FROM bitacora WHERE fecha NOT in (SELECT fecha FROM bitacora ORDER BY fecha desc LIMIT 599 )")
|
||||
kmt.ExecNonQuery("vacuum;")
|
||||
' Log("Borramos mas de 600 de bitacora")
|
||||
End If
|
||||
c.Close
|
||||
End Sub
|
||||
|
||||
'Inserta 50 renglones de prueba a la tabla "errores"
|
||||
Sub insertaRenglonesPruebaEnErrorLog 'ignore
|
||||
If Not(errorLog.IsInitialized) Then revisaBD
|
||||
Log("insertamos 50 renglones a errorLog")
|
||||
For x = 1 To 50
|
||||
errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (fechaKMT(DateTime.now), "abc"))
|
||||
Log(x)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
'Regresa la tabla "errores" en una lista de mapas convertida a JSON
|
||||
Sub dameErroresJSON(SQL As SQL, maxErrores As Int, comprimido As Boolean) As String 'ignore
|
||||
Log("dameErroresJSON")
|
||||
Private j As JSONGenerator
|
||||
Private lim As String
|
||||
Private cur As ResultSet
|
||||
Private l As List
|
||||
Private i As Int = 0
|
||||
l.Initialize
|
||||
Dim m, m2 As Map
|
||||
m2.Initialize
|
||||
If maxErrores = 0 Then lim = "" Else lim = "limit "&maxErrores
|
||||
cur = SQL.ExecQuery("select * from errores order by fecha desc "&lim)
|
||||
Do While cur.NextRow
|
||||
m.Initialize
|
||||
m.Put("fecha", cur.GetString("fecha"))
|
||||
m.Put("error", cur.GetString("error"))
|
||||
m2.Put(i,m)
|
||||
i = i + 1
|
||||
Loop
|
||||
cur.Close
|
||||
j.Initialize(m2)
|
||||
Log(j.ToString)
|
||||
If comprimido Then
|
||||
Return compress(j.ToString)
|
||||
Else
|
||||
Return j.ToString
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Convierte una fecha en formato YYMMDDHHMMSS a Ticks
|
||||
Sub fechaKMT2Ticks(fKMT As String) As Long 'ignore
|
||||
Try
|
||||
If fKMT.Length = 12 Then
|
||||
Private parteFecha As String = fKMT.SubString2(0,6)
|
||||
Private parteHora As String = fKMT.SubString(6)
|
||||
Private OrigFormat As String = DateTime.DateFormat 'save original date format
|
||||
DateTime.DateFormat="yyMMdd"
|
||||
DateTime.TimeFormat="HHmmss"
|
||||
Private ticks As Long = DateTime.DateTimeParse(parteFecha,parteHora)
|
||||
' Log(" +++ +++ pFecha:"&parteFecha&" | pHora:"&parteHora)
|
||||
DateTime.DateFormat=OrigFormat 'return to original date format
|
||||
Return ticks
|
||||
Else
|
||||
Log("Formato de fecha incorrecto, debe de ser 'YYMMDDHHMMSS', no '"&fKMT&"' largo="&fKMT.Length)
|
||||
Return 0
|
||||
End If
|
||||
Catch
|
||||
Log(LastException)
|
||||
LogColor($"Fecha dada: ${fKMT}, Parte Fecha: ${parteFecha}, Parte Hora: ${parteHora}"$, Colors.Red)
|
||||
Return 0
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Sub InstallAPK(dir As String, apk As String) 'ignore
|
||||
If File.Exists(dir, apk) Then
|
||||
Dim i As Intent
|
||||
i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(dir, apk))
|
||||
i.SetType("application/vnd.android.package-archive")
|
||||
StartActivity(i)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Copia la base de datos del almacenamiento interno al externo en el directorio kmts
|
||||
Sub copiaDB(result As Boolean) 'ignore
|
||||
If result Then
|
||||
Dim p As String
|
||||
If File.ExternalWritable Then
|
||||
p = File.DirRootExternal
|
||||
' Log("Externo")
|
||||
Else
|
||||
p = File.DirInternal
|
||||
' Log("Interno")
|
||||
End If
|
||||
Dim theDir As String
|
||||
Try
|
||||
File.MakeDir(File.DirRootExternal,"kmts")
|
||||
theDir = "/kmts"
|
||||
Catch
|
||||
theDir = ""
|
||||
End Try
|
||||
Try
|
||||
File.Copy(File.DirInternal,"kmt.db",File.DirRootExternal&theDir,"guna_rep_kmt.db")
|
||||
ToastMessageShow("BD copiada!", False)
|
||||
Catch
|
||||
ToastMessageShow("No se pudo hacer la copia: "&LastException, True)
|
||||
End Try
|
||||
Log("rootExternal="&p)
|
||||
Log("File.DirInternal="&File.DirInternal)
|
||||
Log("File.DirRootExternal="&File.DirRootExternal)
|
||||
Else
|
||||
ToastMessageShow("Sin permisos", False)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Hace visible el panel con los parametros "Top" y "Left" dados
|
||||
Sub panelVisible(panel As Panel, top As Int, left As Int) 'ignore
|
||||
panel.BringToFront
|
||||
panel.Visible = True
|
||||
panel.Top = top
|
||||
panel.Left = left
|
||||
End Sub
|
||||
|
||||
Sub insertaEnErrores(error As String) 'ignore
|
||||
If Not(errorLog.IsInitialized) Then revisaBD
|
||||
errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (fechaKMT(DateTime.now), error))
|
||||
End Sub
|
||||
|
||||
'Saca el usuario de la tabla USUARIOA
|
||||
Sub dameUsuarioDeDB As String 'ignore
|
||||
Private c As Cursor
|
||||
Private u As String = "SinUsuario"
|
||||
If Not(kmt.IsInitialized) Then revisaBD
|
||||
c=kmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
If c.RowCount > 0 Then u = c.GetString("USUARIO")
|
||||
c.Close
|
||||
Return u
|
||||
End Sub
|
||||
|
||||
Sub SetDivider(lv As ListView, Color As Int, Height As Int) 'ignore
|
||||
Dim r As Reflector
|
||||
r.Target = lv
|
||||
Dim CD As ColorDrawable
|
||||
CD.Initialize(Color, 0)
|
||||
r.RunMethod4("setDivider", Array As Object(CD), Array As String("android.graphics.drawable.Drawable"))
|
||||
r.RunMethod2("setDividerHeight", Height, "java.lang.int")
|
||||
End Sub
|
||||
|
||||
'Centra un listview dentro de un elemento superior
|
||||
Sub centraListView(elemento As ListView, anchoElementoSuperior As Int) 'ignore
|
||||
elemento.Left = Round(anchoElementoSuperior/2)-(elemento.Width/2)
|
||||
End Sub
|
||||
|
||||
'Centra un panel dentro de un elemento superior
|
||||
Sub centraPanel(elemento As Panel, anchoElementoSuperior As Int) 'ignore
|
||||
elemento.Left = Round(anchoElementoSuperior/2)-(elemento.Width/2)
|
||||
End Sub
|
||||
|
||||
'Centra una etiqueta dentro de un elemento superior
|
||||
Sub centraEtiqueta(elemento As Label, anchoElementoSuperior As Int) 'ignore
|
||||
elemento.Left = Round(anchoElementoSuperior/2)-(elemento.Width/2)
|
||||
End Sub
|
||||
|
||||
'Centra un boton dentro de un elemento superior
|
||||
Sub centraBoton(elemento As Button, anchoElementoSuperior As Int) 'ignore
|
||||
elemento.Left = Round(anchoElementoSuperior/2)-(elemento.Width/2)
|
||||
End Sub
|
||||
|
||||
'Change CheckBox colors
|
||||
Sub SetButtonTintList(View As View, Disabled As Int, Enabled As Int)
|
||||
Dim States(2,1) As Int
|
||||
Dim sd As StateListDrawable 'ignore
|
||||
States(0, 0) = sd.State_Enabled
|
||||
States(1, 0) = sd.State_Disabled
|
||||
Dim Color(2) As Int = Array As Int(Enabled, Disabled)
|
||||
Dim CSL As JavaObject
|
||||
CSL.InitializeNewInstance("android.content.res.ColorStateList",Array(States,Color))
|
||||
Dim jo As JavaObject
|
||||
jo.InitializeStatic("android.support.v4.widget.CompoundButtonCompat")
|
||||
jo.RunMethod("setButtonTintList", Array(View, CSL))
|
||||
End Sub
|
||||
234
Tracker.bas
Normal file
@@ -0,0 +1,234 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
#Region Service Attributes
|
||||
#StartAtBoot: True
|
||||
#End Region
|
||||
'******************************************************************************
|
||||
'No olvidar agregar esta linea al editor de manifiesto:
|
||||
' SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
|
||||
'
|
||||
'En Starter agregar estas lineas en Process_Globals
|
||||
' Public rp As RuntimePermissions
|
||||
' Public FLP As FusedLocationProvider
|
||||
' Private flpStarted As Boolean
|
||||
'
|
||||
'En Main agregar estas lineas a Activity_Resume
|
||||
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
' Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
' If Result Then
|
||||
' StartService(Tracker)
|
||||
' Log("Start Tracker")
|
||||
' Else
|
||||
' ToastMessageShow("No permission", True)
|
||||
' End If
|
||||
'
|
||||
'Se necesitan las librerias FusedLocationProvider, GPS, Phone y RunTimePermissions
|
||||
'
|
||||
'Y en Main agregar estas dos lineas:
|
||||
'#AdditionalJar: com.android.support:support-v4
|
||||
'#AdditionalJar: com.google.android.gms:play-services-location
|
||||
|
||||
Sub Process_Globals
|
||||
Private nid As Int = 1
|
||||
Private Tracking As Boolean
|
||||
Private lock As PhoneWakeState
|
||||
'Para FusedLocationProvider (2 lineas)
|
||||
Public FLP As FusedLocationProvider
|
||||
Dim actualLR As LocationRequest
|
||||
Private flpStarted As Boolean
|
||||
Dim locRequest As String
|
||||
Dim UUGCoords As Location 'Ultima Ubicacion Guardada
|
||||
Dim trackerActividad, pushServiceActividad As String
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
|
||||
UUGCoords.Initialize
|
||||
'Para FusedLocationProvider (2 lineas)
|
||||
FLP.Initialize("flp")
|
||||
FLP.Connect
|
||||
lock.PartialLock
|
||||
StartFLP
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuccess
|
||||
If Main.logger Then Log("Connected to location provider")
|
||||
'FLP.GetLastKnownLocation
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionFailed(ConnectionResult1 As Int)
|
||||
If Main.logger Then Log("Failed to connect to location provider")
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuspended(ConnectionResult1 As Int)
|
||||
If Main.logger Then Log("FLP conection suspended")
|
||||
StartFLP
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
LogColor("Iniciando Tracker ...", Colors.Green)
|
||||
Service.StopAutomaticForeground
|
||||
' Service.StartForeground(51042, Subs.notiLowReturn("THIS (T)", PushService.wsStatus, 51042))
|
||||
StartServiceAt(Me, DateTime.Now + 10 * DateTime.TicksPerMinute, True)
|
||||
Track
|
||||
Starter.trackerActividad = Subs.fechaKMT(DateTime.Now)
|
||||
' Log("trackerActividad="&Starter.trackerActividad&"|"& Subs.fechaKMT(DateTime.Now))
|
||||
End Sub
|
||||
|
||||
Public Sub Track
|
||||
If Main.logger Then Log("Inicia Track - Tracking : "&Tracking)
|
||||
If Tracking Then
|
||||
' Log(actualLR.GetSmallestDisplacement)
|
||||
Return 'Si ya estamos "rastreando" no hacemos nada (return)
|
||||
End If
|
||||
If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
|
||||
If Main.logger Then Log("No permission")
|
||||
Return
|
||||
End If
|
||||
StartFLP 'Iniciamos FusedLocationProvider
|
||||
Tracking = True
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLP
|
||||
' If Main.logger Then Log("StartFLP - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
' If Main.logger Then Log("sleeping")
|
||||
Loop
|
||||
' If flpStarted = False Then
|
||||
' If Main.logger Then Log("RequestLocationUpdates")
|
||||
FLP.RequestLocationUpdates(CreateLocationRequest) 'Buscamos ubicacion
|
||||
' If Main.logger Then Log("Buscamos ubicacion")
|
||||
' If Main.logger Then Log(actualLR.GetSmallestDisplacement)
|
||||
flpStarted = True
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLP2Reqs
|
||||
If Main.logger Then Log("StartFLP - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
If Main.logger Then Log("sleeping")
|
||||
Loop
|
||||
dameUltimaUbicacionConocida 'Regresamos ultima ubicacion conocida
|
||||
FLP.RequestLocationUpdates(CreateLocationRequest2times) 'Buscamos ubicacion 2 peticiones
|
||||
If Main.logger Then Log("Buscamos ubicacion 2 peticiones")
|
||||
If Main.logger Then Log(actualLR.GetSmallestDisplacement)
|
||||
End Sub
|
||||
|
||||
Private Sub CreateLocationRequest As LocationRequest
|
||||
If Main.logger Then Log("CreateLocationRequest")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(10000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||
lr.SetSmallestDisplacement(75) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||
lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
|
||||
actualLR=lr
|
||||
Return lr
|
||||
End Sub
|
||||
|
||||
Private Sub CreateLocationRequest2times As LocationRequest
|
||||
If Main.logger Then Log("Iniciamos CreateLocationRequest2times")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(2000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||
lr.setNumUpdates(2) 'Solicitamos solo 2 actualizaciones con estos parametros
|
||||
lr.SetSmallestDisplacement(10) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||
lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
|
||||
actualLR=lr
|
||||
Return lr
|
||||
End Sub
|
||||
|
||||
Sub dameUltimaUbicacionConocida
|
||||
If FLP.GetLastKnownLocation.IsInitialized Then 'Mandamos ultima ubicacion guardada
|
||||
' If Main.logger Then Log("Mandamos UUC : "&formatoFecha(FLP.GetLastKnownLocation.Time))
|
||||
If Main.Logger Then LogColor($"Mandamos UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|Acc:$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|Spd:$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
|
||||
Dim coords As String = FLP.GetLastKnownLocation.Latitude&","&FLP.GetLastKnownLocation.Longitude&","&formatoFecha(FLP.GetLastKnownLocation.Time)
|
||||
' CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
|
||||
Subs.mandamosLoc(coords)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub StopFLP
|
||||
'Log("StopFLP")
|
||||
If flpStarted Then
|
||||
FLP.RemoveLocationUpdates 'Eliminamos todas las solicitudes de ubicacion
|
||||
flpStarted = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub flp_LocationChanged (Location1 As Location)
|
||||
Starter.trackerActividad = Subs.fechaKMT(DateTime.Now)
|
||||
UUGCoords = Location1
|
||||
' If Main.logger Then Log("SmallestDisplacement="&actualLR.GetSmallestDisplacement)
|
||||
CallSub2(Starter, "GPS_LocationChanged", Location1)
|
||||
' CallSub2(gestion, "GPS_LocationChanged", Location1)
|
||||
' CallSubDelayed2(gestion, "GPS_LocationChanged", Location1)
|
||||
Main.lat_gps = Location1.Latitude
|
||||
Main.lon_gps = Location1.Longitude
|
||||
'/////// para la ultima ubicacion FL
|
||||
Dim sDate,sTime As String
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
Try
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, Main.lat_gps, Main.lon_gps))
|
||||
Catch
|
||||
If Main.logger Then Log("Error al borrar o insertar nuevas coordendas en HIST_GPS")
|
||||
End Try
|
||||
'///////
|
||||
Dim coords As String = Location1.Latitude&","&Location1.Longitude&","&formatoFecha(Location1.Time)
|
||||
' If Main.logger Then Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&Main.usuario&"|")
|
||||
If Main.logger Then Log("Mandamos Ubicacion")
|
||||
If Main.logger Then Log(locRequest)
|
||||
' Solo mandamos la ubicacion si la precision es menor a XX mts
|
||||
If Location1.Accuracy < 100 Then
|
||||
Subs.guardaInfoEnBD(coords)'Escribimos coordenadas y fecha en BD
|
||||
' CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
|
||||
Subs.mandamosLoc(coords)
|
||||
End If
|
||||
Dim origFormat As String = DateTime.TimeFormat 'Guardamos formato de fecha
|
||||
DateTime.TimeFormat = "HHmmss" ' Modificamos formato de fecha
|
||||
Dim minsDif As Int = DateTime.Time(DateTime.Now) - Main.ultimaActualizacionGPS
|
||||
' If Main.logger Then Log("UltimaAct="&Main.ultimaActualizacionGPS&" MinsDif="&minsDif)
|
||||
If Location1.Accuracy < 100 And minsDif > 240 Then 'Si precision de 100 y 4 min transcurridos manda a web
|
||||
If Main.logger Then Log("actualizamos Ubicacion Web")
|
||||
CallSubDelayed(Starter, "ENVIA_ULTIMA_GPS")
|
||||
End If
|
||||
DateTime.TimeFormat = origFormat 'Regresamos formato de fecha original
|
||||
'Revisamos servicios
|
||||
Subs.monitor
|
||||
End Sub
|
||||
|
||||
Sub CreateNotification (Body As String) As Notification 'ignore
|
||||
Dim notification As Notification
|
||||
notification.Initialize2(notification.IMPORTANCE_LOW)
|
||||
notification.Icon = "icon"
|
||||
notification.SetInfo("INTMEX", Body, Main)
|
||||
Return notification
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
If Tracking Then
|
||||
StopFLP
|
||||
End If
|
||||
Tracking = False
|
||||
lock.ReleasePartialLock
|
||||
End Sub
|
||||
|
||||
Sub formatoFecha(fecha As String) As String 'Convierte una fecha al formato yyMMddHHmmss
|
||||
' Log(fecha)
|
||||
Dim OrigFormat As String = DateTime.DateFormat 'save orig date format
|
||||
DateTime.DateFormat="yyMMddHHmmss"
|
||||
Dim lastUpdate As String=DateTime.Date(fecha)
|
||||
DateTime.DateFormat=OrigFormat 'return to orig date format
|
||||
' Log(lastUpdate)
|
||||
Return lastUpdate
|
||||
End Sub
|
||||
613
colonia.bas
Normal file
@@ -0,0 +1,613 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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 ruta As String
|
||||
Dim q_buscar As String
|
||||
' Dim skmt As SQL
|
||||
Dim entro As String
|
||||
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 c2 As Cursor
|
||||
Dim ListView1 As ListView
|
||||
' Dim gest As Button
|
||||
Dim lfila As Label
|
||||
Dim busca As EditText
|
||||
Private p_colonia As Panel
|
||||
' Dim distList As List
|
||||
' Dim distMap As Map
|
||||
Dim laRuta As String
|
||||
Private b_GetDirs As Button
|
||||
Private distOrderedMap, clientesMapaO As B4XOrderedMap
|
||||
Private img_getDirs As ImageView
|
||||
Private l_rutaInfo As Label
|
||||
Private b_getRutaInfo As Button
|
||||
Private conMapa As Boolean = False
|
||||
Dim listaWayPoints As List
|
||||
Dim lv1Top As String
|
||||
Private b_limpiarRuta As Button
|
||||
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")
|
||||
Activity.LoadLayout("fila")
|
||||
entro ="2"
|
||||
lv1Top = ListView1.Top
|
||||
' valido donde escribo el archivo de la base de datos de kmt
|
||||
' ruta = Starter.ruta
|
||||
' se crea o no el archivo de la base de ddatos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
' 19.48118148992086,-99.15295579261536
|
||||
' Starter.cedisLocation.Latitude = "19.48118148992086"
|
||||
' Starter.cedisLocation.Longitude = "-99.15295579261536"
|
||||
clientesMapaO.Initialize
|
||||
If FirstTime Then Starter.skmt.ExecNonQuery("delete from waypoints")
|
||||
|
||||
Log("Coordenadas del almacen: " & Starter.cedisLocation.Longitude & "," & Starter.cedisLocation.Latitude)
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
busca.Text = ""
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
entro ="2"
|
||||
' esto es para rutas se quito por colonia
|
||||
'SE COMENTA EL SIGUIENTE CODIGO PARA QUE TODAS LAS TIENDAS APAREZCAN.
|
||||
'c=skmt.ExecQuery("selecTIJ01t CAT_CL_COLONIA, count(*) as cuantos from kmt_info where gestion = 0 group by CAT_CL_COLONIA order by CAT_CL_COLONIA asc")
|
||||
p_colonia.Width = Activity.Width
|
||||
p_colonia.Height = Activity.Height
|
||||
p_colonia.Top = 0
|
||||
p_colonia.Left = 0
|
||||
Subs.centraListView(ListView1, p_colonia.Width)
|
||||
ListView1.Height = p_colonia.Height * 0.75
|
||||
Subs.SetDivider(ListView1, Colors.LightGray, 2)
|
||||
If Not(l_rutaInfo.Visible) Then
|
||||
ListView1.Top = lv1Top
|
||||
Else
|
||||
ListView1.Top = lv1Top + 100
|
||||
End If
|
||||
Private label1 As Label = ListView1.TwoLinesLayout.Label
|
||||
Private label2 As Label = ListView1.TwoLinesLayout.SecondLabel
|
||||
label1.Height = 15dip
|
||||
label2.Height = 50dip
|
||||
label1.top = 10dip
|
||||
label2.Top = label1.Height + 12dip
|
||||
ListView1.TwoLinesLayout.ItemHeight = label1.Height+label2.Height+5dip
|
||||
c=Starter.skmt.ExecQuery("select codigo, indice, CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_NOEXT from waypoints inner join kmt_info on waypoints.codigo = kmt_info.CAT_CL_CODIGO where gestion = 0 order by indice")
|
||||
If c.RowCount > 0 Then 'Ya hay waypoints en la base de datos
|
||||
c.Position = 0
|
||||
' Log("Ya hay waypoints.")
|
||||
conMapa = True
|
||||
' Private t1 As Map
|
||||
ListView1.Clear
|
||||
Dim cs, cs2 As CSBuilder
|
||||
entro = 3
|
||||
' Log("Generamos ListView1 en Activity_Resume")
|
||||
For i=0 To c.RowCount -1 'Generamos el listView con la lista ordenada.
|
||||
c.Position=i
|
||||
cs.Initialize
|
||||
cs2.Initialize
|
||||
' t1 = Starter.waypointsOrdered.Get(k)
|
||||
' c.GetString("codigo")
|
||||
ListView1.AddTwoLines(cs.Color(Colors.RGB(100,149,237)).Append(c.GetString("codigo")).PopAll, cs2.append(c.GetString("CAT_CL_NOMBRE")).Color(Colors.RGB(100,149,237)).Append(" Calle: ").Pop.Append(c.GetString("CAT_CL_CALLE").Trim & " " & c.GetString("CAT_CL_NOEXT")).PopAll )
|
||||
Next
|
||||
Else
|
||||
generaListViewRutas
|
||||
End If
|
||||
c.Close
|
||||
' ESTE FUE EL FIN DEL CODIGO COMENTADO
|
||||
'c2=skmt.ExecQuery("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO from kmt_info where gestion = 0 order by CAT_CL_NOMBRE ")
|
||||
' ListView1.Clear
|
||||
'lfila.text = "Nombre y Calle"
|
||||
|
||||
'If c2.RowCount>0 Then
|
||||
' For i=0 To c2.RowCount -1
|
||||
' c2.Position=i
|
||||
' Dim label1 As Label
|
||||
' label1 = ListView1.TwoLinesLayout.Label
|
||||
' label1.TextSize = 9
|
||||
' label1.TextColor = Colors.White
|
||||
' Dim label2 As Label
|
||||
' label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
' label2.TextSize = 17
|
||||
' label2.TextColor = Colors.White
|
||||
' ListView1.AddTwoLines(c2.GetString("CAT_CL_CODIGO"), c2.GetString("CAT_CL_NOMBRE") &" CALLE: "& c2.GetString("CAT_CL_CALLE"))
|
||||
' Next
|
||||
' End If
|
||||
' entro = "3"
|
||||
p_colonia.Width = Activity.Width
|
||||
p_colonia.Height = Activity.Height
|
||||
Subs.centraEtiqueta(l_rutaInfo, Activity.Width)
|
||||
Subs.centraListView(ListView1, p_colonia.Width)
|
||||
ListView1.Height = p_colonia.Height * 0.70
|
||||
Subs.centraEtiqueta(lfila, Activity.Width)
|
||||
b_getRutaInfo.Visible = True
|
||||
b_getRutaInfo.BringToFront
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemClick (Position As Int, Value As Object)
|
||||
' Log($"Entro= ${entro}"$)
|
||||
ListView1.Clear
|
||||
Sleep(50)
|
||||
Subs.SetDivider(ListView1, Colors.LightGray, 2)
|
||||
If Not(l_rutaInfo.Visible) Then
|
||||
ListView1.Top = lv1Top
|
||||
Else
|
||||
ListView1.Top = lv1Top + 100
|
||||
End If
|
||||
l_rutaInfo.Visible = False
|
||||
b_GetDirs.Visible = False
|
||||
If entro = "2" Then
|
||||
b_GetDirs.Visible = True
|
||||
img_getDirs.Visible = True
|
||||
b_getRutaInfo.Visible = False
|
||||
Private lrt As String
|
||||
lrt = Value
|
||||
laRuta = lrt.SubString(6) 'Quitamos el texto "Ruta: " para obtener el numero de la ruta.
|
||||
' Log($"Original: ${Value} - Mod: |${lrt.SubString(6)}| - laRuta: ${laRuta}"$)
|
||||
c2=Starter.skmt.ExecQuery2("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO, CAT_CL_LAT, CAT_CL_LONG from kmt_info where CAT_CL_RUTA = ? and gestion = 0 order by CAT_CL_NOMBRE ", Array As String(laRuta))
|
||||
Private thisLoc As Location
|
||||
Private label1 As Label
|
||||
Private label2 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.black
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 15
|
||||
label2.TextColor = Colors.black
|
||||
' label1.Height = 70dip
|
||||
' label1.Color = Colors.Gray
|
||||
label2.Height = 55dip
|
||||
thisLoc.Initialize
|
||||
If entro = 2 Then ListView1.TwoLinesLayout.ItemHeight = 75dip
|
||||
ListView1.TwoLinesLayout.ItemHeight = label1.Height+label2.Height+15dip
|
||||
lfila.text = "Nombre y Calle"
|
||||
distOrderedMap.Initialize
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1 'Generamos mapa de clientes
|
||||
c2.Position=i
|
||||
thisLoc.Latitude = c2.GetString("CAT_CL_LAT")
|
||||
thisLoc.Longitude = c2.GetString("CAT_CL_LONG")
|
||||
Private distancia As Int = Tracker.UUGCoords.DistanceTo(thisLoc) 'Calculamos la distancia de la posicion ACTUAL a la tienda.
|
||||
Private esteCliente As Map = CreateMap("distancia": distancia, "ubicacion": thisLoc.Longitude&","&thisLoc.Latitude, "codigo": c2.GetString("CAT_CL_CODIGO"), "nomDirDist": $"${c2.GetString("CAT_CL_NOMBRE")} CALLE: ${c2.GetString("CAT_CL_CALLE")} ${CRLF}Distancia: $1.1{(distancia/1000)} kms"$)
|
||||
distOrderedMap.Put(distancia, esteCliente)
|
||||
Next
|
||||
distOrderedMap.Keys.Sort(True) 'Ordenamos la mapa de clientes por distancia.
|
||||
ListView1.Clear
|
||||
Private m1 As Map
|
||||
For Each k As Object In distOrderedMap.Keys 'Generamos el listView con el mapa ordenada.
|
||||
m1 = distOrderedMap.Get(k)
|
||||
m1.Get("codigo")
|
||||
ListView1.AddTwoLines(m1.Get("codigo"), m1.Get("nomDirDist"))
|
||||
Next
|
||||
End If
|
||||
c2.Close
|
||||
entro = "3"
|
||||
Else If entro = "3" Then
|
||||
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(Value))
|
||||
StartActivity(fila)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Genera el listview que muestra las rutas y clientes a visitar por ruta.
|
||||
Sub generaListViewRutas
|
||||
ListView1.Clear
|
||||
Sleep(110)
|
||||
lfila.Text = "RUTA PREVENTA"
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 15
|
||||
label2.TextColor = Colors.Black
|
||||
ListView1.TwoLinesLayout.ItemHeight = 60dip
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA, count(*) as cuantos from kmt_info where gestion = 0 group by CAT_CL_RUTA order by CAT_CL_RUTA asc")
|
||||
If c.RowCount>0 Then
|
||||
ListView1.Clear
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
ListView1.AddTwoLines("Ruta: " & c.GetString("CAT_CL_RUTA"), "Por visitar: " & c.GetString("cuantos"))
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
End Sub
|
||||
|
||||
Sub Activity_KeyPress (key As Int) As Boolean 'ignore
|
||||
' BACK key pressed
|
||||
If key=KeyCodes.KEYCODE_BACK Then
|
||||
If entro = 3 And Not(conMapa) Then
|
||||
b_GetDirs.Visible = False
|
||||
StartActivity(Activity_Create(False))
|
||||
Return True
|
||||
End If
|
||||
StartActivity(seleccion)
|
||||
Return False
|
||||
'End If
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
End Sub
|
||||
|
||||
Sub BUSCA_TextChanged (Old As String, New As String)
|
||||
q_buscar = "%" & busca.Text & "%"
|
||||
c2=Starter.skmt.ExecQuery2("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO from kmt_info where CAT_CL_NOMBRE like ? and gestion = 0 order by CAT_CL_CODIGO ", Array As String(q_buscar))
|
||||
ListView1.Clear
|
||||
lfila.text = "Nombre y Calle"
|
||||
Subs.SetDivider(ListView1, Colors.LightGray, 2)
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 15
|
||||
label2.TextColor = Colors.Black
|
||||
ListView1.AddTwoLines(c2.GetString("CAT_CL_CODIGO"), c2.GetString("CAT_CL_NOMBRE") &" CALLE: "& c2.GetString("CAT_CL_CALLE"))
|
||||
Next
|
||||
End If
|
||||
entro = "3"
|
||||
c2.Close
|
||||
End Sub
|
||||
|
||||
'Regresa la distancia y tiempo de la ruta entre dos puntos, usa el API del projecto OSRM. (Parte de la funcionalidad OSRM)
|
||||
'Para mas información ir a esta liga:
|
||||
'http://project-osrm.org/docs/v5.24.0/api/?language=cURL#route-service
|
||||
Sub distanciaEntreCoords(id As String, coords1 As String, coords2 As String) As ResumableSub 'ignore
|
||||
Sleep(1050)
|
||||
Private distanciaTotal As String = "0"
|
||||
Private tiempo As String = "0"
|
||||
Dim j As HttpJob
|
||||
j.Initialize("", Me)
|
||||
j.Download("https://router.project-osrm.org/route/v1/driving/"&coords1&";"&coords2&"?overview=false")
|
||||
Wait For (j) JobDone(j As HttpJob)
|
||||
If j.Success Then
|
||||
Dim jp As JSONParser
|
||||
jp.Initialize(j.GetString)
|
||||
Dim m As Map = jp.NextObject
|
||||
Log($"Respuesta: ${m.Get("code")}"$)
|
||||
If m.Get("code") = "Ok" Then
|
||||
' Log(m)
|
||||
Dim rutas As List = m.Get("routes")
|
||||
Dim rutas2 As Map = rutas.Get(0)
|
||||
' Log(rutas2)
|
||||
' Dim legs As List = rutas2.Get("legs")
|
||||
' Log(legs)
|
||||
distanciaTotal = rutas2.Get("distance")
|
||||
tiempo = rutas2.Get("duration")
|
||||
Log($"Distancia total: ${distanciaTotal}, Tiempo: ${tiempo}"$ )
|
||||
End If
|
||||
Else
|
||||
Log("Error!")
|
||||
End If
|
||||
j.Release
|
||||
Private r As List
|
||||
r.Initialize
|
||||
r.Add(id)
|
||||
r.Add(distanciaTotal)
|
||||
r.Add(tiempo)
|
||||
Return r
|
||||
End Sub
|
||||
|
||||
'Regresa la distancia y tiempo estimado de la ruta del repartidor, utiliza el API del projecto OSRM
|
||||
'para calcular la distancia y tiempo de la ruta de un mapa de coordenadas a visitar dado. (Parte de la funcionalidad OSRM)
|
||||
Sub traeRutaDia(aVisitar As B4XOrderedMap)
|
||||
Private coordsInicio As String = $"${Starter.cedisLocation.Longitude},${Starter.cedisLocation.Latitude}"$
|
||||
Log($"Coordenadas de inicio: ${Starter.cedisLocation.Longitude},${Starter.cedisLocation.Latitude}"$)
|
||||
Private rutaCompleta As String = coordsInicio
|
||||
Private preRuta As String = coordsInicio
|
||||
Private distanciaTotal, distanciaTotal0, tiempo0, tiempo As Double
|
||||
Private masDe100 As Boolean
|
||||
Private m4 As Map
|
||||
Private visitaActual As Int = 0
|
||||
Private cuantosAntes As Int = 0
|
||||
listaWayPoints.Initialize
|
||||
If aVisitar.Keys.Size > 98 Then 'Si los clientes a visitar son mas de 100 entonces hacemos 2 rutas, una inicial con pocas visitas (las que pasen de 100) y la final con el resto ...
|
||||
cuantosAntes = aVisitar.Keys.Size - 98 'Definimos de cuantos clientes va a ser la ruta inicial.
|
||||
preRuta = coordsInicio 'Ponemos las coordenadas de inicio (Las del CEDIS).
|
||||
rutaCompleta = ""
|
||||
masDe100 = True
|
||||
End If
|
||||
Log($"a visitar: ${aVisitar.Keys.Size}"$)
|
||||
For Each k As Object In aVisitar.Keys
|
||||
visitaActual = visitaActual + 1
|
||||
m4 = aVisitar.Get(k)
|
||||
' Log($"visitaActual: ${visitaActual} - cuantosAntes: ${cuantosAntes}"$)
|
||||
If visitaActual < cuantosAntes + 2 Then 'Si estas coordenadas son de la ruta inicial las agregamos ...
|
||||
preRuta = preRuta & ";" & m4.Get("coords")
|
||||
' LogColor($"PreRuta - visitaActual: ${visitaActual} - coords: ${m4.Get("coords")}"$, Colors.Magenta)
|
||||
End If
|
||||
If visitaActual >= cuantosAntes + 2 Then 'Si estas coordenadas son de la ruta final las agregamos ...
|
||||
rutaCompleta = rutaCompleta & ";" & m4.Get("coords")
|
||||
' LogColor($"RutaCompleta - visitaActual: ${visitaActual} - coords: ${m4.Get("coords")} - testRuta Size: ${testRutaCompleta.size}"$, Colors.Green)
|
||||
End If
|
||||
Next
|
||||
rutaCompleta = rutaCompleta & ";" & coordsInicio 'Agregamos las coordenadas del CEDIS al final para que sea viaje ida y vuelta.
|
||||
' rutaCompleta = rutaCompleta & ";" & coordsInicio
|
||||
If rutaCompleta.StartsWith(";") Then rutaCompleta = rutaCompleta.SubString(1) 'Si las cooredenadas tienen ";" al principio se lo quitamos.
|
||||
' LogColor(preRuta, Colors.magenta)
|
||||
' LogColor(rutaCompleta, Colors.Green)
|
||||
ProgressDialogShow2("Calculando distancia y tiempo, un momento por favor.", False)
|
||||
Private tiempoVisitas As Double 'TIMEPO DE 4 MINUTOS PROMEDIO POR TIENDA ESTO SE CAMBIA SEGUN EL CLIENTE
|
||||
tiempoVisitas = aVisitar.Keys.Size * 4 * 60 'Aqui se calcula el tiempo que duran las visitas x 4 mins cada una en segundos.
|
||||
tiempo0 = 0
|
||||
distanciaTotal0 = 0
|
||||
If masDe100 Then 'Si son mas de 100, entonces primero calculamos la ruta inicial.
|
||||
Dim j0 As HttpJob
|
||||
j0.Initialize("trip0", Me)
|
||||
j0.Download("https://router.project-osrm.org/trip/v1/driving/"&preRuta&"?source=first&destination=last&roundtrip=false&geometries=geojson")
|
||||
' LogColor("https://router.project-osrm.org/trip/v1/driving/"&preRuta&"?source=first&destination=last&roundtrip=false&geometries=geojson", Colors.Magenta)
|
||||
Wait For (j0) JobDone(j0 As HttpJob)
|
||||
If j0.Success Then
|
||||
Dim jp0 As JSONParser
|
||||
jp0.Initialize(j0.GetString)
|
||||
Dim m0 As Map = jp0.NextObject
|
||||
If m0.Get("code") = "Ok" Then
|
||||
Dim puntos0 As List = m0.Get("waypoints")
|
||||
Private esteWayPoint0 As Map
|
||||
For p = 0 To puntos0.Size -1
|
||||
esteWayPoint0 = puntos0.Get(p)
|
||||
' LogColor("WP:" & esteWayPoint0, Colors.magenta)
|
||||
' LogColor("WP: " & esteWayPoint0.Get("waypoint_index") & ", loc: " & esteWayPoint0.Get("location") & ", name: " & esteWayPoint0.Get("name"), Colors.Magenta)
|
||||
esteWayPoint0.Remove("hint")
|
||||
esteWayPoint0.Remove("distance")
|
||||
esteWayPoint0.Remove("trips_index")
|
||||
listaWayPoints.Add(esteWayPoint0)
|
||||
' LogColor("estewaypoint: "&esteWayPoint0, Colors.Magenta)
|
||||
Next
|
||||
Dim rutas0 As List = m0.Get("trips")
|
||||
Dim rutas20 As Map = rutas0.Get(0)
|
||||
' Dim geometry0 As Map = rutas20.Get("geometry")
|
||||
' Private coords0 As List = geometry0.Get("coordinates")
|
||||
distanciaTotal0 = rutas20.Get("distance")
|
||||
tiempo0 = rutas20.Get("duration")
|
||||
tiempo0 = ((tiempo0 * 2) ) 'Tiempo X 2 (es muy corto porque no toma encuenta el trafico).
|
||||
Log($"Distancia total ruta inicial: $1.1{distanciaTotal0/1000} kms, tiempo aprox: $1.1{tiempo0/60} mins. ($1.1{tiempo0/60/60} hrs)"$)
|
||||
' l_rutaInfo.Text = $"Distancia total: $1.1{distanciaTotal0/1000} kms, tiempo aprox: $1.1{tiempo0/60/60} hrs"$
|
||||
End If
|
||||
Else
|
||||
Log("Error!")
|
||||
End If
|
||||
j0.Release
|
||||
End If
|
||||
|
||||
Dim j As HttpJob
|
||||
j.Initialize("trip", Me) 'Calculamos el resto de la ruta.
|
||||
j.Download("https://router.project-osrm.org/trip/v1/driving/"&rutaCompleta&"?source=first&destination=last&roundtrip=false&geometries=geojson")
|
||||
' LogColor("https://router.project-osrm.org/trip/v1/driving/"&rutaCompleta&"?source=first&destination=last&roundtrip=false&geometries=geojson", Colors.Green)
|
||||
Wait For (j) JobDone(j As HttpJob)
|
||||
If j.Success Then
|
||||
Dim jp As JSONParser
|
||||
jp.Initialize(j.GetString)
|
||||
Dim m As Map = jp.NextObject
|
||||
If m.Get("code") = "Ok" Then
|
||||
Dim puntos As List = m.Get("waypoints")
|
||||
Private esteWayPoint As Map
|
||||
Dim twpi As Int
|
||||
For p = 0 To puntos.Size -1
|
||||
esteWayPoint = puntos.Get(p)
|
||||
' LogColor("WP:" & esteWayPoint, Colors.green)
|
||||
' LogColor("WP: " & esteWayPoint.Get("waypoint_index") & ", loc: " & esteWayPoint.Get("location") & ", name: " & esteWayPoint.Get("name"), Colors.Green)
|
||||
esteWayPoint.Remove("hint")
|
||||
esteWayPoint.Remove("distance")
|
||||
esteWayPoint.Remove("trips_index")
|
||||
twpi = esteWayPoint.Get("waypoint_index")
|
||||
esteWayPoint.Remove("waypoint_index")
|
||||
esteWayPoint.Put("waypoint_index", (twpi + cuantosAntes + 2))
|
||||
listaWayPoints.Add(esteWayPoint)
|
||||
' LogColor("estewaypoint: "&esteWayPoint, Colors.Green)
|
||||
Next
|
||||
Dim rutas As List = m.Get("trips")
|
||||
Dim rutas2 As Map = rutas.Get(0)
|
||||
distanciaTotal = rutas2.Get("distance")
|
||||
Log("distancia ruta 2:" & (distanciaTotal) & "|" & rutas2.Get("distance"))
|
||||
distanciaTotal = distanciaTotal + distanciaTotal0
|
||||
tiempo = rutas2.Get("duration")
|
||||
tiempo = (((tiempo + tiempo0) * 2) + tiempoVisitas) 'Tiempo X 2 (es muy corto porque no toma encuenta el trafico) + tiempoVisitas.
|
||||
Log($"Distancia total: $1.1{distanciaTotal/1000} kms, tiempo aprox: $1.1{tiempo/60} mins. ($1.1{tiempo/60/60} hrs)"$)
|
||||
l_rutaInfo.Text = $"Distancia: $1.1{distanciaTotal/1000} kms, tiempo aprox: $1.1{tiempo/60/60} hrs${CRLF}Visitas restantes: ${aVisitar.Keys.Size}"$
|
||||
l_rutaInfo.Width = Activity.Width * 0.9
|
||||
Subs.centraEtiqueta(l_rutaInfo, Activity.Width)
|
||||
l_rutaInfo.Visible = True
|
||||
l_rutaInfo.BringToFront
|
||||
ListView1.Top = lv1Top + 100
|
||||
End If
|
||||
Else
|
||||
LogColor("**************** Error! ******************", Colors.red)
|
||||
End If
|
||||
j.Release
|
||||
ProgressDialogHide
|
||||
|
||||
LogColor("clientesMapaO size: " & clientesMapaO.Size & "|" & listaWayPoints.Size, Colors.Blue)
|
||||
Private r As Int = 1
|
||||
Private r1, wps As Map
|
||||
Starter.skmt.ExecNonQuery("delete from waypoints")
|
||||
If listaWayPoints.Size > 0 Then
|
||||
For Each k As Object In clientesMapaO.Keys 'Guardamos en la BD el orden de los waypoints para luego generar el listview.
|
||||
r1 = clientesMapaO.Get(k)
|
||||
r1.Get("codigo")
|
||||
' Log(listaWayPoints.Get(r) & "|" & r1.Get("coords") & "|" & r1.Get("calle"))
|
||||
wps = listaWayPoints.Get(r)
|
||||
Starter.skmt.ExecNonQuery2("insert into waypoints values (?,?)", Array As Object(r1.Get("codigo"), wps.get("waypoint_index")))
|
||||
r = r + 1
|
||||
Next
|
||||
ListView1.Clear
|
||||
Sleep(100)
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 15
|
||||
label2.Height = 100dip
|
||||
ListView1.TwoLinesLayout.ItemHeight = 70dip
|
||||
Dim cs, cs2 As CSBuilder
|
||||
entro = 3
|
||||
Log("Generamos ListView1 en traeRutaDia")
|
||||
'Traemos las visitas restantes ordenadas por el indice de waypoints (este indice nos indica el orden en la ruta calculada).
|
||||
c=Starter.skmt.ExecQuery("select codigo, indice, CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_NOEXT from waypoints inner join kmt_info on waypoints.codigo = kmt_info.CAT_CL_CODIGO where gestion = 0 order by indice")
|
||||
If c.RowCount > 0 Then
|
||||
For i=0 To c.RowCount -1 'Generamos el listView con la lista ordenada.
|
||||
c.Position=i
|
||||
cs.Initialize
|
||||
cs2.Initialize
|
||||
ListView1.AddTwoLines(cs.Color(Colors.RGB(100,149,237)).Append(c.GetString("codigo")).PopAll, cs2.append(c.GetString("CAT_CL_NOMBRE")).Color(Colors.RGB(100,149,237)).Append(" Calle: ").Pop.Append(c.GetString("CAT_CL_CALLE").Trim & " " & c.GetString("CAT_CL_NOEXT")).PopAll )
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
Else
|
||||
ToastMessageShow("Hubo un error al generar el ruteo, por favor revise las coordenadas del cedis.", True)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
'Calcula distancia y tiempo de la ubicacion ACTUAL a las 8 primeras tiendas de la lista usando el API de OSRM. (Parte de la funcionalidad OSRM)
|
||||
Private Sub b_GetDirs_Click
|
||||
ProgressDialogShow("Calculando distancias y tiempos ...")
|
||||
Private m2 As Map
|
||||
Private f As Int = 0
|
||||
For Each k As Object In distOrderedMap.Keys 'Traemos la distancia y tiempo desde OSRM (2 puntos)
|
||||
m2 = distOrderedMap.Get(k)
|
||||
Private distancia2 As String = m2.Get("distancia")
|
||||
Private thisLoc1 As String = m2.Get("ubicacion")
|
||||
Private locActual As String = Tracker.UUGCoords.Longitude&","&Tracker.UUGCoords.Latitude
|
||||
If locActual = "0,0" Then 'Si no tenemos ubicacion actual de GPS, buscamos la ultima guardada en la base de datos.
|
||||
c = Starter.skmt.ExecQuery("select * from hist_gps")
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
locActual = c.GetString("hglon") & "," & c.GetString("hglat")
|
||||
End If
|
||||
c.Close
|
||||
End If
|
||||
f = f+1
|
||||
If f < 8 Then
|
||||
If locActual = "0,0" Then 'Si todavia no tenemos ubicacion actual, entonces avisamos.
|
||||
ToastMessageShow("No se pudo obtener la ubicacion actual!!", True)
|
||||
f = 8
|
||||
End If
|
||||
Log($"locActual: ${locActual}, thisLoc1: ${thisLoc1}"$)
|
||||
Wait For(distanciaEntreCoords(distancia2, locActual, thisLoc1)) Complete (r As List)
|
||||
LogColor($"R: ${r.Get(0)} - ${r.Get(1)} - ${r.Get(2)}"$, Colors.Green)
|
||||
Private tId As Int = r.Get(0)
|
||||
Private tMap As Map = distOrderedMap.Get(tId)
|
||||
LogColor("|" & tId & "| - " &distOrderedMap.Get(tId), Colors.Blue)
|
||||
Private tempNDD As String = tMap.Get("nomDirDist")
|
||||
Private indexD As Int = tempNDD.IndexOf("Distancia:")
|
||||
If indexD > -1 Then tempNDD = tempNDD.SubString2(0, indexD)
|
||||
Log(tempNDD)
|
||||
tempNDD = tempNDD & $"Dist: $1.1{(r.Get(1)/1000)} kms, Tiempo aprox: $1.0{((r.Get(2)*2)/60)} min."$ 'Multiplicamos el tiempo X 2 porque el tiempo estimado siempre es muy corto, X2 es mucho mas real con trafico.
|
||||
Private esteCliente As Map = CreateMap("distancia": distancia2, "ubicacion": tMap.Get("ubicacion"), "codigo": tMap.Get("codigo"), "nomDirDist": tempNDD)
|
||||
distOrderedMap.Put(tId, esteCliente)
|
||||
ListView1.Clear
|
||||
Private m3 As Map
|
||||
For Each k As Object In distOrderedMap.Keys 'Generamos el listView con la lista ordenada.
|
||||
m3 = distOrderedMap.Get(k)
|
||||
m3.Get("codigo")
|
||||
ListView1.AddTwoLines(m3.Get("codigo"), m3.Get("nomDirDist"))
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
ProgressDialogHide
|
||||
End Sub
|
||||
|
||||
'Regresa un mapa (B4XOrderedMap) con todos los clientes que tiene que visitar el repartidor. (Parte de la funcionalidad OSRM)
|
||||
Sub traeTodosAVisitar As B4XOrderedMap 'ignore
|
||||
Log("Iniciamos traeTodosAVisitar")
|
||||
' If Starter.waypointsOrdered.isInitialized Then Log(Starter.waypointsOrdered.Size)
|
||||
' Private rutaCompleta As String = ""
|
||||
Private thisLoc, ubicacionInicial As Location
|
||||
ubicacionInicial = Starter.cedisLocation
|
||||
LogColor(ubicacionInicial, Colors.Gray)
|
||||
c=Starter.skmt.ExecQuery("select sum(gestion) as hayVisitados from kmt_info")
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
' Log(c.GetString("hayVisitados"))
|
||||
If c.GetString("hayVisitados") <> Null And c.GetString("hayVisitados") > 0 Then ubicacionInicial = Tracker.UUGCoords 'Si ya hay clientes visitados, entonces ya no estamos en el CEDIS y la ubicacion inicial debe de ser la ACTUAL.
|
||||
End If
|
||||
c.Close
|
||||
LogColor(ubicacionInicial, Colors.Red)
|
||||
thisLoc.Initialize
|
||||
clientesMapaO.Clear
|
||||
'Traemos las rutas asignadas al repartidor.
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA, count(*) as cuantos from kmt_info where gestion = 0 group by CAT_CL_RUTA order by CAT_CL_RUTA asc")
|
||||
If c.RowCount>0 Then
|
||||
'Traemos los clientes de cada ruta.
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
' Log($"Renglones ruta: ${c.RowCount} - i=${i} - Ruta: ${c.GetString("CAT_CL_RUTA")}"$)
|
||||
c2=Starter.skmt.ExecQuery2("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO, CAT_CL_LAT, CAT_CL_LONG from kmt_info where CAT_CL_RUTA = ? and gestion = 0 order by CAT_CL_NOMBRE ", Array As String(c.GetString("CAT_CL_RUTA")))
|
||||
If c2.RowCount>0 Then
|
||||
For j=0 To c2.RowCount -1 'Generamos lista de clientes
|
||||
c2.Position=j
|
||||
' Log($"Renglones clientes: ${c2.RowCount} - j=${j} - Ruta: ${c2.GetString("CAT_CL_CODIGO")}"$)
|
||||
thisLoc.Latitude = c2.GetString("CAT_CL_LAT")
|
||||
thisLoc.Longitude = c2.GetString("CAT_CL_LONG")
|
||||
If Not(thisLoc.Latitude = 0.0) And Not(thisLoc.Latitude = 0) Then 'Este IF es para que si las coordenadas no son válidas, entonces no las agregue al mapeo, porque el API de OSRM nos manda error.
|
||||
Private distancia As Int = ubicacionInicial.DistanceTo(thisLoc) 'Calculamos la distancia del cedis a la tienda.
|
||||
If clientesMapaO.ContainsKey(distancia) Then distancia = distancia + 1 'Si por alguna extraña razon hay dos tiendas a la misma distancia del CEDIS, le sumamos 1 para que sea diferente.
|
||||
Private esteCliente As Map = CreateMap("distancia": distancia, "ordenDist": j, "coords": c2.GetString("CAT_CL_LONG")&","&c2.GetString("CAT_CL_LAT"), "codigo": c2.GetString("CAT_CL_CODIGO"), "nombre": c2.GetString("CAT_CL_NOMBRE"), "calle": c2.GetString("CAT_CL_CALLE"))
|
||||
clientesMapaO.Put(distancia, esteCliente)
|
||||
Else
|
||||
ToastMessageShow("Hay tiendas SIN coordenadas, fueron excluidas!!", False)
|
||||
End If
|
||||
' Log($"${thisLoc}"$)
|
||||
' rutaCompleta = rutaCompleta & ";" & c2.GetString("CAT_CL_LONG")&","&c2.GetString("CAT_CL_LAT")
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
clientesMapaO.Keys.Sort(True) 'Ordenamos la lista de clientes por distancia.
|
||||
c.Close
|
||||
c2.Close
|
||||
Log(c.RowCount & " rutas, " & clientesMapaO.Size & " clientes")
|
||||
' LogColor(rutaCompleta, Colors.Magenta)
|
||||
' Log(clientesMapaO)
|
||||
Return clientesMapaO
|
||||
End Sub
|
||||
|
||||
'Traemos la ruta de visitas via el API de OSRM usando el sub "traeRutaDia(traeTodosAVisitar)".
|
||||
Private Sub b_getRutaInfo_Click
|
||||
traeRutaDia(traeTodosAVisitar)
|
||||
End Sub
|
||||
|
||||
'Mostramos u ocultamos el boton para borrar los waypoints de la ruta.
|
||||
Private Sub b_getRutaInfo_LongClick
|
||||
If b_limpiarRuta.Visible Then
|
||||
b_limpiarRuta.Visible = False
|
||||
Else
|
||||
b_limpiarRuta.Visible = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Borramos los waypoints de la ruta.
|
||||
Private Sub b_limpiarRuta_Click
|
||||
Starter.skmt.ExecNonQuery("delete from waypoints")
|
||||
b_limpiarRuta.Visible = False
|
||||
Activity_Resume
|
||||
End Sub
|
||||
984
colonia2.bas
Normal file
@@ -0,0 +1,984 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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 q_buscar As String
|
||||
' 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 c2 As Cursor
|
||||
Dim ListView1 As ListView
|
||||
Dim entro As String
|
||||
Dim lfila As Label
|
||||
Dim marca As String
|
||||
Dim tipo As String
|
||||
Private BUSCA As EditText
|
||||
Dim ya_entro As String
|
||||
Dim bmp As Bitmap
|
||||
|
||||
Dim c As Cursor
|
||||
Dim e As Cursor
|
||||
Dim f As Cursor
|
||||
Dim h As Cursor
|
||||
Dim CC As Cursor
|
||||
Dim DD As Cursor
|
||||
Dim l_tipo As Label
|
||||
Dim l_sub As Label
|
||||
Dim l_marca As Label
|
||||
Dim l_desc As Label
|
||||
Dim l_precio As Label
|
||||
Dim l_bodega As Label
|
||||
Dim cantidad As EditText
|
||||
Dim guardar As Button
|
||||
Dim Terminar As Button
|
||||
Dim img_prod As ImageView
|
||||
Dim IMG_PASO() As Byte
|
||||
Dim L_PROID As Label
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
Dim t_venta As Label
|
||||
Dim PROMO_C As String
|
||||
Dim i_fotol As ImageView
|
||||
Private DESC_PROMO As Button
|
||||
Private nopromo As Button
|
||||
Dim TOT_ART_PROMO As String
|
||||
Dim cambio As String
|
||||
Dim COSTO_TOT As String
|
||||
Dim ALMACEN As String
|
||||
Dim preciosin As String
|
||||
Dim cl_ruta As String
|
||||
Dim d As Cursor
|
||||
Dim TOT_ART_PROMOR As String
|
||||
Dim PROMO_CR As String
|
||||
Dim TOTAL_PROMO As String
|
||||
Dim HCCP_CANT As String
|
||||
Private Panel1 As Panel
|
||||
Dim query As String
|
||||
Private t_precio As Label
|
||||
Private LV_PRECIOS As ListView
|
||||
Private PERFIL As String
|
||||
Private EXISTE_CAMBIO As String
|
||||
Private QUERY2 As String
|
||||
Dim CAMBIOS As String
|
||||
Dim precio2 As String
|
||||
Private B_MENOS As Button
|
||||
Private B_MAS As Button
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
If(FirstTime) Then
|
||||
g.Initialize("GPS")
|
||||
End If
|
||||
'Do not forget to load the layout file created with the visual designer. For example:
|
||||
'Activity.LoadLayout("Layout1")
|
||||
Activity.RemoveAllViews
|
||||
Activity.LoadLayout("PRODUCTOS")
|
||||
'Dim ruta As String
|
||||
' valido donde escribo el archivo de la base de datos de kmt
|
||||
' ruta = Main.ruta
|
||||
Panel1.Visible= False
|
||||
' se crea o no el archivo de la base de ddatos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
query = "cat_gunaprod"
|
||||
QUERY2 = "COUNT_GUNAPROD"
|
||||
If ya_entro <> "1" Then
|
||||
'BUSCA.Text =""
|
||||
'SE COMENTO LA LINEA DE ARRIBA YA QUE DISPARA EL EVENTO DEL TEXTCHANGE Y PUEDE HACER LENTO EL SISTEMA
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
entro ="1"
|
||||
ya_entro ="1"
|
||||
Log(query)
|
||||
c=Starter.skmt.ExecQuery("select CAT_GP_CLASIF, COUNT(*) AS CUANTOS from " & query & " WHERE CAT_GP_ALMACEN > 0 GROUP BY CAT_GP_CLASIF order by CAT_GP_CLASIF asc")
|
||||
'ESTO ES PARA NO VER PROCTER
|
||||
'c=skmt.ExecQuery2("select CAT_GP_CLASIF, count(*) as cuantos from cat_gunaprod where CAT_GP_ALMACEN > 0 and cat_gp_clasif NOT IN (?,?,?,?,?,?,?,?,?,?) group by CAT_GP_CLASIF order by CAT_GP_CLASIF asc", Array As String("PROCTER","PROMOS","TRES MONTES","CAMPARI","CAMPARI-PRO","CLOROX DE MEXICO","MARS","CONAGRA","VERDE VALLE","MEAD JOHNSON"))
|
||||
ListView1.Clear
|
||||
lfila.Text = "MARCA"
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Black
|
||||
Log(c.RowCount)
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
Log(i)
|
||||
c.Position=i
|
||||
' bmp = LoadBitmap(File.DirAssets, "palomita_verde.png")
|
||||
ListView1.AddTwoLines(c.GetString("CAT_GP_CLASIF"),c.GetString("CUANTOS"))
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
' c=skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("PERFIL"))
|
||||
' c.Position =0
|
||||
' PERFIL = c.GetString("CAT_VA_VALOR")
|
||||
' c.Close
|
||||
' If PERFIL = "V-COSTO" Then
|
||||
' skmt.ExecNonQuery("DELETE FROM CAT_GUNAPROD WHERE CAT_GP_ID IN (SELECT CAT_GP_ID FROM LISTA_PRECIOS WHERE NLISTA = '9' AND PRECIO = '0')")
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub ListView1_ItemClick (Position As Int, Value As Object)
|
||||
'Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
'que_colonia = Value
|
||||
'StartActivity(fila)
|
||||
|
||||
|
||||
If Value = "PROMOS" And fila.cuenta <> "N" Then
|
||||
entro = "3"
|
||||
marca = "PROMOS"
|
||||
tipo = "PROMOS"
|
||||
Else if Value = "PROMOS" And fila.cuenta = "N" Then
|
||||
entro = "5"
|
||||
StartActivity(fila)
|
||||
End If
|
||||
If entro = "1" Then
|
||||
marca = Value
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c2=Starter.skmt.ExecQuery2("select COUNT(*) AS CUANTOS, CAT_GP_TIPO from " & query & " where CAT_GP_ALMACEN > 0 and CAT_GP_CLASIF = ? GROUP BY CAT_GP_TIPO ORDER BY CAT_GP_TIPO ASC", Array As String(Value))
|
||||
ListView1.Clear
|
||||
lfila.text = "TIPO"
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
ListView1.AddTwoLines(c2.GetString("CAT_GP_TIPO"),c2.GetString("CUANTOS"))
|
||||
Next
|
||||
End If
|
||||
entro = "3"
|
||||
Else If entro = "2" Then
|
||||
tipo = Value
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c2=Starter.skmt.ExecQuery2("select COUNT(*) AS CUANTOS, CAT_GP_SUBTIPO from " & query & " where CAT_GP_ALMACEN > 0 and CAT_GP_CLASIF = ? and CAT_GP_TIPO = ? GROUP BY CAT_GP_SUBTIPO ORDER BY CAT_GP_SUBTIPO ASC ", Array As String(marca, Value))
|
||||
ListView1.Clear
|
||||
lfila.text = "SUB-TIPO"
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
ListView1.AddTwoLines(c2.GetString("CAT_GP_SUBTIPO"),c2.GetString("CUANTOS"))
|
||||
Next
|
||||
End If
|
||||
entro = "3"
|
||||
|
||||
Else If entro = "3" Then
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c2=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from " & query & " where CAT_GP_ALMACEN > 0 and CAT_GP_CLASIF = ? AND CAT_GP_TIPO = ? ", Array As String(marca, Value))
|
||||
ListView1.Clear
|
||||
lfila.text = "PRODUCTO"
|
||||
Dim ins As InputStream
|
||||
Dim bmp As Bitmap
|
||||
Dim jpeg() As Byte
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
jpeg = c2.GetBlob("CAT_GP_IMG")
|
||||
ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
|
||||
bmp.Initialize2(ins)
|
||||
|
||||
ListView1.AddTwoLines(c2.GetString("CAT_GP_NOMBRE"),"# " & c2.GetString("CAT_GP_ALMACEN") & " $ " & c2.GetString("CAT_GP_PRECIO"))
|
||||
Next
|
||||
End If
|
||||
entro = "4"
|
||||
Else If entro = "4" Then
|
||||
|
||||
Starter.skmt.ExecNonQuery("delete from PROID")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROID VALUES (?)", Array As Object(Value))
|
||||
'StartActivity(pedidos)
|
||||
HACER_PEDIDO
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_KeyPress (key As Int) As Boolean
|
||||
' BACK key pressed
|
||||
If key=KeyCodes.KEYCODE_BACK Then
|
||||
ya_entro ="0"
|
||||
If entro = "4" Then
|
||||
entro = "3"
|
||||
Activity_Resume
|
||||
Return True
|
||||
Else If entro = "3" Then
|
||||
' entro = "2"
|
||||
' Activity_Resume
|
||||
' Return True
|
||||
' Else If entro = "2" Then
|
||||
' entro = "1"
|
||||
' Activity_Resume
|
||||
' Return True
|
||||
'Else If entro = "1" Then
|
||||
|
||||
' I want to capture the key here so I return True
|
||||
|
||||
StartActivity(fila)
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
|
||||
End Sub
|
||||
|
||||
Sub BUSCA_TextChanged (Old As String, New As String)
|
||||
q_buscar = "%" & BUSCA.Text & "%"
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
' c=skmt.ExecQuery2("select CAT_GP_NOMBRE from cat_gunaprod where CAT_GP_ALMACEN > 0 and CAT_GP_NOMBRE like ? AND cat_gp_clasif NOT IN (?,?,?,?,?,?,?,?,?,?) order by CAT_GP_NOMBRE asc", Array As String(q_buscar, "PROCTER","PROMOS","TRES MONTES","CAMPARI","CAMPARI-PRO","CLOROX DE MEXICO","MARS","CONAGRA","VERDE VALLE","MEAD JOHNSON"))
|
||||
c=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO,CAT_GP_IMG from " & query & " where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_NOMBRE like ? and CAT_GP_CLASIF <> ? and (length(CAT_GP_CODPROMO) = 1 OR CAT_GP_CODPROMO = CAT_GP_ID) order by CAT_GP_NOMBRE asc", Array As String(q_buscar,"PROMOS"))
|
||||
'and CAT_GP_CLASIF <> ? group by CAT_GP_CLASIF order by CAT_GP_CLASIF asc", Array As String("PROMOS") )
|
||||
|
||||
ListView1.Clear
|
||||
|
||||
Dim ins As InputStream
|
||||
Dim bmp As Bitmap
|
||||
Dim jpeg() As Byte
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
jpeg = c.GetBlob("CAT_GP_IMG")
|
||||
ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
|
||||
bmp.Initialize2(ins)
|
||||
|
||||
ListView1.AddTwoLines(c.GetString("CAT_GP_NOMBRE"),"Existencia " & c.GetString("CAT_GP_ALMACEN") & " Precio $" & c.GetString("CAT_GP_PRECIO"))
|
||||
Next
|
||||
End If
|
||||
|
||||
|
||||
|
||||
' If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
' c.Position=i
|
||||
' Dim label1 As Label
|
||||
' label1 = ListView1.SingleLineLayout.Label
|
||||
' label1.TextSize = 13
|
||||
' ListView1.AddSingleLine(c.GetString("CAT_GP_NOMBRE"))
|
||||
' Next
|
||||
' End If
|
||||
c.Close
|
||||
entro= "4"
|
||||
End Sub
|
||||
|
||||
Sub HACER_PEDIDO
|
||||
|
||||
c=Starter.skmt.ExecQuery("Select SUBSTR(CUENTA,1,1) AS CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
|
||||
Panel1.Visible= True
|
||||
cambio = "0"
|
||||
' If g.GPSEnabled=False Then
|
||||
' ToastMessageShow("Habilitar el GPS", True)
|
||||
' StartActivity(g.LocationSettingsIntent)
|
||||
' Else
|
||||
' g.Start(0,0)
|
||||
' End If
|
||||
cantidad.Text = ""
|
||||
c=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
|
||||
C.Position =0
|
||||
ALMACEN = C.GetString("ID_ALMACEN")
|
||||
C.Close
|
||||
i_fotol.Visible = False
|
||||
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.skmt.ExecQuery("select CAT_GP_ID,CAT_GP_NOMBRE,CAT_GP_IMP1,CAT_GP_IMP2,CAT_GP_PRECIO,CAT_GP_CLASIF,CAT_GP_STS,CAT_GP_TIPO,CAT_GP_SUBTIPO,CAT_GP_IMG,CAT_GP_ALMACEN,CAT_GP_DEV from " & query & " where CAT_GP_NOMBRE In (Select PDESC from PROID)")
|
||||
' ListView1.Clear
|
||||
|
||||
'If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
c.Position=0
|
||||
L_PROID.Text = c.GetString("CAT_GP_ID")
|
||||
l_tipo.Text = c.GetString("CAT_GP_TIPO")
|
||||
l_sub.Text = c.GetString("CAT_GP_SUBTIPO")
|
||||
l_marca.Text = c.GetString("CAT_GP_CLASIF")
|
||||
l_desc.Text = c.GetString("CAT_GP_NOMBRE")
|
||||
|
||||
If PERFIL = "V-SUPER" Then
|
||||
c2=Starter.skmt.ExecQuery("select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA = '10' AND CAT_GP_ID =" & "'" &L_PROID.TEXT&"' ORDER BY NLISTA ASC")
|
||||
c2.Position=0
|
||||
l_precio.Text = c2.GetString("PRECIO")
|
||||
c2.Close
|
||||
Else
|
||||
l_precio.Text = c.GetDouble("CAT_GP_PRECIO")
|
||||
End If
|
||||
l_bodega.Text = c.GetString("CAT_GP_ALMACEN")
|
||||
IMG_PASO = c.GetBlob("CAT_GP_IMG")
|
||||
PROMO_C = c.GetString("CAT_GP_STS")
|
||||
cambio = c.GetString("CAT_GP_DEV")
|
||||
preciosin = c.GetString("CAT_GP_IMP2")
|
||||
PROMO_CR = c.GetString("CAT_GP_IMP1")
|
||||
precio2 = l_precio.Text
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" Then
|
||||
DESC_PROMO.Visible = True
|
||||
CC=Starter.skmt.ExecQuery2("select count(*) as CUANTOS FROM PROMOS_COMP WHERE CAT_PA_ID = ?", Array As String(c.GetString("CAT_GP_ID")))
|
||||
CC.Position =0
|
||||
If CC.GetString("CUANTOS") = 0 Then
|
||||
l_bodega.Text = "4"
|
||||
Else
|
||||
CC.Close
|
||||
CC=Starter.skmt.ExecQuery2("select CAT_PA_MAXPROM, CAT_PA_MAXPROMREC, CAT_PA_MAXPROMCLIE FROM PROMOS_COMP WHERE CAT_PA_ID = ?", Array As String(c.GetString("CAT_GP_ID")))
|
||||
CC.Position =0
|
||||
|
||||
DD=Starter.skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM HIST_CLIENTE_CANT_PROMOS WHERE HCCP_CLIENTE IN (Select cuenta from cuentaa) AND HCCP_PROMO =?", Array As String(c.GetString("CAT_GP_ID")))
|
||||
DD.Position =0
|
||||
If DD.GetString("CUANTOS") = 0 Then
|
||||
HCCP_CANT = 0
|
||||
|
||||
Else
|
||||
DD.Close
|
||||
|
||||
DD=Starter.skmt.ExecQuery2("SELECT HCCP_CANT FROM HIST_CLIENTE_CANT_PROMOS WHERE HCCP_CLIENTE IN (Select cuenta from cuentaa) AND HCCP_PROMO =?", Array As String(c.GetString("CAT_GP_ID")))
|
||||
DD.Position =0
|
||||
HCCP_CANT = DD.GetString("HCCP_CANT")
|
||||
DD.Close
|
||||
End If
|
||||
TOTAL_PROMO = CC.GetString("CAT_PA_MAXPROMCLIE") - HCCP_CANT
|
||||
If HCCP_CANT = 0 Then
|
||||
|
||||
l_bodega.Text = CC.GetString("CAT_PA_MAXPROM")
|
||||
Else IF TOTAL_PROMO > CC.GetString("CAT_PA_MAXPROMREC") Then
|
||||
l_bodega.Text = CC.GetString("CAT_PA_MAXPROMREC")
|
||||
Else
|
||||
l_bodega.Text = TOTAL_PROMO
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
DESC_PROMO.Visible = False
|
||||
End If
|
||||
|
||||
c.Close
|
||||
c=Starter.skmt.ExecQuery("select CASE WHEN pe_costo_tot is null then 0 else sum( pe_costo_tot ) end as TOTAL_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
t_venta.Text = c.GetString("TOTAL_CLIE")
|
||||
c.Close
|
||||
' If t_venta.Text < 100 AND l_tipo.Text = "PROMOS" Then
|
||||
'Terminar.Visible = False
|
||||
'guardar.Visible = False
|
||||
'cantidad.Visible = False
|
||||
'nopromo.Visible = True
|
||||
'Else
|
||||
'cambio = 0
|
||||
Terminar.Visible = True
|
||||
guardar.Visible = True
|
||||
cantidad.Visible = True
|
||||
nopromo.Visible = False
|
||||
'End If
|
||||
|
||||
|
||||
Dim out As OutputStream
|
||||
out = File.OpenOutput(Starter.ruta, "1.jpg", False)
|
||||
out.WriteBytes(IMG_PASO, 0, IMG_PASO.Length)
|
||||
out.Close
|
||||
img_prod.Bitmap = LoadBitmap(Starter.ruta,"1.jpg")
|
||||
TOT_ART_PROMO = "0"
|
||||
TOT_ART_PROMOR = "0"
|
||||
If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And l_bodega.Text = "0" Then
|
||||
Msgbox("ALERTA","EL CLIENTE YA NO PUEDE TENER ESTA PROMOCION") 'ignore
|
||||
Panel1.Visible= False
|
||||
End If
|
||||
|
||||
If marca <> "PROMOS" Then
|
||||
|
||||
If PERFIL = "PREVENTA" Then
|
||||
|
||||
t_precio.Visible = False
|
||||
LV_PRECIOS.Visible = False
|
||||
|
||||
ELSE IF PERFIL = "V-ESPECIAL" Then
|
||||
c=Starter.skmt.ExecQuery("select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA IN ('5','6','7','8','10') AND CAT_GP_ID =" & "'" &L_PROID.TEXT&"' ORDER BY NLISTA ASC")
|
||||
LV_PRECIOS.Clear
|
||||
Dim label1 As Label
|
||||
label1 = LV_PRECIOS.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = LV_PRECIOS.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Black
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
LV_PRECIOS.AddTwoLines(c.GetString("NLISTA"),c.GetString("PRECIO"))
|
||||
Next
|
||||
End If
|
||||
ELSE IF PERFIL = "V-MINI" Then
|
||||
t_precio.Visible = False
|
||||
LV_PRECIOS.Visible = False
|
||||
|
||||
c=Starter.skmt.ExecQuery("select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA = '2' AND CAT_GP_ID =" & "'" &L_PROID.TEXT&"' ORDER BY NLISTA ASC")
|
||||
c.Position=0
|
||||
l_precio.Text = c.GetString("PRECIO")
|
||||
c.Close
|
||||
ELSE IF PERFIL = "V-COSTO" Then
|
||||
|
||||
t_precio.Visible = False
|
||||
LV_PRECIOS.Visible = False
|
||||
|
||||
c=Starter.skmt.ExecQuery("select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA = '9' AND CAT_GP_ID =" & "'" &L_PROID.TEXT&"' ORDER BY NLISTA ASC")
|
||||
c.Position=0
|
||||
l_precio.Text = c.GetString("PRECIO")
|
||||
c.Close
|
||||
ELSE IF PERFIL = "V-SUPER" Then
|
||||
|
||||
t_precio.Visible = False
|
||||
LV_PRECIOS.Visible = False
|
||||
|
||||
c=Starter.skmt.ExecQuery("select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA ='9' AND CAT_GP_ID =" & "'" &L_PROID.TEXT&"' ORDER BY NLISTA ASC")
|
||||
c.Position=0
|
||||
l_precio.Text = c.GetString("PRECIO")
|
||||
c.Close
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
Sub guardar_Click
|
||||
If cantidad.Text = "" Then
|
||||
Panel1.Visible= False
|
||||
|
||||
|
||||
ELSE If cantidad.Text > l_bodega.Text Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C > 0 And cantidad.Text > 0 Then
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=Starter.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMO = C.GetString("TOT_ART_PROMO")
|
||||
COSTO_TOT = C.GetString("COSTO_TOT")
|
||||
C.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
TOT_ART_PROMOR = "0" 'Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA")
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMOR = C.GetString("TOT_ART_PROMO")
|
||||
End If
|
||||
C.Close
|
||||
|
||||
|
||||
PROMO_C = PROMO_C * cantidad.Text
|
||||
PROMO_CR = PROMO_CR * cantidad.Text
|
||||
|
||||
If TOT_ART_PROMO = PROMO_C And TOT_ART_PROMOR = PROMO_CR Then
|
||||
' anterior a 29/06/2015
|
||||
'skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(l_precio.text/(TOT_ART_PROMO/cantidad.Text),l_precio.text/(TOT_ART_PROMO/cantidad.Text)))
|
||||
'en pe_cedis meto el codigo de promocion para hacer esta validacion.
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_CEDIS = (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(L_PROID.text))
|
||||
D=Starter.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
D=Starter.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
|
||||
|
||||
|
||||
'skmt.ExecNonQuery("UPDATE PEDIDO SET PE_COSTO_TOT = 0.01 WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))")
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
|
||||
c.Close
|
||||
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=Starter.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 AND CAT_DP_PRECIO = 0")
|
||||
|
||||
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
|
||||
F=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 AND CAT_DP_PRECIO = 0")
|
||||
'se coloco el if por la mala promocion.
|
||||
|
||||
For i=0 To F.RowCount -1
|
||||
F.Position=i
|
||||
|
||||
h=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from " & query & " where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Starter.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,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0, 0, f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta,"VENTA",precio2))
|
||||
h.Close
|
||||
Next
|
||||
|
||||
|
||||
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
|
||||
|
||||
Starter.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,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,"VENTA",precio2))
|
||||
Starter.skmt.ExecNonQuery2("update " & query & " set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
Else
|
||||
Msgbox("Tiene " & TOT_ART_PROMO & " " & TOT_ART_PROMOR & " y necesita " & PROMO_C & " " & PROMO_CR & " Para la Promo. " , "ADVERTENCIA") 'ignore
|
||||
End If
|
||||
End If
|
||||
|
||||
cantidad.Text = ""
|
||||
Panel1.Visible= False
|
||||
|
||||
else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C = 0 Then
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
|
||||
c.Close
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=Starter.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) ")
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS, CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID)")
|
||||
For i =0 To f.RowCount -1
|
||||
F.Position =i
|
||||
h=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from " & query & " where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Starter.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,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,f.GetString("CAT_DP_PRECIO") * cantidad.text * f.GetString("CAT_DP_PZAS"), f.GetString("CAT_DP_PRECIO"), f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta,"VENTA",precio2))
|
||||
h.Close
|
||||
Next
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
Starter.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,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,"VENTA",precio2))
|
||||
Starter.skmt.ExecNonQuery2("update " & query & " set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
cantidad.Text = ""
|
||||
c=Starter.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
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
Starter.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"), Main.lon_gps, Main.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
' If Main.tipov <> "ABORDO" Then
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
|
||||
' End If
|
||||
|
||||
Panel1.Visible= False
|
||||
|
||||
|
||||
Else
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
|
||||
Starter.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,PE_COSTO_SIN,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (ALMACEN,cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,preciosin,"VENTA",precio2))
|
||||
Starter.skmt.ExecNonQuery2("update " & query & " set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
c=Starter.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
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
Starter.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"), Main.lon_gps, Main.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
|
||||
|
||||
Panel1.Visible= False
|
||||
|
||||
End If
|
||||
End Sub
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
' lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
' lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
Sub Terminar_Click
|
||||
If cantidad.Text = "" Then
|
||||
StartActivity(fila)
|
||||
|
||||
ELSE If cantidad.Text > l_bodega.Text Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C > 0 And cantidad.Text > 0 Then
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=Starter.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMO = C.GetString("TOT_ART_PROMO")
|
||||
COSTO_TOT = C.GetString("COSTO_TOT")
|
||||
C.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
TOT_ART_PROMOR = "0" 'Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA")
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMOR = C.GetString("TOT_ART_PROMO")
|
||||
End If
|
||||
C.Close
|
||||
|
||||
|
||||
PROMO_C = PROMO_C * cantidad.Text
|
||||
PROMO_CR = PROMO_CR * cantidad.Text
|
||||
|
||||
If TOT_ART_PROMO = PROMO_C And TOT_ART_PROMOR = PROMO_CR Then
|
||||
' anterior a 29/06/2015
|
||||
'skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(l_precio.text/(TOT_ART_PROMO/cantidad.Text),l_precio.text/(TOT_ART_PROMO/cantidad.Text)))
|
||||
'en pe_cedis meto el codigo de promocion para hacer esta validacion.
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_CEDIS = (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(L_PROID.text))
|
||||
D=Starter.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
D=Starter.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
|
||||
|
||||
|
||||
'skmt.ExecNonQuery("UPDATE PEDIDO SET PE_COSTO_TOT = 0.01 WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))")
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=Starter.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 AND CAT_DP_PRECIO = 0")
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 AND CAT_DP_PRECIO = 0")
|
||||
'meter el otro
|
||||
F.Position =0
|
||||
h=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from " & query & " where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Starter.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,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0, 0, f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta,"VENTA",precio2))
|
||||
h.Close
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
Starter.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,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,"VENTA",precio2))
|
||||
Starter.skmt.ExecNonQuery2("update " & query & " set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
Else
|
||||
Msgbox("Tiene " & TOT_ART_PROMO & " " & TOT_ART_PROMOR & " y necesita " & PROMO_C & " " & PROMO_CR & " Para la Promo. " , "ADVERTENCIA") 'ignore
|
||||
End If
|
||||
End If
|
||||
|
||||
cantidad.Text = ""
|
||||
Panel1.Visible= False
|
||||
StartActivity(fila)
|
||||
else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C = 0 Then
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
|
||||
c.Close
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=Starter.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) ")
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS, CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID)")
|
||||
For i =0 To f.RowCount -1
|
||||
F.Position =i
|
||||
h=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from " & query & " where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Starter.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,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,f.GetString("CAT_DP_PRECIO") * cantidad.text * f.GetString("CAT_DP_PZAS"), f.GetString("CAT_DP_PRECIO"), f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta,"VENTA",precio2))
|
||||
h.Close
|
||||
Next
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
Starter.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,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,"VENTA",precio2))
|
||||
Starter.skmt.ExecNonQuery2("update " & query & " set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
cantidad.Text = ""
|
||||
c=Starter.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
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
Starter.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"), Main.lon_gps, Main.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
|
||||
StartActivity(fila)
|
||||
|
||||
Else
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
|
||||
Starter.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,PE_COSTO_SIN,PE_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (ALMACEN,cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,preciosin,"VENTA",precio2))
|
||||
Starter.skmt.ExecNonQuery2("update " & query & " set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
'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"), lon_gps, lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
'skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Panel1.Visible= False
|
||||
StartActivity(fila)
|
||||
End If
|
||||
End Sub
|
||||
Sub i_fotol_Click
|
||||
i_fotol.Visible = False
|
||||
|
||||
End Sub
|
||||
|
||||
Sub DESC_PROMO_Click
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
|
||||
StartActivity(detalle_promo)
|
||||
End Sub
|
||||
Sub nopromo_Click
|
||||
c=Starter.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("CAMBIOS"))
|
||||
c.Position =0
|
||||
CAMBIOS = c.GetString("CAT_VA_VALOR")
|
||||
c.Close
|
||||
If CAMBIOS = "1" Then
|
||||
c=Starter.skmt.ExecQuery("select COUNT(*) AS CUANTOS from HIST_RMI WHERE HR_CLIENTE IN (Select CUENTA from cuentaa) and HR_PROID = '" & L_PROID.Text & "'")
|
||||
c.Position =0
|
||||
EXISTE_CAMBIO = c.GetString("CUANTOS")
|
||||
c.Close
|
||||
If EXISTE_CAMBIO = 0 Then
|
||||
EXISTE_CAMBIO = 0
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery("select SUM(HR_CANT) AS CUANTOS from HIST_RMI WHERE HR_CLIENTE IN (Select CUENTA from cuentaa) and HR_PROID = '" & L_PROID.Text & "'")
|
||||
c.Position =0
|
||||
EXISTE_CAMBIO = c.GetString("CUANTOS")
|
||||
c.Close
|
||||
|
||||
End If
|
||||
If EXISTE_CAMBIO = 0 Then
|
||||
Msgbox("NO SE VENDIO ESTE PRODUCTO, NO SE PUEDE CAMBIAR","ALERTA") 'ignore
|
||||
ELSE If cantidad.Text = "" Then
|
||||
Msgbox("Cantidad no puede ser 0","Cantidad") 'ignore
|
||||
Else If cantidad.Text > EXISTE_CAMBIO Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
|
||||
Starter.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_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object ("DUR",0,0, cantidad.text,"CAMBIO" & l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,"VENTA",precio2))
|
||||
Starter.skmt.ExecNonQuery2("update " & query & " set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
|
||||
|
||||
cantidad.Text = ""
|
||||
Panel1.Visible= False
|
||||
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
If cantidad.Text > 15 Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
|
||||
Starter.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_TIPO,PE_PRECIO2) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object ("DUR",0,0, cantidad.text,"CAMBIO" & l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,"VENTA",precio2))
|
||||
Starter.skmt.ExecNonQuery2("update " & query & " set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
|
||||
|
||||
cantidad.Text = ""
|
||||
Panel1.Visible= False
|
||||
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub LV_PRECIOS_ItemClick (Position As Int, Value As Object)
|
||||
c=Starter.skmt.ExecQuery("select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA = " & "'" & Value &"' AND CAT_GP_ID =" & "'" &L_PROID.TEXT&"' ORDER BY NLISTA ASC")
|
||||
c.Position=0
|
||||
l_precio.Text = c.GetString("PRECIO")
|
||||
c.Close
|
||||
End Sub
|
||||
|
||||
Sub B_MENOS_Click
|
||||
If cantidad.Text = "" Then
|
||||
cantidad.Text = ""
|
||||
Else IF cantidad.Text > 0 Then
|
||||
cantidad.Text = cantidad.Text -1
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub B_MAS_Click
|
||||
If cantidad.Text = "" Then
|
||||
cantidad.Text = 1
|
||||
Else
|
||||
cantidad.Text = cantidad.Text + 1
|
||||
End If
|
||||
End Sub
|
||||
56
dbc_reparto.b4a.meta
Normal file
@@ -0,0 +1,56 @@
|
||||
VisibleModules=1,2,3,4,5,6,7,8,9,10
|
||||
ModuleBreakpoints0=
|
||||
ModuleBookmarks0=
|
||||
ModuleClosedNodes0=
|
||||
ModuleBreakpoints1=
|
||||
ModuleBookmarks1=
|
||||
ModuleClosedNodes1=3
|
||||
ModuleBreakpoints2=
|
||||
ModuleBookmarks2=
|
||||
ModuleClosedNodes2=
|
||||
ModuleBreakpoints3=
|
||||
ModuleBookmarks3=
|
||||
ModuleClosedNodes3=
|
||||
ModuleBreakpoints4=
|
||||
ModuleBookmarks4=
|
||||
ModuleClosedNodes4=
|
||||
ModuleBreakpoints5=
|
||||
ModuleBookmarks5=
|
||||
ModuleClosedNodes5=
|
||||
ModuleBreakpoints6=
|
||||
ModuleBookmarks6=
|
||||
ModuleClosedNodes6=
|
||||
ModuleBreakpoints7=
|
||||
ModuleBookmarks7=
|
||||
ModuleClosedNodes7=
|
||||
ModuleBreakpoints8=
|
||||
ModuleBookmarks8=
|
||||
ModuleClosedNodes8=
|
||||
ModuleBreakpoints9=
|
||||
ModuleBookmarks9=
|
||||
ModuleClosedNodes9=
|
||||
ModuleBreakpoints10=
|
||||
ModuleBookmarks10=
|
||||
ModuleClosedNodes10=
|
||||
ModuleBreakpoints11=
|
||||
ModuleBookmarks11=
|
||||
ModuleClosedNodes11=
|
||||
ModuleBreakpoints12=
|
||||
ModuleBookmarks12=
|
||||
ModuleClosedNodes12=
|
||||
ModuleBreakpoints13=
|
||||
ModuleBookmarks13=
|
||||
ModuleClosedNodes13=
|
||||
ModuleBreakpoints14=
|
||||
ModuleBookmarks14=
|
||||
ModuleClosedNodes14=
|
||||
ModuleBreakpoints15=
|
||||
ModuleBookmarks15=
|
||||
ModuleClosedNodes15=
|
||||
ModuleBreakpoints16=
|
||||
ModuleBookmarks16=
|
||||
ModuleClosedNodes16=
|
||||
ModuleBreakpoints17=
|
||||
ModuleBookmarks17=
|
||||
ModuleClosedNodes17=
|
||||
SelectedBuild=0
|
||||
132
detalle_promo.bas
Normal file
@@ -0,0 +1,132 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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 Regresar As Button
|
||||
Dim b As Cursor
|
||||
Dim regalo As String
|
||||
|
||||
|
||||
Dim ListView1 As ListView
|
||||
Dim L_CANT As Label
|
||||
Dim L_TOTAL As Label
|
||||
Dim borra As Button
|
||||
Dim Existe As String
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
' ruta = Main.ruta
|
||||
Activity.LoadLayout("detalle_promo")
|
||||
|
||||
' se crea o no el archivo de la base de ddatos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS, CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID)")
|
||||
ListView1.Clear
|
||||
Subs.SetDivider(ListView1, Colors.LightGray, 2)
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
b=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from cat_gunaprod where CAT_GP_ID = ?", Array As String(C.GetString("CAT_DP_IDPROD")))
|
||||
B.Position =0
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.White
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.White
|
||||
If c.GetString("CAT_DP_PRECIO") = 0 Then
|
||||
regalo = "SI"
|
||||
Else
|
||||
regalo = "NO"
|
||||
End If
|
||||
ListView1.AddTwoLines(B.GetString("CAT_GP_NOMBRE"),"Cantidad # "& c.GetString("CAT_DP_PZAS")& " REGALO "& regalo)
|
||||
b.Close
|
||||
Next
|
||||
c.Close
|
||||
End If
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
'ListView1.AddTwoLines(c.GetString("pr_cd_nombre"),c.GetString("pr_cd_colonia"))
|
||||
' Next
|
||||
'End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS, CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID)")
|
||||
ListView1.Clear
|
||||
Subs.SetDivider(ListView1, Colors.LightGray, 2)
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
b=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from cat_gunaprod where CAT_GP_ID = ?", Array As String(C.GetString("CAT_DP_IDPROD")))
|
||||
B.Position =0
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.White
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.White
|
||||
If c.GetString("CAT_DP_PRECIO") = 0 Then
|
||||
regalo = "SI"
|
||||
Else
|
||||
regalo = "NO"
|
||||
End If
|
||||
ListView1.AddTwoLines(B.GetString("CAT_GP_NOMBRE"),"Cantidad # "& c.GetString("CAT_DP_PZAS")& " REGALO "& regalo)
|
||||
b.Close
|
||||
Next
|
||||
c.Close
|
||||
End If
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub Regresar_Click
|
||||
StartActivity(pedidos)
|
||||
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(pedidos)
|
||||
'Return True
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
517
fila.bas
Normal file
@@ -0,0 +1,517 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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 clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
Dim cuenta 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 LONGITUD As String
|
||||
Dim LATITUD As String
|
||||
Dim NOMBRE As String
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Globals
|
||||
'These global variables will be redeclared each time the activity is created.
|
||||
'These variables can only be accessed from this module.
|
||||
|
||||
Dim c As Cursor
|
||||
Dim s As Cursor
|
||||
Dim 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
|
||||
Private L_QR As Label
|
||||
Private BT_QR 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
|
||||
|
||||
Private l_total As Label
|
||||
Private HIST As Button
|
||||
Dim PASA_IMP As String
|
||||
Private B_IMP As Button
|
||||
Dim total_cliente As String
|
||||
Dim CREDITO As String
|
||||
Private p_principal As Panel
|
||||
Private B_PASO2 As Button
|
||||
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")
|
||||
If(FirstTime) Then
|
||||
g.Initialize("GPS")
|
||||
End If
|
||||
Activity.LoadLayout("info_gral")
|
||||
|
||||
' valido donde escribo el archivo de la base de datos de kmt
|
||||
' ruta = Main.ruta
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.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)")
|
||||
s=Starter.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
|
||||
|
||||
' ListView1.Clear
|
||||
|
||||
'If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
c.Position=0
|
||||
la_cuenta.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")
|
||||
la_cp.Text = c.GetString("CAT_CL_CP")
|
||||
l_entre1.Text = c.GetString("CAT_CL_CALLE1")
|
||||
l_entre2.Text = c.GetString("CAT_CL_CALLE2")
|
||||
If c.GetString("CAT_CL_ATIENDE1") <> Null And c.GetString("CAT_CL_ATIENDE1") <> "null" Then
|
||||
l_atiende.Text = c.GetString("CAT_CL_ATIENDE1")
|
||||
Else
|
||||
l_atiende.Text = " "
|
||||
End If
|
||||
If c.GetString("CAT_CL_ATIENTE2") <> Null And c.GetString("CAT_CL_ATIENTE2") <> "NULL" Then
|
||||
l_atiende2.Text = c.GetString("CAT_CL_ATIENTE2")
|
||||
Log("|"&c.GetString("CAT_CL_ATIENTE2")&"|")
|
||||
Else
|
||||
l_atiende2.Text = " "
|
||||
End If
|
||||
la_saldotot.Text = c.GetString("CAT_CL_TELEFONO")
|
||||
la_saldooper.Text = c.GetString("CAT_CL_EMAIL")
|
||||
l_total.Text = s.GetString("TOTAL_CLIE")
|
||||
' la_producto.Text = c.GetString("CDPROD")
|
||||
'la_numero.Text = c.GetString("CDNUMEXT")
|
||||
'la_nint.Text = c.GetString("CDNUMINT")
|
||||
'la_pob.Text = c.GetString("CFSDOGLOBAL")
|
||||
|
||||
'la_saldooper.Text = c.GetString("CAT_CL_FALTA")
|
||||
'Label10.Text = "FECHA DE ALTA"
|
||||
'Label11.Text = "# ENCUESTAS"
|
||||
|
||||
'c=skmt.ExecQuery("select MGCTA, MGACTT, MGGESTT, MGDTEACTT, COMM from hist_gest where MGCTA In (Select cuenta from cuentaa)")
|
||||
'c.Position=0
|
||||
'la_comm.Text = c.GetString("COMM")
|
||||
'la_actdte.Text = C.GetString("MGDTEACTT")
|
||||
'la_usuario.Text = c.GetString("MGGESTT")
|
||||
'la_resultado.Text = c.GetString("MGACTT")
|
||||
|
||||
|
||||
'la_padre.Text = c.GetString("PR_CF_FECHA_DISP")
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
|
||||
' 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.
|
||||
'ListView1.AddTwoLines(c.GetString("pr_cd_nombre"),c.GetString("pr_cd_colonia"))
|
||||
' Next
|
||||
'End If
|
||||
If FirstTime Then
|
||||
btAdmin.Initialize("BlueTeeth")
|
||||
cmp20.Initialize("Printer")
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
' If g.GPSEnabled=False Then
|
||||
' ToastMessageShow("Habilitar el GPS", True)
|
||||
' StartActivity(g.LocationSettingsIntent)
|
||||
' Else
|
||||
' g.Start(0,0)
|
||||
' End If
|
||||
Subs.centraPanel(p_principal, Activity.Width)
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.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_BCREDITO from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
s=Starter.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
|
||||
|
||||
' ListView1.Clear
|
||||
|
||||
'If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
c.Position=0
|
||||
la_cuenta.Text = c.GetString("CAT_CL_CODIGO")
|
||||
La_nombre.Text = c.GetString("CAT_CL_NOMBRE")
|
||||
NOMBRE = c.GetString("CAT_CL_NOMBRE")
|
||||
LONGITUD = c.GetString("CAT_CL_LONG")
|
||||
LATITUD = c.GetString("CAT_CL_LAT")
|
||||
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")
|
||||
If c.GetString("CAT_CL_ATIENDE1") <> Null And c.GetString("CAT_CL_ATIENDE1") <> "null" Then
|
||||
l_atiende.Text = c.GetString("CAT_CL_ATIENDE1")
|
||||
Else
|
||||
l_atiende.Text = " "
|
||||
End If
|
||||
If c.GetString("CAT_CL_ATIENTE2") <> Null And c.GetString("CAT_CL_ATIENTE2") <> "NULL" Then
|
||||
l_atiende2.Text = c.GetString("CAT_CL_ATIENTE2")
|
||||
Else
|
||||
l_atiende2.Text = " "
|
||||
End If
|
||||
la_saldotot.Text = c.GetString("CAT_CL_TELEFONO")
|
||||
la_saldooper.Text = c.GetString("CAT_CL_EMAIL")
|
||||
l_total.Text = s.GetString("TOTAL_CLIE")
|
||||
CREDITO = C.GetString("CAT_CL_BCREDITO")
|
||||
|
||||
If CREDITO = "1" Then
|
||||
Msgbox("AVISO","SE TIENE QUE IMPRIMIR PAGARÉ") 'ignore
|
||||
End If
|
||||
' la_producto.Text = c.GetString("CDPROD")
|
||||
'la_numero.Text = c.GetString("CDNUMEXT")
|
||||
'la_nint.Text = c.GetString("CDNUMINT")
|
||||
'la_pob.Text = c.GetString("CFSDOGLOBAL")
|
||||
|
||||
'la_saldooper.Text = c.GetString("CAT_CL_FALTA")
|
||||
'Label10.Text = "FECHA DE ALTA"
|
||||
'Label11.Text = "# ENCUESTAS"
|
||||
|
||||
|
||||
'c=skmt.ExecQuery("select MGCTA, MGACTT, MGGESTT, MGDTEACTT, COMM from hist_gest where MGCTA In (Select cuenta from cuentaa)")
|
||||
'c.Position=0
|
||||
'la_comm.Text = c.GetString("COMM")
|
||||
'la_actdte.Text = C.GetString("MGDTEACTT")
|
||||
'la_usuario.Text = c.GetString("MGGESTT")
|
||||
'la_resultado.Text = c.GetString("MGACTT")
|
||||
' StartPrinter
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
' lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
' lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
|
||||
|
||||
Dim sDate,sTime As String
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, Main.lat_gps,Main.lon_gps))
|
||||
End Sub
|
||||
|
||||
|
||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub gest_Click
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("select CUENTA from cuentaa")
|
||||
c.Position = 0
|
||||
cuenta = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select usuario from usuarioa")
|
||||
c.Position = 0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c.Close
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM NOVENTA WHERE NV_CLIENTE IN (select cuenta from cuentaa)")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO NOVENTA (NV_CLIENTE,NV_FECHA,NV_USER,NV_MOTIVO,NV_COMM,NV_LAT,NV_LON) VALUES(?,?,?,?,?,?,?) ", Array As Object (cuenta,sDate & sTime, usuario, "ENTREGA","ENTREGA COMPLETA",Main.lat_gps,Main.lon_gps))
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa) ")
|
||||
Starter.skmt.ExecNonQuery("update HIST_VENTAS SET HVD_ESTATUS = 1 WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
StartActivity(seleccion)
|
||||
End Sub
|
||||
|
||||
Sub Tels_Click
|
||||
' skmt.ExecNonQuery("delete from PEDIDO")
|
||||
StartActivity(nopago)
|
||||
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(colonia)
|
||||
'Return True
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub Tar_Click
|
||||
StartActivity(colonia2)
|
||||
End Sub
|
||||
|
||||
Sub DATOS_Click
|
||||
StartActivity(telefonos)
|
||||
End Sub
|
||||
|
||||
Sub Guardar_Click
|
||||
StartActivity(seleccion)
|
||||
End Sub
|
||||
|
||||
Sub NUEVO_Click
|
||||
StartActivity(MAPA_CLIENTE)
|
||||
End Sub
|
||||
|
||||
Sub HIST_Click
|
||||
StartActivity(Historico)
|
||||
End Sub
|
||||
|
||||
Sub B_IMP_Click
|
||||
c=Starter.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)
|
||||
TAMANO = 0
|
||||
ESPACIO = 21
|
||||
BLANCO = " "
|
||||
CREDITO ="1"
|
||||
If CREDITO = "1" Then
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
printer.Initialize(cmp20.OutputStream)
|
||||
printer.WriteLine("DBC.")
|
||||
printer.WriteLine("RFC: ")
|
||||
printer.WriteLine(sDate)
|
||||
printer.WriteLine(sTime)
|
||||
printer.WriteLine("Tienda: " & La_nombre.Text)
|
||||
s=Starter.skmt.ExecQuery("select SUM(HVD_CANT) AS PC_NOART, SUM(HVD_COSTO_TOT) AS PC_MONTO from HIST_VENTAS where HVD_CLIENTE in (Select CUENTA from cuentaa)")
|
||||
s.Position=0
|
||||
printer.WriteLine("Debo (emos) y pagare (mos) incondicionamelte a la orden de DBC a la cantidad de $" & s.GetString("PC_MONTO") & " PESOS _______________________________________________________________________________________________________________ ")
|
||||
printer.WriteLine("en esta ciudad o en cualquier otra que se requiera de pago, valor recibido a mi entera satisfaccion y que me obligo a cumplir el dia______________________.")
|
||||
printer.WriteLine(" ")
|
||||
printer.WriteLine("Si este pagare no fuera cubiertoa su vencimiento Me (nos) obligo (amos) a pagar intereses moratorios a razon de 3 % mensual")
|
||||
printer.WriteLine(" ")
|
||||
printer.WriteLine(" ")
|
||||
printer.WriteLine(" ")
|
||||
printer.WriteLine(" ")
|
||||
printer.WriteLine(" ")
|
||||
printer.WriteLine(" ")
|
||||
printer.WriteLine(" ")
|
||||
printer.WriteLine("------------------------------")
|
||||
printer.WriteLine(" NOMBRE Y FIRMA ")
|
||||
printer.WriteLine("------------------------------")
|
||||
printer.WriteLine(" ")
|
||||
printer.Flush
|
||||
|
||||
End If
|
||||
|
||||
printer.Initialize(cmp20.OutputStream)
|
||||
printer.WriteLine("INTMEX")
|
||||
printer.WriteLine("RFC: ")
|
||||
printer.WriteLine("Tel.:")
|
||||
printer.WriteLine(sDate)
|
||||
printer.WriteLine(sTime)
|
||||
printer.WriteLine("Vendedor:" & usuario)
|
||||
printer.WriteLine("Tienda: " & La_nombre.Text)
|
||||
s=Starter.skmt.ExecQuery("select SUM(HVD_CANT) AS PC_NOART, SUM(HVD_COSTO_TOT) AS PC_MONTO from HIST_VENTAS where HVD_CLIENTE in (Select CUENTA from cuentaa)")
|
||||
s.Position=0
|
||||
c=Starter.skmt.ExecQuery("select SUM(PE_CANT) AS PE_CANT, SUM(PE_COSTO_TOT) AS PE_COSTO_TOT FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
|
||||
printer.WriteLine("Total : $" & (s.GetString("PC_MONTO") + c.GetString("PE_COSTO_TOT")))
|
||||
s.Close
|
||||
printer.WriteLine("-----------ENTREGA------------")
|
||||
S=Starter.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,length(HVD_cant) as L_CANT,HVD_COSTO_TOT,length(HVD_COSTO_TOT) as L_COSTO_TOT from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) ")
|
||||
|
||||
's=skmt.ExecQuery2("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, PE_PROID, PE_CEDIS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)", Array As String("VENTA"))
|
||||
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
|
||||
' printer.WriteLine(s.GetString("PE_PRONOMBRE"))
|
||||
|
||||
'Else
|
||||
|
||||
printer.WriteLine(s.GetString("HVD_CANT") & " " & s.GetString("HVD_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("$" & s.GETSTRING("HVD_COSTO_TOT") )
|
||||
TAMANO = 0
|
||||
ESPACIO = 21
|
||||
BLANCO = " "
|
||||
'End If
|
||||
Next
|
||||
End If
|
||||
s.Close
|
||||
|
||||
s=Starter.skmt.ExecQuery2("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, PE_PROID, PE_CEDIS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)", Array As String("VENTA"))
|
||||
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
|
||||
' printer.WriteLine(s.GetString("PE_PRONOMBRE"))
|
||||
|
||||
'Else
|
||||
|
||||
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("$" & s.GETSTRING("PE_COSTO_TOT") )
|
||||
TAMANO = 0
|
||||
ESPACIO = 21
|
||||
BLANCO = " "
|
||||
'End If
|
||||
Next
|
||||
End If
|
||||
s.Close
|
||||
|
||||
|
||||
|
||||
|
||||
printer.WriteLine("------------------------------")
|
||||
printer.WriteLine("---NO ES UN COMPROBANTE ------")
|
||||
printer.WriteLine("---------FISCAL---------------")
|
||||
printer.WriteLine("---COMPROBANTE DE ENTREGA-----")
|
||||
printer.WriteLine("------------------------------")
|
||||
|
||||
printer.Flush
|
||||
' printer.Close
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Printer_Connected (Success As Boolean)
|
||||
If Success Then
|
||||
|
||||
B_IMP.Enabled = True
|
||||
PASA_IMP = "1"
|
||||
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
|
||||
'FLEOS
|
||||
cmp20.ConnectInsecure(btAdmin,PairedDevices.Get(PairedDevices.GetKeyAt(0)),1)
|
||||
'cmp20.Connect(PairedDevices.Get(PairedDevices.GetKeyAt(0)))
|
||||
|
||||
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_PASO2_Click
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("select CUENTA from cuentaa")
|
||||
c.Position = 0
|
||||
cuenta = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select usuario from usuarioa")
|
||||
c.Position = 0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c.Close
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM NOVENTA WHERE NV_CLIENTE IN (select cuenta from cuentaa)")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO NOVENTA (NV_CLIENTE, NV_FECHA, NV_USER, NV_MOTIVO, NV_COMM, NV_LAT, NV_LON) VALUES(?,?,?,?,?,?,?) ", Array As Object (cuenta, sDate & sTime, usuario, "PASO", "PASO ESPERA", Main.lat_gps, Main.lon_gps))
|
||||
StartActivity(seleccion)
|
||||
End Sub
|
||||
138
fila2.bas
Normal file
@@ -0,0 +1,138 @@
|
||||
Type=Activity
|
||||
Version=3
|
||||
@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.
|
||||
|
||||
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 g As GPS
|
||||
Dim skmt As SQL
|
||||
Dim c 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 la_entre1 As Label
|
||||
Dim la_entre2 As Label
|
||||
Dim gest As Button
|
||||
Dim la_saldotot As Label
|
||||
Dim la_saldooper As Label
|
||||
Dim la_saldof1 As Label
|
||||
Dim la_penal As Label
|
||||
Dim la_producto As Label
|
||||
Dim la_padre As Label
|
||||
Dim la_no_ird As Label
|
||||
|
||||
Dim Tels As Button
|
||||
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")
|
||||
If(FirstTime) Then
|
||||
g.Initialize("GPS")
|
||||
End If
|
||||
Activity.LoadLayout("info_gral")
|
||||
Dim ruta As String
|
||||
|
||||
' valido donde escribo el archivo de la base de datos de kmt
|
||||
If File.ExternalWritable Then
|
||||
ruta = File.DirDefaultExternal
|
||||
Else
|
||||
ruta = File.DirInternal
|
||||
|
||||
End If
|
||||
|
||||
' se crea o no el archivo de la base de ddatos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
c=skmt.ExecQuery("select pr_cd_credito,pr_cd_nombre,pr_cd_calle,pr_cd_numero,pr_cd_num_int,pr_cd_entrecalle1,pr_cd_entrecalle2,pr_cd_colonia,pr_cd_poblacion,pr_cd_edo,pr_cd_cp,pr_Cd_zona, pr_cf_saldotot,pr_cf_saldooper,pr_cf_saldof1, pr_cf_penalizacion, pr_kt_producto, Pr_Ca_Padre, Pr_Ca_No_Ird, PR_CA_CONVENIO,PR_CF_MTO_PRESTAMO,PR_CF_FECHA_DISP,PR_CF_SALDO_ACORT,PR_CF_SALDO_VEN,PR_CF_SALDO_PAGARE,PR_CF_CAPITAL from kmt_info where pr_cd_credito In (select cuenta from cuentaa)")
|
||||
' ListView1.Clear
|
||||
|
||||
'If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
c.Position=0
|
||||
la_cuenta.Text = c.GetString("pr_cd_credito")
|
||||
La_nombre.Text = c.GetString("pr_cd_nombre")
|
||||
la_Calle.Text = c.GetString("pr_cd_calle")
|
||||
'la_numero.Text = c.GetString("pr_cd_numero")
|
||||
'la_nint.Text = c.GetString("pr_cd_num_int")
|
||||
la_entre1.Text = c.GetString("PR_CF_CAPITAL")
|
||||
'la_entre2.Text = c.GetString("pr_cd_entrecalle2")
|
||||
la_col.Text = c.GetString("pr_cd_colonia")
|
||||
la_pob.Text = c.GetString("pr_cd_poblacion")
|
||||
la_edo.Text = c.GetString("pr_cd_edo")
|
||||
la_cp.Text = c.GetString("pr_cd_cp")
|
||||
'la_zona.Text = c.GetString("pr_Cd_zona")
|
||||
la_saldotot.Text = c.GetString("PR_CA_CONVENIO")
|
||||
la_saldooper.Text = c.GetString("PR_CF_MTO_PRESTAMO")
|
||||
la_saldof1.Text = c.GetString("PR_CF_SALDO_VEN")
|
||||
la_penal.Text = c.GetString("PR_CF_SALDO_PAGARE")
|
||||
la_producto.Text = c.GetString("pr_kt_producto")
|
||||
la_padre.Text = c.GetString("PR_CF_FECHA_DISP")
|
||||
la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
|
||||
'ListView1.AddTwoLines(c.GetString("pr_cd_nombre"),c.GetString("pr_cd_colonia"))
|
||||
' Next
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
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)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub gest_Click
|
||||
StartActivity(gestion)
|
||||
End Sub
|
||||
|
||||
Sub Tels_Click
|
||||
StartActivity(telefonos)
|
||||
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
|
||||
198
foto.bas
Normal file
@@ -0,0 +1,198 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@EndOfDesignText@
|
||||
#Region Activity Attributes
|
||||
#FullScreen: False
|
||||
#IncludeTitle: True
|
||||
|
||||
#End Region
|
||||
Sub Process_Globals
|
||||
Private frontCamera As Boolean = False
|
||||
' Dim ruta As String
|
||||
Dim g As GPS
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Globals
|
||||
Private Panel1 As Panel
|
||||
Private camEx As CameraExClass
|
||||
Dim btnTakePicture As Button
|
||||
' Dim skmt As SQL
|
||||
Dim c As Cursor
|
||||
Dim cuenta As String
|
||||
Dim lat_gps As String
|
||||
' Dim lon_gps As String
|
||||
Dim USUARIO As String
|
||||
Dim MOTIVO As String
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
If(FirstTime) Then
|
||||
g.Initialize("GPS")
|
||||
End If
|
||||
Activity.LoadLayout("foto")
|
||||
' ruta = Main.ruta
|
||||
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.skmt.ExecQuery("select cuenta from cuentaa")
|
||||
c.Position = 0
|
||||
cuenta = c.GetString("CUENTA")
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
' If g.GPSEnabled=False Then
|
||||
' ToastMessageShow("Habilitar el GPS", True)
|
||||
' StartActivity(g.LocationSettingsIntent)
|
||||
' Else
|
||||
' g.Start(0,0)
|
||||
' End If
|
||||
InitializeCamera
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub InitializeCamera
|
||||
camEx.Initialize(Panel1, frontCamera, Me, "Camera1")
|
||||
frontCamera = camEx.Front
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
camEx.Release
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
' lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
' lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
'btnTakePicture.Enabled = True
|
||||
's.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE,HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, lat_gps, lon_gps))
|
||||
End Sub
|
||||
|
||||
Sub Camera1_Ready (Success As Boolean)
|
||||
If Success Then
|
||||
camEx.SetJpegQuality(90)
|
||||
camEx.CommitParameters
|
||||
camEx.StartPreview
|
||||
Log(camEx.GetPreviewSize)
|
||||
Else
|
||||
ToastMessageShow("Cannot open camera.", True)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub btnTakePicture_Click
|
||||
Dim ps As CameraSize
|
||||
ps.Width =640
|
||||
ps.Height =480
|
||||
camEx.SetPictureSize(ps.Width, ps.Height)
|
||||
'ToastMessageShow(ps.Width & "x" & ps.Height, False)
|
||||
camEx.CommitParameters
|
||||
camEx.TakePicture
|
||||
End Sub
|
||||
|
||||
Sub btnFocus_Click
|
||||
camEx.FocusAndTakePicture
|
||||
End Sub
|
||||
|
||||
Sub Camera1_PictureTaken (Data() As Byte)
|
||||
Dim filename As String = "1.jpg"
|
||||
Dim dir As String = File.DirRootExternal
|
||||
|
||||
camEx.SavePictureToFile(Data, dir, filename)
|
||||
camEx.StartPreview 'restart preview
|
||||
|
||||
'Dim out As OutputStream
|
||||
|
||||
Dim sDate,sTime As String
|
||||
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("select CUENTA from cuentaa")
|
||||
c.Position = 0
|
||||
cuenta = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position = 0
|
||||
USUARIO = c.GetString("USUARIO")
|
||||
c.Close
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM NOVENTA WHERE NV_CLIENTE IN (select cuenta from cuentaa)")
|
||||
|
||||
c=Starter.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PRONOMBRE asc")
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Starter.skmt.ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT) select HVD_CLIENTE, HVD_PRONOMBRE, HVD_CANT, HVD_COSTO_TOT from hist_ventas where HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(c.GetString("HVD_PRONOMBRE")))
|
||||
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?", Array As Object(c.GetString("HVD_CANT"),c.GetString("HVD_PRONOMBRE")))
|
||||
' ANTES DE MODIFCAR
|
||||
'skmt.ExecNonQuery2("delete FROM HIST_VENTAS WHERE HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(c.GetString("HVD_PRONOMBRE")))
|
||||
'skmt.ExecNonQuery2("update HIST_VENTAS set HVD_EXISTE = ? WHERE HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(motivo, c.GetString("HVD_PRONOMBRE")))
|
||||
Next
|
||||
End If
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO NOVENTA (NV_CLIENTE, NV_FECHA, NV_USER, NV_MOTIVO, NV_COMM, NV_LAT, NV_LON, NV_FOTO, NV_REPROGRAMAR) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object (cuenta, sDate & sTime, USUARIO, "CERRADO", nopago.COMENTARIO, Main.lat_gps, Main.lon_gps, Data, nopago.reprogramar))
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 3 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Starter.skmt.ExecNonQuery("update HIST_VENTAS SET HVD_RECHAZO = 1 WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
StartActivity(seleccion)
|
||||
End Sub
|
||||
|
||||
Sub ChangeCamera_Click
|
||||
camEx.Release
|
||||
frontCamera = Not(frontCamera)
|
||||
InitializeCamera
|
||||
End Sub
|
||||
|
||||
Sub btnEffect_Click
|
||||
Dim effects As List = camEx.GetSupportedColorEffects
|
||||
If effects.IsInitialized = False Then
|
||||
ToastMessageShow("Effects not supported.", False)
|
||||
Return
|
||||
End If
|
||||
Dim effect As String = effects.Get((effects.IndexOf(camEx.GetColorEffect) + 1) Mod effects.Size)
|
||||
camEx.SetColorEffect(effect)
|
||||
ToastMessageShow(effect, False)
|
||||
camEx.CommitParameters
|
||||
End Sub
|
||||
|
||||
Sub btnFlash_Click
|
||||
Dim f() As Float = camEx.GetFocusDistances
|
||||
Log(f(0) & ", " & f(1) & ", " & f(2))
|
||||
Dim flashModes As List = camEx.GetSupportedFlashModes
|
||||
If flashModes.IsInitialized = False Then
|
||||
ToastMessageShow("Flash not supported.", False)
|
||||
Return
|
||||
End If
|
||||
Dim flash As String = flashModes.Get((flashModes.IndexOf(camEx.GetFlashMode) + 1) Mod flashModes.Size)
|
||||
camEx.SetFlashMode(flash)
|
||||
ToastMessageShow(flash, False)
|
||||
camEx.CommitParameters
|
||||
End Sub
|
||||
Sub btnPictureSize_Click
|
||||
Dim pictureSizes() As CameraSize = camEx.GetSupportedPicturesSizes
|
||||
Dim current As CameraSize = camEx.GetPictureSize
|
||||
For i = 0 To pictureSizes.Length - 1
|
||||
If pictureSizes(i).Width = current.Width And pictureSizes(i).Height = current.Height Then Exit
|
||||
Next
|
||||
Dim ps As CameraSize = pictureSizes((i + 1) Mod pictureSizes.Length)
|
||||
camEx.SetPictureSize(ps.Width, ps.Height)
|
||||
ToastMessageShow(ps.Width & "x" & ps.Height & i, False)
|
||||
camEx.CommitParameters
|
||||
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
|
||||
|
||||
256
gestion.bas
Normal file
@@ -0,0 +1,256 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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
|
||||
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 s As SQL
|
||||
Dim c As Cursor
|
||||
Dim nombre As EditText
|
||||
Dim btn As Button
|
||||
Dim lv As ListView
|
||||
Dim telefono As EditText
|
||||
Dim lb_gps As Label
|
||||
Dim lat_gps As String
|
||||
' Dim lon_gps As String
|
||||
|
||||
Dim contacto As EditText
|
||||
Dim Resultado As EditText
|
||||
Dim comentario As EditText
|
||||
Dim codigos As Button
|
||||
Dim parent As Button
|
||||
Dim quien_llamo As String
|
||||
Dim fecha As EditText
|
||||
Dim l_fecha As Label
|
||||
Dim l_monto As Label
|
||||
Dim monto As EditText
|
||||
Dim cuantos As String
|
||||
Dim l_comentario As Label
|
||||
Dim l_ird1 As Label
|
||||
Dim ird1 As EditText
|
||||
Dim l_ird2 As Label
|
||||
Dim ird2 As EditText
|
||||
Dim l_ird3 As Label
|
||||
Dim ird3 As EditText
|
||||
Dim l_ird4 As Label
|
||||
Dim ird4 As EditText
|
||||
Dim despues As Button
|
||||
Dim cuenta As String
|
||||
Dim usuario As String
|
||||
Dim result As String
|
||||
Dim pondera As String
|
||||
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")
|
||||
If(FirstTime) Then
|
||||
g.Initialize("GPS")
|
||||
End If
|
||||
Activity.LoadLayout("guardagestion")
|
||||
' Dim ruta As String
|
||||
' valido donde escribo el archivo de la base de datos de kmt
|
||||
' ruta = Main.ruta
|
||||
' se crea o no el archivo de la base de ddatos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
s.Initialize(Starter.ruta,"kmt.db", True)
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
' If g.GPSEnabled=False Then
|
||||
' ToastMessageShow("Habilitar el GPS", True)
|
||||
' StartActivity(g.LocationSettingsIntent)
|
||||
' Else
|
||||
' g.Start(0,0)
|
||||
' End If
|
||||
monto.Visible = False
|
||||
l_monto.Visible = False
|
||||
l_fecha.Visible = False
|
||||
fecha.Visible = False
|
||||
contacto.Text = ""
|
||||
Resultado.Text= ""
|
||||
comentario.Text =""
|
||||
monto.Text = ""
|
||||
fecha.Text = ""
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
' g.Start(0,0)
|
||||
End Sub
|
||||
Sub btn_Click
|
||||
If Resultado.text<>"" And contacto.Text<>"" And comentario.text<>"" Then
|
||||
' c=s.ExecQuery("select pr_cd_credito,pr_cd_nombre,pr_cd_calle,pr_cd_numero,pr_cd_num_int,pr_cd_entrecalle1,pr_cd_entrecalle2,pr_cd_colonia,pr_cd_poblacion,pr_cd_edo,pr_cd_cp,pr_Cd_zona, pr_cf_saldotot,pr_cf_saldooper,pr_cf_saldof1, pr_cf_penalizacion, pr_kt_producto, Pr_Ca_Padre, Pr_Ca_No_Ird from kmt_info where pr_cd_credito In (select cuenta from cuentaa)")
|
||||
'ESTO SE NECESITA PARA SACAR LOS VALORES Y COMPARAR LOS IRD
|
||||
' c.Position=0
|
||||
' Dim la_cuenta As String = c.GetString("pr_cd_credito")
|
||||
' Dim La_nombre As String = c.GetString("pr_cd_nombre")
|
||||
' la_Calle.Text = c.GetString("pr_cd_calle")
|
||||
' la_numero.Text = c.GetString("pr_cd_numero")
|
||||
' la_nint.Text = c.GetString("pr_cd_num_int")
|
||||
' la_entre1.Text = c.GetString("pr_cd_entrecalle1")
|
||||
' la_entre2.Text = c.GetString("pr_cd_entrecalle2")
|
||||
' la_col.Text = c.GetString("pr_cd_colonia")
|
||||
' la_pob.Text = c.GetString("pr_cd_poblacion")
|
||||
' la_edo.Text = c.GetString("pr_cd_edo")
|
||||
' la_cp.Text = c.GetString("pr_cd_cp")
|
||||
' la_zona.Text = c.GetString("pr_Cd_zona")
|
||||
' la_saldotot.Text = c.GetString("pr_cf_saldotot")
|
||||
' la_saldooper.Text = c.GetString("pr_cf_saldooper")
|
||||
' la_saldof1.Text = c.GetString("pr_cf_saldof1")
|
||||
' la_penal.Text = c.GetString("pr_cf_penalizacion")
|
||||
' la_producto.Text = c.GetString("pr_kt_producto")
|
||||
' la_padre.Text = c.GetString("Pr_Ca_Padre")
|
||||
' la_no_ird.Text = c.GetString("Pr_Ca_No_Ird")
|
||||
|
||||
c=s.ExecQuery("select CUENTA from cuentaa")
|
||||
c.Position = 0
|
||||
cuenta = c.GetString("CUENTA")
|
||||
c=s.ExecQuery("select usuario from usuarioa")
|
||||
c.Position = 0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c=s.ExecQuery2("select CRDESC,CRCOD AS CODIGO,CRPROD from cod_result WHERE CRDESC = ? ", Array As String(Resultado.Text))
|
||||
c.Position = 0
|
||||
result = c.GetString("CODIGO")
|
||||
'pondera = c.GetString("CAT_CO_PONDERACION")
|
||||
Dim sDate,sTime As String
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
s.ExecNonQuery("UPDATE kmt_info set gestion = 1 where MGCTA In (select cuenta from cuentaa)")
|
||||
s.ExecNonQuery2("UPDATE hist_visitas SET HIST_VI_VISITADOR = ?, HIST_VI_RESULTADO = ?, HIST_VI_CODIGO = ?, HIST_VI_PARENTESCO = ?, HIST_VI_COMENTARIO =?, HIST_VI_DPROM =?, HIST_VI_MPROM =? WHERE HIST_VI_CREDITO = ? ", Array As Object(usuario,Resultado.Text,result,contacto.text, comentario.Text,fecha.text,monto.Text, cuenta))
|
||||
'datetime(updatedon,'localtime')
|
||||
'CallSubDelayed(foto,"foto")
|
||||
StartActivity(seleccion)
|
||||
End If
|
||||
End Sub
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
Dim sDate,sTime As String
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
's.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE,HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, lat_gps, lon_gps))
|
||||
End Sub
|
||||
|
||||
Sub codigos_Click
|
||||
quien_llamo = "codigo"
|
||||
c=s.ExecQuery("select COUNT(*) AS CUANTOS from COD_RESULT WHERE CRPROD IN (select productoa from productoa)")
|
||||
c.Position=0
|
||||
cuantos = c.GetString("CUANTOS")
|
||||
If cuantos = 0 Then
|
||||
lv.Clear
|
||||
lv.AddSingleLine("SIN CODIGOS")
|
||||
|
||||
Else
|
||||
c=s.ExecQuery("select CRDESC AS DESC, CRCOD from COD_RESULT WHERE CRPROD IN (select productoa from productoa) ORDER BY CRDESC ASC")
|
||||
lv.Clear
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
lv.AddSingleLine(c.GetString("DESC"))
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Sub lv_ItemClick (Position As Int, Value As Object)
|
||||
Dim es_c_promesa As String
|
||||
If quien_llamo = "codigo" Then
|
||||
Resultado.Text = Value
|
||||
If Resultado.Text <> "EQUIPO RECUPERADO" Then
|
||||
comentario.Visible = True
|
||||
l_comentario.Visible = True
|
||||
l_ird1.Visible = False
|
||||
ird1.Visible = False
|
||||
l_ird2.Visible = False
|
||||
ird2.Visible = False
|
||||
l_ird3.Visible = False
|
||||
ird3.Visible = False
|
||||
l_ird4.Visible = False
|
||||
ird4.Visible = False
|
||||
|
||||
' c=s.ExecQuery2("select CAT_CO_CONFIGURACION from CAT_CODIGOS WHERE CAT_CO_RDESCRIPCION = ? ", Array As String(Value))
|
||||
' c.Position=0
|
||||
' es_c_promesa=c.GetString("CAT_CO_CONFIGURACION")
|
||||
If Resultado.Text = "PROMESA DE PAGO" Then
|
||||
monto.Visible = True
|
||||
l_monto.Visible = True
|
||||
l_fecha.Visible = True
|
||||
fecha.Visible = True
|
||||
Else
|
||||
monto.Visible = False
|
||||
l_monto.Visible = False
|
||||
l_fecha.Visible = False
|
||||
fecha.Visible = False
|
||||
|
||||
End If
|
||||
Else
|
||||
comentario.Visible = False
|
||||
l_comentario.Visible = False
|
||||
l_ird1.Visible = True
|
||||
ird1.Visible = True
|
||||
l_ird2.Visible = True
|
||||
ird2.Visible = True
|
||||
l_ird3.Visible = True
|
||||
ird3.Visible = True
|
||||
l_ird4.Visible = True
|
||||
ird4.Visible = True
|
||||
End If
|
||||
|
||||
Else
|
||||
contacto.Text = Value
|
||||
End If
|
||||
lv.Clear
|
||||
End Sub
|
||||
Sub parent_Click
|
||||
quien_llamo = "parent"
|
||||
c=s.ExecQuery("select CAT_PA_ID, CAT_PA_PARENTESCO from CAT_PARENTESCO order by CAT_PA_PARENTESCO asc")
|
||||
lv.Clear
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
lv.AddSingleLine(c.GetString("CAT_PA_PARENTESCO"))
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
Sub despues_Click
|
||||
s.ExecNonQuery("UPDATE kmt_info set gestion = 2 where pr_cd_credito In (select cuenta from cuentaa)")
|
||||
's.ExecNonQuery2("insert into hist_Act (htel, hanombre) values (?,datetime(updatedon,'localtime'))" Array As String(cuantos))
|
||||
|
||||
'CallSubDelayed(foto,"foto")
|
||||
StartActivity(colonia)
|
||||
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
|
||||
1
gitpull.bat
Normal file
@@ -0,0 +1 @@
|
||||
git pull
|
||||
213
google-services.json
Normal file
@@ -0,0 +1,213 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "821860097209",
|
||||
"project_id": "pusher-4c091",
|
||||
"storage_bucket": "pusher-4c091.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:328e84bfb7adb112f24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "dreparto.keymon.com.mx"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:7bdc730c1cad5927f24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "durakelo.keymon.com.mx"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:4a9c1af4c93ba100f24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "flp2.chv.com"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:7b6620b2a870f23cf24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "gunav2.keymon.com.mx"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:f0e04307b3842e25f24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "prof_rep.keymon.com.mx"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:7780f81ae43bf0f3f24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "pusher.chv.com"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:7c55bc95da6d952df24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "ths.keymon.com.mx"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
374
intmex_reparto.b4a
Normal file
@@ -0,0 +1,374 @@
|
||||
Build1=Default,intmex_rep.keymon.com.mx
|
||||
File1=alert2.png
|
||||
File10=guardagestion.bal
|
||||
File11=guna_viejo.png
|
||||
File12=guna_viejo2.png
|
||||
File13=info_gral.bal
|
||||
File14=infonavit1.jpg
|
||||
File15=itembuttonblue.png
|
||||
File16=kelloggs.png
|
||||
File17=keymon_logo.png
|
||||
File18=kmt.db
|
||||
File19=login.bal
|
||||
File2=alerta.jpg
|
||||
File20=LOGO SANFER.jpg
|
||||
File21=Logo.jpg
|
||||
File22=logo_exitus1.jpg
|
||||
File23=Malo.jpg
|
||||
File24=mapa.bal
|
||||
File25=mapa_cliente.bal
|
||||
File26=mapa_rutas.bal
|
||||
File27=nopago.bal
|
||||
File28=nuevocliente.bal
|
||||
File29=pedido.bal
|
||||
File3=buscar.bal
|
||||
File30=planfia_logo.png
|
||||
File31=planfia_logo_old.png
|
||||
File32=planfia_logo_old2.png
|
||||
File33=productos.bal
|
||||
File34=profina.jpg
|
||||
File35=PROFINA.png
|
||||
File36=seleccion.bal
|
||||
File37=sync.png
|
||||
File38=tarjeta.bal
|
||||
File39=telefonos.bal
|
||||
File4=dbc.png
|
||||
File5=detalle_promo.bal
|
||||
File6=durakelo1.png
|
||||
File7=fila.bal
|
||||
File8=fondo_kmt.jpg
|
||||
File9=foto.bal
|
||||
FileGroup1=Default Group
|
||||
FileGroup10=Default Group
|
||||
FileGroup11=Default Group
|
||||
FileGroup12=Default Group
|
||||
FileGroup13=Default Group
|
||||
FileGroup14=Default Group
|
||||
FileGroup15=Default Group
|
||||
FileGroup16=Default Group
|
||||
FileGroup17=Default Group
|
||||
FileGroup18=Default Group
|
||||
FileGroup19=Default Group
|
||||
FileGroup2=Default Group
|
||||
FileGroup20=Default Group
|
||||
FileGroup21=Default Group
|
||||
FileGroup22=Default Group
|
||||
FileGroup23=Default Group
|
||||
FileGroup24=Default Group
|
||||
FileGroup25=Default Group
|
||||
FileGroup26=Default Group
|
||||
FileGroup27=Default Group
|
||||
FileGroup28=Default Group
|
||||
FileGroup29=Default Group
|
||||
FileGroup3=Default Group
|
||||
FileGroup30=Default Group
|
||||
FileGroup31=Default Group
|
||||
FileGroup32=Default Group
|
||||
FileGroup33=Default Group
|
||||
FileGroup34=Default Group
|
||||
FileGroup35=Default Group
|
||||
FileGroup36=Default Group
|
||||
FileGroup37=Default Group
|
||||
FileGroup38=Default Group
|
||||
FileGroup39=Default Group
|
||||
FileGroup4=Default Group
|
||||
FileGroup5=Default Group
|
||||
FileGroup6=Default Group
|
||||
FileGroup7=Default Group
|
||||
FileGroup8=Default Group
|
||||
FileGroup9=Default Group
|
||||
Group=Default Group
|
||||
Library1=b4xcollections
|
||||
Library10=gps
|
||||
Library11=javaobject
|
||||
Library12=json
|
||||
Library13=okhttputils2
|
||||
Library14=phone
|
||||
Library15=randomaccessfile
|
||||
Library16=reflection
|
||||
Library17=runtimepermissions
|
||||
Library18=serial
|
||||
Library19=sql
|
||||
Library2=baqrcode
|
||||
Library20=togglelibrary
|
||||
Library21=zxing_scanner
|
||||
Library3=byteconverter
|
||||
Library4=camera
|
||||
Library5=compressstrings
|
||||
Library6=core
|
||||
Library7=fusedlocationprovider
|
||||
Library8=googlemaps
|
||||
Library9=googlemapsextras
|
||||
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: http://www.basic4ppc.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="23"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~'End of default text.~\n~~\n~''''' CAMBIA LA CLAVE API~\n~AddApplicationText(~\n~<meta-data~\n~ android:name="com.google.android.geo.API_KEY"~\n~ android:value="AIzaSyBlBnx3O-DncOSv3oFIp-12wgujOYYcl-U"/>~\n~ <meta-data android:name="com.google.android.gms.version"~\n~ android:value="@integer/google_play_services_version" />~\n~)~\n~'End of default text.~\n~ ~\n~ '''''''''''PUSH~\n~CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)~\n~~\n~SetApplicationAttribute(android:usesCleartextTraffic, "true")~\n~AddManifestText(<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="23" />)~\n~AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)~\n~AddManifestText(<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="23" />)~\n~AddManifestText(<uses-permission android:name="android.permission.READ_PHONE_STATE" android:maxSdkVersion="19" />)~\n~AddManifestText(<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" android:maxSdkVersion="19" />~\n~) 'in order to access the device non-resettable identifiers such as IMEI and serial number.~\n~AddManifestText(<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />)~\n~'/////////////// FLP y FBMessageing MOD Inicia /////////////////////~\n~'CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)~\n~'CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)~\n~'CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)~\n~'CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)~\n~SetServiceAttribute(Tracker, android:foregroundServiceType, "location")~\n~'/////////////// FLP y FBMessageing MOD Termina /////////////////////
|
||||
Module1=BatteryUtilities
|
||||
Module10=gestion
|
||||
Module11=Historico
|
||||
Module12=MAPA_CLIENTE
|
||||
Module13=MAPA_RUTAS
|
||||
Module14=mapas
|
||||
Module15=nopago
|
||||
Module16=nuevocliente
|
||||
Module17=pedidos
|
||||
Module18=seleccion
|
||||
Module19=Starter
|
||||
Module2=BUSCAR
|
||||
Module20=Subs
|
||||
Module21=tarjeta
|
||||
Module22=telefonos
|
||||
Module23=Tracker
|
||||
Module3=CameraExClass
|
||||
Module4=colonia
|
||||
Module5=colonia2
|
||||
Module6=DBRequestManager
|
||||
Module7=detalle_promo
|
||||
Module8=fila
|
||||
Module9=foto
|
||||
NumberOfFiles=39
|
||||
NumberOfLibraries=21
|
||||
NumberOfModules=23
|
||||
Version=12.5
|
||||
@EndOfDesignText@
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: Intmex-Reparto
|
||||
#VersionCode: 1
|
||||
#VersionName: 3.11.05
|
||||
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||
#SupportedOrientations: portrait
|
||||
#CanInstallToExternalStorage: False
|
||||
#AdditionalJar: com.android.support:support-v4
|
||||
#AdditionalJar: com.google.android.gms:play-services-location
|
||||
#BridgeLogger: True
|
||||
'###########################################################################################################
|
||||
'###################### PULL #############################################################
|
||||
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
|
||||
'###########################################################################################################
|
||||
'###################### PUSH #############################################################
|
||||
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=github&Args=..\..\
|
||||
'###########################################################################################################
|
||||
'###################### PUSH TORTOISE GIT #########################################################
|
||||
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=TortoiseGitProc&Args=/command:commit&Args=/path:"./../"&Args=/closeonend:2
|
||||
'###########################################################################################################
|
||||
#End Region
|
||||
|
||||
#Region Activity Attributes
|
||||
#FullScreen: False
|
||||
#IncludeTitle: True
|
||||
#End Region
|
||||
#Region Service Attributes
|
||||
#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 reqManager As DBRequestManager
|
||||
' Dim ruta As String
|
||||
Dim usuario As String
|
||||
Dim logger As Boolean = True
|
||||
Dim batt As Int
|
||||
Dim lat_gps, lon_gps As String
|
||||
' Dim skmt As SQL
|
||||
Dim usuario As String
|
||||
Dim server As String
|
||||
Dim montoActual, clientesTotal, clientesVenta, clientesVisitados,almacen, rutaPreventa, CANTIDADPROD As String
|
||||
Dim ultimaActualizacionGPS As String = 235959
|
||||
Dim logger As Boolean = True
|
||||
Dim fechaRuta As String
|
||||
' Public wsServerLink As String = "ws://187.189.244.154:51042/push/b4a_ws2"
|
||||
' Public wsServerLink As String = "ws://10.0.0.214:51042/push/b4a_ws2"
|
||||
Dim srvIp As String
|
||||
Dim phn As Phone
|
||||
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 skmt As SQL
|
||||
Dim user As EditText
|
||||
Dim pass As EditText
|
||||
Dim c As Cursor
|
||||
Dim existe As String
|
||||
Dim paso1 As String
|
||||
Private IMEN As Label
|
||||
Dim IMEI As String
|
||||
Private Label1 As Label
|
||||
Dim server As String
|
||||
Private p_principal As Panel
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
' If File.ExternalWritable Then
|
||||
' ruta = Starter.rp.GetSafeDirDefaultExternal("")
|
||||
' Else
|
||||
' ruta = File.DirInternal
|
||||
' End If
|
||||
' se crea o no el archivo de la base de datos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
' Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
' LogColor("Revisamos BD RUTAA", Colors.Magenta)
|
||||
Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS RUTAA (RUTAA TEXT)")
|
||||
Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS wayPoints (codigo TEXT, indice INT)")
|
||||
Dim server As String = "http://187.189.244.154:1781"
|
||||
' server = "http://10.0.0.205:1782"
|
||||
' server = "http://11.0.0.44:1782"
|
||||
If FirstTime Then
|
||||
reqManager.Initialize(Me, server)
|
||||
'reqManager.Initialize(Me,"http://201.99.139.28:1782")
|
||||
'reqManager.Initialize(Me,"http://177.244.63.54:1782")
|
||||
'reqManager.Initialize(Me,"http://keymon.com.mx:1782")
|
||||
End If
|
||||
Activity.LoadLayout("login")
|
||||
Label1.Text = Application.VersionName
|
||||
Dim P As PhoneId
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
IMEN.Text = P.GetDeviceId
|
||||
IMEI = P.GetDeviceId
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
Subs.centraPanel(p_principal, Activity.Width)
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
StartService(Tracker)
|
||||
Log("Start Tracker")
|
||||
Else
|
||||
ToastMessageShow("No permission", True)
|
||||
End If
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
If c.RowCount > 0 Then
|
||||
' c.Position=0
|
||||
' c=skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
End If
|
||||
c.Close
|
||||
' usuario=Subs.dameUsuarioDeDB
|
||||
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA)
|
||||
Wait For Activity_PermissionResult (Permission As String, resultC As Boolean)
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
|
||||
Wait For Activity_PermissionResult (Permission As String, resultC As Boolean)
|
||||
|
||||
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Entrar_Click
|
||||
If pass.Text = "YA" Then
|
||||
Starter.skmt.ExecNonQuery("delete from usuarioa")
|
||||
Starter.skmt.ExecNonQuery("delete from VERSION")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object("ROOT", "ROOT"))
|
||||
Starter.skmt.ExecNonQuery("delete from cat_almacen")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (user.Text))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO VERSION(NOVERSION) VALUES (?)", Array As Object ("2.1"))
|
||||
StartActivity(seleccion)
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery2("select count(*) as EXISTE1 from usuarioa where usuario = ?", Array As String(user.Text))
|
||||
c.Position=0
|
||||
existe = c.GetString("EXISTE1")
|
||||
c.Close
|
||||
'existe = 1
|
||||
If existe = 0 Then
|
||||
'skmt.ExecNonQuery("delete from usuarioa")
|
||||
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_INTMEX_REPG"
|
||||
cmd.Parameters = Array As Object(user.Text, pass.Text)
|
||||
reqManager.ExecuteQuery(cmd , 0, "usuario")
|
||||
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_version_INTMEX"
|
||||
reqManager.ExecuteQuery(cmd , 0, "version")
|
||||
Else
|
||||
StartActivity(seleccion)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
If Job.Success = False Then
|
||||
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211027
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "version" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
Starter.skmt.ExecNonQuery("delete from VERSION")
|
||||
Dim CAT_VE_VERSION As String = records(result.Columns.Get("CAT_VE_VERSION"))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO VERSION(NOVERSION) VALUES (?)", Array As Object (CAT_VE_VERSION))
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "agencia" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
|
||||
Dim ID_ALMACEN As String = records(result.Columns.Get("ID_ALMACEN"))
|
||||
|
||||
|
||||
|
||||
Next
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "usuario" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
Dim name As String = records(result.Columns.Get("USUARIO"))
|
||||
Dim ID_ALMACEN As String = records(result.Columns.Get("CAT_LO_AGENCIA"))
|
||||
Dim IMEI_BASE As String = records(result.Columns.Get("CAT_LO_IDTELEFONO"))
|
||||
Next
|
||||
paso1 = 1
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End If
|
||||
|
||||
If paso1 = 1 Then
|
||||
If name = "OKActivo" Then
|
||||
Starter.skmt.ExecNonQuery("delete from usuarioa")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(user.Text, pass.Text))
|
||||
Starter.skmt.ExecNonQuery("delete from cat_almacen")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (ID_ALMACEN))
|
||||
StartActivity(seleccion)
|
||||
Else If name = "OKExpirado"& IMEI Then
|
||||
Msgbox("Usuario Expirado llamar al administrador","") 'ignore
|
||||
Else If name = "OKCancelado"& IMEI Then
|
||||
Msgbox("Usuario Cancelado llamar al administrador","") 'ignore
|
||||
Else
|
||||
Msgbox("Usuario o password No validos","") 'ignore
|
||||
End If
|
||||
paso1 = 0
|
||||
End If
|
||||
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(Main)
|
||||
ExitApplication
|
||||
'Return True
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
75
intmex_reparto.b4a.meta
Normal file
@@ -0,0 +1,75 @@
|
||||
ModuleBookmarks0=
|
||||
ModuleBookmarks1=
|
||||
ModuleBookmarks10=
|
||||
ModuleBookmarks11=
|
||||
ModuleBookmarks12=
|
||||
ModuleBookmarks13=
|
||||
ModuleBookmarks14=
|
||||
ModuleBookmarks15=
|
||||
ModuleBookmarks16=
|
||||
ModuleBookmarks17=
|
||||
ModuleBookmarks18=
|
||||
ModuleBookmarks19=
|
||||
ModuleBookmarks2=
|
||||
ModuleBookmarks20=
|
||||
ModuleBookmarks21=
|
||||
ModuleBookmarks22=
|
||||
ModuleBookmarks23=
|
||||
ModuleBookmarks3=
|
||||
ModuleBookmarks4=
|
||||
ModuleBookmarks5=
|
||||
ModuleBookmarks6=
|
||||
ModuleBookmarks7=
|
||||
ModuleBookmarks8=
|
||||
ModuleBookmarks9=
|
||||
ModuleBreakpoints0=
|
||||
ModuleBreakpoints1=
|
||||
ModuleBreakpoints10=
|
||||
ModuleBreakpoints11=
|
||||
ModuleBreakpoints12=
|
||||
ModuleBreakpoints13=
|
||||
ModuleBreakpoints14=
|
||||
ModuleBreakpoints15=
|
||||
ModuleBreakpoints16=
|
||||
ModuleBreakpoints17=
|
||||
ModuleBreakpoints18=
|
||||
ModuleBreakpoints19=
|
||||
ModuleBreakpoints2=
|
||||
ModuleBreakpoints20=
|
||||
ModuleBreakpoints21=
|
||||
ModuleBreakpoints22=
|
||||
ModuleBreakpoints23=
|
||||
ModuleBreakpoints3=
|
||||
ModuleBreakpoints4=
|
||||
ModuleBreakpoints5=
|
||||
ModuleBreakpoints6=
|
||||
ModuleBreakpoints7=
|
||||
ModuleBreakpoints8=
|
||||
ModuleBreakpoints9=
|
||||
ModuleClosedNodes0=
|
||||
ModuleClosedNodes1=
|
||||
ModuleClosedNodes10=
|
||||
ModuleClosedNodes11=
|
||||
ModuleClosedNodes12=2,3
|
||||
ModuleClosedNodes13=
|
||||
ModuleClosedNodes14=
|
||||
ModuleClosedNodes15=
|
||||
ModuleClosedNodes16=
|
||||
ModuleClosedNodes17=
|
||||
ModuleClosedNodes18=2,3,4,6,7,8,9
|
||||
ModuleClosedNodes19=3,4,5,6,7,8
|
||||
ModuleClosedNodes2=
|
||||
ModuleClosedNodes20=
|
||||
ModuleClosedNodes21=
|
||||
ModuleClosedNodes22=
|
||||
ModuleClosedNodes23=
|
||||
ModuleClosedNodes3=4
|
||||
ModuleClosedNodes4=
|
||||
ModuleClosedNodes5=2,3
|
||||
ModuleClosedNodes6=
|
||||
ModuleClosedNodes7=
|
||||
ModuleClosedNodes8=2,7,11
|
||||
ModuleClosedNodes9=
|
||||
NavigationStack=fila,gest_Click,263,0,nopago,GUARDA_Click,112,2,seleccion,Globals,83,0,Starter,ENVIA_ULTIMA_GPS,110,0,Main,Process_Globals,28,0,seleccion,Activity_Resume,185,3,seleccion,Subir_Click,464,6,seleccion,cargar_Click,483,0,Subs,revisaBD,191,0,Main,Activity_Create,77,0
|
||||
SelectedBuild=0
|
||||
VisibleModules=19,23,20,18,4,5,8,15,6,9
|
||||
38
kmt1.b4a.meta
Normal file
@@ -0,0 +1,38 @@
|
||||
VisibleModules=1,2,3,4,5,6,7,8,12
|
||||
ModuleBreakpoints0=
|
||||
ModuleClosedNodes0=
|
||||
ModuleBreakpoints1=
|
||||
ModuleClosedNodes1=1,6,7,9,11,12,13,14,15,16
|
||||
ModuleBreakpoints2=
|
||||
ModuleClosedNodes2=1
|
||||
ModuleBreakpoints3=
|
||||
ModuleClosedNodes3=1
|
||||
ModuleBreakpoints4=
|
||||
ModuleClosedNodes4=
|
||||
ModuleBreakpoints5=
|
||||
ModuleClosedNodes5=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
|
||||
ModuleBreakpoints6=
|
||||
ModuleClosedNodes6=1
|
||||
ModuleBreakpoints7=
|
||||
ModuleClosedNodes7=1,8,9
|
||||
ModuleBreakpoints8=
|
||||
ModuleClosedNodes8=1,2,3,4,6,8,10,11,12,13,14
|
||||
ModuleBreakpoints9=
|
||||
ModuleClosedNodes9=1,2,3,4,5,6
|
||||
ModuleBreakpoints10=
|
||||
ModuleClosedNodes10=1
|
||||
ModuleBreakpoints11=
|
||||
ModuleClosedNodes11=
|
||||
ModuleBreakpoints12=
|
||||
ModuleClosedNodes12=1
|
||||
ModuleBreakpoints13=
|
||||
ModuleClosedNodes13=1
|
||||
ModuleBreakpoints14=
|
||||
ModuleClosedNodes14=1
|
||||
ModuleBreakpoints15=
|
||||
ModuleClosedNodes15=1
|
||||
ModuleBreakpoints16=
|
||||
ModuleClosedNodes16=
|
||||
ModuleBreakpoints17=
|
||||
ModuleClosedNodes17=
|
||||
SelectedBuild=0
|
||||
67
mapas.bas
Normal file
@@ -0,0 +1,67 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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
|
||||
' Dim ruta As String
|
||||
Dim LONGITUD As String
|
||||
Dim LATITUD As String
|
||||
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 WebView1 As WebView
|
||||
Dim reg As Button
|
||||
Dim a_url As String
|
||||
Private l_long As Label
|
||||
Private l_lat As Label
|
||||
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 = Main.ruta
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
Activity.LoadLayout("mapa")
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
|
||||
c=Starter.skmt.ExecQuery("select HV_CLIENTE, HV_LONG, HV_LAT from PUNTEO_GPS where HV_CLIENTE In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
LONGITUD = c.GetString("HV_LONG")
|
||||
LATITUD = c.GetString("HV_LAT")
|
||||
l_lat.Text = LATITUD
|
||||
l_long.Text = LONGITUD
|
||||
' WebView1.LoadUrl("http://maps.googleapis.com/maps/api/staticmap?zoom=16&size=800x800&maptype=roadmap&markers=color:blue%7Clabel:1%7C19.076514,%20-98.228184&markers=color:red%7Clabel:C%7C19.076514,%20-98.238184&key=AIzaSyD-e--ldKJsIkJqaCoABC8J43ITd3jGGQ0")
|
||||
|
||||
WebView1.LoadUrl("http://maps.googleapis.com/maps/api/staticmap?zoom=16&size=800x800&maptype=roadmap&markers=color:blue%7Clabel:1%7C" & LATITUD &",%20" &LONGITUD &"&key=AIzaSyD-e--ldKJsIkJqaCoABC8J43ITd3jGGQ0")
|
||||
'Msgbox("http://maps.googleapis.com/maps/api/staticmap?zoom=16&size=800x800&maptype=roadmap&markers=color:blue%7Clabel:1%7C" & LATITUD &",%20" &LONGITUD &"&sensor=false","titulo")
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub reg_Click
|
||||
StartActivity(fila)
|
||||
End Sub
|
||||
135
nopago.bas
Normal file
@@ -0,0 +1,135 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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
|
||||
Dim COMENTARIO As String
|
||||
Dim reprogramar As Int = 0
|
||||
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 r_1 As RadioButton
|
||||
Dim r_2 As RadioButton
|
||||
Dim r_3 As RadioButton
|
||||
Dim e_comm As EditText
|
||||
Dim motivo As String
|
||||
Dim cuenta As String
|
||||
Dim usuario As String
|
||||
Dim sDate,sTime As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
|
||||
Dim r_4 As RadioButton
|
||||
Private p_principal As Panel
|
||||
Private cb_reprogramar As CheckBox
|
||||
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("nopago")
|
||||
' valido donde escribo el archivo de la base de datos de kmt
|
||||
' ruta = Main.ruta
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
e_comm.Text=""
|
||||
' If g.GPSEnabled=False Then
|
||||
' ToastMessageShow("Habilitar el GPS", True)
|
||||
' StartActivity(g.LocationSettingsIntent)
|
||||
' Else
|
||||
' g.Start(0,0)
|
||||
' End If
|
||||
Subs.SetButtonTintList(r_1, Colors.red, Colors.RGB(210, 105, 30))
|
||||
Subs.SetButtonTintList(r_2, Colors.red, Colors.RGB(210, 105, 30))
|
||||
Subs.SetButtonTintList(r_3, Colors.red, Colors.RGB(210, 105, 30))
|
||||
Subs.SetButtonTintList(r_4, Colors.red, Colors.RGB(210, 105, 30))
|
||||
Subs.SetButtonTintList(cb_reprogramar, Colors.red, Colors.red)
|
||||
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(fila)
|
||||
End Sub
|
||||
|
||||
Sub GUARDA_Click
|
||||
If r_1.Checked Then
|
||||
motivo = "CERRADO"
|
||||
Else If r_2.Checked Then
|
||||
motivo = "NO PIDIO"
|
||||
Else If r_3.Checked Then
|
||||
motivo = "CANCELA"
|
||||
Else
|
||||
motivo = "NO ESTA EL ENCARGADO"
|
||||
End If
|
||||
If motivo <> "CERRADO" Then
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("select CUENTA from cuentaa")
|
||||
c.Position = 0
|
||||
cuenta = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select usuario from usuarioa")
|
||||
c.Position = 0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c.Close
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM NOVENTA WHERE NV_CLIENTE IN (select cuenta from cuentaa)")
|
||||
c=Starter.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT, HVD_FECHA from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PRONOMBRE asc")
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Starter.skmt.ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT,REP_FECHA) VALUES (?,?,?,?,?) ", Array As String(c.GetString("HVD_CLIENTE"),c.GetString("HVD_PRONOMBRE"),c.GetString("HVD_CANT"),c.GetString("HVD_COSTO_TOT"),c.GetString("HVD_FECHA")))
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?", Array As Object(c.GetString("HVD_CANT"),c.GetString("HVD_PRONOMBRE")))
|
||||
' ANTES DE MODIFCAR
|
||||
'skmt.ExecNonQuery2("delete FROM HIST_VENTAS WHERE HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(c.GetString("HVD_PRONOMBRE")))
|
||||
'skmt.ExecNonQuery2("update HIST_VENTAS set HVD_EXISTE = ? WHERE HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(motivo, c.GetString("HVD_PRONOMBRE")))
|
||||
Next
|
||||
End If
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO NOVENTA (NV_CLIENTE, NV_FECHA, NV_USER, NV_MOTIVO, NV_COMM, NV_LAT, NV_LON, NV_REPROGRAMAR) VALUES(?,?,?,?,?,?,?,?) ", Array As Object (cuenta, sDate & sTime, usuario, motivo, e_comm.text, Main.lat_gps, Main.lon_gps, reprogramar))
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 3 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Starter.skmt.ExecNonQuery("update HIST_VENTAS SET HVD_RECHAZO = 1 WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
StartActivity(seleccion)
|
||||
Else
|
||||
COMENTARIO = e_comm.Text
|
||||
StartActivity(foto)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub cb_reprogramar_CheckedChange(Checked As Boolean)
|
||||
If Checked Then
|
||||
reprogramar = 1
|
||||
Else
|
||||
reprogramar = 0
|
||||
End If
|
||||
End Sub
|
||||
100
nuevocliente.bas
Normal file
@@ -0,0 +1,100 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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 = Main.ruta
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
' skmt.Initialize(Starter.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(fila)
|
||||
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=Starter.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
|
||||
|
||||
Starter.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, gestion) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,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"))
|
||||
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(no_cliente))
|
||||
StartActivity(fila)
|
||||
|
||||
End If
|
||||
End Sub
|
||||
617
pedidos.bas
Normal file
@@ -0,0 +1,617 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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
|
||||
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 e As Cursor
|
||||
Dim f As Cursor
|
||||
Dim h As Cursor
|
||||
Dim l_tipo As Label
|
||||
Dim l_sub As Label
|
||||
Dim l_marca As Label
|
||||
Dim l_desc As Label
|
||||
Dim l_precio As Label
|
||||
Dim l_bodega As Label
|
||||
Dim cantidad As EditText
|
||||
Dim guardar As Button
|
||||
Dim Terminar As Button
|
||||
Dim img_prod As ImageView
|
||||
Dim IMG_PASO() As Byte
|
||||
Dim L_PROID As Label
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
Dim t_venta As Label
|
||||
Dim PROMO_C As String
|
||||
Dim i_fotol As ImageView
|
||||
Private DESC_PROMO As Button
|
||||
Private nopromo As Button
|
||||
Dim TOT_ART_PROMO As String
|
||||
Dim cambio As String
|
||||
Dim COSTO_TOT As String
|
||||
Dim ALMACEN As String
|
||||
Dim preciosin As String
|
||||
Dim cl_ruta As String
|
||||
Dim d As Cursor
|
||||
Dim TOT_ART_PROMOR As String
|
||||
Dim PROMO_CR As String
|
||||
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("pedido")
|
||||
i_fotol.Visible = False
|
||||
|
||||
' valido donde escribo el archivo de la base de datos de kmt
|
||||
' ruta = Main.ruta
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.skmt.ExecQuery("select CAT_GP_ID,CAT_GP_NOMBRE,CAT_GP_IMP1,CAT_GP_IMP2,CAT_GP_PRECIO,CAT_GP_CLASIF,CAT_GP_STS,CAT_GP_TIPO,CAT_GP_SUBTIPO,CAT_GP_IMG,CAT_GP_ALMACEN,CAT_GP_DEV from CAT_GUNAPROD where CAT_GP_NOMBRE In (Select PDESC from PROID)")
|
||||
' ListView1.Clear
|
||||
|
||||
'If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
c.Position=0
|
||||
L_PROID.Text = c.GetString("CAT_GP_ID")
|
||||
l_tipo.Text = c.GetString("CAT_GP_TIPO")
|
||||
l_sub.Text = c.GetString("CAT_GP_SUBTIPO")
|
||||
l_marca.Text = c.GetString("CAT_GP_CLASIF")
|
||||
l_desc.Text = c.GetString("CAT_GP_NOMBRE")
|
||||
l_precio.Text = c.GetDouble("CAT_GP_PRECIO")
|
||||
l_bodega.Text = c.GetString("CAT_GP_ALMACEN")
|
||||
IMG_PASO = c.GetBlob("CAT_GP_IMG")
|
||||
PROMO_C = c.GetString("CAT_GP_STS")
|
||||
cambio = c.GetString("CAT_GP_DEV")
|
||||
preciosin = c.GetString("CAT_GP_IMP2")
|
||||
cambio = "0"
|
||||
c.Close
|
||||
c=Starter.skmt.ExecQuery("select CASE WHEN pe_costo_tot is null then 0 else sum( pe_costo_tot ) end as TOTAL_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
t_venta.Text = c.GetString("TOTAL_CLIE")
|
||||
c.Close
|
||||
|
||||
|
||||
Dim out As OutputStream
|
||||
out = File.OpenOutput(Starter.ruta, "1.jpg", False)
|
||||
out.WriteBytes(IMG_PASO, 0, IMG_PASO.Length)
|
||||
out.Close
|
||||
img_prod.Bitmap = LoadBitmap(Starter.ruta,"1.jpg")
|
||||
|
||||
'la_padre.Text = c.GetString("PR_CF_FECHA_DISP")
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
|
||||
' 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.
|
||||
'ListView1.AddTwoLines(c.GetString("pr_cd_nombre"),c.GetString("pr_cd_colonia"))
|
||||
' Next
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
' If g.GPSEnabled=False Then
|
||||
' ToastMessageShow("Habilitar el GPS", True)
|
||||
' StartActivity(g.LocationSettingsIntent)
|
||||
' Else
|
||||
' g.Start(0,0)
|
||||
' End If
|
||||
cantidad.Text = ""
|
||||
c=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
|
||||
C.Position =0
|
||||
ALMACEN = C.GetString("ID_ALMACEN")
|
||||
C.Close
|
||||
i_fotol.Visible = False
|
||||
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.skmt.ExecQuery("select CAT_GP_ID,CAT_GP_NOMBRE,CAT_GP_IMP1,CAT_GP_IMP2,CAT_GP_PRECIO,CAT_GP_CLASIF,CAT_GP_STS,CAT_GP_TIPO,CAT_GP_SUBTIPO,CAT_GP_IMG,CAT_GP_ALMACEN,CAT_GP_DEV from CAT_GUNAPROD where CAT_GP_NOMBRE In (Select PDESC from PROID)")
|
||||
' ListView1.Clear
|
||||
|
||||
'If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
c.Position=0
|
||||
L_PROID.Text = c.GetString("CAT_GP_ID")
|
||||
l_tipo.Text = c.GetString("CAT_GP_TIPO")
|
||||
l_sub.Text = c.GetString("CAT_GP_SUBTIPO")
|
||||
l_marca.Text = c.GetString("CAT_GP_CLASIF")
|
||||
l_desc.Text = c.GetString("CAT_GP_NOMBRE")
|
||||
l_precio.Text = c.GetDouble("CAT_GP_PRECIO")
|
||||
l_bodega.Text = c.GetString("CAT_GP_ALMACEN")
|
||||
IMG_PASO = c.GetBlob("CAT_GP_IMG")
|
||||
PROMO_C = c.GetString("CAT_GP_STS")
|
||||
cambio = c.GetString("CAT_GP_DEV")
|
||||
preciosin = c.GetString("CAT_GP_IMP2")
|
||||
PROMO_CR = c.GetString("CAT_GP_IMP1")
|
||||
|
||||
|
||||
cambio = "0"
|
||||
|
||||
c.Close
|
||||
If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" Then
|
||||
DESC_PROMO.Visible = True
|
||||
Else
|
||||
DESC_PROMO.Visible = False
|
||||
End If
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CASE WHEN pe_costo_tot is null then 0 else sum( pe_costo_tot ) end as TOTAL_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
t_venta.Text = c.GetString("TOTAL_CLIE")
|
||||
c.Close
|
||||
' If t_venta.Text < 100 AND l_tipo.Text = "PROMOS" Then
|
||||
'Terminar.Visible = False
|
||||
'guardar.Visible = False
|
||||
'cantidad.Visible = False
|
||||
'nopromo.Visible = True
|
||||
'Else
|
||||
Terminar.Visible = True
|
||||
guardar.Visible = True
|
||||
cantidad.Visible = True
|
||||
If cambio = "1" Then
|
||||
nopromo.Visible = True
|
||||
Else
|
||||
nopromo.Visible = False
|
||||
End If
|
||||
'End If
|
||||
|
||||
Dim out As OutputStream
|
||||
out = File.OpenOutput(Starter.ruta, "1.jpg", False)
|
||||
out.WriteBytes(IMG_PASO, 0, IMG_PASO.Length)
|
||||
out.Close
|
||||
img_prod.Bitmap = LoadBitmap(Starter.ruta,"1.jpg")
|
||||
TOT_ART_PROMO = "0"
|
||||
TOT_ART_PROMOR = "0"
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
' g.Start(0,0)
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub guardar_Click
|
||||
If cantidad.Text > l_bodega.Text Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C > 0 And cantidad.Text > 0 Then
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=Starter.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMO = C.GetString("TOT_ART_PROMO")
|
||||
COSTO_TOT = C.GetString("COSTO_TOT")
|
||||
C.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
TOT_ART_PROMOR = "0" 'Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA")
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMOR = C.GetString("TOT_ART_PROMO")
|
||||
End If
|
||||
C.Close
|
||||
|
||||
|
||||
PROMO_C = PROMO_C * cantidad.Text
|
||||
PROMO_CR = PROMO_CR * cantidad.Text
|
||||
|
||||
If TOT_ART_PROMO = PROMO_C And TOT_ART_PROMOR = PROMO_CR Then
|
||||
' anterior a 29/06/2015
|
||||
'skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(l_precio.text/(TOT_ART_PROMO/cantidad.Text),l_precio.text/(TOT_ART_PROMO/cantidad.Text)))
|
||||
'en pe_cedis meto el codigo de promocion para hacer esta validacion.
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_CEDIS = (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(L_PROID.text))
|
||||
D=Starter.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
D=Starter.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
|
||||
|
||||
|
||||
'skmt.ExecNonQuery("UPDATE PEDIDO SET PE_COSTO_TOT = 0.01 WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))")
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=Starter.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 AND CAT_DP_PRECIO = 0")
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 AND CAT_DP_PRECIO = 0")
|
||||
F.Position =0
|
||||
h=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Starter.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 (L_PROID.text,0, 0, f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta))
|
||||
h.Close
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
Starter.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 (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta))
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
Else
|
||||
Msgbox("Tiene " & TOT_ART_PROMO & " " & TOT_ART_PROMOR & " y necesita " & PROMO_C & " " & PROMO_CR & " Para la Promo. " , "ADVERTENCIA") 'ignore
|
||||
End If
|
||||
End If
|
||||
|
||||
cantidad.Text = ""
|
||||
StartActivity(colonia2)
|
||||
else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C = 0 Then
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
|
||||
c.Close
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=Starter.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) ")
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS, CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID)")
|
||||
For i =0 To f.RowCount -1
|
||||
F.Position =i
|
||||
h=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Starter.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 (L_PROID.text,f.GetString("CAT_DP_PRECIO") * cantidad.text * f.GetString("CAT_DP_PZAS"), f.GetString("CAT_DP_PRECIO"), f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta))
|
||||
h.Close
|
||||
Next
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
Starter.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 (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta))
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
cantidad.Text = ""
|
||||
c=Starter.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
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
Starter.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"), Main.lon_gps, Main.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
|
||||
StartActivity(colonia2)
|
||||
|
||||
Else
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'agregar el query para que todo cuadre
|
||||
' skmt.ExecNonQuery2("delete from reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT) select HVD_CLIENTE, HVD_PRONOMBRE, HVD_CANT, HVD_COSTO_TOT from hist_ventas where HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
||||
|
||||
Starter.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,PE_COSTO_SIN) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (ALMACEN,cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,preciosin))
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
c=Starter.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
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
Starter.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"), Main.lon_gps, Main.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
StartActivity(colonia2)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
' lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
' lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
Sub Terminar_Click
|
||||
If cantidad.Text > l_bodega.Text Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C > 0 And cantidad.Text > 0 Then
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=Starter.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMO = C.GetString("TOT_ART_PROMO")
|
||||
COSTO_TOT = C.GetString("COSTO_TOT")
|
||||
C.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
TOT_ART_PROMOR = "0" 'Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA")
|
||||
Else
|
||||
c=Starter.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMOR = C.GetString("TOT_ART_PROMO")
|
||||
End If
|
||||
C.Close
|
||||
|
||||
|
||||
PROMO_C = PROMO_C * cantidad.Text
|
||||
PROMO_CR = PROMO_CR * cantidad.Text
|
||||
|
||||
If TOT_ART_PROMO = PROMO_C And TOT_ART_PROMOR = PROMO_CR Then
|
||||
' anterior a 29/06/2015
|
||||
'skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(l_precio.text/(TOT_ART_PROMO/cantidad.Text),l_precio.text/(TOT_ART_PROMO/cantidad.Text)))
|
||||
'en pe_cedis meto el codigo de promocion para hacer esta validacion.
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_CEDIS = (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(L_PROID.text))
|
||||
D=Starter.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 0")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
D=Starter.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO = 0 AND CAT_DP_TIPO = 1")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
|
||||
Starter.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
|
||||
|
||||
|
||||
'skmt.ExecNonQuery("UPDATE PEDIDO SET PE_COSTO_TOT = 0.01 WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))")
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=Starter.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 AND CAT_DP_PRECIO = 0")
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 AND CAT_DP_PRECIO = 0")
|
||||
F.Position =0
|
||||
h=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Starter.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 (L_PROID.text,0, 0, f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta))
|
||||
h.Close
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
Starter.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 (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta))
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
Else
|
||||
Msgbox("Tiene " & TOT_ART_PROMO & " " & TOT_ART_PROMOR & " y necesita " & PROMO_C & " " & PROMO_CR & " Para la Promo. " , "ADVERTENCIA") 'ignore
|
||||
End If
|
||||
End If
|
||||
|
||||
cantidad.Text = ""
|
||||
StartActivity(fila)
|
||||
else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C = 0 Then
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
|
||||
c.Close
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=Starter.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) ")
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=Starter.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS, CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID)")
|
||||
For i =0 To f.RowCount -1
|
||||
F.Position =i
|
||||
h=Starter.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Starter.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 (L_PROID.text,f.GetString("CAT_DP_PRECIO") * cantidad.text * f.GetString("CAT_DP_PZAS"), f.GetString("CAT_DP_PRECIO"), f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta))
|
||||
h.Close
|
||||
Next
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
Starter.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 (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta))
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
cantidad.Text = ""
|
||||
c=Starter.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
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
Starter.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"), Main.lon_gps, Main.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
|
||||
StartActivity(fila)
|
||||
|
||||
Else
|
||||
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
c=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
|
||||
Starter.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,PE_COSTO_SIN) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (ALMACEN,cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,preciosin))
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
c=Starter.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
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
Starter.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"), Main.lon_gps, Main.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
StartActivity(fila)
|
||||
End If
|
||||
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(colonia2)
|
||||
Msgbox("Presione Boton Terminar.","ADVERTENCIA") 'ignore
|
||||
'Return True
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub img_prod_Click
|
||||
i_fotol.Visible = True
|
||||
i_fotol.Bitmap = LoadBitmap(Starter.ruta,"1.jpg")
|
||||
End Sub
|
||||
|
||||
Sub i_fotol_Click
|
||||
i_fotol.Visible = False
|
||||
|
||||
End Sub
|
||||
|
||||
Sub DESC_PROMO_Click
|
||||
Starter.skmt.ExecNonQuery("delete from PROIDID")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
|
||||
StartActivity(detalle_promo)
|
||||
End Sub
|
||||
|
||||
Sub nopromo_Click
|
||||
If cantidad.Text = "" Then
|
||||
Msgbox("Cantidad no puede ser 0","Cantidad") 'ignore
|
||||
Else If cantidad.Text > l_bodega.Text Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",0,0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
|
||||
|
||||
cantidad.Text = ""
|
||||
StartActivity(colonia2)
|
||||
|
||||
End If
|
||||
End Sub
|
||||
1198
seleccion.bas
Normal file
217
tarjeta.bas
Normal file
@@ -0,0 +1,217 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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
|
||||
Dim g As GPS
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
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 Regresar As Button
|
||||
|
||||
Dim ListView1 As ListView
|
||||
Dim L_CANT As Label
|
||||
Dim L_TOTAL As Label
|
||||
Dim borra As Button
|
||||
Dim Existe As String
|
||||
Dim result As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
|
||||
Private Titulo As Label
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
If(FirstTime) Then
|
||||
g.Initialize("GPS")
|
||||
End If
|
||||
' ruta = Main.ruta
|
||||
Activity.LoadLayout("tarjeta")
|
||||
borra.Visible = True
|
||||
Titulo.Text = "Pedido Actual"
|
||||
|
||||
' se crea o no el archivo de la base de ddatos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.skmt.ExecQuery("select count(*) as EXISTE from pedido_cliente WHERE pc_cliente IN (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
Existe = C.GetString("EXISTE")
|
||||
C.Close
|
||||
c=Starter.skmt.ExecQuery("select PE_PRONOMBRE,PE_COSTO_TOT, PE_CANT FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_PRONOMBRE asc")
|
||||
ListView1.Clear
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("PE_PRONOMBRE"),"Cantidad #"& c.GetString("PE_CANT")& " SubTotal $"& c.GetString("PE_COSTO_TOT"))
|
||||
Next
|
||||
End If
|
||||
If Existe <> 0 Then
|
||||
c=Starter.skmt.ExecQuery("select pc_noart, pc_monto from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
L_CANT.Text = c.GetString("PC_NOART")
|
||||
L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||
End If
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
|
||||
|
||||
'ListView1.AddTwoLines(c.GetString("pr_cd_nombre"),c.GetString("pr_cd_colonia"))
|
||||
' Next
|
||||
'End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
If g.GPSEnabled=False Then
|
||||
ToastMessageShow("Habilitar el GPS", True)
|
||||
StartActivity(g.LocationSettingsIntent)
|
||||
Else
|
||||
' g.Start(0,0)
|
||||
End If
|
||||
|
||||
L_CANT.Text =""
|
||||
L_TOTAL.Text=""
|
||||
c=Starter.skmt.ExecQuery("select count(*) as EXISTE from pedido_cliente WHERE pc_cliente IN (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
Existe = C.GetString("EXISTE")
|
||||
C.Close
|
||||
c=Starter.skmt.ExecQuery("select PE_PRONOMBRE,PE_COSTO_TOT, PE_CANT FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_PRONOMBRE asc")
|
||||
ListView1.Clear
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("PE_PRONOMBRE"),"Cantidad #"& c.GetString("PE_CANT")& " SubTotal $"& c.GetString("PE_COSTO_TOT"))
|
||||
Next
|
||||
End If
|
||||
If Existe <> 0 Then
|
||||
c=Starter.skmt.ExecQuery("select pc_noart, pc_monto from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
L_CANT.Text = c.GetString("PC_NOART")
|
||||
L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||
End If
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
'lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
'lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub Regresar_Click
|
||||
StartActivity(fila)
|
||||
End Sub
|
||||
Sub Activity_KeyPress (key As Int) As Boolean
|
||||
' BACK key pressed
|
||||
If key=KeyCodes.KEYCODE_BACK Then
|
||||
' I want to capture the key here so I return True
|
||||
StartActivity(seleccion)
|
||||
'Return True
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
Sub borra_Click
|
||||
result = Msgbox2("Seguro que desa borrar el pedido?","Cancelar pedido", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
|
||||
c=Starter.skmt.ExecQuery("select PE_PROID,PE_CANT FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) ")
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?", Array As Object(c.GetString("PE_CANT"),c.GetString("PE_PROID")))
|
||||
Next
|
||||
End If
|
||||
|
||||
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
Starter.skmt.ExecNonQuery("delete from pedido where pe_cliente in (Select CUENTA from cuentaa)")
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
result = Msgbox2("Seguro que desa borrar este articulo?","Borrar Articulo", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
c=Starter.skmt.ExecQuery2("select PE_PROID,PE_CANT FROM PEDIDO where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
||||
c.Position=0
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?", Array As Object(c.GetString("PE_CANT"),c.GetString("PE_PROID")))
|
||||
c.Close
|
||||
c=Starter.skmt.ExecQuery2("select count(*) AS CUANTOS from cat_gunaprod where CAT_GP_ID in (select pe_cedis from pedido where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa)) and CAT_GP_CLASIF = 'PROMOS' AND CAT_GP_TIPO = 'PROMOS' AND CAT_GP_SUBTIPO = 'PROMOS'", Array As String(Value))
|
||||
c.Position=0
|
||||
If c.GetString("CUANTOS") > 0 Then
|
||||
Starter.skmt.ExecNonQuery2("delete from pedido where pe_cedis in (select pe_cedis from pedido where pe_pronombre = ?) and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(Value))
|
||||
Else
|
||||
Starter.skmt.ExecNonQuery2("delete from pedido where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(Value))
|
||||
End If
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
|
||||
c=Starter.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
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
Starter.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"), Main.lon_gps, Main.lat_gps))
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Else
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
End If
|
||||
Activity_Resume
|
||||
|
||||
End If
|
||||
End Sub
|
||||
128
telefonos.bas
Normal file
@@ -0,0 +1,128 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=7.01
|
||||
@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 = Main.ruta
|
||||
Activity.LoadLayout("telefonos")
|
||||
' If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
' File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
' End If
|
||||
' skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.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(Starter.ruta,"kmt.db", True)
|
||||
c=Starter.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=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
C.Position =0
|
||||
Starter.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
|
||||