- VERSION 5.02.17
- Se cambio en MAPA_RUTAS el codigo de los marcadores (globitos), para que use una sola imagen y el numero sea dinamico. - Se borarron las imagenes de marcadores que ya no se necesitan.
16
.gitattributes
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# linguist-language
|
||||
*.b4a linguist-language=B4X
|
||||
*.b4i linguist-language=B4X
|
||||
*.b4j linguist-language=B4X
|
||||
*.b4r linguist-language=B4X
|
||||
*.bas linguist-language=B4X
|
||||
|
||||
# linguist-detectable
|
||||
*.b4a linguist-detectable=true
|
||||
*.b4i linguist-detectable=true
|
||||
*.b4j linguist-detectable=true
|
||||
*.b4r linguist-detectable=true
|
||||
*.bas linguist-detectable=true
|
||||
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
**/Objects
|
||||
**/AutoBackups
|
||||
1007
B4A/B4XMainPage.bas
Normal file
24
B4A/B4XUpdateAvailable.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
125
B4A/BatteryUtilities.bas
Normal file
@@ -0,0 +1,125 @@
|
||||
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:
|
||||
'0 - EXTRA_LEVEL = current battery level, from 0 To EXTRA_SCALE.
|
||||
'1 - EXTRA_SCALE = the maximum battery level possible.
|
||||
'2 - EXTRA_HEALTH = the current health constant.
|
||||
'3 - EXTRA_ICON_SMALL = the resource ID of a small status bar icon indicating the current battery state.
|
||||
'4 - 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.
|
||||
'5 - EXTRA_STATUS = the current status constant.
|
||||
'6 - EXTRA_TEMPERATURE = the current battery temperature.
|
||||
'7 - EXTRA_VOLTAGE = the current battery voltage level.
|
||||
'8 - A value indicating if the battery is being charged or fully charged (If neither it returns 0 Else it returns 1)
|
||||
'9 - A value indicating if it is charging via USB (0 = Not USB, 2 = USB)
|
||||
'10 - 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
|
||||
109
B4A/C_Buscar.bas
Normal file
@@ -0,0 +1,109 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Dim c As Cursor
|
||||
Dim ListView1 As ListView
|
||||
Dim b_noventa As Button
|
||||
Private p_principal As Panel
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
Root.LoadLayout("buscar")
|
||||
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
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
p_principal.Width = Root.Width
|
||||
p_principal.Height = Root.Height
|
||||
Subs.centraPanel(p_principal, Root.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
|
||||
End Sub
|
||||
|
||||
Sub Regresar_Click
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
' I want to capture the key here so I return True
|
||||
B4XPages.ShowPage("Principal")
|
||||
'Return True
|
||||
' 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))
|
||||
B4XPages.ShowPage("Cliente")
|
||||
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
|
||||
797
B4A/C_Cheklist.bas
Normal file
@@ -0,0 +1,797 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Private p_check As Panel
|
||||
Private sv_datos As ScrollView
|
||||
|
||||
Private camEx As CameraExClass
|
||||
Dim frontCamera As Boolean = False
|
||||
Private p_cam As Panel
|
||||
Dim nombrefoto As String = "0"
|
||||
Dim nombrefoto1 As String = "0"
|
||||
Dim nombrefoto2 As String = "0"
|
||||
Dim nombrefoto3 As String = "0"
|
||||
Private p_camara As Panel
|
||||
Private teclado As IME
|
||||
Dim fototomada As String
|
||||
Private ImageView1 As ImageView
|
||||
Private ImageView3 As ImageView
|
||||
Private ImageView2 As ImageView
|
||||
Private ImageView4 As ImageView
|
||||
Private b_foto As Button
|
||||
Dim device As Phone
|
||||
Dim MES1 As ManageExternalStorage
|
||||
Dim x As Int = 0
|
||||
Private rb_docsi1 As RadioButton
|
||||
Private rb_docno1 As RadioButton
|
||||
Private rb_docsi2 As RadioButton
|
||||
Private rb_docno2 As RadioButton
|
||||
Private rb_docsi3 As RadioButton
|
||||
Private rb_docno3 As RadioButton
|
||||
Private rb_docsi4 As RadioButton
|
||||
Private rb_docno4 As RadioButton
|
||||
Private rb_docsi5 As RadioButton
|
||||
Private rb_docno5 As RadioButton
|
||||
Private rb_docsi6 As RadioButton
|
||||
Private rb_docno6 As RadioButton
|
||||
Private rb_docsi7 As RadioButton
|
||||
Private rb_docno7 As RadioButton
|
||||
Private rb_docsi8 As RadioButton
|
||||
Private rb_docno8 As RadioButton
|
||||
Private rb_docsi9 As RadioButton
|
||||
Private rb_docno9 As RadioButton
|
||||
Private rb_docsi10 As RadioButton
|
||||
Private rb_docno10 As RadioButton
|
||||
Private rb_docsi11 As RadioButton
|
||||
Private rb_docno11 As RadioButton
|
||||
Private rb_docsi12 As RadioButton
|
||||
Private rb_docno12 As RadioButton
|
||||
Private rb_docsi13 As RadioButton
|
||||
Private rb_docno13 As RadioButton
|
||||
Private rb_docsi14 As RadioButton
|
||||
Private rb_docno14 As RadioButton
|
||||
Private rb_docsi15 As RadioButton
|
||||
Private rb_docno15 As RadioButton
|
||||
Private rb_docsi16 As RadioButton
|
||||
Private rb_docno16 As RadioButton
|
||||
Private rb_docsi17 As RadioButton
|
||||
Private rb_docno17 As RadioButton
|
||||
Private rb_docsi18 As RadioButton
|
||||
Private rb_docno18 As RadioButton
|
||||
Private rb_docsi19 As RadioButton
|
||||
Private rb_docno19 As RadioButton
|
||||
Private et_carroceria As EditText
|
||||
Private et_luces As EditText
|
||||
Private et_placas As EditText
|
||||
Private et_liquidos As EditText
|
||||
|
||||
Dim p1 As String
|
||||
Dim p2 As String
|
||||
Dim p3 As String
|
||||
Dim p4 As String
|
||||
Dim p5 As String
|
||||
Dim p6 As String
|
||||
Dim p7 As String
|
||||
Dim p8 As String
|
||||
Dim p9 As String
|
||||
Dim p10 As String
|
||||
Dim p11 As String
|
||||
Dim p12 As String
|
||||
Dim p13 As String
|
||||
Dim p14 As String
|
||||
Dim p15 As String
|
||||
Dim p16 As String
|
||||
Dim p17 As String
|
||||
Dim p18 As String
|
||||
Dim p19 As String
|
||||
Private cb_izqdel As B4XComboBox
|
||||
Private cb_derdel As B4XComboBox
|
||||
Private cb_izqatras As B4XComboBox
|
||||
Private cb_deratras As B4XComboBox
|
||||
Dim itemselect1 As String
|
||||
Dim itemselect2 As String
|
||||
Dim itemselect3 As String
|
||||
Dim itemselect4 As String
|
||||
Dim foto1() As Byte
|
||||
Dim foto2() As Byte
|
||||
Dim foto3() As Byte
|
||||
Dim foto4() As Byte
|
||||
Dim c As Cursor
|
||||
Dim reqManager As DBRequestManager
|
||||
Private l_placa As Label
|
||||
Private et_km As EditText
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
Root.LoadLayout("checklist")
|
||||
|
||||
sv_datos.Height = Root.Height
|
||||
sv_datos.Width = Root.Width
|
||||
sv_datos.Panel.LoadLayout("check")
|
||||
sv_datos.Panel.Height = p_check.Height
|
||||
p_check.Width = Root.Width
|
||||
p_camara.Width = Root.Width
|
||||
p_camara.Height = Root.Height
|
||||
|
||||
|
||||
Dim items As List
|
||||
items.Initialize
|
||||
items.Add("100%")
|
||||
items.Add("75%")
|
||||
items.Add("50%")
|
||||
items.Add("25%")
|
||||
cb_deratras.SetItems(items)
|
||||
cb_izqatras.SetItems(items)
|
||||
cb_derdel.SetItems(items)
|
||||
cb_izqdel.SetItems(items)
|
||||
itemselect1 = "100%"
|
||||
itemselect2 = "100%"
|
||||
itemselect3 = "100%"
|
||||
itemselect4 = "100%"
|
||||
|
||||
reqManager.Initialize(Me, B4XPages.MainPage.server)
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_Appear
|
||||
c = Starter.skmt.ExecQuery("SELECT PLACA FROM HIST_VENTAS")
|
||||
c.Position = 0
|
||||
Log(c.GetString("PLACA"))
|
||||
l_placa.Text = c.GetString("PLACA")
|
||||
c.Close
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA)
|
||||
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
' camEx.Initialize(p_cam, frontCamera, Me, "Camera1")
|
||||
' frontCamera = camEx.Front
|
||||
Log("inicializamos Camara")
|
||||
Else
|
||||
ToastMessageShow("No permission Camara!!!", True)
|
||||
End If
|
||||
MES1.Initialize(Me, "MES1")
|
||||
|
||||
' get the device SDK version
|
||||
Dim SdkVersion As Int = device.SdkVersion
|
||||
|
||||
' Choose which permission to request in order to access external storgage
|
||||
If SdkVersion < 30 Then
|
||||
Log("SDK = " & SdkVersion & " : Requesting WRITE_EXTERNAL_STORAGE permission")
|
||||
Dim rp As RuntimePermissions
|
||||
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE) ' Implicit read capability if granted
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
Log($"PERMISSION_WRITE_EXTERNAL_STORAGE = ${Result}"$)
|
||||
Else
|
||||
Log("SDK = " & SdkVersion & " : Requesting MANAGE_EXTERNAL_STORAGE permission")
|
||||
Log("On Entry MANAGE_EXTERNAL_STORAGE = " & MES1.HasPermission)
|
||||
If Not(MES1.HasPermission) Then
|
||||
MsgboxAsync("Esta aplicación requiere acceso a todos los archivos, habilite la opción", "Administrar todos los archivos")
|
||||
Wait For Msgbox_Result(Res As Int)
|
||||
Log("Getting permission")
|
||||
MES1.GetPermission
|
||||
Wait For MES_StorageAvailable
|
||||
End If
|
||||
End If
|
||||
p_camara.Visible = False
|
||||
|
||||
|
||||
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
|
||||
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
' If Result Then
|
||||
' Log("conpermisos para escritura")
|
||||
' Else
|
||||
' ToastMessageShow("No permission Escritura!!!", True)
|
||||
' End If
|
||||
'
|
||||
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
|
||||
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
' If Result Then
|
||||
' Log("conpermisos para escritura")
|
||||
' Else
|
||||
' ToastMessageShow("No permission Lectura!!!", True)
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
If p_camara.visible Then
|
||||
p_camara.visible = False
|
||||
StopCamera2
|
||||
Else
|
||||
B4XPages.ShowPage("principal")
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Private Sub InitializeCamera2
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA)
|
||||
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
camEx.Initialize(p_cam, frontCamera, Me, "Camera1")
|
||||
frontCamera = camEx.Front
|
||||
Log("inicializamos Camara")
|
||||
Else
|
||||
ToastMessageShow("No permission Camara!!!", True)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub Camera1_Ready (Success As Boolean)
|
||||
Log("Camara ready")
|
||||
If Success Then
|
||||
camEx.SetJpegQuality(90)
|
||||
camEx.SetContinuousAutoFocus
|
||||
camEx.CommitParameters
|
||||
camEx.StartPreview
|
||||
Log(camEx.GetPreviewSize)
|
||||
Else
|
||||
ToastMessageShow("Cannot open camera.", True)
|
||||
Log("Cannot open camera")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub Camera1_PictureTaken (Data()As Byte)
|
||||
If x = 1 Then
|
||||
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||
nombrefoto = DateTime.Now & "_FOTO1.jpg"
|
||||
teclado.HideKeyboard
|
||||
fototomada = nombrefoto
|
||||
|
||||
Else If x = 2 Then
|
||||
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||
nombrefoto1 = DateTime.Now & "_FOTO2.jpg"
|
||||
teclado.HideKeyboard
|
||||
fototomada = nombrefoto1
|
||||
|
||||
Else If x = 3 Then
|
||||
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||
nombrefoto2 = DateTime.Now & "_FOTO3.jpg"
|
||||
teclado.HideKeyboard
|
||||
fototomada = nombrefoto2
|
||||
|
||||
Else If x = 4 Then
|
||||
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||
nombrefoto3 = DateTime.Now & "_FOTO4.jpg"
|
||||
teclado.HideKeyboard
|
||||
fototomada = nombrefoto3
|
||||
|
||||
End If
|
||||
|
||||
Log("tome foto")
|
||||
Dim filename As String = fototomada
|
||||
Dim Dirp As String = File.DirInternal
|
||||
Dim Dir As String
|
||||
Dim Dir2 As String
|
||||
Try
|
||||
File.MakeDir(Dirp,"/md")
|
||||
Dir = "/md"
|
||||
Log("creado en promotoria " & Dirp & Dir)
|
||||
Catch
|
||||
Dir = ""
|
||||
Log("creado en raiz")
|
||||
End Try
|
||||
|
||||
Try
|
||||
File.MakeDir(Dirp & Dir,"/reduccion")
|
||||
Dir2 = "/reduccion"
|
||||
Log("creado en promotoria " & Dirp & Dir & Dir2)
|
||||
Catch
|
||||
Dir = ""
|
||||
Log("creado en raiz")
|
||||
End Try
|
||||
|
||||
camEx.SavePictureToFile(Data, Dirp&Dir, filename)
|
||||
camEx.StartPreview 'restart preview
|
||||
' ToastMessageShow("Picture saved." & CRLF & "File size: " & File.Size(Dir, filename) & Dir &"," & filename, True)
|
||||
Log("Picture saved." & CRLF & "File size: " & File.Size(Dir, filename) & Dir &"," & filename)
|
||||
p_camara.Visible = False
|
||||
|
||||
Log(nombrefoto)
|
||||
Log(nombrefoto1)
|
||||
Log(nombrefoto2)
|
||||
Log(nombrefoto3)
|
||||
|
||||
If nombrefoto <> "0" Then
|
||||
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 450, 600, True)
|
||||
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, True)
|
||||
img.WriteToStream(out, 100, "PNG")
|
||||
' foto1 = File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto)
|
||||
|
||||
out.Close
|
||||
ImageView1.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto)
|
||||
|
||||
End If
|
||||
|
||||
If nombrefoto1 <> "0" Then
|
||||
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 450, 600, True)
|
||||
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||
img.WriteToStream(out, 100, "PNG")
|
||||
' foto2 = File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto1)
|
||||
|
||||
out.Close
|
||||
ImageView2.Bitmap = LoadBitmap(File.DirInternal & Dir& Dir2,nombrefoto1)
|
||||
End If
|
||||
|
||||
If nombrefoto2 <> "0" Then
|
||||
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 450, 600, True)
|
||||
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||
img.WriteToStream(out, 100, "PNG")
|
||||
' foto3 = File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto2)
|
||||
|
||||
out.Close
|
||||
ImageView3.Bitmap = LoadBitmap(File.DirInternal & Dir& Dir2,nombrefoto2)
|
||||
End If
|
||||
|
||||
If nombrefoto3 <> "0" Then
|
||||
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 450, 600, True)
|
||||
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||
img.WriteToStream(out, 100, "PNG")
|
||||
' foto4 = File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto3)
|
||||
|
||||
out.Close
|
||||
ImageView4.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto3)
|
||||
End If
|
||||
|
||||
StopCamera2
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub p_camara_Click
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub b_foto_Click
|
||||
camEx.TakePicture
|
||||
p_camara.Visible = False
|
||||
' StopCamera2
|
||||
End Sub
|
||||
|
||||
Private Sub StopCamera2
|
||||
' Capturing = False
|
||||
If camEx.IsInitialized Then
|
||||
camEx.Release
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ImageView1_Click
|
||||
|
||||
x = 1
|
||||
InitializeCamera2
|
||||
p_camara.Visible = True
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ImageView2_Click
|
||||
|
||||
x = 2
|
||||
InitializeCamera2
|
||||
p_camara.Visible = True
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ImageView3_Click
|
||||
|
||||
x = 3
|
||||
InitializeCamera2
|
||||
p_camara.Visible = True
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ImageView4_Click
|
||||
|
||||
x = 4
|
||||
InitializeCamera2
|
||||
p_camara.Visible = True
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno1_CheckedChange(Checked As Boolean)
|
||||
p1 = "No"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi1_CheckedChange(Checked As Boolean)
|
||||
p1 = "Si"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno2_CheckedChange(Checked As Boolean)
|
||||
p2 = "No"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi2_CheckedChange(Checked As Boolean)
|
||||
p2 = "Si"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno3_CheckedChange(Checked As Boolean)
|
||||
p3 = "No"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi3_CheckedChange(Checked As Boolean)
|
||||
p3 = "Si"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno4_CheckedChange(Checked As Boolean)
|
||||
p4 = "No"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi4_CheckedChange(Checked As Boolean)
|
||||
p4 = "Si"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno5_CheckedChange(Checked As Boolean)
|
||||
p5 = "No"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi5_CheckedChange(Checked As Boolean)
|
||||
p5 = "Si"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno6_CheckedChange(Checked As Boolean)
|
||||
p6 = "No"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi6_CheckedChange(Checked As Boolean)
|
||||
p6 = "Si"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno7_CheckedChange(Checked As Boolean)
|
||||
p7 = "No"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi7_CheckedChange(Checked As Boolean)
|
||||
p7 = "Si"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno8_CheckedChange(Checked As Boolean)
|
||||
p8 = "No"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi8_CheckedChange(Checked As Boolean)
|
||||
p8 = "Si"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno9_CheckedChange(Checked As Boolean)
|
||||
p9 = "Incorrecto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi9_CheckedChange(Checked As Boolean)
|
||||
p9 = "Correcto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno11_CheckedChange(Checked As Boolean)
|
||||
p11 = "Incorrecto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi11_CheckedChange(Checked As Boolean)
|
||||
p11 = "Correcto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno13_CheckedChange(Checked As Boolean)
|
||||
p13 = "Incorrecto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi13_CheckedChange(Checked As Boolean)
|
||||
p13 = "Correcto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno15_CheckedChange(Checked As Boolean)
|
||||
p15 = "Incorrecto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi15_CheckedChange(Checked As Boolean)
|
||||
p15 = "Correcto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno16_CheckedChange(Checked As Boolean)
|
||||
p16 = "Incorrecto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi16_CheckedChange(Checked As Boolean)
|
||||
p16 = "Correcto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno17_CheckedChange(Checked As Boolean)
|
||||
p17 = "Incorrecto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi17_CheckedChange(Checked As Boolean)
|
||||
p17 = "Correcto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno18_CheckedChange(Checked As Boolean)
|
||||
p18 = "Incorrecto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi18_CheckedChange(Checked As Boolean)
|
||||
p18 = "Correcto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docno19_CheckedChange(Checked As Boolean)
|
||||
p19 = "Incorrecto"
|
||||
End Sub
|
||||
|
||||
Private Sub rb_docsi19_CheckedChange(Checked As Boolean)
|
||||
p19 = "Correcto"
|
||||
End Sub
|
||||
|
||||
Private Sub cb_izqdel_SelectedIndexChanged (Index As Int)
|
||||
itemselect1 = cb_izqdel.SelectedItem
|
||||
Log(itemselect1)
|
||||
End Sub
|
||||
|
||||
Private Sub cb_izqatras_SelectedIndexChanged (Index As Int)
|
||||
itemselect2 = cb_izqatras.SelectedItem
|
||||
Log(itemselect2)
|
||||
End Sub
|
||||
|
||||
Private Sub cb_derdel_SelectedIndexChanged (Index As Int)
|
||||
itemselect3 = cb_derdel.SelectedItem
|
||||
Log(itemselect3)
|
||||
End Sub
|
||||
|
||||
Private Sub cb_deratras_SelectedIndexChanged (Index As Int)
|
||||
itemselect4 = cb_deratras.SelectedItem
|
||||
Log(itemselect4)
|
||||
End Sub
|
||||
|
||||
Private Sub b_guardar_Click
|
||||
Dim Dirp As String = File.DirInternal
|
||||
Dim Dir As String
|
||||
Dim Dir2 As String
|
||||
Try
|
||||
File.MakeDir(Dirp,"/md")
|
||||
Dir = "/md"
|
||||
Log("creado en promotoria " & Dirp & Dir)
|
||||
Catch
|
||||
Dir = ""
|
||||
Log("creado en raiz")
|
||||
End Try
|
||||
Try
|
||||
File.MakeDir(Dirp & Dir,"/reduccion")
|
||||
Dir2 = "/reduccion"
|
||||
Log("creado en promotoria " & Dirp & Dir & Dir2)
|
||||
Catch
|
||||
Dir = ""
|
||||
Log("creado en raiz")
|
||||
End Try
|
||||
DateTime.TimeFormat="HH:mm:ss"
|
||||
DateTime.DateFormat="dd/MM/yyyy"
|
||||
Dim checkdate As String = DateTime.Date(DateTime.Now)
|
||||
Dim checktime As String = DateTime.Time(DateTime.Now)
|
||||
If et_km.Text <> "" Then
|
||||
If rb_docno1.Checked Or rb_docsi1.Checked Then
|
||||
If rb_docno2.Checked Or rb_docsi2.Checked Then
|
||||
If rb_docno3.Checked Or rb_docsi3.Checked Then
|
||||
If rb_docno4.Checked Or rb_docsi4.Checked Then
|
||||
If rb_docno5.Checked Or rb_docsi5.Checked Then
|
||||
If rb_docno6.Checked Or rb_docsi6.Checked Then
|
||||
If rb_docno7.Checked Or rb_docsi7.Checked Then
|
||||
If rb_docno8.Checked Or rb_docsi8.Checked Then
|
||||
If rb_docno9.Checked Or rb_docsi9.Checked Then
|
||||
If (rb_docno9.Checked And et_carroceria.Text <> "") Or (rb_docsi9.Checked And et_carroceria.Text = "") Then
|
||||
If rb_docno11.Checked Or rb_docsi11.Checked Then
|
||||
If (rb_docno11.Checked And et_luces.Text <> "") Or (rb_docsi11.Checked And et_luces.Text = "") Then
|
||||
If rb_docno13.Checked Or rb_docsi13.Checked Then
|
||||
If (rb_docno12.Checked And et_placas.Text <> "") Or (rb_docsi13.Checked And et_placas.Text = "") Then
|
||||
If rb_docno15.Checked Or rb_docsi15.Checked Then
|
||||
If rb_docno16.Checked Or rb_docsi16.Checked Then
|
||||
If rb_docno17.Checked Or rb_docsi17.Checked Then
|
||||
If rb_docno18.Checked Or rb_docsi18.Checked Then
|
||||
If rb_docno19.Checked Or rb_docsi19.Checked Then
|
||||
If et_liquidos.Text <> "" And (rb_docno15.Checked Or rb_docno16.Checked Or rb_docno17.Checked Or rb_docno18.Checked Or rb_docno19.Checked) Or et_liquidos.Text = "" And (rb_docsi15.Checked And rb_docsi16.Checked And rb_docsi17.Checked And rb_docsi18.Checked And rb_docsi19.Checked) Then
|
||||
If nombrefoto <> "0" And nombrefoto1 <> "0" And nombrefoto2 <> "0" And nombrefoto3 <> "0" Then
|
||||
c = Starter.skmt.ExecQuery("SELECT RUTAA FROM RUTAA")
|
||||
c.Position = 0
|
||||
Private rutacheck As String = c.GetString("RUTAA")
|
||||
c.Close
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM CHECKLIST2")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CHECKLIST2(USUARIO, PLACA, FECHA_CAPTURA, TARJETA_CIRCULACION , POLIZA_SEGURO, LICENCIA_CONDUCIR, LIMPIA_EXTERNA, LIMPIA_INTERNA, TRIANGULO, GATO, LLANTA_REFACCION, CARROCERIA, CARROCERIA_COMENTARIOS, LUCES, LUCES_COMENTARIOS, CONDICION_PLACAS, CONDICION_PLACAS_COMENTARIOS, CONDICION_LLANTAS_DEL_DER, CONDICION_LLANTAS_DEL_IZQ, CONDICION_LLANTAS_TRASERA_DER, CONDICION_LLANTAS_TRASERA_IZQ, ACEITE, ANTICONGELANTE, FRENOS, AIRE, FUGAS, COMETARIOS_FUGAS, FOTO1, FOTO12, FOTO3, FOTO4, KILIMETRAJE,RUTA) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",Array As Object(B4XPages.MainPage.usuario,l_placa.Text,checkdate&" "&checktime,p1,p2,p3,p4,p5,p6,p7,p8,p9,et_carroceria.Text,p11,et_luces.Text,p13,et_placas.Text,itemselect1,itemselect2,itemselect3,itemselect4,p15,p16,p17,p18,p19,et_liquidos.Text,File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto),File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto1),File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto2),File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto3), et_km.Text, rutacheck))
|
||||
|
||||
|
||||
mandaPendientes
|
||||
|
||||
rb_docno1.Checked = False
|
||||
rb_docno2.Checked = False
|
||||
rb_docno3.Checked = False
|
||||
rb_docno4.Checked = False
|
||||
rb_docno5.Checked = False
|
||||
rb_docno6.Checked = False
|
||||
rb_docno7.Checked = False
|
||||
rb_docno8.Checked = False
|
||||
rb_docno9.Checked = False
|
||||
rb_docno11.Checked = False
|
||||
rb_docno13.Checked = False
|
||||
rb_docno15.Checked = False
|
||||
rb_docno16.Checked = False
|
||||
rb_docno17.Checked = False
|
||||
rb_docno18.Checked = False
|
||||
rb_docno19.Checked = False
|
||||
|
||||
rb_docsi1.Checked = False
|
||||
rb_docsi2.Checked = False
|
||||
rb_docsi3.Checked = False
|
||||
rb_docsi4.Checked = False
|
||||
rb_docsi5.Checked = False
|
||||
rb_docsi6.Checked = False
|
||||
rb_docsi7.Checked = False
|
||||
rb_docsi8.Checked = False
|
||||
rb_docsi9.Checked = False
|
||||
rb_docsi11.Checked = False
|
||||
rb_docsi13.Checked = False
|
||||
rb_docsi15.Checked = False
|
||||
rb_docsi16.Checked = False
|
||||
rb_docsi17.Checked = False
|
||||
rb_docsi18.Checked = False
|
||||
rb_docsi19.Checked = False
|
||||
|
||||
cb_deratras.SelectedIndex = 0
|
||||
cb_derdel.SelectedIndex = 0
|
||||
cb_izqatras.SelectedIndex = 0
|
||||
cb_izqdel.SelectedIndex = 0
|
||||
|
||||
et_carroceria.Text = ""
|
||||
et_liquidos.Text = ""
|
||||
et_luces.Text = ""
|
||||
et_placas.Text = ""
|
||||
|
||||
ImageView1.Bitmap = LoadBitmap(File.DirAssets,"frontal1.png")
|
||||
ImageView2.Bitmap = LoadBitmap(File.DirAssets,"derecha1.png")
|
||||
ImageView3.Bitmap = LoadBitmap(File.DirAssets,"atras1.png")
|
||||
ImageView4.Bitmap = LoadBitmap(File.DirAssets,"izquierda1.png")
|
||||
|
||||
nombrefoto = "0"
|
||||
nombrefoto1 = "0"
|
||||
nombrefoto2 = "0"
|
||||
nombrefoto3 = "0"
|
||||
|
||||
B4XPages.ShowPage("Principal")
|
||||
Else
|
||||
MsgboxAsync("Favor de tomar todas las fotos","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Especifica Fugas o detallaes en los liquidos","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Fugas","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Aire","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Frenos","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Anticongelante","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Aceite","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Especifica daños en las condiciones de placas","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Conciciones de placas de Correcto","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Especifica daños en las luces","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Funcionamiento de luces de Correcto","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Especifica daños en la carrocería","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Carrocería de Buen estado","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Seguridad y refación de Llanta de refacción","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Seguridad y refación de gato","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Seguridad y refación de Triagulo reflectante","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Limpieza unidad interna","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Limpieza unidad externa","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Documentación viegnte de Licencia de conducir","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Documentación viegnte de Póliza de seguro","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Seleeciona una opción en Documentación viegnte de tarjeta de circulación","Atención")
|
||||
End If
|
||||
Else
|
||||
MsgboxAsync("Captura el kilometraje inicial.","Atención")
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub mandaPendientes
|
||||
Log("MandaPendientes")
|
||||
'PEDIDO (Pendientes)
|
||||
c=Starter.skmt.ExecQuery("SELECT USUARIO, PLACA, FECHA_CAPTURA, TARJETA_CIRCULACION , POLIZA_SEGURO, LICENCIA_CONDUCIR, LIMPIA_EXTERNA, LIMPIA_INTERNA, TRIANGULO, GATO, LLANTA_REFACCION, CARROCERIA, CARROCERIA_COMENTARIOS, LUCES, LUCES_COMENTARIOS, CONDICION_PLACAS, CONDICION_PLACAS_COMENTARIOS, CONDICION_LLANTAS_DEL_DER, CONDICION_LLANTAS_DEL_IZQ, CONDICION_LLANTAS_TRASERA_DER, CONDICION_LLANTAS_TRASERA_IZQ, ACEITE, ANTICONGELANTE, FRENOS, AIRE, FUGAS, COMETARIOS_FUGAS, FOTO1, FOTO12, FOTO3, FOTO4 FROM CHECKLIST2")
|
||||
Log($"Pedido PENDIENTE: ${c.RowCount}"$)
|
||||
If c.RowCount > 0 Then
|
||||
For i = 0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim cmd As DBCommand
|
||||
|
||||
foto1 = c.GetBlob("FOTO1")
|
||||
foto2 = c.GetBlob("FOTO12")
|
||||
foto3 = c.GetBlob("FOTO3")
|
||||
foto4 = c.GetBlob("FOTO4")
|
||||
|
||||
cmd.Initialize
|
||||
cmd.Name = "insert_CHECK_MARDS"
|
||||
cmd.Parameters = Array As Object(C.GetString("USUARIO"),C.GetString("PLACA"),C.GetString("FECHA_CAPTURA"),C.GetString("TARJETA_CIRCULACION"),C.GetString("POLIZA_SEGURO"),C.GetString("LICENCIA_CONDUCIR"),C.GetString("LIMPIA_EXTERNA"),C.GetString("LIMPIA_INTERNA"),C.GetString("TRIANGULO"),C.GetString("GATO"), C.GetString("LLANTA_REFACCION"),C.GetString("CARROCERIA"),c.GetString("CARROCERIA_COMENTARIOS"),c.GetString("LUCES"),c.GetString("LUCES_COMENTARIOS"),c.GetString("CONDICION_PLACAS"),c.GetString("CONDICION_PLACAS_COMENTARIOS"))'c.GetString("CONDICION_PLACAS_INCORRECTO"),c.GetString("CONDICION_PLACAS_COMENTARIOS"),c.GetString("CONDICION_LLANTAS_DEL_DER"),c.GetString("CONDICION_LLANTAS_DEL_IZQ"),c.GetString("CONDICION_LLANTAS_TRASERA_DER"),c.GetString("CONDICION_LLANTAS_TRASERA_IZQ"),c.GetString("ACEITE"),c.GetString("ANTICONGELANTE"),c.GetString("FRENOS"),c.GetString("AIRE"),c.GetString("FUGAS"),c.GetString("COMETARIOS_FUGAS"),foto1,foto2,foto3,foto4,B4XPages.MainPage.principal.ALMACEN)
|
||||
reqManager.ExecuteCommand(cmd , $"ins_checkliPendientes_head_${c.GetString("USUARIO")}"$)
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
Log("JOBDONE CLIENTE . " & Job.Success)
|
||||
If Job.Success = False Then
|
||||
' ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
' LogColor("JobDone Error: '" & reqManager.HandleJob(Job).tag, Colors.red) 'Mod por CHV - 211027
|
||||
LogColor("Error: " & Job.tag & " : " & Job.ErrorMessage, Colors.Blue)
|
||||
Else
|
||||
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green)
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim resultado As DBResult = reqManager.HandleJob(Job)
|
||||
If resultado.Tag.As(String).IndexOf("ins_checkliPendientes_head_") > -1 Then
|
||||
Private cliente As String= resultado.Tag
|
||||
cliente = cliente.SubString(cliente.IndexOf("_")+24)
|
||||
Log($"Cliente1:${cliente}"$)
|
||||
|
||||
c=Starter.skmt.ExecQuery("SELECT USUARIO, PLACA, FECHA_CAPTURA, TARJETA_CIRCULACION , POLIZA_SEGURO, LICENCIA_CONDUCIR, LIMPIA_EXTERNA, LIMPIA_INTERNA, TRIANGULO, GATO, LLANTA_REFACCION, CARROCERIA, CARROCERIA_COMENTARIOS, LUCES, LUCES_COMENTARIOS, CONDICION_PLACAS, CONDICION_PLACAS_COMENTARIOS, CONDICION_LLANTAS_DEL_DER, CONDICION_LLANTAS_DEL_IZQ, CONDICION_LLANTAS_TRASERA_DER, CONDICION_LLANTAS_TRASERA_IZQ, ACEITE, ANTICONGELANTE, FRENOS, AIRE, FUGAS, COMETARIOS_FUGAS, FOTO1, FOTO12, FOTO3, FOTO4, KILIMETRAJE, RUTA FROM CHECKLIST2")
|
||||
Log($"Pedido PENDIENTE: ${c.RowCount}"$)
|
||||
If c.RowCount > 0 Then
|
||||
For i = 0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim cmd As DBCommand
|
||||
|
||||
foto1 = c.GetBlob("FOTO1")
|
||||
foto2 = c.GetBlob("FOTO12")
|
||||
foto3 = c.GetBlob("FOTO3")
|
||||
foto4 = c.GetBlob("FOTO4")
|
||||
|
||||
cmd.Initialize
|
||||
cmd.Name = "update_CHECK_MARDS"
|
||||
cmd.Parameters = Array As Object(c.GetString("CONDICION_LLANTAS_DEL_DER"),c.GetString("CONDICION_LLANTAS_DEL_IZQ"),c.GetString("CONDICION_LLANTAS_TRASERA_DER"),c.GetString("CONDICION_LLANTAS_TRASERA_IZQ"),c.GetString("ACEITE"),c.GetString("ANTICONGELANTE"),c.GetString("FRENOS"),c.GetString("AIRE"),c.GetString("FUGAS"),c.GetString("COMETARIOS_FUGAS"),foto1,foto2,foto3,foto4,B4XPages.MainPage.principal.ALMACEN, C.GetString("KILIMETRAJE"),C.GetString("RUTA"), C.GetString("USUARIO"),C.GetString("PLACA"),C.GetString("FECHA_CAPTURA"))
|
||||
reqManager.ExecuteCommand(cmd , "update")
|
||||
Next
|
||||
End If
|
||||
|
||||
For Each records() As Object In resultado.Rows
|
||||
For Each k As String In resultado.Columns.Keys
|
||||
Log(resultado.Tag & ": " & k & ": " & records(resultado.Columns.Get(k)))
|
||||
Next
|
||||
Next
|
||||
Starter.skmt.ExecNonQuery("UPDATE CHECADO_CHECK set CHECADO = 1 ")
|
||||
B4XPages.MainPage.principal.checachek
|
||||
End If
|
||||
End If
|
||||
|
||||
Job.Release
|
||||
End If
|
||||
|
||||
End Sub
|
||||
973
B4A/C_Cliente.bas
Normal file
@@ -0,0 +1,973 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Dim g As GPS
|
||||
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 impresoraConectada As Boolean = False
|
||||
Dim LONGITUD As String
|
||||
Dim LATITUD As String
|
||||
Dim NOMBRE As String
|
||||
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 reqManager As DBRequestManager
|
||||
Dim b_noEntrega As Button
|
||||
Dim Label10 As Label
|
||||
Dim Label11 As Label
|
||||
Dim d As Cursor
|
||||
Dim Tar As Button
|
||||
Private L_QR As Label
|
||||
Private BT_QR As Button
|
||||
Dim Printer1 As EscPosPrinter
|
||||
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
|
||||
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
|
||||
Private L_CANT As Label
|
||||
Dim errorImpresora As Int = 0
|
||||
Dim banderaimp As Int
|
||||
Private l_credi As Label
|
||||
Private l_pagare As Label
|
||||
Private l_montopag As Label
|
||||
Private l_efectivo As Label
|
||||
Private l_montoefec As Label
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
g.Initialize("GPS")
|
||||
' Activity.LoadLayout("info_gral")
|
||||
Root.LoadLayout("cliente")
|
||||
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
|
||||
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")
|
||||
btAdmin.Initialize("BlueTeeth")
|
||||
cmp20.Initialize("Printer")
|
||||
reqManager.Initialize(Me, B4XPages.MainPage.SERVER)
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
banderaimp = 0
|
||||
Subs.centraPanel(p_principal, Root.Width)
|
||||
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
reqManager.Initialize(Me, B4XPages.MainPage.SERVER)
|
||||
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
|
||||
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")
|
||||
|
||||
|
||||
Private cym As Map = Subs.traeCantYMonto2(Subs.traeCliente)
|
||||
L_CANT.Text = cym.Get("cantidad")
|
||||
l_total.Text = Round2(cym.Get("monto"), 2)
|
||||
|
||||
' If CREDITO = "1" Then
|
||||
' Msgbox("AVISO","SE TIENE QUE IMPRIMIR PAGARÉ") 'ignore
|
||||
' End If
|
||||
' Private cym As Map = Subs.traemosCantYMonto(clv_pedido)
|
||||
' L_CANT.Text = cym.Get("cantidad")
|
||||
' l_total.Text = cym.Get("monto")
|
||||
Starter.skmt.ExecNonQuery("UPDATE HIST_VENTAS set ESPROMO = 1 where HVD_CODPROMO = HVD_PROID AND HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
Private vc As Cursor = Starter.skmt.ExecQuery($"select HVD_PROID,HVD_COSTO_TOT, HVD_CANT, IFNULL(HVD_RECHAZOCANT, 0) AS HVD_RECHAZOCANT from HIST_VENTAS where BCAJAS = 0 and HVD_CODPROMO ='${Subs.traealmacen}' and HVD_CLIENTE in (select cuenta from cuentaa)"$)
|
||||
|
||||
Private cuenta0 As String = 0
|
||||
Private arti As String = 0
|
||||
If vc.RowCount > 0 Then
|
||||
For i = 0 To vc.RowCount - 1
|
||||
vc.Position = i
|
||||
|
||||
|
||||
cuenta0 = cuenta0 + ((vc.GetString("HVD_CANT") - vc.GetString("HVD_RECHAZOCANT"))*(vc.GetString("HVD_COSTO_TOT")/vc.GetString("HVD_CANT")))
|
||||
|
||||
|
||||
|
||||
' Log(vc.GetString("HVD_CANT")&","&vc.GetString("HVD_RECHAZOCANT"))
|
||||
arti = arti + (vc.GetString("HVD_CANT") - vc.GetString("HVD_RECHAZOCANT"))
|
||||
' Log(vc.GetString("HVD_CANT") &" - "& vc.GetString("HVD_RECHAZOCANT")&" * "& vc8.GetString("CAT_GP_PRECIO"))
|
||||
Next
|
||||
End If
|
||||
' Log(cuenta0)
|
||||
|
||||
Private vc2 As Cursor = Starter.skmt.ExecQuery("select HVD_PROID, HVD_CANT, IFNULL(HVD_RECHAZOCANT, 0) AS HVD_RECHAZOCANT, CANTC,HVD_COSTO_TOT from HIST_VENTAS where HVD_CLIENTE in (select cuenta from cuentaa) AND BCAJAS = 1")
|
||||
Private Cuenta1 As String = 0
|
||||
Private arti1 As String = 0
|
||||
If vc2.RowCount > 0 Then
|
||||
For i = 0 To vc2.RowCount - 1
|
||||
vc2.Position = i
|
||||
Dim preu As Float = NumberFormat2(vc2.GetString("HVD_COSTO_TOT")/vc2.GetString("CANTC"),0,2,2,False)
|
||||
Private vc3 As Cursor = Starter.skmt.ExecQuery($"select PRECIOCONVER, CONVERSION from CAT_GUNAPROD where CAT_GP_ID = '${vc2.GetString("HVD_PROID")}'"$)
|
||||
If vc3.RowCount > 0 Then
|
||||
vc3.Position = 0
|
||||
Cuenta1 = Cuenta1 + ((vc2.GetString("CANTC")-(vc2.GetString("HVD_RECHAZOCANT")/vc3.GetString("CONVERSION")))*preu)
|
||||
arti1 = arti1 + (vc2.GetString("HVD_CANT") - vc2.GetString("HVD_RECHAZOCANT"))
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
' Log(Cuenta1)
|
||||
|
||||
Private vc4 As Cursor = Starter.skmt.ExecQuery($"select HVD_PROID,HVD_PRONOMBRE,HVD_COSTO_TOT, HVD_CANT, IFNULL(HVD_RECHAZOCANT, 0) AS HVD_RECHAZOCANT, CANTC,HVD_COSTO_TOT, HVD_RECHAZO, HVD_CODPROMO from HIST_VENTAS where HVD_CLIENTE in (select cuenta from cuentaa) AND BCAJAS = 0 and HVD_CODPROMO <> '${Subs.traeAlmacen}'"$)
|
||||
Private Cuenta2 As String = 0
|
||||
Private arti2 As String = 0
|
||||
If vc4.RowCount > 0 Then
|
||||
|
||||
For i = 0 To vc4.RowCount - 1
|
||||
vc4.Position = i
|
||||
If vc4.GetString("HVD_PROID") <> vc4.GetString("HVD_CODPROMO") Then
|
||||
If vc4.GetString("HVD_RECHAZO") = 0 Then
|
||||
Cuenta2 = Cuenta2 + vc4.GetString("HVD_COSTO_TOT")
|
||||
arti2 = arti2 + vc4.GetString("HVD_CANT")
|
||||
Else
|
||||
Private vc5 As Cursor = Starter.skmt.ExecQuery($"select CAT_GP_PRECIO from CAT_GUNAPROD where CAT_GP_ID = '${vc4.GetString("HVD_PROID")}'"$)
|
||||
If vc5.RowCount > 0 Then
|
||||
vc5.Position= 0
|
||||
' Log(vc5.GetString("CAT_GP_PRECIO"))
|
||||
Cuenta2 = Cuenta2 +((vc4.GetString("HVD_CANT")- vc4.GetString("HVD_RECHAZOCANT"))*(vc4.GetString("HVD_COSTO_TOT")/vc4.GetString("HVD_CANT")))
|
||||
arti2 = arti2 +(vc4.GetString("HVD_CANT")- vc4.GetString("HVD_RECHAZOCANT"))
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
End If
|
||||
' Log(arti2)
|
||||
|
||||
Private c4 As Cursor = Starter.skmt.ExecQuery($"SELECT IFNULL(PE_CANT,0) AS PE_CANT, iFNULL(PE_COSTO_TOT,0) AS PE_COSTO_TOT FROM PEDIDO WHERE PE_CLIENTE IN (SELECT CUENTA FROM CUENTAA)"$)
|
||||
Private Cuenta3 As String = 0
|
||||
Private arti3 As String = 0
|
||||
If c4.RowCount > 0 Then
|
||||
For i = 0 To c4.RowCount -1
|
||||
c4.Position = i
|
||||
arti3 = arti3 + c4.GetString("PE_CANT")
|
||||
Cuenta3 = Cuenta3 + c4.GetString("PE_COSTO_TOT")
|
||||
Next
|
||||
End If
|
||||
Log(cuenta0)
|
||||
Log(Cuenta1)
|
||||
Log(Cuenta2)
|
||||
Log(Cuenta3)
|
||||
|
||||
l_total.Text = NumberFormat2((cuenta0 + Cuenta1 + Cuenta2 + Cuenta3),0,2,2,True)
|
||||
L_CANT.Text = NumberFormat2((arti + arti1 +arti2 + arti3),0,0,0,True)
|
||||
|
||||
' l_total.Text = cuenta + Cuenta1 + Cuenta2
|
||||
' L_CANT.Text = arti + arti1 +arti2
|
||||
|
||||
c = Starter.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MACIMP"))
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
Starter.MAC_IMPRESORA = c.GetString("CAT_VA_VALOR")
|
||||
End If
|
||||
If Starter.MAC_IMPRESORA = "" Then Starter.MAC_IMPRESORA = "0"
|
||||
' Log("|" & Starter.MAC_IMPRESORA & "|")
|
||||
Printer1.Initialize(Me, "Printer1")
|
||||
|
||||
If Printer1.IsConnected = False Then
|
||||
' Printer1.Connect
|
||||
' Log("1")
|
||||
Else
|
||||
Printer1.DisConnect
|
||||
Printer1.Connect
|
||||
Log("2")
|
||||
End If
|
||||
|
||||
Dim pag As Cursor = Starter.skmt.ExecQuery("select * FROM PAGARES WHERE TMP_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
If pag.RowCount > 0 Then
|
||||
pag.Position = 0
|
||||
l_credi.Visible = True
|
||||
l_pagare.Visible = True
|
||||
l_montoefec.Visible = True
|
||||
l_efectivo.Visible = True
|
||||
l_montopag.Visible = True
|
||||
l_montopag.Text = pag.GetString("TMP_MONTO_PAGARE")
|
||||
Dim PAGAREMONTO As Float = cuenta0 + Cuenta1 + Cuenta2 + Cuenta3
|
||||
Dim PAGAREMONTO2 As Float = pag.GetString("TMP_MONTO_PAGARE")
|
||||
' Log
|
||||
If PAGAREMONTO - PAGAREMONTO2 < 0 Then
|
||||
l_montoefec.Text = 0
|
||||
Else
|
||||
l_montoefec.Text = PAGAREMONTO - PAGAREMONTO2
|
||||
End If
|
||||
Else If pag.RowCount = 0 Then
|
||||
l_credi.Visible = False
|
||||
l_pagare.Visible = False
|
||||
l_montoefec.Visible = False
|
||||
l_efectivo.Visible = False
|
||||
l_montopag.Visible = False
|
||||
End If
|
||||
|
||||
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, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub gest_Click
|
||||
B_IMP_Click
|
||||
banderaimp = 1
|
||||
End Sub
|
||||
|
||||
Sub Guardado
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
DateTime.TimeFormat="HHmmss"
|
||||
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
|
||||
d = Starter.skmt.ExecQuery("SELECT RUTAA FROM RUTAA")
|
||||
d.Position = 0
|
||||
Dim ruta As String = d.GetString("RUTAA")
|
||||
d.Close
|
||||
d = Starter.skmt.ExecQuery("SELECT CAT_CL_RUTA FROM kmt_info WHERE CAT_CL_CODIGO IN (SELECT CUENTA FROM CUENTAA)")
|
||||
d.Position = 0
|
||||
Dim rutapre As String = d.GetString("CAT_CL_RUTA")
|
||||
d.Close
|
||||
|
||||
' d = Starter.skmt.ExecQuery("SELECT HVD_FECHA FROM HIST_VENTAS WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
' d.Position = 0
|
||||
Dim fechaprev As String = Subs.traefECHAPREV
|
||||
' d.Close
|
||||
|
||||
Dim rutaactualizar As String
|
||||
Dim rut As Cursor = Starter.skmt.ExecQuery("SELECT CAT_CL_RUTA FROM kmt_info WHERE CAT_CL_CODIGO IN (SELECT CUENTA FROM CUENTAA)")
|
||||
If rut.RowCount > 0 Then
|
||||
rut.Position = 0
|
||||
rutaactualizar = rut.GetString("CAT_CL_RUTA")
|
||||
End If
|
||||
|
||||
Starter.skmt.ExecNonQuery($"DELETE FROM NOVENTA WHERE NV_CLIENTE IN (select cuenta from cuentaa) AND NV_RUTA ='${rutaactualizar}' "$)
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO NOVENTA (NV_CLIENTE,NV_FECHA,NV_USER,NV_MOTIVO,NV_COMM,NV_LAT,NV_LON,NV_RUTA) VALUES(?,?,?,?,?,?,?,?) ", Array As Object (cuenta,sDate &" "& sTime, usuario, "ENTREGA","ENTREGA COMPLETA", B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps,rutaactualizar))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO REPARTO_GEO (CLIENTE, USUARIO, FECHA_PUNTEO, LATITUD, LONGITUD, ALMACEN, RUTA_REPARTO, RUTA_PREV, FECHA_PREVENTA, TIPO,ENVIO) VALUES(?,?,?,?,?,?,?,?,?,?,0)",Array As String (la_cuenta.Text, usuario, sDate &" "&sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps,B4XPages.MainPage.almacen,ruta,rutapre,fechaprev, "ENTREGADO"))
|
||||
Starter.skmt.ExecNonQuery($"UPDATE kmt_info set gestion = 2, HORAENT = '${sDate & " " & sTime}' where CAT_CL_CODIGO In (select cuenta from cuentaa) and CAT_CL_RUTA = '${rutaactualizar}' "$)
|
||||
Starter.skmt.ExecNonQuery("update HIST_VENTAS SET HVD_ESTATUS = 1 WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
mandaPendientesreparto
|
||||
|
||||
|
||||
' Dim mandamapa As Cursor = Starter.skmt.ExecQuery("SELECT * FROM kmt_info WHERE gestion = 0 and CAT_CL_CODIGO <> 63403")
|
||||
' If mandamapa.RowCount > 0 Then
|
||||
' StartActivity(MAPA_RUTAS)
|
||||
' Else If mandamapa.RowCount = 0 Then
|
||||
B4XPages.ShowPage("Principal")
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub b_noEntrega_Click
|
||||
' skmt.ExecNonQuery("delete from PEDIDO")
|
||||
B4XPages.ShowPage("noVenta")
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
' I want to capture the key here so I return True
|
||||
B4XPages.ShowPage("Clientes")
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub Tar_Click
|
||||
' StartActivity(colonia2)
|
||||
B4XPages.ShowPage("Productos")
|
||||
End Sub
|
||||
|
||||
Sub DATOS_Click
|
||||
' StartActivity(telefonos)
|
||||
End Sub
|
||||
|
||||
Sub Guardar_Click
|
||||
' Dim mandamapa As Cursor = Starter.skmt.ExecQuery("SELECT * FROM kmt_info WHERE gestion = 0 AND cat_cl_codigo <> 63403")
|
||||
' If mandamapa.RowCount > 0 Then
|
||||
' StartActivity(MAPA_RUTAS)
|
||||
' Else If mandamapa.RowCount = 0 Then
|
||||
B4XPages.ShowPage("Principal")
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub NUEVO_Click
|
||||
StartActivity(MAPA_CLIENTE)
|
||||
End Sub
|
||||
|
||||
Sub HIST_Click
|
||||
' B4XPages.MainPage.historico.prodsMap.Initialize
|
||||
'' B4XPages.MainPage.historico.clv_pedido.Clear
|
||||
' B4XPages.ShowPage("Historico")
|
||||
B4XPages.MainPage.detalleVenta.prodsMap.Initialize
|
||||
' B4XPages.MainPage.historico.clv_pedido.Clear
|
||||
B4XPages.ShowPage("DetalleVenta")
|
||||
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("PROFINA")
|
||||
' 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
|
||||
|
||||
' 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)
|
||||
' c.Close
|
||||
'' c=Starter.skmt.ExecQuery2("SELECT CAT_VA_VALOR FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION =?", Array As String ("SUCURSAL"))
|
||||
'' c.Position = 0
|
||||
'' sucursal = c.GetString("CAT_VA_VALOR")
|
||||
'' c.Close
|
||||
'
|
||||
' ProgressDialogShow("Imprimiendo, un momento ...")
|
||||
' Printer1.DisConnect
|
||||
' If Not(Printer1.IsConnected) Then
|
||||
'' Log("Conectando a impresora ...")
|
||||
' Printer1.Connect
|
||||
' Private cont As Int = 0
|
||||
' Do While Not(impresoraConectada)
|
||||
' Sleep(1000)
|
||||
'' Log("++++++ " & cont)
|
||||
' cont = cont + 1
|
||||
' If cont = 2 Then Printer1.Connect 'Tratamos de reconectar
|
||||
' If cont > 3 Then impresoraConectada = True
|
||||
' Loop
|
||||
' Sleep(500)
|
||||
' impresoraConectada = False
|
||||
' Else
|
||||
'' Log("conectando 2")
|
||||
' Printer1.Connect
|
||||
' Private cont As Int = 0
|
||||
' Do While Not(impresoraConectada) Or Not(Printer1.IsConnected)
|
||||
' Sleep(1000)
|
||||
'' Log("****** " & cont)
|
||||
' cont = cont + 1
|
||||
' If cont = 2 Then Printer1.Connect
|
||||
' If cont > 3 Then impresoraConectada = True
|
||||
' Loop
|
||||
' Sleep(500)
|
||||
' impresoraConectada = False
|
||||
' End If
|
||||
'
|
||||
' TAMANO = 0
|
||||
' ESPACIO = 28
|
||||
' BLANCO = " "
|
||||
'' Dim bmp As Bitmap
|
||||
'' bmp.InitializeResize(File.DirAssets, "mariana.jpg", 192, 250, True) 'ignore
|
||||
'' Dim myimage As AnImage = Printer1.ImageToBWIMage(bmp)
|
||||
'
|
||||
'' myimage = Printer1.DitherImage2D(myimage, 128)
|
||||
''
|
||||
'' myimage= Printer1.PackImage(myimage)
|
||||
'' Printer1.WriteString(CRLF) ' nudge the Printer1 to show the user something is happening
|
||||
'' Printer1.WriteString(Printer1.REVERSE)
|
||||
''
|
||||
'' Printer1.PrintImage(myimage)
|
||||
'' Printer1.WriteString(Printer1.UNREVERSE)
|
||||
'
|
||||
'' Printer1.Justify = 1
|
||||
' 'Printer1.Initialize(cmp20.OutputStream)
|
||||
'' Printer1.WriteString("DISTRIBUIDORA ROCHA TULA PACHUCA" & CRLF)
|
||||
' Printer1.WriteString("MAZAPA Distribuciones" & CRLF)
|
||||
'' Printer1.WriteString(sucursal & CRLF)
|
||||
' Printer1.WriteString(sDate & CRLF)
|
||||
' Printer1.WriteString(sTime & CRLF)
|
||||
' Printer1.WriteString("Vendedor:" & usuario & CRLF)
|
||||
' Printer1.WriteString("Tienda: " & La_nombre.Text & CRLF)
|
||||
' Printer1.WriteString("ID.Cliente: " & la_cuenta.Text & CRLF)
|
||||
' Printer1.WriteString("Calle: " & la_Calle.Text & CRLF)
|
||||
' Printer1.WriteString("Colonia: " & la_col.Text & CRLF)
|
||||
'' Printer1.WriteString("C.P.: " & la_cp.Text & CRLF)
|
||||
'' Printer1.WriteString("Entre calle1: " & l_entre1.Text & CRLF)
|
||||
'' Printer1.WriteString("Entre Calle2: " & l_entre2.Text & CRLF)
|
||||
' Printer1.WriteString(" " & CRLF)
|
||||
' c = Starter.skmt.ExecQuery("SELECT * FROM HIST_VENTAS WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
' If c.RowCount > 0 Then
|
||||
' Printer1.WriteString("------------ENTREGA-----------" & CRLF)
|
||||
'
|
||||
'' Printer1.WriteString("--------------------------------" & CRLF)
|
||||
' Printer1.WriteString("Cant. Precio Importe" & CRLF)
|
||||
'
|
||||
' Printer1.WriteString("------------------------------" & CRLF)
|
||||
' ' aqui es donde esta el pedo de julieta de los descuentos quitar el precio2 pero meter un if para saber si es ruta especial o es normal o que show.
|
||||
' s=Starter.skmt.ExecQuery($"select HVD_PRONOMBRE, HVD_CANT, length(HVD_CANT) as L_CANT, HVD_COSTO_TOT, length(HVD_COSTO_TOT) as L_COSTOU,HVD_PROID, HVD_CODPROMO,IFNULL(HVD_RECHAZOCANT,0) AS HVD_RECHAZOCANT, HVD_RECHAZO FROM HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PROID"$)
|
||||
' If S.RowCount>0 Then
|
||||
' For i=0 To S.RowCount -1
|
||||
' S.Position=i
|
||||
' Log(s.GetString("HVD_RECHAZO"))
|
||||
' If s.GetString("HVD_CANT") - s.GetString("HVD_RECHAZOCANT") > 0 Then
|
||||
'
|
||||
'
|
||||
' If s.GetString("HVD_CODPROMO") = Subs.traeAlmacen Then
|
||||
'
|
||||
' Printer1.Justify = 0
|
||||
' Printer1.WriteString(s.GetString("HVD_PRONOMBRE") & CRLF)
|
||||
'
|
||||
'
|
||||
' Dim punit As String = NumberFormat2((s.GETSTRING("HVD_COSTO_TOT")/s.GetString("HVD_CANT")),0,2,2,False)
|
||||
' TAMANO = punit.Length + TAMANO
|
||||
'
|
||||
'' Private ptot As String = NumberFormat2((punit*s.GetString("HVD_CANT")),0,2,2,False)
|
||||
' Private ptot As String = NumberFormat2(( (s.GetString("HVD_CANT") - s.GetString("HVD_RECHAZOCANT")) * punit ),0,2,2,False)
|
||||
' TAMANO = ptot.Length + TAMANO
|
||||
'
|
||||
' ESPACIO = (ESPACIO - TAMANO)/2
|
||||
'' Log(ESPACIO)
|
||||
' For E=0 To ESPACIO -1
|
||||
' BLANCO = " " & BLANCO
|
||||
' Next
|
||||
' Printer1.Justify = 0
|
||||
' Printer1.WriteString( (s.GetString("HVD_CANT") - s.GetString("HVD_RECHAZOCANT"))& BLANCO)
|
||||
' Printer1.Justify = 1
|
||||
' Printer1.WriteString( punit & BLANCO)
|
||||
' Printer1.Justify = 2
|
||||
' Printer1.WriteString( ptot & CRLF )
|
||||
' TAMANO = 0
|
||||
' ESPACIO = 29
|
||||
' BLANCO = " "
|
||||
'
|
||||
' Else If s.GetString("HVD_RECHAZO") = 1 Then
|
||||
'
|
||||
' Printer1.Justify = 0
|
||||
' Printer1.WriteString(s.GetString("HVD_PRONOMBRE") & CRLF)
|
||||
'
|
||||
' Private vc5 As Cursor = Starter.skmt.ExecQuery($"select iFNULL(CAT_GP_PRECIO,0) AS CAT_GP_PRECIO from CAT_GUNAPROD where CAT_GP_ID = '${s.GetString("HVD_PROID")}'"$)
|
||||
' vc5.Position = 0
|
||||
' Dim punit As String = NumberFormat2((vc5.GetString("CAT_GP_PRECIO")),0,2,2,False)
|
||||
' TAMANO = punit.Length + TAMANO
|
||||
' vc5.Close
|
||||
'
|
||||
' Private ptot As String = NumberFormat2(( (s.GetString("HVD_CANT") - s.GetString("HVD_RECHAZOCANT")) * punit ),0,2,2,False)
|
||||
' TAMANO = ptot.Length + TAMANO
|
||||
'
|
||||
' ESPACIO = (ESPACIO - TAMANO)/2
|
||||
'' Log(ESPACIO)
|
||||
' For E=0 To ESPACIO -1
|
||||
' BLANCO = " " & BLANCO
|
||||
' Next
|
||||
' Printer1.Justify = 0
|
||||
' Printer1.WriteString( (s.GetString("HVD_CANT") - s.GetString("HVD_RECHAZOCANT"))& BLANCO)
|
||||
' Printer1.Justify = 1
|
||||
' Printer1.WriteString( punit & BLANCO)
|
||||
' Printer1.Justify = 2
|
||||
' Printer1.WriteString(ptot& CRLF )
|
||||
' TAMANO = 0
|
||||
' ESPACIO = 29
|
||||
' BLANCO = " "
|
||||
' Printer1.Justify = 0
|
||||
' End If
|
||||
' End If
|
||||
' Next
|
||||
' End If
|
||||
' End If
|
||||
' Printer1.Justify = 0
|
||||
' s.Close
|
||||
' Printer1.WriteString(" " & CRLF)
|
||||
' s=Starter.skmt.ExecQuery($"select HVD_PRONOMBRE, HVD_CANT, length(HVD_CANT) as L_CANT, HVD_COSTO_TOT, length(HVD_COSTO_TOT) as L_COSTOU,HVD_PROID, HVD_CODPROMO,IFNULL(HVD_RECHAZOCANT,0) AS HVD_RECHAZOCANT FROM HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) AND HVD_RECHAZO = 0 AND HVD_CODPROMO <> '${Subs.traeAlmacen}' order by HVD_CODPROMO, ESPROMO DESC, HVD_PROID"$)
|
||||
'
|
||||
' If S.RowCount>0 Then
|
||||
' Printer1.WriteString("-------PROMOS ENTREGA--------" & CRLF)
|
||||
' Printer1.WriteString("Cant. Precio Importe" & CRLF)
|
||||
' Printer1.WriteString("------------------------------" & CRLF)
|
||||
'
|
||||
' For i=0 To S.RowCount -1
|
||||
' S.Position=i
|
||||
' If s.GetString("HVD_CANT") - s.GetString("HVD_RECHAZOCANT") > 0 Then
|
||||
'
|
||||
'
|
||||
' If s.GetString("HVD_CODPROMO") <> Subs.traeAlmacen Then
|
||||
'
|
||||
' Printer1.Justify = 0
|
||||
' If s.GetString("HVD_CODPROMO") = s.GetString("HVD_PROID") Then
|
||||
' Printer1.WriteString("* "&s.GetString("HVD_PRONOMBRE") & CRLF)
|
||||
' Else
|
||||
' Printer1.WriteString(s.GetString("HVD_PRONOMBRE") & CRLF)
|
||||
' End If
|
||||
'
|
||||
'
|
||||
' Dim punit As String =NumberFormat2((s.GETSTRING("HVD_COSTO_TOT")/s.GetString("HVD_CANT")),0,2,2,False)
|
||||
' TAMANO = punit.Length + TAMANO
|
||||
'
|
||||
'
|
||||
' Private ptot As String = NumberFormat2((punit*s.GetString("HVD_CANT")),0,2,2,False)
|
||||
' TAMANO = ptot.Length + TAMANO
|
||||
'
|
||||
'
|
||||
' ESPACIO = (ESPACIO - TAMANO)/2
|
||||
' Log(ESPACIO)
|
||||
' For E=0 To ESPACIO -1
|
||||
' BLANCO = " " & BLANCO
|
||||
' Next
|
||||
' Printer1.Justify = 0
|
||||
' Printer1.WriteString( (s.GetString("HVD_CANT") - s.GetString("HVD_RECHAZOCANT"))& BLANCO)
|
||||
' Printer1.Justify = 1
|
||||
' Printer1.WriteString( punit & BLANCO)
|
||||
' Printer1.Justify = 2
|
||||
' Printer1.WriteString(ptot & CRLF )
|
||||
' TAMANO = 0
|
||||
' ESPACIO = 29
|
||||
' BLANCO = " "
|
||||
' Printer1.Justify = 0
|
||||
' Else
|
||||
'
|
||||
' End If
|
||||
' End If
|
||||
' Next
|
||||
' End If
|
||||
'
|
||||
' Printer1.WriteString(" " & CRLF)
|
||||
' s=Starter.skmt.ExecQuery($"select PE_PRONOMBRE, PE_CANT, length(PE_CANT) as L_CANT, PE_COSTO_TOT, length(PE_COSTO_TOT) as L_COSTOU,PE_PROID FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order BY PE_PROID"$)
|
||||
'
|
||||
' If S.RowCount>0 Then
|
||||
' Printer1.WriteString("-----------VENTA------------" & CRLF)
|
||||
' Printer1.WriteString("Cant. Precio Importe" & CRLF)
|
||||
' Printer1.WriteString("------------------------------" & CRLF)
|
||||
'
|
||||
' For i=0 To S.RowCount -1
|
||||
' S.Position=i
|
||||
'
|
||||
' Printer1.Justify = 0
|
||||
' Printer1.WriteString(s.GetString("PE_PRONOMBRE") & CRLF)
|
||||
'
|
||||
'
|
||||
' Dim punit As String =NumberFormat2( (s.GETSTRING("PE_COSTO_TOT")/s.GetString("PE_CANT")),0,2,2,False)
|
||||
' TAMANO = punit.Length + TAMANO
|
||||
'
|
||||
' Private ptot As String = NumberFormat2((punit*s.GetString("PE_CANT")),0,2,2,False)
|
||||
' TAMANO = ptot.Length + TAMANO
|
||||
'
|
||||
'
|
||||
' ESPACIO = (ESPACIO - TAMANO)/2
|
||||
' Log(ESPACIO)
|
||||
' For E=0 To ESPACIO -1
|
||||
' BLANCO = " " & BLANCO
|
||||
' Next
|
||||
' Printer1.Justify = 0
|
||||
' Printer1.WriteString( s.GetString("PE_CANT") & BLANCO)
|
||||
' Printer1.Justify = 1
|
||||
' Printer1.WriteString( punit & BLANCO)
|
||||
' Printer1.Justify = 2
|
||||
' Printer1.WriteString(ptot & CRLF )
|
||||
' TAMANO = 0
|
||||
' ESPACIO = 29
|
||||
' BLANCO = " "
|
||||
' Printer1.Justify = 0
|
||||
'
|
||||
' Next
|
||||
' End If
|
||||
' Printer1.WriteString(" " & CRLF)
|
||||
' Printer1.WriteString("------------------------------" & CRLF)
|
||||
'
|
||||
'
|
||||
' Printer1.WriteString("Total Articulos: " & L_CANT.Text & CRLF)
|
||||
' Printer1.WriteString("Total: $" & l_total.Text)
|
||||
'
|
||||
'
|
||||
' Printer1.WriteString(" " & CRLF)
|
||||
' Printer1.WriteString("------------------------------" & CRLF)
|
||||
'' Printer1.WriteString("ENTREGA EN :" & CRLF)
|
||||
'' Printer1.WriteString(la_Calle.Text & CRLF)
|
||||
' Printer1.WriteString("----ESTE TICKET NO ES UN -----" & CRLF)
|
||||
' Printer1.WriteString("--COMPROBANTE FISCAL, SOLO ES-" & CRLF)
|
||||
' Printer1.WriteString("--------INFORMATIVO-----------" & CRLF)
|
||||
' Printer1.WriteString("------------------------------" & CRLF)
|
||||
' Printer1.WriteString(" " & CRLF)
|
||||
' Printer1.WriteString(" " & CRLF)
|
||||
' Printer1.WriteString(" " & CRLF)
|
||||
' Sleep(1000)
|
||||
' Printer1.DisConnect
|
||||
'
|
||||
' ProgressDialogHide
|
||||
'
|
||||
' If banderaimp = 1 Then
|
||||
' Msgbox2Async("Deseas imprimir de nuevo el ticket?", "ATENCION","SI","", "NO",LoadBitmap(File.DirAssets,"alert2.png"), False)
|
||||
' Wait For Msgbox_Result (resultado As Int)
|
||||
' If resultado = DialogResponse.POSITIVE Then
|
||||
' B_IMP_Click
|
||||
' Else
|
||||
' Guardado
|
||||
' End If
|
||||
'
|
||||
'' printer.Flush
|
||||
' ' printer.Close
|
||||
' Else If banderaimp = 0 Then
|
||||
' Msgbox2Async("Deseas imprimir de nuevo el ticket?", "ATENCION","SI","", "NO",LoadBitmap(File.DirAssets,"alert2.png"), False)
|
||||
' Wait For Msgbox_Result (resultado As Int)
|
||||
' If resultado = DialogResponse.POSITIVE Then
|
||||
' B_IMP_Click
|
||||
' End If
|
||||
' End If
|
||||
|
||||
Guardado
|
||||
End Sub
|
||||
|
||||
Sub Printer1_Connected (Success As Boolean)
|
||||
' If Logger Then Log("Printer1_Connected")
|
||||
If Success Then
|
||||
ToastMessageShow("Impresora conectada", False)
|
||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("MACIMP"))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("MACIMP",Starter.mac_impresora))
|
||||
LogColor("Impresora conectada", Colors.Green)
|
||||
' B_IMP2.Enabled = True
|
||||
impresoraConectada = True
|
||||
Else
|
||||
' Msgbox(Printer1.ConnectedErrorMsg, "Error connecting.") 'ignore
|
||||
' ToastMessageShow("Error conectando la impresora", False)
|
||||
LogColor("Error conectando la impresora", Colors.Red)
|
||||
errorImpresora = errorImpresora + 1
|
||||
If errorImpresora > 1 Then
|
||||
Starter.MAC_IMPRESORA = "0"
|
||||
errorImpresora = 0
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub 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", B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
|
||||
|
||||
' Dim mandamapa As Cursor = Starter.skmt.ExecQuery("SELECT * FROM kmt_info WHERE gestion = 0")
|
||||
' If mandamapa.RowCount > 0 Then
|
||||
' StartActivity(MAPA_RUTAS)
|
||||
' Else If mandamapa.RowCount = 0 Then
|
||||
B4XPages.ShowPage("Principal")
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
|
||||
Sub mandaPendientesreparto
|
||||
' c=Starter.skmt.ExecQuery("SELECT CLIENTE, USUARIO, FECHA_PUNTEO, LATITUD, LONGITUD, ALMACEN, RUTA_REPARTO, RUTA_PREV, FECHA_PREVENTA, MOTIVO, COMENTARIO,TIPO FROM REPARTO_GEO where ENVIO <> 1")
|
||||
' Log($"REPARTO_Cliente PENDIENTE: ${c.RowCount}"$)
|
||||
' If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
' c.Position=i
|
||||
'
|
||||
' Dim cmd As DBCommand
|
||||
' cmd.Initialize
|
||||
' cmd.Name = "insert_REPARTO_MARDS"'Ojala no Truene
|
||||
' cmd.Parameters = Array As Object(c.GetString("CLIENTE"), c.GetString("USUARIO"), c.GetString("FECHA_PUNTEO"), c.GetString("LATITUD"), c.GetString("LONGITUD"), c.GetString("ALMACEN"), c.GetString("RUTA_REPARTO"), c.GetString("RUTA_PREV"), c.GetString("FECHA_PREVENTA"), c.GetString("MOTIVO"), c.GetString("COMENTARIO"),c.GetString("TIPO"))
|
||||
' reqManager.ExecuteCommand(cmd , $"ins_REPARTOPendientes_head_${c.GetString("CLIENTE")}"$)
|
||||
'
|
||||
' Next
|
||||
' End If
|
||||
' c.Close
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
Log(Job.Success)
|
||||
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 resultado As DBResult = reqManager.HandleJob(Job)
|
||||
If resultado.Tag.As(String).IndexOf("ins_REPARTOPendientes_head_") > -1 Then
|
||||
Private cliente As String= resultado.Tag
|
||||
cliente = cliente.SubString(cliente.IndexOf("_")+24)
|
||||
Log($"Cliente1:${cliente}"$)
|
||||
Starter.skmt.ExecNonQuery2("update REPARTO_GEO SET ENVIO = ? WHERE CLIENTE = ? AND ENVIO <> ?",Array As String ("1", cliente,"1"))
|
||||
For Each records() As Object In resultado.Rows
|
||||
For Each k As String In resultado.Columns.Keys
|
||||
Log(resultado.Tag & ": " & k & ": " & records(resultado.Columns.Get(k)))
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End If
|
||||
|
||||
End Sub
|
||||
687
B4A/C_Clientes.bas
Normal file
@@ -0,0 +1,687 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Dim q_buscar As String
|
||||
' Dim skmt As SQL
|
||||
Dim entro As String
|
||||
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
|
||||
Dim rutaGenerada As Boolean = False
|
||||
Dim rutaacambiar As String
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
Root.LoadLayout("clientes")
|
||||
entro ="2"
|
||||
lv1Top = ListView1.Top
|
||||
clientesMapaO.Initialize
|
||||
Starter.skmt.ExecNonQuery("delete from waypoints")
|
||||
Log("Coordenadas del almacen: " & Starter.cedisLocation.Longitude & "," & Starter.cedisLocation.Latitude)
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
busca.Text = ""
|
||||
b_GetDirs.Visible = False
|
||||
' 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("select 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 = Root.Width
|
||||
p_colonia.Height = Root.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
|
||||
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 AND CAT_CL_RUTA <> 1000 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")
|
||||
' Log(c.GetString("indice"))
|
||||
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
|
||||
p_colonia.Width = Root.Width
|
||||
p_colonia.Height = Root.Height
|
||||
Subs.centraEtiqueta(l_rutaInfo, Root.Width)
|
||||
Subs.centraListView(ListView1, p_colonia.Width)
|
||||
ListView1.Height = p_colonia.Height * 0.70
|
||||
Subs.centraEtiqueta(lfila, Root.Width)
|
||||
b_getRutaInfo.Visible = True
|
||||
b_getRutaInfo.BringToFront
|
||||
If Starter.cedisLocation.Latitude = "0" Then
|
||||
Private x As Cursor = Starter.skmt.ExecQuery("select * from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'COORDS_ALMACEN'")
|
||||
If x.RowCount > 0 Then
|
||||
x.Position = 0
|
||||
Private y() As String
|
||||
Starter.cedisLocation.Latitude = Regex.Split(",", x.GetString("CAT_VA_VALOR"))(1)
|
||||
Starter.cedisLocation.Longitude = Regex.Split(",", x.GetString("CAT_VA_VALOR"))(0)
|
||||
End If
|
||||
End If
|
||||
Log(Starter.cedisLocation)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
'Return True to close, False to cancel
|
||||
Log(entro)
|
||||
If rutaGenerada Or entro = 3 Then ' Si ya generamos el ruteo o entramos a una de las rutas, nos regresamos!
|
||||
b_limpiarRuta_Click
|
||||
l_rutaInfo.Text = ""
|
||||
rutaGenerada = False
|
||||
else if entro = 2 Then ' Si estamos mostrando las rutas, nos regresamos a la principal.
|
||||
B4XPages.ShowPage("Principal")
|
||||
End If
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemClick (Position As Int, Value As Object)
|
||||
' Log($"Entro= ${entro}"$)
|
||||
Log(Value)
|
||||
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}"$)
|
||||
rutaacambiar = 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 AND CAT_CL_RUTA <> 1000 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
|
||||
label2.Height = 57dip
|
||||
thisLoc.Initialize
|
||||
If entro = 2 Then ListView1.TwoLinesLayout.ItemHeight = 90dip
|
||||
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")
|
||||
' Log(Tracker.UUGCoords)
|
||||
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")
|
||||
' Log(m1.Get("nomDirDist"))
|
||||
ListView1.AddTwoLines(m1.Get("codigo"), m1.Get("nomDirDist"))
|
||||
Next
|
||||
End If
|
||||
c2.Close
|
||||
entro = "3"
|
||||
Else If entro = "3" Then
|
||||
' LogColor("Guardamos CLIENTE " & Value, Colors.red)
|
||||
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(Value))
|
||||
B4XPages.ShowPage("Cliente")
|
||||
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 AND CAT_CL_RUTA <> 1000 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))
|
||||
B4XPage_Created(Root)
|
||||
Return True
|
||||
End If
|
||||
B4XPages.ShowPage("Principal")
|
||||
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 AND CAT_CL_RUTA <> 1000 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 = Root.Width * 0.9
|
||||
Subs.centraEtiqueta(l_rutaInfo, Root.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")
|
||||
Log("BORRAMOS WAYPOINTS")
|
||||
For Each k As Object In clientesMapaO.Keys 'Guardamos en la BD el orden de los waypoints para luego generar el listview.
|
||||
If listaWayPoints.Size > 0 Then
|
||||
r1 = clientesMapaO.Get(k)
|
||||
r1.Get("codigo")
|
||||
Log(listaWayPoints.Get(r) & "|" & r1.Get("coords") & "|" & r1.Get("calle"))
|
||||
wps = listaWayPoints.Get(r)
|
||||
Starter.skmt.ExecNonQuery($"update kmt_info set SECUENCIA = ${wps.get("waypoint_index")} where CAT_CL_CODIGO = '${r1.Get("codigo")}'"$)
|
||||
Starter.skmt.ExecNonQuery2("insert into waypoints values (?,?)", Array As Object(r1.Get("codigo"), wps.get("waypoint_index")))
|
||||
r = r + 1
|
||||
End If
|
||||
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 AND CAT_CL_RUTA <> 1000 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
|
||||
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") > 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 AND CAT_CL_RUTA <> 1000 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 AND CAT_CL_RUTA <> 1000 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)
|
||||
caculaRutaGPS(todosAVisitar)
|
||||
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
|
||||
B4XPage_Appear
|
||||
End Sub
|
||||
|
||||
Sub caculaRutaGPS(coords As List)
|
||||
Private tmpList As List
|
||||
Dim cs, cs2 As CSBuilder
|
||||
tmpList.Initialize
|
||||
tmpList.AddAll(Array As String("ACTUAL", Tracker.UUGCoords.Longitude, Tracker.UUGCoords.Latitude))
|
||||
coords.InsertAt(0,tmpList)
|
||||
Log("=================================")
|
||||
' Log(coords)
|
||||
Private coordsStr As String = ""
|
||||
For Each tienda As List In coords
|
||||
' Log(tienda)
|
||||
If coordsStr = "" Then
|
||||
coordsStr = $"${tienda.get(0)},${tienda.get(1)},${tienda.get(2)}"$
|
||||
Else
|
||||
coordsStr = $"${coordsStr};${tienda.get(0)},${tienda.get(1)},${tienda.get(2)}"$
|
||||
End If
|
||||
Next
|
||||
Log(coordsStr)
|
||||
ProgressDialogShow2("Calculando distancia y tiempo, un momento por favor.", False)
|
||||
Dim j As HttpJob
|
||||
j.Initialize("trip", Me) 'Calculamos el resto de la ruta.
|
||||
j.Download($"http://keymon.lat:9002/ruteador?m=OSRM&r=${Subs.traeRutaReparto}&a=${Subs.traeAlmacen}&f=CEDIS,${Starter.cedisLocation.Longitude},${Starter.cedisLocation.Latitude}&c=${coordsStr}"$)
|
||||
Log($"http://keymon.lat:9002/ruteador?m=OSRM&r=${Subs.traeRutaReparto}&a=${Subs.traeAlmacen}&f=CEDIS,${Starter.cedisLocation.Longitude},${Starter.cedisLocation.Latitude}&c=${coordsStr}"$)
|
||||
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(m)
|
||||
If m.Get("code") = "OK" Then
|
||||
Log("===== OK")
|
||||
rutaGenerada = True
|
||||
Dim puntos As Int = m.Get("puntos")
|
||||
Private coords As List = m.Get("coords")
|
||||
Private duration As String = m.Get("duration")
|
||||
Private distance As String = m.Get("distance")
|
||||
Private mensaje As String = m.Get("mensaje")
|
||||
Starter.skmt.ExecNonQuery("delete from waypoints")
|
||||
Starter.skmt.ExecNonQuery("update kmt_info set SECUENCIA = 0")
|
||||
For i = 0 To coords.Size - 1
|
||||
Private ti As Map = coords.Get(i)
|
||||
Starter.skmt.ExecNonQuery($"update kmt_info set SECUENCIA = ${ti.Get("pos")} where CAT_CL_CODIGO = '${ti.Get("id").As(String).SubString(1)}'"$) ' Ponemos la secuencia con el orden del ruteo para poder verla en el mapa.
|
||||
Starter.skmt.ExecNonQuery($"insert into waypoints (codigo, indice) values ('${ti.Get("id").As(String).SubString(1)}', '${ti.Get("pos")}')"$)
|
||||
Next
|
||||
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 AND CAT_CL_RUTA <> 1000 order by indice")
|
||||
If c.RowCount > 0 Then 'Ya hay waypoints en la base de datos.
|
||||
c.Position = 0
|
||||
conMapa = True
|
||||
ListView1.Clear
|
||||
Dim cs, cs2 As CSBuilder
|
||||
entro = 3
|
||||
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
|
||||
Log($"Distancia total: $1.1{distance/1000} kms, tiempo aprox: $1.1{duration/60} mins. ($1.1{duration/60/60} hrs)"$)
|
||||
l_rutaInfo.Text = $"Distancia: $1.1{distance/1000} kms, tiempo aprox: $1.1{duration/60/60} hrs${CRLF}Visitas restantes: ${puntos - 1}"$
|
||||
l_rutaInfo.Width = Root.Width * 0.9
|
||||
Subs.centraEtiqueta(l_rutaInfo, Root.Width)
|
||||
l_rutaInfo.Visible = True
|
||||
l_rutaInfo.BringToFront
|
||||
ListView1.Top = lv1Top + 100
|
||||
End If
|
||||
Else
|
||||
LogColor("**************** Error! ******************", Colors.red)
|
||||
End If
|
||||
j.Release
|
||||
ProgressDialogHide
|
||||
End Sub
|
||||
|
||||
'Regresa lista de los clientes a visitar y sus coordenadas, iniciando con el cedis.
|
||||
Sub todosAVisitar As List
|
||||
Log(laRuta)
|
||||
Log(entro)
|
||||
Private sqlDeRuta As String = ""
|
||||
If entro = 3 Then sqlDeRuta = $"and CAT_CL_RUTA = '${laRuta}'"$
|
||||
Private aVisitar, tmpList As List
|
||||
aVisitar.Initialize
|
||||
Private coords As ResultSet = Starter.skmt.ExecQuery($"select CAT_CL_CODIGO, CAT_CL_LAT, CAT_CL_LONG from kmt_info where gestion = 0 AND CAT_CL_RUTA <> 1000 ${sqlDeRuta}"$)
|
||||
Do While coords.NextRow
|
||||
tmpList.Initialize
|
||||
tmpList.AddAll(Array As String(coords.GetString("CAT_CL_CODIGO"), coords.GetString("CAT_CL_LONG"), coords.GetString("CAT_CL_LAT")))
|
||||
aVisitar.Add(tmpList)
|
||||
Loop
|
||||
Log(aVisitar)
|
||||
Return aVisitar
|
||||
End Sub
|
||||
1073
B4A/C_DetalleVenta.bas
Normal file
112
B4A/C_Detalle_Promo.bas
Normal file
@@ -0,0 +1,112 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
Root.LoadLayout("detalle_promo")
|
||||
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
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
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)
|
||||
B4XPages.ShowPage("")
|
||||
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)
|
||||
B4XPages.ShowPage("")
|
||||
'Return True
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
167
B4A/C_Foto.bas
Normal file
@@ -0,0 +1,167 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Private frontCamera As Boolean = False
|
||||
Dim g As GPS
|
||||
Private p_camara As Panel
|
||||
Private camEx As CameraExClass
|
||||
Dim btnTakePicture As Button
|
||||
Dim c As Cursor
|
||||
Dim cuenta As String
|
||||
Dim lat_gps As String
|
||||
Dim USUARIO As String
|
||||
Dim MOTIVO As String
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
g.Initialize("GPS")
|
||||
Root.LoadLayout("foto")
|
||||
c=Starter.skmt.ExecQuery("select cuenta from cuentaa")
|
||||
c.Position = 0
|
||||
cuenta = c.GetString("CUENTA")
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
InitializeCamera
|
||||
End Sub
|
||||
|
||||
Private Sub InitializeCamera
|
||||
camEx.Initialize(p_camara, frontCamera, Me, "Camera1")
|
||||
frontCamera = camEx.Front
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
' camEx.Release
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
|
||||
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.DirInternal
|
||||
|
||||
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
|
||||
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) VALUES(?,?,?,?,?,?,?,?) ", Array As Object (cuenta,sDate & sTime, USUARIO, "CERRADO", B4XPages.MainPage.noVenta.COMENTARIO, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps, Data))
|
||||
Starter.skmt.ExecNonQuery($"UPDATE kmt_info set gestion = 3, HORAENT = '${sDate & " " & sTime}' 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)")
|
||||
B4XPages.ShowPage("Cliente")
|
||||
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
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
' I want to capture the key here so I return True
|
||||
B4XPages.ShowPage("Cliente")
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
609
B4A/C_Historico.bas
Normal file
@@ -0,0 +1,609 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Dim g As GPS
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
Dim c As Cursor
|
||||
' Dim ruta As String
|
||||
Dim b_regresar As Button
|
||||
Dim ListView1 As ListView
|
||||
Dim L_CANT As Label
|
||||
Dim L_TOTAL As Label
|
||||
Dim b_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
|
||||
Dim clv_pedido As CustomListView
|
||||
Private p_prods As Panel
|
||||
Private l_prodX As Label
|
||||
Private l_pCant As Label
|
||||
Private et_pCant As EditText
|
||||
Dim bmp As Bitmap
|
||||
Dim etCantHasFocus As Boolean = False
|
||||
Dim totalProds As Int = 0
|
||||
Dim totalCompra As Int = 0
|
||||
Dim prodsMap As Map
|
||||
Dim reconstruirPedido As Boolean = False
|
||||
Dim promoABorrar As String
|
||||
Private b_guardar As Button
|
||||
Private b_prodMas As Button
|
||||
Private b_prodMenos As Button
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
g.Initialize("GPS")
|
||||
Root.LoadLayout("historico")
|
||||
b_borra.Visible = False
|
||||
Titulo.Text = "Pedido"
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
Subs.centraPanel(p_principal, Root.Width)
|
||||
' b_guardar.Visible = False
|
||||
|
||||
' 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 distinct hist_ventas.hvd_num_registro, HIST_VENTAS.HVD_CLIENTE, HIST_VENTAS.HVD_PRONOMBRE, HIST_VENTAS.HVD_PROID, HIST_VENTAS.HVD_CANT, HIST_VENTAS2.HVD_CANT as HVD_CANT2, HIST_VENTAS.HVD_COSTO_TOT, HIST_VENTAS.HVD_CODPROMO from HIST_VENTAS inner join HIST_VENTAS2 on HIST_VENTAS.HVD_PROID = HIST_VENTAS2.HVD_PROID and HIST_VENTAS.HVD_CLIENTE = HIST_VENTAS2.HVD_CLIENTE WHERE HIST_VENTAS.HVD_CLIENTE IN (Select CUENTA from cuentaa) and HIST_VENTAS.HVD_RECHAZO = 0 order by HIST_VENTAS.HVD_CODPROMO desc, HIST_VENTAS.HVD_PRONOMBRE asc")
|
||||
c=Starter.skmt.ExecQuery("select hvd_num_registro, HVD_CLIENTE, HVD_PRONOMBRE, HVD_PROID, HVD_CANT, HVD_COSTO_TOT, HVD_CODPROMO from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) and HVD_RECHAZO = 0 and hvd_cant > 0 order by HVD_CODPROMO desc, HVD_PRONOMBRE asc")
|
||||
ListView1.Clear
|
||||
clv_pedido.Clear
|
||||
Subs.SetDivider(ListView1, Colors.LightGray, 2)
|
||||
clv_pedido.GetBase.SetLayoutAnimated(100, 0dip, 60dip, Root.Width - 50, Root.Height * 0.62) 'Cambiamos el tamaño y posición de la lista de productos
|
||||
clv_pedido.Base_Resize(clv_pedido.GetBase.Width, clv_pedido.GetBase.Height) 'Cambiamos el tamaño del panel interno de la lista para que ajuste al nuevo tamaño.
|
||||
' Log("RC1:"&c.RowCount)
|
||||
If c.RowCount>0 Then
|
||||
' Log("Usamos HV")
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
'Traemos cantidad de hvd2
|
||||
Private oc As Cursor = Starter.skmt.ExecQuery($"select HVD_CANT from HIST_VENTAS2 WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) and hvd_proid = '${c.GetString("HVD_PROID")}' and HVD_NUM_REGISTRO = '${c.GetString("HVD_NUM_REGISTRO")}'"$)
|
||||
Private cant2 As Int = 0
|
||||
If oc.RowCount > 0 Then
|
||||
oc.Position = 0
|
||||
cant2 = oc.GetString("HVD_CANT")
|
||||
End If
|
||||
oc.Close
|
||||
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
|
||||
Private bgColor, textColor As Int
|
||||
bgColor = Colors.RGB(177, 200, 249)'azul
|
||||
textColor = Colors.black
|
||||
If c.GetString("HVD_CODPROMO") <> "1" Then
|
||||
' bgColor = Colors.RGB(255, 212, 163) 'naranja
|
||||
bgColor = Colors.White
|
||||
End If
|
||||
' Log($"Agregamos prod a lista1 | ${c.GetString("HVD_CANT")} - ${c.GetString("HVD_CANT2")}"$) 'HVD_CANT2 es la original de la orden.
|
||||
' ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT"))
|
||||
clv_pedido.Add(CreateListItem(c.GetString("HVD_PRONOMBRE"), Subs.traePrecio(c.GetString("HVD_PROID"), c.GetString("HVD_CODPROMO")), c.GetString("HVD_CANT"), 0, clv_pedido.AsView.Width, 50dip, bmp, c.GetString("HVD_PROID"), bgColor, textColor, c.GetString("HVD_CODPROMO"),Subs.traeCliente), c.GetString("HVD_PRONOMBRE"))
|
||||
Next
|
||||
' cuentaProds("")
|
||||
End If
|
||||
'Traemos lo vendido
|
||||
Private vc As Cursor = Starter.skmt.ExecQuery("select * from REPARTO where REP_CLIENTE in (select cuenta from cuentaa) and REP_RECHAZO = '0' and REP_CANT > 0 order by REP_PRONOMBRE")
|
||||
Log($"VENTA: ${vc.RowCount}"$)
|
||||
If vc.RowCount > 0 Then
|
||||
' Log("Usamos REPARTO")
|
||||
' bgColor = Colors.RGB(248,113,113)
|
||||
textColor = Colors.RGB(0,87,142)
|
||||
For i=0 To vc.RowCount -1
|
||||
vc.Position = i
|
||||
Private cantCO As Int = 0
|
||||
'Traemos la cantidad disponible del cliente original
|
||||
Private cco As Cursor = Starter.skmt.ExecQuery($"select * from REPARTO where REP_CLIENTE = '${vc.GetString("REP_CLI_ORIG")}' and REP_CLI_ORIG = '${vc.GetString("REP_CLI_ORIG")}' and REP_PRODID='${vc.GetString("REP_PRODID")}' and REP_RECHAZO = '1' and REP_CANT > 0"$)
|
||||
|
||||
If cco.RowCount > 0 Then
|
||||
cco.Position = 0
|
||||
cantCO = cco.GetString("REP_CANT") + vc.GetString("REP_CANT")
|
||||
End If
|
||||
cantCO = Subs.traeCantidadRechazada(vc.GetString("REP_CLI_ORIG"), vc.GetString("REP_PRODID"))
|
||||
|
||||
' Log($"${vc.GetString("REP_CLI_ORIG")}, ${vc.GetString("REP_CLIENTE")}, ${vc.GetString("REP_PRODID")}, ${vc.GetString("REP_PRONOMBRE")}, ${vc.GetString("REP_RECHAZO")}, ${vc.GetString("REP_CANT")}, ${vc.GetString("REP_PRECIO")}, ${cantCO}, ${cco.GetString("REP_CANT")}, ${vc.GetString("REP_CANT")}"$)
|
||||
clv_pedido.Add(CreateListItem(vc.GetString("REP_PRONOMBRE"), Subs.traePrecio(vc.GetString("REP_PRODID"), Subs.traeAlmacen), vc.GetString("REP_CANT"), cantCO, clv_pedido.AsView.Width, 50dip, bmp, vc.GetString("REP_PRODID"), bgColor, textColor, 1, vc.GetString("REP_CLI_ORIG")), vc.GetString("REP_PRONOMBRE"))
|
||||
Next
|
||||
cco.Close
|
||||
vc.Close
|
||||
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 = Round2(c.GetString("PC_MONTO"), 2)
|
||||
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)
|
||||
' Log("RC2:" & c.RowCount)
|
||||
' 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
|
||||
' Log("Agegamos prod a lista 2")
|
||||
' 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 = Round2(L_TOTAL.Text + c.GetString("PE_COSTO_TOT"), 2)
|
||||
End If
|
||||
'la_no_ird.Text = c.GetString("PR_CF_SALDO_ACORT")
|
||||
' cuentaProds("")
|
||||
Private cym As Map = Subs.traemosCantYMonto(clv_pedido)
|
||||
L_CANT.Text = cym.Get("cantidad")
|
||||
L_TOTAL.Text = Round2(cym.Get("monto"), 2)
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
' lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
' lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
Sub b_regresar_Click
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
' I want to capture the key here so I return True
|
||||
B4XPages.ShowPage("Cliente")
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object) 'BORRAR
|
||||
' 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
|
||||
' b_regresar.Visible =False
|
||||
' b_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, REP_CLI_ORIG) select HVD_CLIENTE, HVD_PRONOMBRE, HVD_CANT, HVD_COSTO_TOT, HVD_FECHA, HVD_CLIENTE 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)")
|
||||
' B4XPage_Appear
|
||||
' End If
|
||||
'
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub lv2_ItemClick (Position As Int, Value As Object) 'BORRAR
|
||||
' ' 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, REP_CLI_ORIG) select HVD_CLIENTE, HVD_PRONOMBRE, HVD_CANT, HVD_COSTO_TOT, HVD_FECHA, HVD_CLIENTE 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))
|
||||
' b_regresar.Visible =True
|
||||
' b_borra.Visible=True
|
||||
' P1.Visible =False
|
||||
' B4XPage_Appear
|
||||
' 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, REP_CLI_ORIG) select HVD_CLIENTE, HVD_PRONOMBRE, ?, ? * (HVD_COSTO_TOT/?), HVD_FECHA, HVD_CLIENTE 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)")
|
||||
' B4XPage_Appear
|
||||
' b_regresar.Visible =True
|
||||
' b_borra.Visible=True
|
||||
' P1.Visible =False
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
'****************************************************************************
|
||||
'***************** PARA EL MAS/MENOS *************************************
|
||||
'****************************************************************************
|
||||
|
||||
Sub CreateListItem(Text As String, precioU As String, inv As Int, inv2 As Int, Width As Int, Height As Int, img As Bitmap, prodId As String, bc As Int, tc As Int, promo As String, cliente_original As String) As Panel
|
||||
Dim p As B4XView = xui.CreatePanel("")
|
||||
Private cs As CSBuilder
|
||||
cs.Initialize
|
||||
p.SetLayoutAnimated(0, 0, 0, Width, Height)
|
||||
p.LoadLayout("prodItem")
|
||||
p_prods.Color = bc
|
||||
l_prodX.TextColor = tc
|
||||
precioU = $"$1.2{precioU}"$
|
||||
l_prodX.Text = Text&CRLF&"Cant: " & inv2 & " $" & precioU
|
||||
If promo <> "1" And precioU = 0 Then
|
||||
l_prodX.Text = cs.Color(Colors.RGB(123,0,0)).append(Text&CRLF&"Cant: " & inv2 & " $" & precioU).PopAll
|
||||
End If
|
||||
l_prodX.Tag = $"ID: ${prodId}${CRLF}${Text}${CRLF}Precio: $$1.2{precioU}${CRLF}Inv: ${inv} pzs"$
|
||||
' l_pCant.Text = 0
|
||||
l_pCant.Tag = Round2(precioU,2)&"|"&inv&"|"&prodId&"|"&promo&"|"&inv2&"|"&cliente_original
|
||||
et_pCant.Tag = Round2(precioU,2)&"|"&inv&"|"&prodId&"|"&promo&"|"&inv2&"|"&cliente_original
|
||||
p_prods.Tag = l_pCant.tag
|
||||
' Log($"Ponemos la cant en ${inv}"$)
|
||||
l_pCant.Text = inv
|
||||
' et_pCant.Text = inv
|
||||
' et_pCant.BringToFront
|
||||
|
||||
l_pCant.BringToFront
|
||||
et_pCant.SendToBack
|
||||
|
||||
' i_prod.Bitmap = img
|
||||
Return p
|
||||
End Sub
|
||||
|
||||
Sub b_prodMenos_Click
|
||||
etCantHasFocus = False
|
||||
Log("etCantHasFocus=" & etCantHasFocus)
|
||||
LogColor("b_prodMenos_Click", Colors.Magenta)
|
||||
Dim index As Int = clv_pedido.GetItemFromView(Sender)
|
||||
Dim pnl0 As B4XView = clv_pedido.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(3)
|
||||
' Log(pnl.GetView(2).GetView(0) & "|" & pnl.GetView(2).GetView(1) & "|" & pnl.GetView(2).GetView(2))
|
||||
Dim esteTag As List = Regex.Split("\|", laCant.Tag)
|
||||
Log("LC_TEXT:"&laCant.Text&"|PROMO:"&esteTag.Get(3)&"|LC_TAG:"&laCant.Tag&"|ET:"&esteTag)
|
||||
If esteTag.Get(3) <> "1" Then 'Si es PROMO entonces ...
|
||||
Log("ES PROMO")
|
||||
result = Msgbox2("Si se modifica una promoción, la promoción se rompe y solo quedarán los productos sueltos, ¿seguro que desea continuar?","Modificar Promoción", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then 'Quitamos esta promo
|
||||
prodsMap.Remove(esteTag.Get(3))
|
||||
Starter.skmt.ExecNonQuery($"update HIST_VENTAS set HVD_RECHAZO = 1 WHERE HVD_PROID = '${esteTag.Get(3)}' and HVD_cliente in (Select CUENTA from cuentaa)"$)
|
||||
Starter.skmt.ExecNonQuery($"update HIST_VENTAS set HVD_CODPROMO = '${Subs.traeAlmacen}' WHERE HVD_cliente in (Select CUENTA from cuentaa) AND HVD_CODPROMO = '${esteTag.Get(3)}'"$)
|
||||
LogColor(prodsMap, Colors.red)
|
||||
reconstruirPedido = True
|
||||
promoABorrar = esteTag.Get(3)
|
||||
B4XPage_Appear
|
||||
End If
|
||||
Else
|
||||
If laCant.Text = "" Then laCant.Text = 0
|
||||
laCant.Text = $"$1.0{laCant.Text-1}"$
|
||||
If laCant.Text < 0 Then laCant.Text = 0
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + 1 where cat_gp_id = ?", Array As Object(esteTag.Get(2)))
|
||||
End If
|
||||
Dim preciou As Float = esteTag.Get(0)/esteTag.Get(1)
|
||||
Log("PU: " & preciou)
|
||||
' LogColor("estamos aqui mmenos " & laCant.Text& " , " & (preciou * laCant.Text),Colors.Green )
|
||||
' If L_CANT.Text - 1 >= 0 Then
|
||||
' L_CANT.Text = L_CANT.Text - 1
|
||||
' End If
|
||||
' b_guardar.Visible = True
|
||||
Subs.prodRechazo(esteTag.Get(5), esteTag.Get(2))
|
||||
Private cym As Map = Subs.traemosCantYMonto(clv_pedido)
|
||||
L_CANT.Text = cym.Get("cantidad")
|
||||
L_TOTAL.Text = Round2(cym.Get("monto"), 2)
|
||||
' cuentaProds("-")
|
||||
End Sub
|
||||
|
||||
Sub b_prodMas_Click
|
||||
etCantHasFocus = False
|
||||
' Log("etCantHasFocus=" & etCantHasFocus)
|
||||
LogColor("b_prodMas_Click", Colors.Magenta)
|
||||
Dim index As Int = clv_pedido.GetItemFromView(Sender)
|
||||
Dim pnl0 As B4XView = clv_pedido.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(3)
|
||||
' Log(pnl.GetView(2).GetView(1).text&"|"&pnl.GetView(2).GetView(2)&"|"&pnl.GetView(2).GetView(4).text)
|
||||
' Log($"precio|stock:${laCant.tag}"$)
|
||||
' Log($"Indice: ${index}, cant:${laCant.Text+1}, precioU: ${laCant.tag}"$)
|
||||
Dim esteTag As List = Regex.Split("\|", laCant.Tag)
|
||||
Log("LC_TEXT:"&laCant.Text&"|LC_TAG:"&laCant.Tag&"|ET:"&esteTag)
|
||||
If laCant.Text = "" Then laCant.Text = 0
|
||||
|
||||
Private maxProds as string = esteTag.Get(1) + esteTag.Get(4) 'Prods disponibles + prods comprados
|
||||
|
||||
LogColor($"++++++++++++++++++++++++++ ${esteTag}"$, Colors.Green)
|
||||
' Log(esteTag.get(4))
|
||||
If laCant.Text + 1 <= maxProds Then
|
||||
Log($"NuevaCant = ${laCant.Text + 1}"$)
|
||||
laCant.Text = $"$1.0{laCant.Text + 1}"$
|
||||
Starter.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - 1 where cat_gp_id = ?", Array As Object(esteTag.Get(2)))
|
||||
Subs.prodVenta(esteTag.Get(5), esteTag.Get(2))
|
||||
Private cym As Map = Subs.traemosCantYMonto(clv_pedido)
|
||||
L_CANT.Text = cym.Get("cantidad")
|
||||
L_TOTAL.Text = Round2(cym.Get("monto"), 2)
|
||||
' cuentaProds("+")
|
||||
End If
|
||||
' Dim preciou As Float = esteTag.Get(0)/esteTag.Get(1)
|
||||
' Log(preciou)
|
||||
' LogColor("estamos aquii mas " & laCant.Text& " , " & (preciou * laCant.Text) ,Colors.Green )
|
||||
' b_guardar.Visible = True
|
||||
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
||||
' c = Starter.skmt.ExecQuery($"SELECT HVD_CANT FROM HIST_VENTAS2 WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA) AND HVD_PROID = '${esteTag.Get(2)}' "$)
|
||||
' c.Position = 0
|
||||
' Dim cantoriginal As String = 0
|
||||
' If c.RowCount > 0 Then
|
||||
' cantoriginal = c.GetString("HVD_CANT")
|
||||
' End If
|
||||
' If cantoriginal <= esteTag.Get(1) Then
|
||||
' L_CANT.Text = L_CANT.Text + 1
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub cuentaProds(accion As String)
|
||||
' Log("Entramos a cuentaProds")
|
||||
Log("*******************************************************")
|
||||
Private cantRechazada As Int = 0
|
||||
If Not(reconstruirPedido) Then
|
||||
Log("*********** CUENTAPRODS - NO RECONSTRUIR")
|
||||
prodsMap.Initialize
|
||||
For i = 0 To clv_pedido.GetSize - 1
|
||||
Private p0 As B4XView = clv_pedido.GetPanel(i)
|
||||
Private p As B4XView = p0.GetView(0)
|
||||
Private cant1 As B4XView = p.GetView(2).GetView(3)
|
||||
If cant1.Text = "" Then cant1.Text = 0
|
||||
' totalProds = totalProds + cant1.Text
|
||||
Private esteTag As List = Regex.Split("\|", cant1.Tag)
|
||||
Log("-------------------------------------")
|
||||
Log($"ET: ${esteTag}"$)
|
||||
Private esteProd As String = esteTag.Get(2)
|
||||
Private estaCant As Int = cant1.Text
|
||||
Private estaCantOriginal As Int = esteTag.Get(1)
|
||||
Private esteCliente = Subs.traeCliente
|
||||
Private esteProdNombre = Subs.traeNombre(esteProd)
|
||||
Private esteClienteOriginal As Int = esteTag.Get(5)
|
||||
Private fechaReparto As String = Subs.traeFechaReparto
|
||||
Private maxProds = Subs.traeMaxCantidad(esteTag.Get(5), esteTag.Get(2))
|
||||
|
||||
If cant1.Text > maxProds Then cant1.Text = maxProds
|
||||
|
||||
cantRechazada = esteTag.Get(4) - cant1.Text
|
||||
' If accion = "-" Then cantRechazada = Subs.traeCantidadRechazada(esteClienteOriginal, esteProd) + 1
|
||||
' If accion = "+" Then cantRechazada = Subs.traeCantidadRechazada(esteClienteOriginal, esteProd) - 1
|
||||
Log($"${Subs.traeCantidadRechazada(esteClienteOriginal, esteProd)}, ${Subs.traeCantidadVendida(esteClienteOriginal, esteProd)}"$)
|
||||
|
||||
' LogColor($"cantRechazada = ${esteTag.Get(4)} - ${cant1.Text}"$, Colors.Magenta)
|
||||
LogColor($"cantRechazada = ${cantRechazada}"$, Colors.Magenta)
|
||||
Private estePrecio As String = 0
|
||||
If Subs.traePrecio(esteProd, 1) <> Null Then estePrecio = Subs.traePrecio(esteProd, Subs.traeAlmacen) * cantRechazada
|
||||
|
||||
' LogColor(esteProd & "|" & cant1.Text & "|" & estaCantOriginal & "|" & cantRechazada & "|" & estePrecio, Colors.red)
|
||||
' LogColor($"cantRechazada=${cantRechazada} | ${esteProdNombre}"$, Colors.Blue)
|
||||
' Log($"Ponemos HVD_CANT ${esteProd} en ${cant1.text}"$)
|
||||
Starter.skmt.ExecNonQuery2("update HIST_VENTAS set HVD_PARCIAL = 1, HVD_CANT = ? WHERE HVD_PROID = ? and HVD_CLIENTE in (Select CUENTA from cuentaa)", Array As String(cant1.Text ,esteProd))
|
||||
Private rr As Cursor = Starter.skmt.ExecQuery($"select count(REP_CLIENTE) as hayRechazo from REPARTO where rep_prodid = '${esteProd}' and REP_CLIENTE in (Select CUENTA from cuentaa)"$)
|
||||
rr.Position = 0
|
||||
' Log($"HayRechazo=${rr.GetString("hayRechazo")}"$)
|
||||
If rr.GetString("hayRechazo") = 0 Then
|
||||
Log("INSERTAMOS EN REPARTO")
|
||||
Starter.skmt.ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT, REP_FECHA, REP_RECHAZO, REP_PRODID, REP_PRECIO, REP_CLI_ORIG) VALUES (?,?,?,?,?,1,?,?,?) ", Array As String(esteCliente, esteProdNombre, 0, estePrecio, fechaReparto, esteProd, estePrecio, esteCliente))
|
||||
Starter.skmt.ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT, REP_FECHA, REP_RECHAZO, REP_PRODID, REP_PRECIO, REP_CLI_ORIG) VALUES (?,?,?,?,?,0,?,?,?) ", Array As String(esteCliente, esteProdNombre, cantRechazada, 0, fechaReparto, esteProd, estePrecio, esteCliente))
|
||||
Else if esteClienteOriginal = "0" Then 'Actualizamos el rechazo en el cliente actual.
|
||||
' Log($"Actualizamos REP_CANT=${cantRechazada}"$)
|
||||
' Starter.skmt.ExecNonQuery($"update reparto set REP_CANT = '${cantRechazada}', REP_PRECIO = '${estePrecio}', REP_COSTO_TOT = '${estePrecio * cantRechazada}' where REP_CLIENTE in (Select CUENTA from cuentaa) and REP_CLI_ORIG = '${esteClienteOriginal}' and REP_RECHAZO = 1 and REP_PRODID = '${esteProd}'"$)
|
||||
Else 'Cliente original <> 0 entonces actualizamos el rechazo en el cliente original y NO en el actual.
|
||||
Log($"Actualizamos REP_CANT RECHAZO = ${cantRechazada}"$)
|
||||
' Starter.skmt.ExecNonQuery($"update reparto set REP_CANT = ${cantRechazada}, REP_PRECIO = '${estePrecio}', REP_COSTO_TOT = '${estePrecio * cantRechazada}' where REP_CLIENTE = '${esteClienteOriginal}' and REP_CLI_ORIG = '${esteClienteOriginal}' and REP_RECHAZO = 1 and REP_PRODID = '${esteProd}'"$)
|
||||
' Starter.skmt.ExecNonQuery($"update reparto set REP_CANT = '${cant1.Text}', REP_PRECIO = '${estePrecio}', REP_COSTO_TOT = '${estePrecio * cantRechazada}' where REP_CLIENTE in (Select CUENTA from cuentaa) and REP_CLI_ORIG = '${esteClienteOriginal}' and REP_RECHAZO = 0 and REP_PRODID = '${esteProd}'"$)
|
||||
End If
|
||||
|
||||
If cant1.Text > 0 Then
|
||||
' totalCompra = totalCompra + (esteTag.get(0) * cant1.text)
|
||||
' Log($"Cant: ${cant1.Text}, Suma: ${totalCompra}"$)
|
||||
Private m As Map
|
||||
m=CreateMap("cant":cant1.Text, "cant2":esteTag.get(4), "precio":esteTag.get(0), "promo":esteTag.get(3), "nombre":Subs.traeNombre(esteTag.Get(2)), "cli_orig":esteTag.get(5))
|
||||
' LogColor("PUT:" & esteTag.Get(2), Colors.Red)
|
||||
prodsMap.Put(esteTag.Get(2), m)
|
||||
End If
|
||||
Log("-------------------------------------")
|
||||
Next
|
||||
End If
|
||||
Private bgColor, textColor As Int
|
||||
|
||||
If reconstruirPedido Then
|
||||
Log("*********** CUENTAPRODS - SI RECONSTRUIR")
|
||||
Private newPromo, newPrecio As String
|
||||
clv_pedido.Clear
|
||||
Log("Usamos PRODSMAP")
|
||||
For Each pr As String In prodsMap.Keys
|
||||
Private pr1 As Map = prodsMap.Get(pr)
|
||||
Log("PPP: " & pr & "|PromoABorrar=" & promoABorrar & "|" & pr1)
|
||||
bgColor = Colors.RGB(177, 200, 249)'azul
|
||||
textColor = Colors.black
|
||||
newPromo = pr1.Get("promo")
|
||||
newPrecio = pr1.Get("precio")
|
||||
Log("AAA: " & newPromo & "|" & promoABorrar)
|
||||
If newPromo = promoABorrar Then
|
||||
newPromo = 1
|
||||
newPrecio = Subs.traePrecio(pr, False) * pr1.Get("cant")
|
||||
'Ponemos precio SIN promo y sacamos el producto de la promo.
|
||||
Starter.skmt.ExecNonQuery($"update HIST_VENTAS set HVD_COSTO_TOT = ${newPrecio}, HVD_CODPROMO = '${Subs.traeAlmacen}' WHERE HVD_PRONOMBRE = '${pr1.Get("nombre")}' and HVD_cliente in (Select CUENTA from cuentaa)"$)
|
||||
LogColor("CAMBIAMOS PROMO: " & newPromo, Colors.Magenta)
|
||||
End If
|
||||
If newPromo <> "1" Then
|
||||
' bgColor = Colors.RGB(255, 212, 163) 'naranja
|
||||
bgColor = Colors.White
|
||||
End If
|
||||
Log($"CLI: ${pr1.Get("nombre")}, ${newPrecio}, ${pr1.Get("cant")}, ${pr1.Get("cant2")}"$)
|
||||
clv_pedido.Add(CreateListItem(pr1.Get("nombre"), newPrecio, pr1.Get("cant"), pr1.Get("cant2"), clv_pedido.AsView.Width, 50dip, bmp, pr, bgColor, textColor, newPromo, pr1.Get("cli_orig")), pr1.Get("nombre"))
|
||||
reconstruirPedido = False
|
||||
Next
|
||||
promoABorrar = ""
|
||||
End If
|
||||
Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
||||
LogColor("prodsMap=" & prodsMap, Colors.Green)
|
||||
|
||||
|
||||
LogColor(prodsMap, Colors.Blue)
|
||||
c = Starter.skmt.ExecQuery($"SELECT sum(HVD_CANT) as CANTIDAD FROM HIST_VENTAS WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)"$)
|
||||
Dim cantidad1 As String = 0
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
cantidad1 = c.GetString("CANTIDAD")
|
||||
L_CANT.Text = Round(cantidad1)
|
||||
End If
|
||||
c.Close
|
||||
|
||||
Dim totalfinal As String = 0
|
||||
For Each pr As String In prodsMap.Keys
|
||||
Private pr1 As Map = prodsMap.Get(pr)
|
||||
' LogColor(pr,Colors.Red)
|
||||
Dim x As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_GP_PRECIO FROM CAT_GUNAPROD WHERE CAT_GP_ID = '${pr}'"$)
|
||||
c = Starter.skmt.ExecQuery($"SELECT HVD_CANT FROM HIST_VENTAS WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA) AND HVD_PROID ='${pr}' "$)
|
||||
Dim cantidady As String = 0
|
||||
If c.RowCount >0 Then
|
||||
c.Position = 0
|
||||
cantidady = c.GetString("HVD_CANT")
|
||||
End If
|
||||
' Log(x.RowCount)
|
||||
If x.RowCount > 0 Then
|
||||
x.Position = 0
|
||||
' Log(x.GetString("CAT_GP_PRECIO"))
|
||||
Dim preciou As String = x.GetString("CAT_GP_PRECIO")
|
||||
Dim costototalhist As String = preciou * cantidady
|
||||
' Log("Total ==== "&costototalhist)
|
||||
End If
|
||||
totalfinal = totalfinal + costototalhist
|
||||
x.Close
|
||||
Next
|
||||
L_TOTAL.Text = Round2(totalfinal, 2)
|
||||
c.Close
|
||||
|
||||
c = Starter.skmt.ExecQuery("select COUNT(*) AS CUANTOS from REPARTO where REP_CLIENTE in (select cuenta from cuentaa) and REP_RECHAZO = '0' and REP_CANT > 0 order by REP_PRONOMBRE")
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
If c.GetString("CUANTOS") > 0 Then
|
||||
|
||||
Dim z As Cursor = Starter.skmt.ExecQuery($"select SUM(REP_CANT) AS CANTIDAD , SUM(REP_PRECIO) AS PRECIO from REPARTO where REP_CLIENTE in (select cuenta from cuentaa) and REP_RECHAZO = '0' and REP_CANT > 0 order by REP_PRONOMBRE"$)
|
||||
Dim cantidad2 As String = 0
|
||||
' Log(z.RowCount)
|
||||
If z.RowCount > 0 Then
|
||||
z.Position = 0
|
||||
cantidad2= z.GetString("CANTIDAD")
|
||||
' LogColor(z.GetString("PRECIO")&" , " & z.GetString("CANTIDAD"), Colors.Magenta)
|
||||
' Log(cantidad1 &" , "& cantidad2)
|
||||
L_CANT.Text = Round((cantidad1 + cantidad2))
|
||||
End If
|
||||
z.Close
|
||||
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub b_guardar_Click
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub l_pCant_Click
|
||||
|
||||
End Sub
|
||||
|
||||
Sub p_prods_Click
|
||||
Log(Sender.As(Panel).tag)
|
||||
End Sub
|
||||
24
B4A/C_Mapas.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
201
B4A/C_NoVenta.bas
Normal file
@@ -0,0 +1,201 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Dim g As GPS
|
||||
Dim c As Cursor
|
||||
Dim COMENTARIO As String
|
||||
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 r_4 As RadioButton
|
||||
Private p_principal As Panel
|
||||
Dim d As Cursor
|
||||
Dim reqManager As DBRequestManager
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
Root.LoadLayout("no_venta")
|
||||
reqManager.Initialize(Me, B4XPages.MainPage.SERVER)
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
reqManager.Initialize(Me, B4XPages.MainPage.SERVER)
|
||||
e_comm.Text=""
|
||||
r_1.Checked = False
|
||||
r_2.Checked = False
|
||||
r_3.Checked = False
|
||||
r_4.Checked = False
|
||||
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
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
Sub GUARDA_Click
|
||||
If r_1.Checked = False And r_2.Checked = False And r_3.Checked = False And r_4.Checked = False Then
|
||||
MsgboxAsync("Selecciona un motivo de rechazo","Atención")
|
||||
Else
|
||||
|
||||
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" Or motivo = "CERRADO" Then
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
DateTime.TimeFormat="HHmmss"
|
||||
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
|
||||
Dim rutaactualizar As String
|
||||
Dim rut As Cursor = Starter.skmt.ExecQuery("SELECT CAT_CL_RUTA FROM kmt_info WHERE CAT_CL_CODIGO IN (SELECT CUENTA FROM CUENTAA)")
|
||||
If rut.RowCount > 0 Then
|
||||
rut.Position = 0
|
||||
rutaactualizar = rut.GetString("CAT_CL_RUTA")
|
||||
End If
|
||||
Starter.skmt.ExecNonQuery($"DELETE FROM NOVENTA WHERE NV_CLIENTE IN (select cuenta from cuentaa) AND NV_RUTA ='${rutaactualizar}' "$)
|
||||
'Traemos los productos del pedido.
|
||||
c=Starter.skmt.ExecQuery("select HVD_NUM_REGISTRO, HVD_CLIENTE, HVD_PRONOMBRE, HVD_CANT, HVD_COSTO_TOT, HVD_FECHA, HVD_PROID, CAT_GP_PRECIO from HIST_VENTAS2 join CAT_GUNAPROD on CAT_GP_ID = HVD_PROID WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PRONOMBRE asc")
|
||||
If c.RowCount > 0 Then 'Si hay pedido en HIST_VENTAS ...
|
||||
|
||||
'Revisamos si se le ha agregado venta al pedido.
|
||||
Private esteCliente As String = Subs.traeCliente
|
||||
Private rv As Cursor = Starter.skmt.ExecQuery($"select * from REPARTO where REP_CLIENTE = '${esteCliente}' and REP_CLI_ORIG <> '${esteCliente}' and REP_RECHAZO = 0"$)
|
||||
If rv.RowCount > 0 Then 'Si tenemos venta en el pedido ...
|
||||
For i2=0 To rv.RowCount - 1
|
||||
rv.Position = i2
|
||||
Log($"Actualizamos REPARTO - cliente=${rv.GetString("REP_CLIENTE")}, cliente orignal=${rv.GetString("REP_CLI_ORIG")}, le agregamos ${rv.GetString("REP_CANT")}"$)
|
||||
Starter.skmt.ExecNonQuery($"update REPARTO set REP_CANT = REP_CANT + ${rv.GetString("REP_CANT")} where REP_RECHAZO = '1' and REP_CLIENTE = '${rv.GetString("REP_CLI_ORIG")}' and REP_CLI_ORIG = '${rv.GetString("REP_CLI_ORIG")}'"$)
|
||||
Next
|
||||
End If
|
||||
|
||||
Starter.skmt.ExecNonQuery("delete from reparto where REP_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
For i=0 To c.RowCount - 1 'Insertamos los productos en REPARTO.
|
||||
c.Position=i
|
||||
Log($"REGISTRO= ${c.GetString("HVD_NUM_REGISTRO")}"$)
|
||||
Starter.skmt.ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT, REP_FECHA, REP_RECHAZO, REP_PRODID, REP_PRECIO, REP_PRODREGISTRO, REP_CLI_ORIG) VALUES (?,?,?,?,?,1,?,?,?,?) ", Array As String(c.GetString("HVD_CLIENTE"),c.GetString("HVD_PRONOMBRE"),c.GetString("HVD_CANT"),c.GetString("HVD_COSTO_TOT"),c.GetString("HVD_FECHA"), c.GetString("HVD_PROID"), c.GetString("CAT_GP_PRECIO"), c.GetString("HVD_NUM_REGISTRO"), c.GetString("HVD_CLIENTE")))
|
||||
Starter.skmt.ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT, REP_FECHA, REP_RECHAZO, REP_PRODID, REP_PRECIO, REP_PRODREGISTRO, REP_CLI_ORIG) VALUES (?,?,?,?,?,0,?,?,?,?) ", Array As String(c.GetString("HVD_CLIENTE"),c.GetString("HVD_PRONOMBRE"),0,c.GetString("HVD_COSTO_TOT"),c.GetString("HVD_FECHA"), c.GetString("HVD_PROID"), c.GetString("CAT_GP_PRECIO"), c.GetString("HVD_NUM_REGISTRO"), c.GetString("HVD_CLIENTE")))
|
||||
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")))
|
||||
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) VALUES(?,?,?,?,?,?,?,?) ", Array As Object (cuenta,sDate & sTime, usuario, motivo,e_comm.text, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps,rutaactualizar))
|
||||
Starter.skmt.ExecNonQuery($"UPDATE kmt_info set gestion = 3, HORAENT = '${sDate & " " & sTime}' where CAT_CL_CODIGO In (select cuenta from cuentaa) and CAT_CL_RUTA = '${rutaactualizar}'"$)
|
||||
Starter.skmt.ExecNonQuery("update HIST_VENTAS SET HVD_RECHAZO = 1, HVD_RECHAZOCANT = HVD_CANT, HVD_RECHAZOCANTC = CANTC, BCAJAS = 0 , CANTC = 0 WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
Starter.skmt.ExecNonQuery($"update HIST_VENTAS set HVD_RECHAZO = 2, HVD_RECHAZOCANT = HVD_RECHAZOCANT WHERE HVD_PROID = HVD_CODPROMO and HVD_CLIENTE in (Select CUENTA from cuentaa)"$)
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM PEDIDO WHERE PE_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
d = Starter.skmt.ExecQuery("SELECT RUTAA FROM RUTAA")
|
||||
d.Position = 0
|
||||
Dim ruta As String = d.GetString("RUTAA")
|
||||
d.Close
|
||||
d = Starter.skmt.ExecQuery("SELECT CAT_CL_RUTA FROM kmt_info WHERE CAT_CL_CODIGO IN (SELECT CUENTA FROM CUENTAA)")
|
||||
d.Position = 0
|
||||
Dim rutapre As String = d.GetString("CAT_CL_RUTA")
|
||||
d.Close
|
||||
d = Starter.skmt.ExecQuery("SELECT HVD_FECHA FROM HIST_VENTAS WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")
|
||||
d.Position = 0
|
||||
Dim fechaprev As String = d.GetString("HVD_FECHA")
|
||||
d.Close
|
||||
d = Starter.skmt.ExecQuery("SELECT CUENTA FROM CUENTAA")
|
||||
d.Position = 0
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO REPARTO_GEO (CLIENTE, USUARIO, FECHA_PUNTEO, LATITUD, LONGITUD, ALMACEN, RUTA_REPARTO, RUTA_PREV, FECHA_PREVENTA, MOTIVO, COMENTARIO,TIPO,ENVIO) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,0)",Array As String (cuenta, usuario, sDate &" "&sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps,B4XPages.MainPage.almacen,ruta,rutapre,fechaprev, motivo, e_comm.Text,"NO ENTREGADO"))
|
||||
|
||||
' Dim mandamapa As Cursor = Starter.skmt.ExecQuery("SELECT * FROM kmt_info WHERE gestion = 0")
|
||||
' If mandamapa.RowCount > 0 Then
|
||||
' StartActivity(MAPA_RUTAS)
|
||||
' Else If mandamapa.RowCount = 0 Then
|
||||
B4XPages.ShowPage("Principal")
|
||||
' End If
|
||||
Else
|
||||
COMENTARIO = e_comm.Text
|
||||
' B4XPages.ShowPage("Foto")
|
||||
' StartActivity(foto)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Sub mandaPendientesreparto
|
||||
' c=Starter.skmt.ExecQuery("SELECT CLIENTE, USUARIO, FECHA_PUNTEO, LATITUD, LONGITUD, ALMACEN, RUTA_REPARTO, RUTA_PREV, FECHA_PREVENTA, MOTIVO, COMENTARIO,TIPO FROM REPARTO_GEO where ENVIO <> 1")
|
||||
' Log($"REPARTO_Cliente PENDIENTE: ${c.RowCount}"$)
|
||||
' If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
' c.Position=i
|
||||
'
|
||||
' Dim cmd As DBCommand
|
||||
' cmd.Initialize
|
||||
' cmd.Name = "insert_REPARTO_MARDS"
|
||||
' cmd.Parameters = Array As Object(c.GetString("CLIENTE"), c.GetString("USUARIO"), c.GetString("FECHA_PUNTEO"), c.GetString("LATITUD"), c.GetString("LONGITUD"), c.GetString("ALMACEN"), c.GetString("RUTA_REPARTO"), c.GetString("RUTA_PREV"), c.GetString("FECHA_PREVENTA"), c.GetString("MOTIVO"), c.GetString("COMENTARIO"),c.GetString("TIPO"))
|
||||
' reqManager.ExecuteCommand(cmd , $"ins_REPARTOPendientes_head_${c.GetString("CLIENTE")}"$)
|
||||
'
|
||||
' Next
|
||||
' End If
|
||||
' c.Close
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
Log(Job.Success)
|
||||
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 resultado As DBResult = reqManager.HandleJob(Job)
|
||||
If resultado.Tag.As(String).IndexOf("ins_REPARTOPendientes_head_") > -1 Then
|
||||
Private cliente As String= resultado.Tag
|
||||
cliente = cliente.SubString(cliente.IndexOf("_")+24)
|
||||
Log($"Cliente1:${cliente}"$)
|
||||
Starter.skmt.ExecNonQuery2("update REPARTO_GEO SET ENVIO = ? WHERE CLIENTE = ? AND ENVIO <> ?",Array As String ("1", cliente,"1"))
|
||||
For Each records() As Object In resultado.Rows
|
||||
For Each k As String In resultado.Columns.Keys
|
||||
Log(resultado.Tag & ": " & k & ": " & records(resultado.Columns.Get(k)))
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End If
|
||||
|
||||
End Sub
|
||||
24
B4A/C_NuevoCliente.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
24
B4A/C_Pedidos.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
2188
B4A/C_Principal.bas
Normal file
1108
B4A/C_Productos.bas
Normal file
24
B4A/C_TicketsDia.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
74
B4A/C_UpdateAvailable.bas
Normal file
@@ -0,0 +1,74 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
Root.Color = Colors.Transparent
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
Try
|
||||
Do While Not(CanRequestPackageInstalls)
|
||||
MsgboxAsync($"Por favor permita que ${Application.PackageName} instale actualizaciones"$, "Instalar actualización")
|
||||
Wait For Msgbox_Result(Result As Int)
|
||||
Dim in As Intent
|
||||
in.Initialize("android.settings.MANAGE_UNKNOWN_APP_SOURCES", "package:" & Application.PackageName)
|
||||
StartActivity(in)
|
||||
Loop
|
||||
Catch
|
||||
Log("updateAvailable() Error - " & LastException.Message)
|
||||
End Try
|
||||
If appUpdater.newApp.update Then
|
||||
ofreceActualizacion
|
||||
Else
|
||||
sinActualizacion
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
'//// Esta es una actividad usada por el servicio appUpdater para mostrar notificaciones
|
||||
'//// cuando hay alguna actualizacion de apk.
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Sub CanRequestPackageInstalls As Boolean
|
||||
' // https://www.b4x.com/android/forum/threads/version-safe-apk-installation.87667/#content
|
||||
Dim ctxt As JavaObject
|
||||
ctxt.InitializeContext
|
||||
Dim PackageManager As JavaObject = ctxt.RunMethod("getPackageManager", Null)
|
||||
Return PackageManager.RunMethod("canRequestPackageInstalls", Null)
|
||||
End Sub
|
||||
|
||||
Sub ofreceActualizacion
|
||||
If Msgbox2(appUpdater.newApp.newMsg,"Actualización disponible","Si","","No",Null) = DialogResponse.Positive Then 'ignore
|
||||
' StartService(DownloadService)
|
||||
CallSubDelayed(appUpdater, "download_newApk")
|
||||
' ToastMessageShow("Descargando actualización", True)
|
||||
End If
|
||||
B4XPages.MainPage.ocultaProgreso
|
||||
StartActivity(Main)
|
||||
' Activity.Finish
|
||||
B4XPages.ShowPage("Login")
|
||||
End Sub
|
||||
|
||||
Sub sinActualizacion
|
||||
Msgbox(appUpdater.newApp.okMsg, "Aplicación al corriente") 'ignore
|
||||
' StartActivity(Main)
|
||||
B4XPages.MainPage.ocultaProgreso
|
||||
B4XPages.ShowPage("Login")
|
||||
End Sub
|
||||
134
B4A/C_tabulador.bas
Normal file
@@ -0,0 +1,134 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Private et_mil As EditText
|
||||
Private et_quinientos As EditText
|
||||
Private et_docientos As EditText
|
||||
Private et_cien As EditText
|
||||
Private et_cincuenta As EditText
|
||||
Private et_veinte As EditText
|
||||
Private et_m_veinte As EditText
|
||||
Private et_m_diez As EditText
|
||||
Private et_m_cinco As EditText
|
||||
Private et_m_dos As EditText
|
||||
Private et_m_peso As EditText
|
||||
Private et_m_centavo As EditText
|
||||
Private b_calcular As Button
|
||||
Private b_guardar As Button
|
||||
Private l_total As Label
|
||||
Dim sum_billetes As Int
|
||||
Dim sum_monedas As Float
|
||||
Dim total As Float
|
||||
Dim c As Cursor
|
||||
Dim d As Cursor
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
Root.LoadLayout("tabulador")
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
d = Starter.skmt.ExecQuery("SELECT VEINTE, DIEZ, CINCO, DOS, PESO, CENTAVO, TOTAL FROM TABULADOR_MONEDAS")
|
||||
c = Starter.skmt.ExecQuery("SELECT MIL, QUINIENTOS, DOCIENTOS, CIEN, CINCUENTA, VEINTE FROM TABULADOR_BILLETES")
|
||||
c.Position = 0
|
||||
d.Position = 0
|
||||
If c.RowCount > 0 And d.RowCount > 0 Then
|
||||
Log("TABULADR CON RESUKTADO")
|
||||
et_mil.Text = c.GetString("MIL")
|
||||
et_quinientos.Text = c.GetString("QUINIENTOS")
|
||||
et_docientos.Text = c.GetString("DOCIENTOS")
|
||||
et_cien.Text = c.GetString("CIEN")
|
||||
et_cincuenta.Text = c.GetString("CINCUENTA")
|
||||
et_veinte.Text = c.GetString("VEINTE")
|
||||
et_m_veinte.Text = d.GetString("VEINTE")
|
||||
et_m_diez.Text = d.GetString("DIEZ")
|
||||
et_m_cinco.Text = d.GetString("CINCO")
|
||||
et_m_dos.Text = d.GetString("DOS")
|
||||
et_m_peso.Text = d.GetString("PESO")
|
||||
et_m_centavo.Text = d.GetString("CENTAVO")
|
||||
l_total.Text = d.GetString("TOTAL")
|
||||
else If c.RowCount = 0 And d.RowCount = 0 Then
|
||||
Log("TABULADR SIN RESUKTADO")
|
||||
et_mil.Text = ""
|
||||
et_quinientos.Text = ""
|
||||
et_docientos.Text = ""
|
||||
et_cien.Text = ""
|
||||
et_cincuenta.Text = ""
|
||||
et_veinte.Text = ""
|
||||
et_m_veinte.Text = ""
|
||||
et_m_diez.Text = ""
|
||||
et_m_cinco.Text = ""
|
||||
et_m_dos.Text = ""
|
||||
et_m_peso.Text = ""
|
||||
et_m_centavo.Text = ""
|
||||
l_total.Text = ""
|
||||
End If
|
||||
c.Close
|
||||
d.Close
|
||||
End Sub
|
||||
|
||||
Private Sub b_guardar_Click
|
||||
b_calcular_Click
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM TABULADOR_MONEDAS")
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM TABULADOR_BILLETES")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO TABULADOR_BILLETES (MIL, QUINIENTOS, DOCIENTOS, CIEN, CINCUENTA, VEINTE) VALUES (?,?,?,?,?,?)", Array As Object(et_mil.Text,et_quinientos.Text,et_docientos.Text,et_cien.Text,et_cincuenta.Text,et_veinte.Text))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO TABULADOR_MONEDAS (VEINTE, DIEZ, CINCO, DOS, PESO, CENTAVO, TOTAL) VALUES (?,?,?,?,?,?,?)", Array As Object(et_m_veinte.Text,et_m_diez.Text,et_m_cinco.Text,et_m_dos.Text,et_m_peso.Text,et_m_centavo.Text,l_total.Text))
|
||||
B4XPages.ShowPage("Principal")
|
||||
End Sub
|
||||
|
||||
Private Sub b_calcular_Click
|
||||
If et_mil.Text = "" Then
|
||||
et_mil.Text = 0
|
||||
End If
|
||||
If et_quinientos.Text = "" Then
|
||||
et_quinientos.Text = 0
|
||||
End If
|
||||
If et_docientos.Text = "" Then
|
||||
et_docientos.Text = 0
|
||||
End If
|
||||
If et_cien.Text = "" Then
|
||||
et_cien.Text = 0
|
||||
End If
|
||||
If et_cincuenta.Text = "" Then
|
||||
et_cincuenta.Text = 0
|
||||
End If
|
||||
If et_veinte.Text = "" Then
|
||||
et_veinte.Text = 0
|
||||
End If
|
||||
If et_m_veinte.Text = "" Then
|
||||
et_m_veinte.Text = 0
|
||||
End If
|
||||
If et_m_diez.Text = "" Then
|
||||
et_m_diez.Text = 0
|
||||
End If
|
||||
If et_m_cinco.Text = "" Then
|
||||
et_m_cinco.Text = 0
|
||||
End If
|
||||
If et_m_dos.Text = "" Then
|
||||
et_m_dos.Text = 0
|
||||
End If
|
||||
If et_m_peso.Text = "" Then
|
||||
et_m_peso.Text = 0
|
||||
End If
|
||||
If et_m_centavo.Text = "" Then
|
||||
et_m_centavo.Text = 0
|
||||
End If
|
||||
sum_billetes = (et_mil.Text * 1000) + (et_quinientos.Text * 500) + (et_docientos.Text * 200) + ( et_cien.Text * 100 ) + ( et_cincuenta.Text * 50 ) + ( et_veinte.Text * 20 )
|
||||
sum_monedas = (et_m_veinte.Text * 20) + ( et_m_diez.Text * 10 ) + ( et_m_cinco.Text * 5 ) + ( et_m_dos.Text * 2 ) + ( et_m_peso.Text * 1 ) + ( et_m_centavo.Text * 0.50 )
|
||||
total = sum_billetes + sum_monedas
|
||||
l_total.Text = Round2(total, 2)
|
||||
End Sub
|
||||
290
B4A/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
|
||||
|
||||
|
||||
|
||||
272
B4A/DBRequestManager.bas
Normal file
@@ -0,0 +1,272 @@
|
||||
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
|
||||
|
||||
|
||||
1158
B4A/EscPosPrinter.bas
Normal file
BIN
B4A/Files/2023.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
B4A/Files/alert2.png
Normal file
|
After Width: | Height: | Size: 632 B |
BIN
B4A/Files/alerta.jpg
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
B4A/Files/atras.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
B4A/Files/atras1.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
B4A/Files/buscar.bal
Normal file
BIN
B4A/Files/check.bal
Normal file
BIN
B4A/Files/checklist.bal
Normal file
BIN
B4A/Files/cliente.bal
Normal file
BIN
B4A/Files/clientes.bal
Normal file
BIN
B4A/Files/dbc.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
B4A/Files/derecha.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
B4A/Files/derecha1.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
B4A/Files/detalle_promo.bal
Normal file
BIN
B4A/Files/detalleventa.bal
Normal file
BIN
B4A/Files/durakelo1.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
B4A/Files/engrane.jpg
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
B4A/Files/fondo_kmt.jpg
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
B4A/Files/foto.bal
Normal file
BIN
B4A/Files/frintal.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
B4A/Files/frontal1.gif
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
B4A/Files/frontal1.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
B4A/Files/guardagestion.bal
Normal file
BIN
B4A/Files/guna_viejo.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
B4A/Files/guna_viejo2.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
B4A/Files/historico.bal
Normal file
BIN
B4A/Files/infonavit1.jpg
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
B4A/Files/intmex_logo_192x192.jpg
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
B4A/Files/intmex_logo_192x192.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
B4A/Files/itembuttonblue.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
B4A/Files/izquierda.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
B4A/Files/izquierda1.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
B4A/Files/kelloggs.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
B4A/Files/keymon_logo.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
B4A/Files/kmt.db
Normal file
BIN
B4A/Files/kmt2.db
Normal file
BIN
B4A/Files/kmt3.db
Normal file
BIN
B4A/Files/login.bal
Normal file
BIN
B4A/Files/logo sanfer.jpg
Normal file
|
After Width: | Height: | Size: 7.8 KiB |
BIN
B4A/Files/logo_exitus1.jpg
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
B4A/Files/logo_mariana.jpg
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
BIN
B4A/Files/mainpage.bal
Normal file
BIN
B4A/Files/malo.jpg
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
B4A/Files/mapa.bal
Normal file
BIN
B4A/Files/mapa_cliente.bal
Normal file
BIN
B4A/Files/mapa_rutas.bal
Normal file
BIN
B4A/Files/mariana.jpg
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
B4A/Files/mariana_logo_192x192.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
B4A/Files/marker-azul.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
B4A/Files/marker-azul1.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
B4A/Files/marker-azul2.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
B4A/Files/marker-azul3.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
B4A/Files/marker-azul4.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
B4A/Files/marker-azul5.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
B4A/Files/marker-rojo.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
B4A/Files/marker-rojo1.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
B4A/Files/marker-rojo2.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
B4A/Files/marker-verde.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
B4A/Files/no_venta.bal
Normal file
BIN
B4A/Files/nuevocliente.bal
Normal file
BIN
B4A/Files/panel_pick_ciego.bal
Normal file
BIN
B4A/Files/pedido.bal
Normal file
BIN
B4A/Files/planfia_logo.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
B4A/Files/planfia_logo_old.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
B4A/Files/planfia_logo_old2.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
B4A/Files/principal.bal
Normal file
BIN
B4A/Files/proditem.bal
Normal file
BIN
B4A/Files/proditem2.bal
Normal file
BIN
B4A/Files/productos.bal
Normal file
BIN
B4A/Files/profina.jpg
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
B4A/Files/profina.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
B4A/Files/sync.png
Normal file
|
After Width: | Height: | Size: 763 B |
BIN
B4A/Files/tabulador.bal
Normal file
BIN
B4A/Files/telefonos.bal
Normal file
115
B4A/MAPA_CLIENTE.bas
Normal file
@@ -0,0 +1,115 @@
|
||||
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
|
||||
Private b_regresar As Button
|
||||
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
|
||||
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))
|
||||
Dim marcador1 As Marker = gmap.AddMarker (latmarker,longmarker, "TIENDA")
|
||||
marcador1.Snippet = B4XPages.MainPage.cliente.NOMBRE
|
||||
'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
|
||||
Subs.centraBoton(b_regresar, Activity.Width)
|
||||
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 = B4XPages.MainPage.cliente.LATITUD
|
||||
longmarker = B4XPages.MainPage.cliente.LONGITUD
|
||||
NOMBRE_TIENDA = B4XPages.MainPage.cliente.NOMBRE
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
GPS.Stop
|
||||
End Sub
|
||||
|
||||
Sub reg_Click
|
||||
' StartActivity(fila)
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
Private Sub b_regresar_Click
|
||||
Log("Pressed")
|
||||
Activity.Finish
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||