Files
Kelloggs_v4/B4A/C_NoVenta.bas
Jose Alberto Guerra Ugalde af1f4b9ead VERSION 5.12.18
- Se agrego auditoria en los "principales" eventos, se guardan en la tabla "auditoria"
2025-12-22 11:47:23 -06:00

130 lines
3.9 KiB
QBasic

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
Dim g As GPS
Dim ruta As String
' Dim skmt As SQL
Dim c As Cursor
Dim t3 As Timer
'// Globals
Dim CANCELA As Button
Dim GUARDA As Button
Dim r_1 As RadioButton
Dim r_2 As RadioButton
Dim r_3 As RadioButton
Dim e_comm As EditText
Dim motivo As String
Dim cuenta As String
Dim usuario As String
Dim sDate,sTime As String
Dim lat_gps, lon_gps As String
Dim CUANTOS As String
Dim r_4 As RadioButton
Private ImageView1 As ImageView
Private ImageView2 As ImageView
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("noventa")
ruta = File.DirInternal
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub B4XPage_Appear
B4XPages.MainPage.aud.guarda("Entrada a No Venta")
e_comm.Text=""
lat_gps = 0
lon_gps = 0
res_gps
End Sub
Private Sub B4XPage_CloseRequest As ResumableSub
' BACK key pressed
Subs.iniciaActividad("Cliente")
' B4XPages.ShowPage("Principal")
Return True
End Sub
Sub res_gps
GUARDA.Visible = False
t3.Initialize("T3", 5000) ' 1000 = 1 second
t3.Enabled = True
Wait For t3_tick
GUARDA.Visible = True
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
Subs.iniciaActividad("Cliente")
End Sub
Sub GUARDA_Click
If r_1.Checked Then
motivo = "CERRADO"
Else If r_2.Checked Then
motivo = "NO COMPRA"
Else If r_3.Checked Then
motivo = "CON PRODUCTO"
Else
motivo = "NO ESTA EL ENCARGADO"
End If
B4XPages.MainPage.aud.guarda($"Guarda No Venta: ${motivo}"$)
usuario = Subs.traeUsuarioDeBD
If B4XPages.MainPage.cliente.IsInitialized Then
B4XPages.MainPage.cliente.motivoNoVenta = motivo
Subs.bitacora(Subs.fechanormal(DateTime.Now), usuario, Subs.traeAlmacen, Subs.traeRuta, "No Venta", Subs.traeCliente, "", Subs.fechanormal(DateTime.Now), Starter.lat_gps, Starter.lon_gps, B4XPages.MainPage.cliente.precision, motivo, e_comm.text)
Starter.enVenta = False
End If
DateTime.DateFormat = "MM/dd/yyyy"
sDate=DateTime.Date(DateTime.Now)
sTime=DateTime.Time(DateTime.Now)
c=Starter.skmt.ExecQuery("select CUENTA from cuentaa")
c.Position = 0
cuenta = c.GetString("CUENTA")
c=Starter.skmt.ExecQuery("select PE_PROID,PE_CANT FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) ")
If c.RowCount>0 Then
For i=0 To c.RowCount -1
c.Position=i
Starter.skmt.ExecNonQuery2("update cat_gunaprod2 set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?", Array As Object(c.GetString("PE_CANT"),c.GetString("PE_PROID")))
Next
End If
If lat_gps = 0 Then
c=Starter.skmt.ExecQuery("select count(*) as CUANTOS from HIST_GPS")
c.Position =0
CUANTOS = c.GetString("CUANTOS")
c.Close
If CUANTOS > 0 Then
c=Starter.skmt.ExecQuery("SELECT HGLAT as HGLAT, HGLON as HGLON FROM HIST_GPS")
c.Position=0
lon_gps = c.GetString("HGLON")
lat_gps = c.GetString("HGLAT")
c.Close
End If
End If
Starter.skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
Starter.skmt.ExecNonQuery("delete from pedido where pe_cliente in (Select CUENTA from cuentaa)")
Starter.skmt.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, motivo,e_comm.text,Starter.lat_gps,Starter.lon_gps))
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 3 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
Subs.iniciaActividad("Principal")
' B4XPages.ShowPage("Principal")
End Sub