mirror of
https://github.com/KeymonSoft/Durakelo.git
synced 2026-04-17 19:36:12 +00:00
1251 lines
50 KiB
QBasic
1251 lines
50 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 kh as kms_helperSubs
|
|
Dim ruta As String
|
|
Dim q_buscar As String
|
|
Dim forzarBusqueda As Boolean = False
|
|
Dim skmt As SQL
|
|
Dim c As Cursor
|
|
Dim c2 As Cursor
|
|
Dim C3 As Cursor
|
|
Dim s As Cursor
|
|
Dim lv_catalogos As ListView
|
|
Dim lv_promos As ListView
|
|
Dim entro As String
|
|
Dim gest As Button
|
|
Dim lfila As Label
|
|
Dim marca As String
|
|
Dim tipo As String
|
|
Dim subtipo As String
|
|
Private BUSCA As EditText
|
|
Dim ya_entro As String
|
|
Dim TIENE_PROMOS As String
|
|
Dim RES As String
|
|
Dim S1 As Cursor
|
|
Dim bmp As Bitmap
|
|
Dim ciclo As String
|
|
Private b_qr As Button
|
|
Private p_productos As Panel
|
|
Dim clv_productos As CustomListView
|
|
Private ImageView1 As ImageView
|
|
Private Panel3 As Panel
|
|
Private p_prods As Panel
|
|
Private i_prod As ImageView
|
|
Private l_prodX As Label
|
|
Private b_prodMas As Button
|
|
Private l_pCant As Label
|
|
Private et_pCant As EditText
|
|
Private b_prodMenos As Button
|
|
Dim b_terminar1 As Button
|
|
Dim b_continuar As Button
|
|
' Private l_total As Label
|
|
' Private l_totProds As Label
|
|
Dim totalProds As Int = 0
|
|
Dim totalCompra As Float = 0
|
|
Dim etCantHasFocus As Boolean = False
|
|
Dim prodsMap As Map
|
|
Private l_Cargando As Label
|
|
Private l_info As Label
|
|
Private b_buscar As Button
|
|
Private p_botonesVenta As Panel
|
|
Private lv_tipo As ListView
|
|
Private lv_subtipo As ListView
|
|
Private p_vistaPreviaTrans As Panel
|
|
Private lv_prodsPedido As ListView
|
|
Private b_rechazar As Button
|
|
Private b_aceptar As Button
|
|
Private p_vistaPrevia As Panel
|
|
Dim folio As String
|
|
Dim result As String
|
|
Private l_cant As Label
|
|
Private l_total2 As Label
|
|
Dim prodsPedidoActual As String
|
|
Dim montoPedidoActual As String
|
|
Private clv_prods_ll As CustomListView
|
|
Dim PCLV As PreoptimizedCLV
|
|
Dim listaProds As List
|
|
' Type AirportData (Name As String, AirportID As Int, IATA As String, ICAO As String, City As String, Latitude As Float, Longitude As Float, Altitude As String)
|
|
Dim pedidoMap As Map
|
|
Private p_botMasMen As Panel
|
|
Dim reiniciarlistaProds As Boolean= False
|
|
' Dim listaRenglones As List
|
|
Dim listaTiempos As List
|
|
Dim clienteId As String
|
|
Dim rutaUsuario As String
|
|
Dim hayPedido As Boolean
|
|
Dim listaHints As List
|
|
Dim query, query2 As String
|
|
Private p_rmi As Panel
|
|
Private b_rmi_aceptar As Button
|
|
Private l_montoDisponible As Label
|
|
Private b_rmi_menos As Button
|
|
Private l_rmi_cant As Label
|
|
Private b_rmi_mas As Button
|
|
Private l_rmi_nombre As Label
|
|
Private l_rmi_total As Label
|
|
Dim rmiMap As Map
|
|
Private l_rmi_usado As Label
|
|
Dim list_prodsPedido As List
|
|
Private b_rmi As Button
|
|
Private l_mDisponible 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
|
|
' Activity.RemoveAllViews
|
|
Root.LoadLayout("productos")
|
|
ruta = File.DirInternal
|
|
kh.Initialize(Me, "kh")
|
|
If File.Exists(ruta, "kmt.db") = False Then
|
|
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
|
End If
|
|
PCLV.Initialize(Me, "PCLV", clv_prods_ll)
|
|
ciclo = 1
|
|
l_info.Width = Root.Width * 0.8
|
|
l_info.Left = (Root.Width/2) - (l_info.Width/2)
|
|
c = Starter.skmt.ExecQuery("select distinct CAT_GP_TIPO from cat_gunaprod2 where CAT_GP_TIPO <> 'PROMOS' order by CAT_GP_TIPO")
|
|
If c.RowCount > 0 Then
|
|
Dim label1 As Label
|
|
label1 = lv_tipo.SingleLineLayout.Label
|
|
label1.TextSize = 17
|
|
label1.TextColor = Colors.Black
|
|
lv_tipo.Clear
|
|
For i=0 To c.RowCount-1
|
|
c.Position=i
|
|
lv_tipo.AddSingleLine(c.GetString("CAT_GP_TIPO"))
|
|
Next
|
|
End If
|
|
c.Close
|
|
' llenaCatalogo(False)
|
|
' listaRenglones.Initialize
|
|
listaTiempos.Initialize
|
|
listaProds.Initialize
|
|
pedidoMap.Initialize
|
|
listaHints.Initialize
|
|
Log("Llamamos LlenaProdsLL")
|
|
LlenaProdsLL(Null, Null)
|
|
list_prodsPedido.Initialize
|
|
Log("list_prodsPedido.Initialize")
|
|
prodsMap.Initialize
|
|
End Sub
|
|
|
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
|
|
|
Sub B4XPage_Appear
|
|
' clv_prods_ll.Initialize(Me, "clv_prods_ll")
|
|
' list_prodsPedido.Initialize
|
|
' Log("list_prodsPedido.Initialize")
|
|
clienteId = kh.traeCliente(Starter.skmt)
|
|
rutaUsuario = kh.traeRuta(Starter.skmt)
|
|
If p_rmi.Visible Then p_rmi.Visible = False
|
|
' l_mDisponible.Visible = False
|
|
' Starter.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("PRIORITARIO","1"))
|
|
' Starter.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("ESTRATEGICO","2"))
|
|
' Starter.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("COMPLEMENTARIO","3"))
|
|
' Starter.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("CATALOGO REGULAR","0"))
|
|
' Starter.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_CLASIF = (?) ",Array As Object("PROMOS","PROMOS"))
|
|
If Starter.tipov = "PREVENTA" Then
|
|
query = "cat_gunaprod"
|
|
query2 = "COUNT_GUNAPROD"
|
|
Else IF Starter.tipov = "VENTA" Then
|
|
query = "cat_gunaprod2"
|
|
query2= " COUNT_GUNAPROD2"
|
|
ELSE IF Starter.tipov = "ABORDO" Then
|
|
query = "cat_gunaprod"
|
|
query2 = "COUNT_GUNAPROD"
|
|
Else
|
|
query = "cat_gunaprod"
|
|
query2 = "COUNT_GUNAPROD"
|
|
End If
|
|
clv_prods_ll.GetBase.SetLayoutAnimated(0, 5dip, 130dip, Root.Width + 10, Root.Height * 0.68) 'Cambiamos el tamaño y posición de la lista de productos
|
|
clv_prods_ll.Base_Resize(clv_prods_ll.GetBase.Width, clv_prods_ll.GetBase.Height) 'Cambiamos el tamaño del panel interno de la lista para que ajuste al nuevo tamaño.
|
|
If B4XPages.MainPage.bTerminarClicked Then
|
|
lv_catalogos.Visible = True
|
|
lv_promos.Visible = False
|
|
lv_tipo.Visible = False
|
|
lv_subtipo.Visible = False
|
|
clv_prods_ll.AsView.Visible = False
|
|
B4XPages.MainPage.bTerminarClicked = False
|
|
End If
|
|
If ya_entro <> "1" Then
|
|
If BUSCA.Text <> "" Then BUSCA.Text =""
|
|
entro ="3"
|
|
lv_catalogos.Clear
|
|
Sleep(100)
|
|
lfila.Text = "CATALOGOS"
|
|
p_productos.Height = Root.Height
|
|
clv_prods_ll.AsView.Visible = False
|
|
lv_catalogos.BringToFront
|
|
lv_catalogos.Visible = True
|
|
p_botonesVenta.Visible = False
|
|
p_botonesVenta.Top = clv_prods_ll.AsView.top + clv_prods_ll.AsView.Height - 10
|
|
lv_promos.Visible = False
|
|
End If
|
|
Dim label1 As Label
|
|
label1 = lv_catalogos.SingleLineLayout.Label
|
|
label1.TextSize = 17
|
|
label1.TextColor = Colors.Black
|
|
lv_catalogos.Clear
|
|
lv_catalogos.AddSingleLine("CATALOGO")
|
|
' Log(Starter.tipov)
|
|
c = Starter.skmt.ExecQuery("select count(*) as hayPromos from promos_comp")
|
|
c.Position = 0
|
|
' Log(Subs.revisaImpresa)
|
|
If c.GetInt("hayPromos") > 0 And clienteId <> 0 And kh.revisaImpresa(Starter.skmt) = False Then
|
|
lv_catalogos.AddSingleLine("PROMOS")
|
|
End If
|
|
Sleep(100)
|
|
' l_total.Visible = False
|
|
' l_totProds.Visible = False
|
|
' l_total.Left = 5dip
|
|
' l_totProds.Width = Root.Width * 0.19
|
|
' l_total.Left = l_totProds.Width + 20
|
|
' l_total.Width = Root.Width * 0.25
|
|
|
|
' Log(Subs.traeTotalesClienteActual)
|
|
Dim m As Map = subs.traeTotalesClienteActual
|
|
prodsPedidoActual = m.Get("productos")
|
|
montoPedidoActual = m.Get("monto")
|
|
hayPedido = kh.hayPedido(Starter.skmt)
|
|
' LogColor("Pedido ant? - "&hayPedido, Colors.Magenta)
|
|
If reiniciarlistaProds Then
|
|
' Log("Llamamos LlenaProdsLL")
|
|
LlenaProdsLL(Null, Null)
|
|
else If hayPedido Then
|
|
' LogColor("HAY PEDIDO ANTERIOR", Colors.red)
|
|
' Log("Llamamos LlenaProdsLL")
|
|
LlenaProdsLL(Null, Null)
|
|
End If
|
|
|
|
If clv_prods_ll.Size > 0 Then
|
|
clv_prods_ll.JumpToItem(0) 'Vamos al primer artículo de la lista.
|
|
PCLV.lblHint.SetTextSizeAnimated(0,13)
|
|
PCLV.B4XSeekBar1.Color1=Colors.DarkGray
|
|
PCLV.B4XSeekBar1.Color2=Colors.DarkGray
|
|
PCLV.B4XSeekBar1.ThumbColor=Colors.red
|
|
PCLV.B4XSeekBar1.mBase.Left=Root.Width *0.91
|
|
' PCLV.B4XSeekBar1.mBase.Top=-50
|
|
PCLV.B4XSeekBar1.mBase.Height=clv_prods_ll.AsView.Height
|
|
PCLV.pnlOverlay.Height = clv_prods_ll.AsView.Height
|
|
PCLV.B4XSeekBar1.Update
|
|
Else
|
|
PCLV.B4XSeekBar1.mBase.Left=Root.Width *1.5 'Si no hay productos, que NO se vea la barra de busqueda.
|
|
End If
|
|
If lfila.Text = "RMI" Then
|
|
b_rmi.Visible = False
|
|
l_mDisponible.Visible = True
|
|
End If
|
|
' Log(Starter.tipov)
|
|
End Sub
|
|
|
|
Sub PCLV_AddProds
|
|
|
|
End Sub
|
|
|
|
Sub lv_catalogos_ItemClick (Position As Int, Value As Object)
|
|
If Value = "CATALOGO" Then
|
|
' lfila.text = "TIPO"
|
|
lfila.text = "PRODUCTOS"
|
|
lv_catalogos.Visible = False
|
|
If Starter.tipov <> "ABORDO" Then b_rmi.Visible = True
|
|
' lv_tipo.Visible = True
|
|
LlenaProdsLL(Null, Null)
|
|
clv_prods_ll.AsView.BringToFront
|
|
clv_prods_ll.AsView.Visible = True
|
|
If hayPedido Then p_botonesVenta.Visible = True 'Si ya hay pedido, entonces mostramos los botones.
|
|
l_mDisponible.Visible = False
|
|
Else
|
|
clv_prods_ll.AsView.Visible = False
|
|
lv_promos.Visible = True
|
|
lfila.text = "PROMOCIONES"
|
|
lv_catalogos.Visible = False
|
|
lv_promos.Clear
|
|
Dim label1 As Label
|
|
label1 = lv_promos.TwoLinesLayout.Label
|
|
label1.TextSize = 15
|
|
label1.TextColor = Colors.Black
|
|
Dim label2 As Label
|
|
label2 = lv_promos.TwoLinesLayout.SecondLabel
|
|
label2.TextSize = 15
|
|
label2.TextColor = Colors.Black
|
|
Dim label13 As Label
|
|
label13 = lv_promos.TwoLinesAndBitmap.Label
|
|
label13.TextSize = 15
|
|
label13.TextColor = Colors.Black
|
|
Dim label14 As Label
|
|
label14 = lv_promos.TwoLinesAndBitmap.SecondLabel
|
|
label14.TextSize = 15
|
|
label14.TextColor = Colors.Black
|
|
' lfila.text = "PROMOS"
|
|
' c2=Starter.skmt.ExecQuery2("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from " & query & " where CAT_GP_ALMACEN > 0 AND CAT_GP_TIPO = ? AND CAT_GP_SUBTIPO = ? AND CAT_GP_TIPOPROD <> 1 and (length(CAT_GP_CODPROMO) = 1 OR CAT_GP_CODPROMO = CAT_GP_ID)", Array As String(Value, Value))
|
|
c2=Starter.skmt.ExecQuery2("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from " & query & " where CAT_GP_ALMACEN > 0 AND CAT_GP_TIPO = ? AND CAT_GP_SUBTIPO =? AND CAT_GP_TIPOPROD <> 1 and (length(CAT_GP_CODPROMO) = 1 OR CAT_GP_CODPROMO = CAT_GP_ID) ", Array As String( Value, Value))
|
|
' Log($"Resultados : ${c2.RowCount}, ${Value}, ${marca}, ${tipo}"$)
|
|
If c2.RowCount > 0 Then
|
|
For i=0 To c2.RowCount -1
|
|
c2.Position=i
|
|
Private tm As Map = Subs.procesaPromocion(c2.GetString("CAT_GP_ID"), clienteId)
|
|
If tm.Get("status") = "ok" Then 'Solo muestrala si hay producto.
|
|
lv_promos.AddTwoLines(c2.GetString("CAT_GP_NOMBRE"),"# " & c2.GetString("CAT_GP_ALMACEN") & " $ " & c2.GetString("CAT_GP_PRECIO") & " F:" & tm.Get("mp").As(Map).Get("prodsFijosCant") & " V:" & tm.Get("mp").As(Map).Get("prodsVariablesCant"))
|
|
End If
|
|
Next
|
|
Else
|
|
ToastMessageShow("No hay promociones disponibles.", False)
|
|
End If
|
|
c2.Close
|
|
entro = "4"
|
|
End If
|
|
End Sub
|
|
|
|
Sub lv_catalogos2_ItemClick (Position As Int, Value As Object)
|
|
clv_prods_ll.AsView.Visible = False
|
|
BUSCA.Text = ""
|
|
Dim cliente As C_Cliente = B4XPages.GetPage("Cliente")
|
|
Log($"value=${Value}"$)
|
|
If Value = "PROMOS" And cliente.cuenta <> "N" Then
|
|
entro = "3"
|
|
marca = "PROMOS"
|
|
tipo = "PROMOS"
|
|
Else if Value = "PROMOS" And cliente.cuenta = "N" Then
|
|
entro = "5"
|
|
Subs.iniciaActividad("Cliente")
|
|
' B4XPages.ShowPage("Cliente")
|
|
End If
|
|
If Value = "PROMOS" Then
|
|
LogColor("Promos", Colors.red)
|
|
c2=Starter.skmt.ExecQuery2("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from cat_gunaprod2 where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD = ? AND CAT_GP_TIPO = ? AND CAT_GP_SUBTIPO = ? AND CAT_GP_ID NOT IN (SELECT PE_PROID FROM PEDIDO WHERE PE_CLIENTE IN (Select cuenta from cuentaa) )", Array As String(Value, marca, tipo))
|
|
Else
|
|
LogColor("Catalogo", Colors.red)
|
|
c2=Starter.skmt.ExecQuery("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG, CAT_GP_TIPOPROD, CAT_GP_INICIATIVA from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD <> 'PROMOS' ")
|
|
End If
|
|
If Value = "CATALOGO" Then
|
|
lv_catalogos.Visible = False
|
|
lv_promos.Visible = False
|
|
lfila.text = "CATALOGO"
|
|
Log("PGS")
|
|
ProgressDialogShow("Cargando catalogo ...")
|
|
Sleep(100)
|
|
Private inicioContador As String = DateTime.Now
|
|
llenaCatalogo(False)
|
|
clv_prods_ll.AsView.Visible = True
|
|
Log("PGH")
|
|
LogColor("TIEMPO DE PROCESO DEL CATALOGO: " & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
|
ProgressDialogHide
|
|
c2.Close
|
|
Else
|
|
clv_prods_ll.AsView.Visible = False
|
|
lv_promos.Visible = True
|
|
lv_catalogos.Visible = False
|
|
lv_promos.Clear
|
|
Dim label1 As Label
|
|
label1 = lv_promos.TwoLinesLayout.Label
|
|
label1.TextSize = 15
|
|
label1.TextColor = Colors.Black
|
|
Dim label2 As Label
|
|
label2 = lv_promos.TwoLinesLayout.SecondLabel
|
|
label2.TextSize = 15
|
|
label2.TextColor = Colors.Black
|
|
Dim label13 As Label
|
|
label13 = lv_promos.TwoLinesAndBitmap.Label
|
|
label13.TextSize = 15
|
|
label13.TextColor = Colors.Black
|
|
Dim label14 As Label
|
|
label14 = lv_promos.TwoLinesAndBitmap.SecondLabel
|
|
label14.TextSize = 15
|
|
label14.TextColor = Colors.Black
|
|
lfila.text = "PROMOS"
|
|
If c2.RowCount > 0 Then
|
|
For i=0 To c2.RowCount -1
|
|
c2.Position=i
|
|
Private tm As Map = Subs.procesaPromocion(c2.GetString("CAT_GP_ID"), clienteId)
|
|
If tm.Get("status") = "ok" Then 'Solo muestrala si hay producto.
|
|
lv_promos.AddTwoLines(c2.GetString("CAT_GP_NOMBRE"),"# " & c2.GetString("CAT_GP_ALMACEN") & " $ " & c2.GetString("CAT_GP_PRECIO") & " F:" & tm.Get("mp").As(Map).Get("prodsFijosCant") & " V:" & tm.Get("mp").As(Map).Get("prodsVariablesCant"))
|
|
End If
|
|
Next
|
|
End If
|
|
c2.Close
|
|
End If
|
|
entro = "4"
|
|
End Sub
|
|
|
|
Sub lv_promos_ItemClick (Position As Int, Value As Object)
|
|
clv_prods_ll.AsView.Visible = False
|
|
Dim cliente As C_Cliente = B4XPages.GetPage("Cliente")
|
|
' Log($"Entro=${entro}, value=${Value}, cuenta=${cliente.cuenta}"$)
|
|
If Value = "PROMOS" And cliente.cuenta <> "N" Then
|
|
entro = "3"
|
|
marca = "PROMOS"
|
|
tipo = "PROMOS"
|
|
Else if Value = "PROMOS" And cliente.cuenta = "N" Then
|
|
entro = "5"
|
|
Subs.iniciaActividad("Cliente")
|
|
' B4XPages.ShowPage("Cliente")
|
|
End If
|
|
If entro = "3" Then
|
|
'xxxxxxxxxxxxxxxxxxxxx
|
|
Else If entro = "4" Then
|
|
' Log("Entro = 4")
|
|
Starter.skmt.ExecNonQuery("delete from PROID")
|
|
Starter.skmt.ExecNonQuery2("INSERT INTO PROID VALUES (?)", Array As Object(Value))
|
|
Dim promos As C_Promos = B4XPages.GetPage("Promos")
|
|
promos.laPromo = Subs.traeProdIdDeBD.Get("id")
|
|
promos.elCliente = Subs.traeUsuarioDeBD
|
|
B4XPages.ShowPage("Promos")
|
|
End If
|
|
End Sub
|
|
|
|
'Generamos la lista de productos.
|
|
Sub llenaCatalogo(subtipo1 As String)
|
|
' Log("LlenaCatalogo")
|
|
' Private c2 As Cursor
|
|
' c2=Starter.skmt.ExecQuery2("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG, CAT_GP_TIPOPROD, CAT_GP_INICIATIVA from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD <> 'PROMOS' and CAT_GP_SUBTIPO = ? ", Array As String(subtipo1))
|
|
' Private bgColor, textColor As Int
|
|
' If c2.RowCount > 0 And clv_productos.Size <> c2.RowCount Then
|
|
' clv_productos.Clear : Log("limpiamos productos")
|
|
' For i=0 To c2.RowCount -1
|
|
' c2.Position=i
|
|
' If c2.GetString("CAT_GP_TIPOPROD") = "PRIORITARIO" Then
|
|
' bgColor = Colors.RGB(255, 212, 163) 'naranja
|
|
' Else If c2.GetString("CAT_GP_TIPOPROD") = "COMPLEMENTARIO" Then
|
|
' bgColor = Colors.RGB(177, 200, 249)'azul
|
|
' else If c2.GetString("CAT_GP_TIPOPROD") = "CATALOGO REGULAR" Then
|
|
' bgColor = Colors.White
|
|
' else If c2.GetString("CAT_GP_TIPOPROD") = "ESTRATEGICO" Then
|
|
' bgColor = Colors.RGB(241, 255, 163) 'amarillo
|
|
' End If
|
|
' textColor = Colors.Black
|
|
' clv_productos.Add(CreateListItem(c2.GetString("CAT_GP_NOMBRE"), c2.GetString("CAT_GP_PRECIO"), c2.GetString("CAT_GP_ALMACEN"), clv_productos.AsView.Width, 60dip, bmp, c2.GetString("CAT_GP_ID"), bgColor, textColor), c2.GetString("CAT_GP_NOMBRE"))
|
|
' Next
|
|
' End If
|
|
' c2.Close
|
|
End Sub
|
|
|
|
Private Sub B4XPage_CloseRequest As ResumableSub
|
|
' BACK key pressed
|
|
' Return True To close, False To cancel
|
|
If p_rmi.Visible Then p_rmi.Visible = False
|
|
If l_info.Visible Then
|
|
l_info.Visible = False
|
|
Return False
|
|
else if p_vistaPreviaTrans.Visible Then
|
|
p_vistaPreviaTrans.Visible = False
|
|
Return False
|
|
else if lv_promos.visible Then
|
|
lv_promos.Visible = False
|
|
lv_catalogos.Visible = True
|
|
p_botonesVenta.Visible = False
|
|
' l_total.Visible = False
|
|
' l_totProds.Visible = False
|
|
Return False
|
|
else if clv_prods_ll.AsView.Visible Then
|
|
lfila.text = "CATALOGO"
|
|
clv_prods_ll.AsView.Visible = False
|
|
lv_subtipo.Visible = False
|
|
p_botonesVenta.Visible = False
|
|
' l_total.Visible = False
|
|
' l_totProds.Visible = False
|
|
lv_catalogos.Visible = True
|
|
Return False
|
|
else If entro = "4" Then
|
|
entro = "3"
|
|
B4XPage_Appear
|
|
Return True
|
|
Else If entro = "3" Then
|
|
Subs.iniciaActividad("Cliente")
|
|
' B4XPages.ShowPage("Cliente")
|
|
Return False
|
|
Else
|
|
Subs.iniciaActividad("Cliente")
|
|
' B4XPages.ShowPage("Cliente")
|
|
Return False
|
|
End If
|
|
End Sub
|
|
|
|
Sub b_QR_Click
|
|
If ciclo = 1 Then
|
|
ciclo = 2
|
|
ya_entro = "0"
|
|
B4XPage_Appear
|
|
else if ciclo = 2 Then
|
|
ciclo = 3
|
|
ya_entro = "0"
|
|
B4XPage_Appear
|
|
else if ciclo = 3 Then
|
|
ciclo = 4
|
|
ya_entro = "0"
|
|
B4XPage_Appear
|
|
else if ciclo = 4 Then
|
|
ciclo = 5
|
|
ya_entro = "0"
|
|
B4XPage_Appear
|
|
else if ciclo = 5 Then
|
|
ciclo = 1
|
|
ya_entro = "0"
|
|
B4XPage_Appear
|
|
End If
|
|
End Sub
|
|
|
|
'****************************************************************************
|
|
'***************** PARA EL MAS/MENOS *************************************
|
|
'****************************************************************************
|
|
Sub CreateListItem(Text As String, precioU As String, inv As Int, Width As Int, Height As Int, img As Bitmap, prodId As String, bc As Int, tc As Int) As Panel
|
|
' Dim p As B4XView = xui.CreatePanel("")
|
|
' p.SetLayoutAnimated(0, 0, 0, Width, Height)
|
|
' p.LoadLayout("prodItem")
|
|
' p_prods.Color = bc
|
|
' l_prodX.TextColor = tc
|
|
' l_prodX.TextSize = 15
|
|
' p_prods.Height = Height
|
|
' l_prodX.Height = Height
|
|
' l_prodX.Text = Text&CRLF&"# " & inv & " $ " & precioU
|
|
' l_prodX.Tag = $"ID: ${prodId}${CRLF}${Text}${CRLF}Precio: $$1.2{precioU}${CRLF}Inv: ${inv} pzs"$
|
|
' l_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
|
' et_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
|
' et_pCant.BringToFront
|
|
' Return p
|
|
End Sub
|
|
|
|
Sub b_prodMenos_Click
|
|
etCantHasFocus = False
|
|
' Log(Sender.As(Button).text & "|" & Sender.As(Button).tag)
|
|
Private buttonTag As String = Sender.As(Button).tag
|
|
LogColor("b_prodMenos_Click", Colors.Magenta)
|
|
Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
|
Private inv As Int = clv_prods_ll.GetValue(index).As(Map).Get("almacen")
|
|
Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index)
|
|
Dim pnl As B4XView = pnl0.GetView(0)
|
|
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
|
' Log($"precio|stock:${laCant.tag}"$)
|
|
' Log("lacant.text="&laCant.text & "|" & buttonTag)
|
|
If buttonTag = "vendido" And laCant.Text > 0 Then
|
|
Log(clv_prods_ll.GetValue(index).As(Map))
|
|
clv_prods_ll.GetValue(index).As(Map).Put("almacen",inv + 1)
|
|
Log(clv_prods_ll.GetValue(index).As(Map))
|
|
' clv_prods_ll.GetValue(index).As(Map).Get("almacen") = clv_prods_ll.GetValue(index).As(Map).Get("almacen") + 1
|
|
End If
|
|
If laCant.Text = "" Then laCant.Text = 0
|
|
laCant.Text = $"$1.0{laCant.Text - 1}"$
|
|
If laCant.Text < 0 Then laCant.Text = 0
|
|
Private tmpMap As Map = clv_prods_ll.GetValue(index).As(Map)
|
|
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio")
|
|
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id")
|
|
Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":Subs.traeAlmacen)
|
|
' Log(tmpMap)
|
|
prodsMap.Put(id, tmpMap)
|
|
If laCant.Text = 0 Then prodsMap.Remove(id)
|
|
' LogColor("prodsMap="&prodsMap, Colors.blue)
|
|
' (Subs.traeAlmacen, p1.Get("precio"), p1.Get("cant"), pn, p, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, B4XPages.MainPage.tipo_venta)
|
|
Private almacenX As String = Subs.traeAlmacen
|
|
Private nombreX As String = Subs.traeProdNombre(id)
|
|
Private precioX As String = precio
|
|
If lfila.Text = "RMI" Then
|
|
almacenX = "DUR"
|
|
nombreX = "CAMBIO"&Subs.traeRMINombre(id)
|
|
precioX = precioX * -1
|
|
End If
|
|
Subs.actualizaProducto(almacenX, precioX, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov)
|
|
cuentaProds
|
|
If Subs.totalPedido < 1 Then laCant.Text = "0"
|
|
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
|
End Sub
|
|
|
|
Sub b_prodMas_Click
|
|
etCantHasFocus = False
|
|
Private buttonTag As String = Sender.As(Button).tag
|
|
Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
|
LogColor("b_prodMas_Click", Colors.Magenta)
|
|
Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index)
|
|
Dim pnl As B4XView = pnl0.GetView(0)
|
|
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
|
If laCant.Text = "" Then laCant.Text = 0
|
|
Private tmpMap As Map = clv_prods_ll.GetValue(index).As(Map)
|
|
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio")
|
|
Private inv As Int = clv_prods_ll.GetValue(index).As(Map).Get("almacen")
|
|
If buttonTag = "vendido" Then
|
|
If inv > 0 And (laCant.Text + 1 <= inv) And (Subs.totalPedido - precio > 1) Then
|
|
' Log(clv_prods_ll.GetValue(index).As(Map))
|
|
clv_prods_ll.GetValue(index).As(Map).Put("almacen", (inv - 1))
|
|
inv = inv - 1
|
|
laCant.Text = $"$1.0{laCant.Text+1}"$
|
|
' Log(clv_prods_ll.GetValue(index).As(Map))
|
|
End If
|
|
else If laCant.Text + 1 <= inv And lfila.Text = "PRODUCTOS" Then
|
|
' LogColor(inv, Colors.blue)
|
|
laCant.Text = $"$1.0{laCant.Text + 1}"$
|
|
Log(Subs.totalPedido)
|
|
else If lfila.Text = "RMI" And laCant.Text + 1 <= inv And (Subs.totalPedido - precio > 1) Then
|
|
' LogColor(inv, Colors.blue)
|
|
laCant.Text = $"$1.0{laCant.Text + 1}"$
|
|
Log(Subs.totalPedido)
|
|
else if Subs.totalPedido < 1 Then
|
|
laCant.Text = "0"
|
|
End If
|
|
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id")
|
|
Private almacenX As String = Subs.traeAlmacen
|
|
Private nombreX As String = Subs.traeProdNombre(id)
|
|
Private precioX As String = precio
|
|
If lfila.Text = "RMI" Then
|
|
almacenX = "DUR"
|
|
nombreX = "CAMBIO"&Subs.traeRMINombre(id)
|
|
precioX = precioX * -1
|
|
End If
|
|
Subs.actualizaProducto(almacenX, precioX, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov)
|
|
cuentaProds
|
|
If Subs.totalPedido < 1 Then
|
|
etCantHasFocus = True
|
|
Log("A CERO")
|
|
laCant.Text = "0"
|
|
et_pCant_TextChanged(100, 0)
|
|
End If
|
|
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
|
End Sub
|
|
|
|
Private Sub et_pCant_TextChanged (Old As String, New As String)
|
|
' LogColor($"txt changed: ${Old}|${New}, hasfocus=${etCantHasFocus}"$,Colors.Magenta)
|
|
' If Not(Old = "0" And New = "") And etCantHasFocus Then cuentaProds
|
|
|
|
If etCantHasFocus = True Then
|
|
Try
|
|
' LogColor($"txt changed: ${Old}|${New}, hasfocus=${etCantHasFocus}"$,Colors.Magenta)
|
|
Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
|
Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index)
|
|
Dim pnl As B4XView = pnl0.GetView(0)
|
|
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
|
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id")
|
|
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio")
|
|
Log("++++++++++ " & precio)
|
|
Dim tempTot As String = Subs.totalPedido
|
|
Dim disp As String = 0
|
|
If tempTot > 0 Then disp = (Subs.totalPedido / precio) - 1
|
|
disp = NumberFormat2(disp, 1, 0, 0, False)
|
|
|
|
Log($"${laCant.text}, ${precio}, DISPONIBLES: ${disp}"$)
|
|
Private inv As String=clv_prods_ll.GetValue(index).As(Map).Get("almacen")
|
|
Private inv As String=clv_prods_ll.GetValue(index).As(Map).Get("almacen")
|
|
If(New = "" Or New = Null) Then New = 0
|
|
If(New > inv) Then
|
|
Sender.As(EditText).text = inv
|
|
End If
|
|
Private almacenX As String = Subs.traeAlmacen
|
|
Private nombreX As String = Subs.traeProdNombre(id)
|
|
Private precioX As String = precio
|
|
If lfila.Text = "RMI" Then
|
|
almacenX = "DUR"
|
|
nombreX = "CAMBIO"&Subs.traeRMINombre(id)
|
|
precioX = precioX * -1
|
|
Log("RMI")
|
|
Else
|
|
' elProd = Subs.traeProdNombre(id)
|
|
Log("NO RMI")
|
|
End If
|
|
' Log($"inventario=${inv}"$)
|
|
' Dim tmpCant As String = laCant.text
|
|
If laCant.Text = "" Then laCant.Text = "0"
|
|
If laCant.Text > disp Then
|
|
Log($"Ponemos laCant en: ${disp}"$)
|
|
' laCant.Text = ""
|
|
laCant.text = "0"
|
|
' etCantHasFocus = True
|
|
End If
|
|
If Not(Old = "0" And New = "") And laCant.Text <> Null And laCant.Text <> "" And etCantHasFocus Then
|
|
Subs.actualizaProducto(almacenX, precioX, laCant.Text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, B4XPages.MainPage.tipo_venta)
|
|
cuentaProds
|
|
End If
|
|
Catch
|
|
Log(LastException)
|
|
End Try
|
|
' etCantHasFocus = False
|
|
' laCant.text = ""
|
|
' laCant.text = tmpCant
|
|
' cuentaProds
|
|
' Log(laCant.text)
|
|
' Sender.As(EditText).text = disp
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub et_pCant_FocusChanged (HasFocus As Boolean)
|
|
' LogColor($"focus changed=${HasFocus}"$, Colors.Magenta)
|
|
etCantHasFocus = HasFocus
|
|
cuentaProds
|
|
End Sub
|
|
|
|
Sub cuentaProds
|
|
'LogColor($"Productos de la orden: ${c_prodsX.GetString("cantProds")}, Total: ${c_prodsX.GetString("costoTotal")}"$, Colors.red)
|
|
' Log("===========================")
|
|
Private c As Cursor = Starter.skmt.ExecQuery($"select sum(PE_COSTO_TOT) as total, sum(PE_CANT) as cant from PEDIDO where PE_CLIENTE = '${clienteId}'"$)
|
|
' LogColor("TIEMPO cuentaProds =" & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
|
' LogColor(prodsMap, Colors.Magenta)
|
|
p_botonesVenta.Visible = True
|
|
p_botonesVenta.BringToFront
|
|
c.Position=0
|
|
If Subs.totalPedido > 1 And lfila.Text <> "RMI" And Starter.tipov <> "ABORDO" Then b_rmi.Visible = True Else b_rmi.Visible = False
|
|
Log(Subs.totalPedido)
|
|
If lfila.Text = "RMI" Then l_mDisponible.Visible = True Else l_mDisponible.Visible = False
|
|
l_mDisponible.Text = $"Disponible: $${Subs.totalPedido}"$
|
|
' Log($"Total Prods: ${c.GetString("cant")}, Total Compra: $$1.2{c.GetString("total")}"$)
|
|
c.Close
|
|
End Sub
|
|
|
|
Sub b_terminar1_Click
|
|
' Log("b_terminar1_Click")
|
|
' ya_entro = "0" : Log("ya_entro=1")
|
|
Private totalPedido As String = 0
|
|
Private cantPedido As String = 0
|
|
lv_promos.Visible = False
|
|
clv_prods_ll.AsView.Visible = False
|
|
lv_catalogos.Visible = True
|
|
Subs.agrupador
|
|
lv_prodsPedido.Clear
|
|
list_prodsPedido.Initialize
|
|
Private c_prods As Cursor=Starter.skmt.ExecQuery("select PE_PRONOMBRE,PE_COSTO_TOT, PE_COSTOU, PE_CANT, PE_FOLIO, PE_CEDIS, PE_PROID FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_CEDIS, PE_PRONOMBRE")
|
|
' Log(c_prods.RowCount)
|
|
If c_prods.RowCount > 0 Then
|
|
c_prods.Position = 0
|
|
' l_total2.Text = c_prods.GetString("PE_COSTO_TOT")
|
|
lv_prodsPedido.BringToFront
|
|
Private cs As CSBuilder
|
|
For i = 0 To c_prods.RowCount -1
|
|
cs.Initialize
|
|
c_prods.Position = i
|
|
Dim label1 As Label
|
|
' lv_prodsPedido.TwoLinesLayout.ItemHeight = 50dip
|
|
label1 = lv_prodsPedido.TwoLinesLayout.Label
|
|
label1.TextSize = 14
|
|
label1.TextColor = Colors.Black
|
|
label1.color = Colors.White
|
|
label1.Height = 30dip
|
|
Private textColor As Int = Colors.black
|
|
' Log(c_prods.GetString("PE_CEDIS"))
|
|
If Not(IsNumber(c_prods.GetString("PE_CEDIS"))) Then textColor = Colors.RGB(210,105,30) 'Si es promo, cambiamos el color del texto.
|
|
If c_prods.GetString("PE_CEDIS") = "DUR" Then textColor = Colors.red 'Si es promo, cambiamos el color del texto.
|
|
Dim label2 As Label
|
|
label2 = lv_prodsPedido.TwoLinesLayout.SecondLabel
|
|
label2.TextSize = 10
|
|
label2.TextColor = Colors.Blue
|
|
label2.Tag = i
|
|
' Log(c_prods.GetString("PE_PRONOMBRE"))
|
|
lv_prodsPedido.AddTwoLines(cs.Color(textColor).append(c_prods.GetString("PE_PRONOMBRE")).pop,"Cantidad #"& c_prods.GetString("PE_CANT")& " SubTotal $"& c_prods.GetString("PE_COSTO_TOT")& " Folio "& c_prods.GetString("PE_FOLIO"))
|
|
list_prodsPedido.Add(CreateMap("prodNom":c_prods.GetString("PE_PRONOMBRE"), "cedis":c_prods.GetString("PE_CEDIS"), "prodId": c_prods.GetString("PE_PROID"), "cant": c_prods.GetString("PE_CANT")))
|
|
folio = 0
|
|
totalPedido = totalPedido + (c_prods.GetString("PE_COSTOU") * c_prods.GetString("PE_CANT"))
|
|
' Log("|" & Subs.esPromo(c_prods.GetString("PE_PROID")) & "|")
|
|
If Not(Subs.esPromo(c_prods.GetString("PE_PROID"))) Then cantPedido = cantPedido + c_prods.GetString("PE_CANT")
|
|
If c_prods.GetString("PE_FOLIO") <> Null Then folio = c_prods.GetString("PE_FOLIO")
|
|
Next
|
|
c=Starter.skmt.ExecQuery("select pc_noart, pc_monto from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
|
C.Position=0
|
|
' l_cant.Text = c.GetString("PC_NOART")
|
|
c.Close
|
|
End If
|
|
' Log(list_prodsPedido)
|
|
c_prods.Close
|
|
l_total2.Text = $"$1.2{totalPedido}"$
|
|
l_cant.Text = cantPedido
|
|
If Subs.revisaImpresa Then b_rechazar.Visible = False Else b_rechazar.Visible = True
|
|
p_vistaPreviaTrans.Width = Root.Width
|
|
p_vistaPreviaTrans.Height = Root.Height
|
|
Subs.centraPanel(p_vistaPrevia, Root.Width)
|
|
p_vistaPrevia.Visible=True
|
|
p_vistaPreviaTrans.Visible=True
|
|
End Sub
|
|
|
|
Private Sub b_continuar_Click
|
|
' Log("b_continuar_Click")
|
|
cuentaProds
|
|
' Private p1 As Map
|
|
' Log("prodsMap="&prodsMap)
|
|
' For Each p As String In prodsMap.Keys
|
|
' p1 = prodsMap.Get(p)
|
|
' Log(p & "|" & p1)
|
|
' Private pn As String = Subs.traeProdNombre(p)
|
|
' If pn <> "N/A" Then
|
|
' LogColor("INSERTAMOS PROD Continuar", Colors.red)
|
|
' Subs.guardaProductoSinGestion(Subs.traeAlmacen, p1.Get("precio"), p1.Get("cant"), pn, p, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov)
|
|
' End If
|
|
' Next
|
|
' Log("promos-inv, prods-inv, cat-vis")
|
|
lv_promos.Visible = False
|
|
clv_prods_ll.AsView.Visible = False
|
|
lv_subtipo.Visible = False
|
|
lv_tipo.Visible = False
|
|
lv_catalogos.Visible = True
|
|
Log("Continuar")
|
|
Dim m As Map = Subs.traeTotalesClienteActual
|
|
prodsPedidoActual = m.Get("productos")
|
|
montoPedidoActual = m.Get("monto")
|
|
' LlenaProdsLL(Null)
|
|
' BUSCA.Text = " "
|
|
End Sub
|
|
|
|
Private Sub l_info_Click
|
|
l_info.Visible = False
|
|
End Sub
|
|
|
|
Private Sub lv_promos_ItemLongClick (Position As Int, Value As Object)
|
|
Log("Promo longclic = "&Value)
|
|
Private id As String = ""
|
|
Dim c As Cursor = Starter.skmt.ExecQuery($"select CAT_GP_ID from cat_gunaprod where CAT_GP_TIPO = 'PROMOS' and CAT_GP_NOMBRE = '${Value}'"$)
|
|
If c.RowCount > 0 Then
|
|
c.Position = 0
|
|
id = c.GetString("CAT_GP_ID")
|
|
End If
|
|
l_info.Text = $"ID: ${id}${CRLF}${Value}"$
|
|
l_info.Visible = True
|
|
End Sub
|
|
|
|
Private Sub b_buscar_Click
|
|
forzarBusqueda = True
|
|
Busca_TextChanged("",BUSCA.Text)
|
|
End Sub
|
|
|
|
Private Sub lv_tipo_ItemClick (Position As Int, Value As Object)
|
|
' lfila.text = "SUB TIPO"
|
|
' lv_tipo.Visible = False
|
|
' lv_subtipo.Height = Root.Height * 0.7
|
|
' lv_subtipo.Visible = True
|
|
' Private c As Cursor = Starter.skmt.ExecQuery2("select distinct CAT_GP_SUBTIPO from cat_gunaprod where CAT_GP_TIPO = ? order by CAT_GP_SUBTIPO", Array As String(Value))
|
|
' If c.RowCount > 0 Then
|
|
' Dim label1 As Label
|
|
' label1 = lv_subtipo.SingleLineLayout.Label
|
|
' label1.TextSize = 17
|
|
' label1.TextColor = Colors.Black
|
|
' lv_subtipo.Clear
|
|
' For i=0 To c.RowCount-1
|
|
' c.Position=i
|
|
' lv_subtipo.AddSingleLine(c.GetString("CAT_GP_SUBTIPO"))
|
|
' Next
|
|
' End If
|
|
' c.Close
|
|
End Sub
|
|
|
|
Private Sub lv_subtipo_ItemClick (Position As Int, Value As Object)
|
|
' lfila.text = "SUB TIPO"
|
|
' LogColor("Catalogo", Colors.red)
|
|
' lv_catalogos.Visible = False
|
|
' lv_subtipo.Visible = False
|
|
' lv_promos.Visible = False
|
|
' lfila.text = "CATALOGO"
|
|
' ProgressDialogShow("Cargando catalogo ...")
|
|
' Sleep(100)
|
|
' Private inicioContador As String = DateTime.Now
|
|
' llenaCatalogo(Value)
|
|
' clv_prods_ll.AsView.Visible = True
|
|
' LogColor("TIEMPO DE PROCESO DEL CATALOGO: " & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
|
' ProgressDialogHide
|
|
End Sub
|
|
|
|
Private Sub p_vistaPreviaTrans_Click
|
|
|
|
End Sub
|
|
|
|
Private Sub b_rechazar_Click
|
|
If folio <> "" Then
|
|
result = Msgbox2($"Seguro que desea borrar el pedido completo?${CRLF}Haciendo clic largo sobre un producto se pueden borrar articulos por separado."$,"Rechazar Pedido", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
|
If result = DialogResponse.POSITIVE Then
|
|
Subs.borraPedidoClienteActual
|
|
prodsMap.Initialize
|
|
B4XPages.MainPage.promos.promosMap.Initialize
|
|
' Log("Llamamos LlenaProdsLL")
|
|
LlenaProdsLL(Null, Null)
|
|
' Log("Positivo")
|
|
Subs.iniciaActividad("Cliente")
|
|
' B4XPages.ShowPage("Cliente")
|
|
Else
|
|
' Log("NO Positivo")
|
|
p_vistaPreviaTrans.Visible = False
|
|
End If
|
|
Else
|
|
' Msgbox("LA VENTA YA SE TRANSMITIO, FAVOR DE LLAMAR A SOPORTE PARA ASISTENCIA","AVISO") 'ignore
|
|
End If
|
|
p_vistaPreviaTrans.Visible=False
|
|
Subs.iniciaActividad("Cliente")
|
|
' B4XPages.ShowPage("Cliente")
|
|
End Sub
|
|
|
|
Private Sub b_aceptar_Click
|
|
' Log(listaProds)
|
|
Private p As Cursor = Starter.skmt.ExecQuery("select count(pe_costo_tot) as total FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
|
p.Position = 0
|
|
' LogColor(p.GetString("total"), Colors.red)
|
|
If p.GetString("total") < 1 Then LlenaProdsLL(Null, Null)
|
|
p_vistaPreviaTrans.Visible=False
|
|
Subs.iniciaActividad("Cliente")
|
|
' B4XPages.ShowPage("Cliente")
|
|
End Sub
|
|
|
|
Private Sub lv_prodsPedido_ItemLongClick (Position As Int, Value As Object)
|
|
c=Starter.skmt.ExecQuery("select count(*) as CUANTOS from CLIENTE_IMPRESO where CI_CUENTA in (Select CUENTA from cuentaa)")
|
|
c.Position = 0
|
|
Log(list_prodsPedido)
|
|
Log("lista prods="&list_prodsPedido.Get(Position))
|
|
Private m As Map = list_prodsPedido.Get(Position)
|
|
Log("m1= "&m)
|
|
If c.GetString("CUANTOS") = 0 Then 'Si la venta no está impresa o es abordo entonces continuamos ... 'Para que baordo pueda borra poner "Or Subs.clienteActual = "0""
|
|
Private sDate,sTime, clie_id, usuario As String
|
|
result = Msgbox2("Seguro que desea borrar este articulo?","Borrar Articulo", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
|
If result = DialogResponse.POSITIVE Then
|
|
Private prod As Cursor=Starter.skmt.ExecQuery2("select PE_PROID, PE_CANT, PE_CEDIS FROM PEDIDO where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
|
prod.Position=0
|
|
Log("m2= " & m)
|
|
c.Close
|
|
Log($"Buscamos: ${Value}, ${m.Get("cedis")}"$)
|
|
c=Starter.skmt.ExecQuery2("select count(*) AS CUANTOS from cat_gunaprod2 where CAT_GP_ID in (select pe_cedis from pedido where pe_pronombre = ? and pe_cedis = ? and pe_cliente in (Select CUENTA from cuentaa)) and CAT_GP_CLASIF = 'PROMOS' AND CAT_GP_TIPO = 'PROMOS' AND CAT_GP_SUBTIPO = 'PROMOS'", Array As String(Value, m.Get("cedis")))
|
|
c.Position=0
|
|
If c.GetString("CUANTOS") > 0 Then
|
|
Log($"Borramos de PROMO ${Value}"$)
|
|
Private pPromos As Cursor = Starter.skmt.ExecQuery($"select pe_proid, pe_cant from pedido where pe_cedis = '${m.Get("cedis")}'"$)
|
|
For tp = 0 To pPromos.RowCount - 1
|
|
pPromos.Position = tp
|
|
Log($"SUMAMOS ${pPromos.GetString("PE_CANT")} a ${pPromos.GetString("PE_PROID")} "$)
|
|
Starter.skmt.ExecNonQuery($"update ${Subs.traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ${pPromos.GetString("PE_CANT")} where cat_gp_id = '${pPromos.Getstring("PE_PROID")}'"$)
|
|
Next
|
|
Starter.skmt.ExecNonQuery2("delete from pedido where pe_cedis in (select pe_cedis from pedido where PE_CEDIS = ? and pe_pronombre = ?) and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(m.Get("cedis"), Value))
|
|
Else
|
|
Log($"SUMAMOS ${m.get("cant")} a ${m.get("prodId")} "$)
|
|
Starter.skmt.ExecNonQuery2($"update ${Subs.traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?"$, Array As Object(m.get("cant"), m.get("prodId")))
|
|
Log($"BORRAMOS ${Value}, ${m.Get("cedis")}"$)
|
|
Starter.skmt.ExecNonQuery2("delete from pedido where pe_pronombre = ? and pe_cedis = ? and pe_cant = ? and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(Value, m.Get("cedis"), m.Get("cant")))
|
|
End If
|
|
prod.Close
|
|
DateTime.DateFormat = "MM/dd/yyyy"
|
|
sDate=DateTime.Date(DateTime.Now)
|
|
sTime=DateTime.Time(DateTime.Now)
|
|
c=Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
|
c.Position=0
|
|
clie_id = c.GetString("CUENTA")
|
|
c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
|
|
c.Position=0
|
|
usuario = c.GetString("USUARIO")
|
|
c=Starter.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, count(*) as CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
|
c.Position=0
|
|
If c.GetString("CUANTOS") > 0 Then
|
|
Log($"============== TOTAL = ${c.GetString("TOTAL_CLIE")}"$)
|
|
If c.GetString("TOTAL_CLIE") < 1 Then
|
|
Starter.skmt.ExecNonQuery("delete from pedido where PE_PRONOMBRE like 'CAMBIO%' and PE_CLIENTE In (select cuenta from cuentaa)"$)
|
|
End If
|
|
|
|
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
|
Starter.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT) VALUES (?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps))
|
|
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
|
Else
|
|
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
|
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
|
End If
|
|
b_terminar1_Click
|
|
End If
|
|
Else
|
|
ToastMessageShow("Esta venta ya esta impresa, no se puede editar ni borrar.", False)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub clv_prods_ll_ItemClick (Index As Int, Value As Object)
|
|
|
|
End Sub
|
|
|
|
Sub l_prodX_Click
|
|
Log("l_prodx clicked")
|
|
l_info.Text = Sender.as(Label).text
|
|
Log(Sender.as(Label).tag)
|
|
l_info.BringToFront
|
|
l_info.Visible = True
|
|
' Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
|
' Private p0 As B4XView = clv_prods_ll.GetPanel(index)
|
|
' Private p As B4XView = p0.GetView(0)
|
|
' Private cant1 As B4XView = p.GetView(2).GetView(2)
|
|
' Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
|
'' Log(clv_prods_ll.GetValue(index))
|
|
' Log(cant1.Text)
|
|
End Sub
|
|
|
|
Private Sub l_prodX_LongClick
|
|
'' Log("longClic = "&Sender.as(Label).Text)
|
|
' If Subs.traeCliente <> 0 Then
|
|
' Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
|
' Private pId As String = clv_prods_ll.GetValue(index).As(Map).Get("id")
|
|
' Private pNombre As String = clv_prods_ll.GetValue(index).As(Map).Get("prod")
|
|
' Private t As Cursor = Starter.skmt.ExecQuery("select sum(PE_COSTO_TOT) as ventaTotal from pedido where PE_CLIENTE in (Select CUENTA from cuentaa)")
|
|
' t.Position = 0
|
|
' Private ventaT As String = t.GetString("ventaTotal")
|
|
' If ventaT = Null Then ventaT = 0
|
|
' If ventaT > 0 Then
|
|
' t = Starter.skmt.ExecQuery("select sum(PE_PRECIO2) as totalRMI from pedido where PE_PRONOMBRE like 'CAMBIO%' and PE_CLIENTE in (Select CUENTA from cuentaa)")
|
|
' t.Position = 0
|
|
' Private totalRMI As String = t.GetString("totalRMI")
|
|
' If totalRMI = Null Then totalRMI = 0
|
|
' l_rmi_nombre.Text = Sender.as(Label).Text
|
|
' Private pu0() As String = Regex.Split("\$", Sender.as(Label).Text)
|
|
' Private pu As String
|
|
' If pu0.Length > 1 Then pu = pu0(pu0.Length-1) Else pu = 0
|
|
'' Log(ventaT & ", " & totalRMI & ", " & Sender.as(Label).tag & ", " & pu)
|
|
' l_rmi_usado.Text = $"RMI usado: $$1.2{(totalRMI)}"$
|
|
' l_montoDisponible.Text = $"Disponible para RMI: $$1.2{(ventaT-totalRMI)}"$
|
|
' Private m As Map = CreateMap("disponible":(ventaT-totalRMI), "inv":Sender.as(Label).tag, "totalRMI":totalRMI, "pu":pu, "id":pId, "nombre":pNombre)
|
|
' rmiMap = m
|
|
' ' b_rmi_mas.Tag = m
|
|
' ' b_rmi_menos.Tag = m
|
|
' ' b_rmi_aceptar.Tag = m
|
|
' Subs.centraPanel(p_rmi, Root.Width)
|
|
' l_rmi_cant.Text = 0
|
|
' l_rmi_total.text = ""
|
|
' p_rmi.BringToFront
|
|
' p_rmi.Visible = True
|
|
' Else
|
|
' ToastMessageShow("No hay venta suficiente para RMIs", True)
|
|
' End If
|
|
' End If
|
|
End Sub
|
|
|
|
Private Sub clv_prods_ll_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
|
|
' Private inicioContador As String = DateTime.Now
|
|
' Log($"clv_prods_ll_VisibleRangeChanged : ${FirstIndex}, ${LastIndex} "$)
|
|
Dim ExtraSize As Int = 30 'List size
|
|
For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, clv_prods_ll.Size - 1)
|
|
Dim Pnl As B4XView = clv_prods_ll.GetPanel(i)
|
|
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
|
|
' Log(listaRenglones)
|
|
If Pnl.NumberOfViews = 0 Then 'Add each item/layout to the list/main layout
|
|
Pnl.LoadLayout("proditem")
|
|
p_prods.Width = Root.Width * 0.90
|
|
p_botMasMen.Left = p_prods.Width - (p_botMasMen.Width + 5)
|
|
Pnl.Height = p_prods.Height
|
|
Private cs As CSBuilder
|
|
cs.Initialize
|
|
l_prodX.Width = p_prods.Width - p_botMasMen.Width
|
|
l_prodX.SetTextSizeAnimated(0, 13)
|
|
If clv_prods_ll.GetValue(i).As(Map).Get("cant") <> Null And clv_prods_ll.GetValue(i).As(Map).Get("cant") > 0 Then
|
|
p_prods.Color=0xFFE2EEFF
|
|
et_pCant.TextColor=Colors.Red
|
|
' Log("VENDIDO ")
|
|
b_prodMenos.Tag = "vendido"
|
|
b_prodMas.Tag = "vendido"
|
|
If Subs.revisaImpresa Then
|
|
Log("YA IMPRESO")
|
|
et_pCant.Enabled = False
|
|
' b_prodMas.Enabled = False
|
|
b_prodMenos.Enabled = False
|
|
End If
|
|
End If
|
|
Private precio As String=NumberFormat2(clv_prods_ll.GetValue(i).As(Map).Get("precio").As(Double),1,2,2,False)
|
|
If clv_prods_ll.GetValue(i).As(Map).Get("cant") <> Null Then et_pCant.Text = clv_prods_ll.GetValue(i).As(Map).Get("cant")
|
|
l_prodX.Text = cs.Color(Colors.red).append(clv_prods_ll.GetValue(i).As(Map).Get("prod")).pop.append(CRLF).Append("Existencias: " & clv_prods_ll.GetValue(i).As(Map).Get("almacen")).Color(0xFF017F01).Append($" $${precio}"$).Popall
|
|
l_prodX.Tag = clv_prods_ll.GetValue(i).As(Map).Get("almacen")
|
|
l_pCant.Tag = clv_prods_ll.GetValue(i).As(Map).Get("id")
|
|
End If
|
|
' Log($"${i}, ${FirstIndex}, ${LastIndex}, ${Pnl.NumberOfViews}. ${clv_prods_ll.Size}"$)
|
|
Else 'Not visible
|
|
' If Pnl.NumberOfViews > 0 Then
|
|
' Pnl.RemoveAllViews 'Remove none visable item/layouts from the list/main layout
|
|
' End If
|
|
End If
|
|
PCLV.B4XSeekBar1.Value = clv_prods_ll.Size - FirstIndex
|
|
' Log($"Bar value: ${PCLV.B4XSeekBar1.Value}"$)
|
|
Next
|
|
End Sub
|
|
|
|
Sub Busca_TextChanged (Old As String, New As String)
|
|
' Private inicioContador As String = DateTime.Now
|
|
If (New.Length = 1 Or New.Length = 2) And Not(forzarBusqueda) Then Return
|
|
forzarBusqueda = False
|
|
If lfila.text = "PROMOCIONES" Then
|
|
If Not(lv_promos.Visible) Then lv_promos.Visible = True
|
|
Private cPromo As Cursor=Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from ${query} where CAT_GP_NOMBRE like '%${New}%' and CAT_GP_ALMACEN > 0 AND CAT_GP_TIPO = 'PROMOS' AND CAT_GP_SUBTIPO = 'PROMOS' AND CAT_GP_TIPOPROD <> 1 and (length(CAT_GP_CODPROMO) = 1 OR CAT_GP_CODPROMO = CAT_GP_ID)"$)
|
|
Log($"res:${cPromo.RowCount}"$)
|
|
If cPromo.RowCount > 0 Then
|
|
lv_promos.Clear
|
|
For i=0 To cPromo.RowCount -1
|
|
cPromo.Position=i
|
|
Private tm As Map = Subs.procesaPromocion(cPromo.GetString("CAT_GP_ID"), clienteId)
|
|
If tm.Get("status") = "ok" Then 'Solo muestrala si hay producto.
|
|
lv_promos.AddTwoLines(cPromo.GetString("CAT_GP_NOMBRE"),"# " & cPromo.GetString("CAT_GP_ALMACEN") & " $ " & cPromo.GetString("CAT_GP_PRECIO") & " F:" & tm.Get("mp").As(Map).Get("prodsFijosCant") & " V:" & tm.Get("mp").As(Map).Get("prodsVariablesCant"))
|
|
End If
|
|
Next
|
|
Else
|
|
ToastMessageShow("No hay promociones disponibles.", False)
|
|
End If
|
|
cPromo.Close
|
|
else if lfila.text = "RMI" Then
|
|
Dim p As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, '1000' as CAT_GP_ALMACEN from CAT_RMI where CAT_GP_NOMBRE like '%${New}%' order by CAT_GP_NOMBRE"$)
|
|
Log($"Llamamos LlenaProdsLL con ${p.RowCount} prods."$)
|
|
lfila.Text = "RMI"
|
|
b_rmi.Visible = False
|
|
lv_catalogos.Visible = False
|
|
LlenaProdsLL(p, "rmi")
|
|
clv_prods_ll.AsView.BringToFront
|
|
clv_prods_ll.AsView.Visible = True
|
|
l_mDisponible.Visible = True
|
|
Else
|
|
If Not(clv_prods_ll.AsView.Visible) Then clv_prods_ll.AsView.Visible = True
|
|
clv_prods_ll.Clear
|
|
listaProds.Initialize
|
|
listaHints.Initialize
|
|
Sleep(0)
|
|
Dim p As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD from CAT_GUNAPROD2 where CAT_GP_NOMBRE like '%${New}%' and CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_CLASIF <> 'PROMOS' order by CAT_GP_NOMBRE"$)
|
|
' c2= Starter.skmt.ExecQuery2("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from " & query & " where CAT_GP_ALMACEN > 0 AND CAT_GP_TIPO = ? AND CAT_GP_SUBTIPO =? AND CAT_GP_TIPOPROD <> 1 and (length(CAT_GP_CODPROMO) = 1 OR CAT_GP_CODPROMO = CAT_GP_ID) ", Array As String( Value, Value)
|
|
Log("Llamamos LlenaProdsLL")
|
|
LlenaProdsLL(p, Null)
|
|
End If
|
|
End Sub
|
|
|
|
Sub LlenaProdsLL(p As ResultSet, extra As String)
|
|
' Log("LlenaProdsLL")
|
|
listaProds.Initialize
|
|
hayPedido = Subs.hayPedido
|
|
' Log($"HAYPEDIDO: ${hayPedido}"$)
|
|
If hayPedido Then 'Si hay pedido obtenemos las cantidades de los productos para agregarlos al CLV.
|
|
Dim cantsMap As Map
|
|
cantsMap.Initialize
|
|
Dim pe As ResultSet = Starter.skmt.ExecQuery($"select PE_PROID, PE_CANT from PEDIDO where PE_CLIENTE = '${clienteId}' and PE_CEDIS = '${Subs.traeAlmacen}'"$)
|
|
'Si EXTRA es igual a rmi, entonces regresamos los RMIs existentes.
|
|
If extra = "rmi" Then pe = Starter.skmt.ExecQuery($"select PE_PROID, PE_CANT from PEDIDO where PE_CLIENTE = '${clienteId}' and PE_CEDIS = 'DUR'"$)
|
|
|
|
' LogColor("Ponemos productos de pedido anterior: "&pe.RowCount, Colors.red)
|
|
Do While pe.NextRow
|
|
Private cant As Int = 0
|
|
cantsMap.put(pe.GetString("PE_PROID"), pe.GetString("PE_CANT"))
|
|
Loop
|
|
' Log($"Con pedido: ${pe.RowCount}"$)
|
|
' Log("CANTSMAP: " & cantsMap)
|
|
pe.Close
|
|
End If
|
|
' Log(p.IsInitialized)
|
|
If query = "" Or query = Null Then query = "cat_gunaprod2"
|
|
If p.IsInitialized Then
|
|
' Log($"YA HAY RESULTSET ${p.RowCount}"$)
|
|
Else
|
|
' Log("NO HAY RESULTSET")
|
|
Dim p As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Subs.traeTablaProds(Starter.tipov)} where CAT_GP_PRECIO > 0 And CAT_GP_CLASIF <> 'PROMOS' order by CAT_GP_NOMBRE"$)
|
|
End If
|
|
|
|
Do While p.NextRow
|
|
Private cant As Int = 0
|
|
If hayPedido And cantsMap.ContainsKey(p.GetString("CAT_GP_ID")) Then cant = cantsMap.Get(p.GetString("CAT_GP_ID"))
|
|
Dim tempMap As Map = CreateMap("prod":p.GetString("CAT_GP_NOMBRE"), "precio":p.GetString("CAT_GP_PRECIO"), "almacen":p.GetString("CAT_GP_ALMACEN"), "id":p.GetString("CAT_GP_ID"), "cant":cant)
|
|
listaProds.Add(tempMap)
|
|
' Log($"${p.GetString("CAT_GP_ID")}, ${p.GetString("CAT_GP_NOMBRE")}, ${cant}"$)
|
|
Loop
|
|
p.Close
|
|
|
|
' Log("LISTAPRODS: " & listaProds)
|
|
PCLV.Commit
|
|
clv_prods_ll.Clear
|
|
Private listaProdsConCant, listaProdsConCantIndex As List
|
|
listaProdsConCant.Initialize
|
|
listaProdsConCantIndex.Initialize
|
|
listaHints.Initialize
|
|
' Log(listaProds)
|
|
For q = 0 To listaProds.Size - 1' Sacamos los productos con cantidad previa.
|
|
If listaProds.Get(q).As(Map).Get("cant").As(Int) <> 0 Then
|
|
' Log(listaProds.Get(q).As(Map).Get("cant"))
|
|
listaProdsConCant.Add(listaProds.Get(q))
|
|
listaProdsConCantIndex.Add(q)
|
|
End If
|
|
Next
|
|
' Log("PRODCONCANT: " & listaProdsConCant)
|
|
' Log(listaProdsConCantIndex)
|
|
Private cont As Int = 0
|
|
For pr0=0 To listaProdsConCant.Size - 1 'Agregamos los productos con cantidad previa.
|
|
Private Pnl As B4XView = xui.CreatePanel("")
|
|
Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 50dip)
|
|
Private tempMap As Map = listaProdsConCant.Get(pr0)
|
|
Private inv = tempMap.Get("almacen") + tempMap.Get("cant")
|
|
tempMap.Put("almacen", inv)
|
|
' Log(tempMap)
|
|
clv_prods_ll.Add(Pnl, tempMap)
|
|
listaHints.Add(listaProdsConCant.get(pr0).As(Map).Get("prod"))
|
|
cont = cont + 1
|
|
Next
|
|
' LogColor(clv_prods_ll.Size, Colors.red)
|
|
' Log(listaProds.Size)
|
|
For pr = 0 To listaProds.Size - 1
|
|
If listaProdsConCantIndex.IndexOf(pr) = -1 Then
|
|
Private Pnl As B4XView = xui.CreatePanel("")
|
|
If listaProds.Get(pr).As(Map).Get("almacen") < 1 Then
|
|
' Log("EN CERO" & listaProds.Get(pr).As(Map).Get("prod") & "|" & listaProds.Get(pr).As(Map).Get("almacen"))
|
|
Else
|
|
Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 50dip)
|
|
clv_prods_ll.Add(Pnl, listaProds.Get(pr))
|
|
listaHints.Add(listaProds.get(pr).As(Map).Get("prod"))
|
|
cont = cont + 1
|
|
End If
|
|
End If
|
|
Next
|
|
' LogColor(clv_prods_ll.Size, Colors.red)
|
|
' PCLV.Commit
|
|
' Log("CONT=" & cont)
|
|
' Log("CLV_PRODSLL="&clv_prods_ll.Size)
|
|
PCLV.B4XSeekBar1.MaxValue = clv_prods_ll.Size
|
|
PCLV.B4XSeekBar1.MinValue = 0
|
|
PCLV.B4XSeekBar1.Interval = clv_prods_ll.Size/20
|
|
PCLV.B4XSeekBar1.Value = clv_prods_ll.Size
|
|
PCLV.B4XSeekBar1.Update
|
|
' Log($"Min:0, max:${clv_prods_ll.Size}, Interval:${clv_prods_ll.Size/20}"$)
|
|
reiniciarlistaProds = False
|
|
End Sub
|
|
|
|
'Return the hint that will be displayed when the user fast scrolls the list. It can be a string or CSBuilder.
|
|
Sub PCLV_HintRequested(Index As Int) As Object
|
|
Dim word As String = listaHints.get(Index)
|
|
Return word
|
|
End Sub
|
|
|
|
'Return the hint that will be displayed when the user fast scrolls the list. It can be a string or CSBuilder.
|
|
Sub PCLV2_HintRequested(Index As Int) As Object
|
|
Dim word As String = listaHints.get(Index)
|
|
Return word
|
|
End Sub
|
|
|
|
Private Sub p_rmi_Click
|
|
|
|
End Sub
|
|
|
|
Private Sub b_rmi_aceptar_Click
|
|
If l_rmi_cant.Text > 0 Then Subs.guardaCambiosDeProducto(l_rmi_cant.Text, rmiMap.Get("nombre"), rmiMap.Get("id"), rmiMap.Get("pu")*l_rmi_cant.Text, query)
|
|
' Log($"${l_rmi_cant.Text}, ${rmiMap.Get("nombre")}, ${rmiMap.Get("id")}, ${rmiMap.Get("pu")}, ${query}"$)
|
|
p_rmi.Visible = False
|
|
End Sub
|
|
|
|
Private Sub b_rmi_menos_Click
|
|
Log(Sender.As(Button).tag)
|
|
' Private d As Map = Sender.As(Button).tag
|
|
Private cant As String = l_rmi_cant.Text
|
|
If (cant - 1) >= 0 Then
|
|
l_rmi_cant.Text = $"$1.0{(l_rmi_cant.Text - 1)}"$
|
|
l_rmi_total.Text = $"Total RMI $$1.2{(cant - 1) * rmiMap.Get("pu")}"$
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub b_rmi_mas_Click
|
|
Log(Sender.As(Button).tag)
|
|
' Private d As Map = Sender.As(Button).tag
|
|
Private cant As String = l_rmi_cant.Text
|
|
If (cant + 1) <= rmiMap.Get("inv") And ((cant + 1) * rmiMap.Get("pu")) <= rmiMap.Get("disponible") Then
|
|
l_rmi_cant.Text = $"$1.0{(l_rmi_cant.Text + 1)}"$
|
|
l_rmi_total.Text = $"Total RMI $$1.2{(cant + 1) * rmiMap.Get("pu")}"$
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub b_rmi_Click
|
|
Dim p As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, '1000' as CAT_GP_ALMACEN from CAT_RMI order by CAT_GP_NOMBRE"$)
|
|
Log($"Llamamos LlenaProdsLL con ${p.RowCount} prods."$)
|
|
lfila.Text = "RMI"
|
|
b_rmi.Visible = False
|
|
lv_catalogos.Visible = False
|
|
LlenaProdsLL(p, "rmi")
|
|
clv_prods_ll.AsView.BringToFront
|
|
clv_prods_ll.AsView.Visible = True
|
|
l_mDisponible.Visible = True
|
|
End Sub
|