mirror of
https://github.com/KeymonSoft/Intmex_Multiventa.git
synced 2026-04-17 21:06:08 +00:00
- Se completo el codigo para productos variables 3 en promos. - Se cambio codigo de validador para contemplar la posibilidad de que se pongan "_" en el nombre de las promos. - Se agregó columna VARREG3 a la tabla de cat_gunaprod2.
1339 lines
46 KiB
QBasic
1339 lines
46 KiB
QBasic
B4A=true
|
|
Group=Default Group
|
|
ModulesStructureVersion=1
|
|
Type=Class
|
|
Version=11.5
|
|
@EndOfDesignText@
|
|
Sub Class_Globals
|
|
Private Root As B4XView
|
|
Private xui As XUI
|
|
Private pnlPantallaCompleta As Panel
|
|
Private etCantidadProductos As Label
|
|
Private etCantidadProductos2 As Label
|
|
Private etCantidadProductos3 As Label
|
|
Private etCantidadProductos4 As Label
|
|
Private etLimiteSuma_Sub_pnl1 As Label
|
|
Private etLimiteSuma_Sub_pnl2 As Label
|
|
Private etLimiteSuma_Sub_pnl3 As Label
|
|
Private etLimiteSuma_Sub_pnl4 As Label
|
|
Private scrollView As ScrollView
|
|
Private pnlSecundario1 As Panel
|
|
Private pnlSecundario2 As Panel
|
|
Private pnlSecundario3 As Panel
|
|
Private pnlSecundario4 As Panel
|
|
Private panelHeight As Int = 60dip
|
|
|
|
Private pnlMaxPromo As Panel
|
|
Private lblPromocion As Label
|
|
Private lblMaxPromo As Label
|
|
Private btnMenosPromo As Button
|
|
Private lblSumPromo As Label
|
|
Private btnSumaPromo As Button
|
|
Private btnGuardaPromo As Button
|
|
Private btnContinuar As Button
|
|
|
|
Private pnlProdTot As Panel
|
|
Private lblTotProd As Label
|
|
Private lblSumaTotal As Label
|
|
Private lblTotalProdPromo As Label
|
|
Private lblTotalValor As Label
|
|
Private lblNomPromo As Label
|
|
|
|
Dim estaPromo, esteCliente As String
|
|
Dim tpf2 As Int = 0
|
|
Dim laPromo = "", elCliente = "" As String
|
|
Dim prodsPedidoActual As String
|
|
Dim montoPedidoActual As String
|
|
Dim promosMap As Map
|
|
Dim prodsVarReq As Int = 0
|
|
Dim prodsVarReq_ As Int = 0
|
|
Dim prodsVarReq2_ As Int = 0
|
|
|
|
Dim productosFijos As Int
|
|
Dim variablesRequeridas1 As Int
|
|
Dim variablesRequeridas2 As Int
|
|
Dim variablesRequeridas3 As Int
|
|
Dim productosFijos_Iniciales As Int
|
|
Dim variablesRequeridas1_Inicial As Int
|
|
Dim variablesRequeridas2_Inicial As Int
|
|
Dim variablesRequeridas3_Inicial As Int
|
|
|
|
Private sumaVar1Tot As Int = 0
|
|
Private sumaVar2Tot As Int = 0
|
|
Private sumaVar3Tot As Int = 0
|
|
Dim Encabezado As String
|
|
End Sub
|
|
|
|
Public Sub Initialize As Object
|
|
Return Me
|
|
End Sub
|
|
|
|
Private Sub B4XPage_Created (Root1 As B4XView)
|
|
Root = Root1
|
|
Dim pnlProdTotHeight As Int = 80dip
|
|
|
|
ObtenerVariablesRequeridas(estaPromo)
|
|
ObtenerFijos(estaPromo)
|
|
|
|
pnlMaxPromo = xui.CreatePanel("pnlMaxPromo")
|
|
pnlMaxPromo.SetLayoutAnimated(0, 0, 0, Root.Width, 100dip)
|
|
pnlMaxPromo.Color = xui.Color_LightGray
|
|
Root.AddView(pnlMaxPromo, 0, 0, Root.Width, 100dip)
|
|
|
|
lblPromocion.Initialize("lblPromocion")
|
|
lblPromocion.TextSize = 14
|
|
lblPromocion.TextColor = Colors.RGB(100,149,237)
|
|
lblPromocion.Gravity = Gravity.CENTER_VERTICAL
|
|
Dim lblPromocionWidth As Int = 180dip
|
|
lblPromocion.Text = "Max promos: "
|
|
pnlMaxPromo.AddView(lblPromocion, 10dip, 10dip, lblPromocionWidth, 30dip)
|
|
|
|
lblMaxPromo.Initialize("lblMaxPromo")
|
|
lblMaxPromo.TextSize = 16
|
|
lblMaxPromo.TextColor = xui.Color_Black
|
|
lblMaxPromo.Gravity = Gravity.CENTER
|
|
lblMaxPromo.Color = xui.Color_White
|
|
Dim lblMaxPromoWidth As Int = 40dip
|
|
pnlMaxPromo.AddView(lblMaxPromo, lblPromocion.Left + lblPromocion.Width, 10dip, lblMaxPromoWidth, 30dip)
|
|
|
|
btnMenosPromo.Initialize("btnMenosPromo")
|
|
btnMenosPromo.Text = "-"
|
|
btnMenosPromo.TextSize = 16
|
|
btnMenosPromo.Color = Colors.RGB(185, 106, 106)
|
|
btnMenosPromo.TextColor = xui.Color_White
|
|
Dim btnMenosPromoWidth As Int = 30dip
|
|
pnlMaxPromo.AddView(btnMenosPromo, lblMaxPromo.Left + lblMaxPromo.Width + 10dip, 10dip, btnMenosPromoWidth, 30dip)
|
|
|
|
lblSumPromo.Initialize("lblSumPromo")
|
|
lblSumPromo.TextSize = 16
|
|
lblSumPromo.TextColor = xui.Color_Black
|
|
lblSumPromo.Gravity = Gravity.CENTER
|
|
lblSumPromo.Color = xui.Color_White
|
|
Dim lblSumPromoWidth As Int = 40dip
|
|
pnlMaxPromo.AddView(lblSumPromo, btnMenosPromo.Left + btnMenosPromo.Width + 10dip, 10dip, lblSumPromoWidth, 30dip)
|
|
|
|
btnSumaPromo.Initialize("btnSumaPromo")
|
|
btnSumaPromo.Text = "+"
|
|
btnSumaPromo.TextSize = 16
|
|
btnSumaPromo.Color = Colors.RGB(133, 185, 106)
|
|
btnSumaPromo.TextColor = xui.Color_White
|
|
Dim btnSumaPromoWidth As Int = 30dip
|
|
pnlMaxPromo.AddView(btnSumaPromo, lblSumPromo.Left + lblSumPromo.Width + 10dip, 10dip, btnSumaPromoWidth, 30dip)
|
|
|
|
Dim lblNomPromo As Label
|
|
lblNomPromo.Initialize("lblNomPromo")
|
|
lblNomPromo.TextSize = 14
|
|
lblNomPromo.TextColor = xui.Color_Black
|
|
lblNomPromo.Gravity = Gravity.CENTER_VERTICAL
|
|
pnlMaxPromo.AddView(lblNomPromo, 10dip, 50dip, 100%x, 50dip)
|
|
|
|
pnlPantallaCompleta = xui.CreatePanel("pnlPantallaCompleta")
|
|
pnlPantallaCompleta.SetLayoutAnimated(0, 0, pnlMaxPromo.Height, Root.Width, Root.Height - pnlMaxPromo.Height - pnlProdTotHeight)
|
|
Root.AddView(pnlPantallaCompleta, 0, pnlMaxPromo.Height, Root.Width, Root.Height - pnlMaxPromo.Height - pnlProdTotHeight)
|
|
|
|
pnlProdTot.Initialize("pnlProdTot")
|
|
pnlProdTot.Color = xui.Color_White
|
|
Root.AddView(pnlProdTot, 0, Root.Height - pnlProdTotHeight, Root.Width, pnlProdTotHeight)
|
|
|
|
lblTotProd.Initialize("lblTotProd")
|
|
lblTotProd.Text = "Productos: "
|
|
lblTotProd.TextSize = 14
|
|
lblTotProd.TextColor = xui.Color_Black
|
|
pnlProdTot.AddView(lblTotProd, 10dip, 10dip, 100dip, 30dip)
|
|
|
|
lblSumaTotal.Initialize("lblSumaTotal")
|
|
lblSumaTotal.Text = "0"
|
|
lblSumaTotal.TextSize = 14
|
|
lblSumaTotal.TextColor = xui.Color_Blue
|
|
pnlProdTot.AddView(lblSumaTotal, lblTotProd.Left + lblTotProd.Width + 10dip, 10dip, 60dip, 30dip)
|
|
|
|
lblTotalProdPromo.Initialize("lblTotalProdPromo")
|
|
lblTotalProdPromo.Text = "Total: $"
|
|
lblTotalProdPromo.TextSize = 14
|
|
lblTotalProdPromo.TextColor = xui.Color_Black
|
|
pnlProdTot.AddView(lblTotalProdPromo, 10dip, 50dip, 100dip, 30dip)
|
|
|
|
lblTotalValor.Initialize("lblTotalValor")
|
|
lblTotalValor.Text = "0"
|
|
lblTotalValor.TextSize = 14
|
|
lblTotalValor.TextColor = xui.Color_Blue
|
|
pnlProdTot.AddView(lblTotalValor, lblTotalProdPromo.Left + lblTotalProdPromo.Width + 10dip, 50dip, 100dip, 30dip)
|
|
|
|
btnGuardaPromo.Initialize("btnGuardaPromo")
|
|
btnGuardaPromo.Text = "Terminar"
|
|
btnGuardaPromo.Color = Colors.RGB(106, 162, 185)
|
|
btnGuardaPromo.TextColor = xui.Color_White
|
|
btnGuardaPromo.Enabled = False
|
|
|
|
Dim btnWidth As Int = pnlProdTot.Width * 0.25
|
|
Dim btnHeight As Int = 50dip
|
|
|
|
pnlProdTot.AddView(btnGuardaPromo, pnlProdTot.Width - btnWidth, (pnlProdTot.Height - btnHeight) / 2, btnWidth, btnHeight)
|
|
|
|
btnContinuar.Initialize("btnContinuar")
|
|
btnContinuar.Text = "Continuar"
|
|
btnContinuar.Color = Colors.RGB(133, 185, 106)
|
|
btnContinuar.TextColor = xui.Color_White
|
|
btnContinuar.Enabled = False
|
|
|
|
Dim btnWidth As Int = pnlProdTot.Width * 0.25
|
|
Dim btnHeight As Int = 50dip
|
|
|
|
Dim separacion As Int = 5dip
|
|
pnlProdTot.AddView(btnContinuar, pnlProdTot.Width - btnWidth * 2 - separacion, (pnlProdTot.Height - btnHeight) / 2, btnWidth, btnHeight)
|
|
|
|
scrollView.Initialize(1000)
|
|
pnlPantallaCompleta.AddView(scrollView, 0, 0, pnlPantallaCompleta.Width, pnlPantallaCompleta.Height)
|
|
|
|
Dim pnlContainer As Panel
|
|
pnlContainer.Initialize("pnlContainer")
|
|
scrollView.Panel.AddView(pnlContainer, 0, 0, pnlPantallaCompleta.Width, 10000000dip)
|
|
|
|
etCantidadProductos.Initialize("etCantidadProductos")
|
|
etCantidadProductos.TextColor = xui.Color_Black
|
|
etCantidadProductos.TextSize = 12
|
|
etCantidadProductos.Color = xui.Color_LightGray
|
|
etCantidadProductos.Gravity = Gravity.CENTER
|
|
etCantidadProductos.SingleLine = True
|
|
|
|
pnlSecundario1.Initialize("pnlSecundario1")
|
|
pnlContainer.AddView(pnlSecundario1, 5dip, etCantidadProductos.Top + etCantidadProductos.Height + 10dip, pnlContainer.Width - 10dip, 100dip)
|
|
pnlSecundario1.Color = xui.Color_White
|
|
pnlSecundario1.Tag = "pnlSecundario1"
|
|
|
|
etCantidadProductos2.Initialize("etCantidadProductos2")
|
|
etCantidadProductos2.TextColor = xui.Color_Black
|
|
etCantidadProductos2.TextSize = 12
|
|
etCantidadProductos2.Color = xui.Color_LightGray
|
|
etCantidadProductos2.Gravity = Gravity.CENTER
|
|
etCantidadProductos2.SingleLine = True
|
|
|
|
pnlSecundario2.Initialize("pnlSecundario2")
|
|
pnlContainer.AddView(pnlSecundario2, 5dip, etCantidadProductos2.Top + etCantidadProductos2.Height + 10dip, pnlContainer.Width - 10dip, 100dip)
|
|
pnlSecundario2.Color = xui.Color_White
|
|
pnlSecundario2.Tag = "pnlSecundario2"
|
|
|
|
etCantidadProductos3.Initialize("etCantidadProductos3")
|
|
etCantidadProductos3.TextSize = 12
|
|
etCantidadProductos3.Color = xui.Color_LightGray
|
|
etCantidadProductos3.Gravity = Gravity.CENTER
|
|
etCantidadProductos3.TextColor = xui.Color_Black
|
|
etCantidadProductos3.SingleLine = True
|
|
|
|
pnlSecundario3.Initialize("pnlSecundario3")
|
|
pnlContainer.AddView(pnlSecundario3, 5dip, etCantidadProductos3.Top + etCantidadProductos3.Height + 10dip, pnlContainer.Width - 10dip, 100dip)
|
|
pnlSecundario3.Color = xui.Color_White
|
|
pnlSecundario3.Tag = "pnlSecundario3"
|
|
|
|
etLimiteSuma_Sub_pnl1.Initialize("etLimiteSuma_Sub_pnl1")
|
|
etLimiteSuma_Sub_pnl1.TextColor = xui.Color_Black
|
|
etLimiteSuma_Sub_pnl1.SingleLine = True
|
|
|
|
etLimiteSuma_Sub_pnl2.Initialize("etLimiteSuma_Sub_pnl2")
|
|
etLimiteSuma_Sub_pnl2.TextColor = xui.Color_Black
|
|
etLimiteSuma_Sub_pnl2.SingleLine = True
|
|
|
|
etLimiteSuma_Sub_pnl3.Initialize("etLimiteSuma_Sub_pnl3")
|
|
etLimiteSuma_Sub_pnl3.TextColor = xui.Color_Black
|
|
etLimiteSuma_Sub_pnl3.SingleLine = True
|
|
|
|
Dim anchoTotal As Int = pnlContainer.Width - 20dip
|
|
Dim anchoEtCantidadProductos As Int = anchoTotal * 0.65
|
|
Dim anchoEtLimiteSuma As Int = anchoTotal - anchoEtCantidadProductos
|
|
|
|
pnlContainer.AddView(etCantidadProductos, 10dip, 10dip, anchoEtCantidadProductos, 50dip)
|
|
pnlContainer.AddView(etLimiteSuma_Sub_pnl1, etCantidadProductos.Left + etCantidadProductos.Width + 10dip, 10dip, anchoEtLimiteSuma, 50dip)
|
|
|
|
pnlContainer.AddView(etCantidadProductos2, 10dip, etCantidadProductos.Top + etCantidadProductos.Height + 10dip, anchoEtCantidadProductos, 50dip)
|
|
pnlContainer.AddView(etLimiteSuma_Sub_pnl2, etCantidadProductos2.Left + etCantidadProductos2.Width + 10dip, etCantidadProductos2.Top, anchoEtLimiteSuma, 50dip)
|
|
|
|
pnlContainer.AddView(etCantidadProductos3, 10dip, etCantidadProductos2.Top + etCantidadProductos2.Height + 10dip, anchoEtCantidadProductos, 50dip)
|
|
pnlContainer.AddView(etLimiteSuma_Sub_pnl3, etCantidadProductos3.Left + etCantidadProductos3.Width + 10dip, etCantidadProductos3.Top, anchoEtLimiteSuma, 50dip)
|
|
|
|
etCantidadProductos4.Initialize("etCantidadProductos4")
|
|
etCantidadProductos4.TextSize = 12
|
|
etCantidadProductos4.Color = xui.Color_LightGray
|
|
etCantidadProductos4.Gravity = Gravity.CENTER
|
|
etCantidadProductos4.TextColor = xui.Color_Black
|
|
etCantidadProductos4.SingleLine = True
|
|
|
|
etLimiteSuma_Sub_pnl4.Initialize("etLimiteSuma_Sub_pnl4")
|
|
etLimiteSuma_Sub_pnl4.TextColor = xui.Color_Black
|
|
etLimiteSuma_Sub_pnl4.SingleLine = True
|
|
|
|
pnlSecundario4.Initialize("pnlSecundario4")
|
|
pnlContainer.AddView(pnlSecundario4, 5dip, etCantidadProductos4.Top + etCantidadProductos4.Height + 10dip, pnlContainer.Width - 10dip, 100dip)
|
|
pnlSecundario4.Color = xui.Color_White
|
|
pnlSecundario4.Tag = "pnlSecundario4"
|
|
|
|
pnlContainer.AddView(etCantidadProductos4, 10dip, etCantidadProductos3.Top + etCantidadProductos3.Height + 10dip, anchoEtCantidadProductos, 50dip)
|
|
pnlContainer.AddView(etLimiteSuma_Sub_pnl4, etCantidadProductos4.Left + etCantidadProductos4.Width + 10dip, etCantidadProductos4.Top, anchoEtLimiteSuma, 50dip)
|
|
|
|
If VerificarCondicionesParabtnGuardaPromo Then
|
|
btnGuardaPromo.Visible = True
|
|
Else
|
|
btnGuardaPromo.Visible = False
|
|
End If
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub B4XPage_Appear
|
|
etCantidadProductos.Text = "0"
|
|
etCantidadProductos2.Text = "0"
|
|
etCantidadProductos3.Text = "0"
|
|
etCantidadProductos4.Text = "0"
|
|
|
|
productosFijos = 0
|
|
variablesRequeridas1= 0
|
|
variablesRequeridas2= 0
|
|
variablesRequeridas3= 0
|
|
|
|
sumaVar1Tot = 0
|
|
sumaVar2Tot = 0
|
|
sumaVar3Tot = 0
|
|
|
|
If pnlSecundario1.IsInitialized Then pnlSecundario1.RemoveAllViews
|
|
If pnlSecundario2.IsInitialized Then pnlSecundario2.RemoveAllViews
|
|
If pnlSecundario3.IsInitialized Then pnlSecundario3.RemoveAllViews
|
|
If pnlSecundario4.IsInitialized Then pnlSecundario4.RemoveAllViews
|
|
|
|
btnGuardaPromo.Visible = False
|
|
|
|
Dim m As Map = Subs.traeTotalesClienteActual
|
|
prodsPedidoActual = m.Get("productos")
|
|
montoPedidoActual = m.Get("monto")
|
|
|
|
If laPromo <> "" Then
|
|
muestraPromo(laPromo, elCliente)
|
|
End If
|
|
|
|
ObtenerVariablesRequeridas(estaPromo)
|
|
ObtenerFijos(estaPromo)
|
|
|
|
ActualizarTotalValor
|
|
|
|
lblSumaTotal.Text = SumarValoresLblValue
|
|
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
|
|
AjustarScroll
|
|
|
|
scrollView.ScrollPosition = 0
|
|
End Sub
|
|
|
|
Private Sub ObtenerFijos(promo As String)
|
|
Dim cursorProductosFijos As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_DP_PZAS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID = '${promo}' AND CAT_DP_TIPO = '0'"$)
|
|
|
|
If cursorProductosFijos.RowCount > 0 Then
|
|
cursorProductosFijos.Position = 0
|
|
|
|
If cursorProductosFijos.GetInt("CAT_DP_PZAS") <> 0 And cursorProductosFijos.GetString("CAT_DP_PZAS") <> " " Then
|
|
productosFijos = cursorProductosFijos.GetInt("CAT_DP_PZAS")
|
|
Else
|
|
etCantidadProductos.Visible = False
|
|
etLimiteSuma_Sub_pnl1.Visible = False
|
|
pnlSecundario1.Visible = False
|
|
End If
|
|
|
|
Else
|
|
productosFijos = 0
|
|
End If
|
|
|
|
productosFijos_Iniciales = productosFijos
|
|
End Sub
|
|
|
|
Private Sub ObtenerVariablesRequeridas(promo As String)
|
|
Dim cursorVariablesReq As Cursor = Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_STS AS CAT_GP_VAR1REQ, CAT_GP_IMP1 AS CAT_GP_VAR2REQ, CAT_GP_VARREQ3 from cat_gunaprod2 where cat_gp_id = '${promo}'"$)
|
|
|
|
If cursorVariablesReq.RowCount > 0 Then
|
|
cursorVariablesReq.Position = 0
|
|
|
|
If cursorVariablesReq.GetInt("CAT_GP_VAR1REQ") <> 0 And cursorVariablesReq.GetString("CAT_GP_VAR1REQ") <> " " Then
|
|
variablesRequeridas1 = cursorVariablesReq.GetInt("CAT_GP_VAR1REQ")
|
|
Else
|
|
etCantidadProductos2.Visible = False
|
|
etLimiteSuma_Sub_pnl2.Visible = False
|
|
pnlSecundario2.Visible = False
|
|
End If
|
|
|
|
If cursorVariablesReq.GetInt("CAT_GP_VAR2REQ") <> 0 And cursorVariablesReq.GetString("CAT_GP_VAR2REQ") <> " " Then
|
|
variablesRequeridas2 = cursorVariablesReq.GetInt("CAT_GP_VAR2REQ")
|
|
Else
|
|
etCantidadProductos3.Visible = False
|
|
etLimiteSuma_Sub_pnl3.Visible = False
|
|
pnlSecundario3.Visible = False
|
|
End If
|
|
|
|
If cursorVariablesReq.GetInt("CAT_GP_VARREQ3") <> 0 And cursorVariablesReq.GetString("CAT_GP_VARREQ3") <> " " Then
|
|
variablesRequeridas3 = cursorVariablesReq.GetInt("CAT_GP_VARREQ3")
|
|
etCantidadProductos4.Visible = True
|
|
etLimiteSuma_Sub_pnl4.Visible = True
|
|
pnlSecundario4.Visible = True
|
|
Else
|
|
etCantidadProductos4.Visible = False
|
|
etLimiteSuma_Sub_pnl4.Visible = False
|
|
pnlSecundario4.Visible = False
|
|
End If
|
|
Else
|
|
variablesRequeridas1 = 0
|
|
variablesRequeridas2 = 0
|
|
variablesRequeridas3 = 0
|
|
End If
|
|
|
|
variablesRequeridas1_Inicial = variablesRequeridas1
|
|
variablesRequeridas2_Inicial = variablesRequeridas2
|
|
variablesRequeridas3_Inicial = variablesRequeridas3
|
|
End Sub
|
|
|
|
Sub muestraPromo(promo As String, cliente As String)
|
|
estaPromo = promo
|
|
esteCliente = cliente
|
|
Private mp As Map = Subs.traePromo(promo, cliente)
|
|
Private prodsPromo As Map = mp.Get("productos")
|
|
Dim invDispPromo As Map = Subs.traemosInventarioDisponibleParaPromo(promo)
|
|
|
|
lblMaxPromo.Text = Subs.revisaMaxPromosProdsVariablesPorInventario(mp)
|
|
lblSumPromo.Text = 1
|
|
|
|
Private cs As CSBuilder
|
|
cs.Initialize
|
|
|
|
lblNomPromo.text = cs.Color(Colors.RGB(100,149,237)).Size(18).Append("Promocion: ").Pop.Append(promo).Append(CRLF).Append(mp.Get("descripcion")).Popall
|
|
Log(lblNomPromo.text)
|
|
ObtenerVariablesRequeridas(promo)
|
|
ObtenerFijos(promo)
|
|
|
|
Log(etLimiteSuma_Sub_pnl2.Text)
|
|
|
|
If pnlSecundario1.IsInitialized Then pnlSecundario1.RemoveAllViews
|
|
If pnlSecundario2.IsInitialized Then pnlSecundario2.RemoveAllViews
|
|
If pnlSecundario3.IsInitialized Then pnlSecundario3.RemoveAllViews
|
|
If pnlSecundario4.IsInitialized Then pnlSecundario4.RemoveAllViews
|
|
|
|
Encabezado = promo
|
|
|
|
If productosFijos > 0 Then
|
|
pnlSecundario1.Visible = True
|
|
etCantidadProductos.Visible = True
|
|
etCantidadProductos.Text = $"Productos Fijos: '${productosFijos}'"$
|
|
etCantidadProductos.Left = 0
|
|
etCantidadProductos.Width = Root.Width
|
|
Dim cursorProdFijo As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_DP_PRECIO, CAT_DP_ID, CAT_DP_IDPROD, CAT_DP_TIPO FROM CAT_DETALLES_PAQ INNER JOIN CAT_GUNAPROD ON CAT_DP_IDPROD = CAT_GP_ID WHERE CAT_DP_ID = '${promo}' AND CAT_DP_TIPO = 0"$)
|
|
If cursorProdFijo.RowCount > 0 Then
|
|
For i = 0 To cursorProdFijo.RowCount - 1
|
|
cursorProdFijo.Position = i
|
|
GenerarPanelesP1(cursorProdFijo.GetString("CAT_GP_NOMBRE"), cursorProdFijo.GetString("CAT_GP_ALMACEN"), cursorProdFijo.GetString("CAT_DP_PRECIO"), cursorProdFijo.GetString("CAT_DP_IDPROD"), i)
|
|
Next
|
|
End If
|
|
Else
|
|
pnlSecundario1.Visible = False
|
|
' etCantidadProductos.Text = $"No hay productos Fijos"$
|
|
etCantidadProductos.Visible = False
|
|
End If
|
|
|
|
If variablesRequeridas1 > 0 Then
|
|
pnlSecundario2.Visible = True
|
|
etCantidadProductos2.Visible = True
|
|
etCantidadProductos2.Text = $"Primeros Variables Requeridos: '${variablesRequeridas1}'"$
|
|
etCantidadProductos2.Left = 0
|
|
etCantidadProductos2.Width = Root.Width
|
|
Dim cursorNomProductosVar1 As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_DP_PRECIO, CAT_DP_ID, CAT_DP_IDPROD, CAT_DP_TIPO FROM CAT_DETALLES_PAQ INNER JOIN CAT_GUNAPROD ON CAT_DP_IDPROD = CAT_GP_ID WHERE CAT_DP_ID = '${promo}' AND CAT_DP_TIPO = 1"$)
|
|
If cursorNomProductosVar1.RowCount > 0 Then
|
|
For i = 0 To cursorNomProductosVar1.RowCount - 1
|
|
cursorNomProductosVar1.Position = i
|
|
GenerarPanelesP2(cursorNomProductosVar1.GetString("CAT_GP_NOMBRE"), cursorNomProductosVar1.GetString("CAT_GP_ALMACEN"), cursorNomProductosVar1.GetString("CAT_DP_PRECIO"), cursorNomProductosVar1.GetString("CAT_DP_IDPROD"), i)
|
|
Next
|
|
End If
|
|
Else
|
|
pnlSecundario2.Visible = False
|
|
etCantidadProductos2.Visible = False
|
|
End If
|
|
|
|
If variablesRequeridas2 > 0 Then
|
|
pnlSecundario3.Visible = True
|
|
etCantidadProductos3.Visible = True
|
|
etCantidadProductos3.Text = $"Segundos Variables Requeridos: '${variablesRequeridas2}'"$
|
|
etCantidadProductos3.Left = 0
|
|
etCantidadProductos3.Width = Root.Width
|
|
Dim cursorNomProductosVar2 As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_DP_PRECIO, CAT_DP_ID, CAT_DP_IDPROD, CAT_DP_TIPO FROM CAT_DETALLES_PAQ INNER JOIN CAT_GUNAPROD ON CAT_DP_IDPROD = CAT_GP_ID WHERE CAT_DP_ID = '${promo}' AND CAT_DP_TIPO = 2"$)
|
|
If cursorNomProductosVar2.RowCount > 0 Then
|
|
For i = 0 To cursorNomProductosVar2.RowCount - 1
|
|
cursorNomProductosVar2.Position = i
|
|
GenerarPanelesP3(cursorNomProductosVar2.GetString("CAT_GP_NOMBRE"), cursorNomProductosVar2.GetString("CAT_GP_ALMACEN"), cursorNomProductosVar2.GetString("CAT_DP_PRECIO"), cursorNomProductosVar2.GetString("CAT_DP_IDPROD"), i)
|
|
Next
|
|
End If
|
|
Else
|
|
pnlSecundario3.Visible = False
|
|
etCantidadProductos3.Visible = False
|
|
End If
|
|
|
|
If variablesRequeridas3 > 0 Then
|
|
pnlSecundario4.Visible = True
|
|
etCantidadProductos4.Visible = True
|
|
etCantidadProductos4.Text = $"Tercer Variables Requeridas: '${variablesRequeridas3}'"$
|
|
etCantidadProductos4.Width = Root.Width
|
|
Dim cursorNomProductosVar3 As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_DP_PRECIO, CAT_DP_ID, CAT_DP_IDPROD, CAT_DP_TIPO FROM CAT_DETALLES_PAQ INNER JOIN CAT_GUNAPROD ON CAT_DP_IDPROD = CAT_GP_ID WHERE CAT_DP_ID = '${promo}' AND CAT_DP_TIPO = 3"$)
|
|
If cursorNomProductosVar3.RowCount > 0 Then
|
|
For i = 0 To cursorNomProductosVar3.RowCount - 1
|
|
cursorNomProductosVar3.Position = i
|
|
GenerarPanelesP4(cursorNomProductosVar3.GetString("CAT_GP_NOMBRE"), cursorNomProductosVar3.GetString("CAT_GP_ALMACEN"), cursorNomProductosVar3.GetString("CAT_DP_PRECIO"), cursorNomProductosVar3.GetString("CAT_DP_IDPROD"), i)
|
|
Next
|
|
End If
|
|
Else
|
|
pnlSecundario4.Visible = False
|
|
etCantidadProductos4.Visible = False
|
|
End If
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub btnMenosPromo_Click
|
|
Dim currentValue As Int = lblSumPromo.Text.As(Int)
|
|
|
|
If currentValue > 1 Then
|
|
currentValue = currentValue - 1
|
|
End If
|
|
|
|
lblSumPromo.Text = currentValue
|
|
|
|
productosFijos = productosFijos_Iniciales * currentValue
|
|
variablesRequeridas1 = variablesRequeridas1_Inicial * currentValue
|
|
variablesRequeridas2 = variablesRequeridas2_Inicial * currentValue
|
|
variablesRequeridas3 = variablesRequeridas3_Inicial * currentValue
|
|
|
|
etCantidadProductos.Text = $"Productos Fijos: '${productosFijos}'"$
|
|
etCantidadProductos.Left = 0
|
|
etCantidadProductos.Width = Root.Width
|
|
|
|
etCantidadProductos2.Text = $"Primeros Variables Requeridos: '${variablesRequeridas1}'"$
|
|
etCantidadProductos2.Left = 0
|
|
etCantidadProductos2.Width = Root.Width
|
|
|
|
etCantidadProductos3.Text = $"Segundos Variables Requeridos: '${variablesRequeridas2}'"$
|
|
etCantidadProductos3.Left = 0
|
|
etCantidadProductos3.Width = Root.Width
|
|
|
|
etCantidadProductos4.Text = $"Tercer Variables Requeridas: '${variablesRequeridas3}'"$
|
|
etCantidadProductos4.Left = 0
|
|
etCantidadProductos4.Width = Root.Width
|
|
|
|
lblSumaTotal.Text = SumarValoresLblValue
|
|
|
|
ActualizarTotalValor
|
|
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
End Sub
|
|
|
|
Private Sub btnSumaPromo_Click
|
|
Dim currentValue As Int = lblSumPromo.Text.As(Int)
|
|
|
|
Dim maxValue As Int = lblMaxPromo.Text.As(Int)
|
|
|
|
If currentValue < maxValue Then
|
|
currentValue = currentValue + 1
|
|
End If
|
|
|
|
lblSumPromo.Text = currentValue
|
|
|
|
productosFijos = productosFijos_Iniciales * currentValue
|
|
variablesRequeridas1 = variablesRequeridas1_Inicial * currentValue
|
|
variablesRequeridas2 = variablesRequeridas2_Inicial * currentValue
|
|
variablesRequeridas3 = variablesRequeridas3_Inicial * currentValue
|
|
|
|
etCantidadProductos.Text = $"Productos Fijos: '${productosFijos}'"$
|
|
etCantidadProductos.Left = 0
|
|
etCantidadProductos.Width = Root.Width
|
|
etCantidadProductos2.Text = $"Primeros Variables Requeridos: '${variablesRequeridas1}'"$
|
|
etCantidadProductos2.Left = 0
|
|
etCantidadProductos2.Width = Root.Width
|
|
etCantidadProductos3.Text = $"Segundos Variables Requeridos: '${variablesRequeridas2}'"$
|
|
etCantidadProductos3.Left = 0
|
|
etCantidadProductos3.Width = Root.Width
|
|
etCantidadProductos4.Text = $"Tercer Variables Requeridas: '${variablesRequeridas3}'"$
|
|
etCantidadProductos4.Left = 0
|
|
etCantidadProductos4.Width = Root.Width
|
|
|
|
lblSumaTotal.Text = SumarValoresLblValue
|
|
|
|
ActualizarTotalValor
|
|
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
End Sub
|
|
|
|
Private Sub btnVars1Mas_Click
|
|
If sumaVar1Tot >= variablesRequeridas1 Then
|
|
Return
|
|
End If
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto = Sender.As(View).Parent
|
|
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
|
|
Dim currentValue As Int
|
|
If IsNumber(lblValue.Text) Then
|
|
currentValue = lblValue.Text.As(Int)
|
|
Else
|
|
currentValue = 0
|
|
End If
|
|
|
|
currentValue = currentValue + 1
|
|
lblValue.Text = currentValue
|
|
|
|
sumaVar1Tot = sumaVar1Tot + 1
|
|
|
|
lblSumaTotal.Text = SumarValoresLblValue
|
|
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
|
|
ActualizarTotalValor
|
|
End Sub
|
|
|
|
Private Sub btnVars1Menos_Click
|
|
Dim pnlProducto As Panel
|
|
pnlProducto = Sender.As(View).Tag
|
|
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
|
|
Dim currentValue As Int
|
|
If IsNumber(lblValue.Text) Then
|
|
currentValue = lblValue.Text.As(Int)
|
|
Else
|
|
currentValue = 0
|
|
End If
|
|
|
|
If currentValue > 0 Then
|
|
currentValue = currentValue - 1
|
|
lblValue.Text = currentValue
|
|
|
|
sumaVar1Tot = sumaVar1Tot - 1
|
|
|
|
lblSumaTotal.Text = SumarValoresLblValue
|
|
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
|
|
ActualizarTotalValor
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnVars2Mas_Click
|
|
If sumaVar2Tot >= variablesRequeridas2 Then
|
|
Return
|
|
End If
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto = Sender.As(View).Parent
|
|
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
|
|
Dim currentValue As Int
|
|
If IsNumber(lblValue.Text) Then
|
|
currentValue = lblValue.Text.As(Int)
|
|
Else
|
|
currentValue = 0
|
|
End If
|
|
|
|
currentValue = currentValue + 1
|
|
lblValue.Text = currentValue
|
|
|
|
sumaVar2Tot = sumaVar2Tot + 1
|
|
|
|
lblSumaTotal.Text = SumarValoresLblValue
|
|
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
|
|
ActualizarTotalValor
|
|
End Sub
|
|
|
|
Private Sub btnVars2Menos_Click
|
|
Dim pnlProducto As Panel
|
|
pnlProducto = Sender.As(View).Tag
|
|
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
|
|
Dim currentValue As Int
|
|
If IsNumber(lblValue.Text) Then
|
|
currentValue = lblValue.Text.As(Int)
|
|
Else
|
|
currentValue = 0
|
|
End If
|
|
|
|
If currentValue > 0 Then
|
|
currentValue = currentValue - 1
|
|
lblValue.Text = currentValue
|
|
|
|
sumaVar2Tot = sumaVar2Tot - 1
|
|
|
|
lblSumaTotal.Text = SumarValoresLblValue
|
|
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
|
|
ActualizarTotalValor
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnVars3Mas_Click
|
|
If sumaVar3Tot >= variablesRequeridas3 Then
|
|
Return
|
|
End If
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto = Sender.As(View).Parent
|
|
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
|
|
Dim currentValue As Int
|
|
If IsNumber(lblValue.Text) Then
|
|
currentValue = lblValue.Text.As(Int)
|
|
Else
|
|
currentValue = 0
|
|
End If
|
|
|
|
currentValue = currentValue + 1
|
|
lblValue.Text = currentValue
|
|
|
|
sumaVar3Tot = sumaVar3Tot + 1
|
|
|
|
lblSumaTotal.Text = SumarValoresLblValue
|
|
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
|
|
ActualizarTotalValor
|
|
End Sub
|
|
|
|
Private Sub btnVars3Menos_Click
|
|
Dim pnlProducto As Panel
|
|
pnlProducto = Sender.As(View).Tag
|
|
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
|
|
Dim currentValue As Int
|
|
If IsNumber(lblValue.Text) Then
|
|
currentValue = lblValue.Text.As(Int)
|
|
Else
|
|
currentValue = 0
|
|
End If
|
|
|
|
If currentValue > 0 Then
|
|
currentValue = currentValue - 1
|
|
lblValue.Text = currentValue
|
|
|
|
sumaVar3Tot = sumaVar3Tot - 1
|
|
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
|
|
ActualizarTotalValor
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GenerarPanelesP1(nombreProd As String, inventario As String, precio As String, idProducto As String, numberOfViews As Int)
|
|
If Not(pnlSecundario1.IsInitialized) Then
|
|
Return
|
|
End If
|
|
|
|
Private estePrecio As String = precio
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto.Initialize("pnlProducto")
|
|
pnlProducto.SetLayout(0, 0, pnlSecundario1.Width, 70dip)
|
|
|
|
Dim lblNombre As Label
|
|
lblNombre.Initialize("lblNombre")
|
|
lblNombre.Text = nombreProd & CRLF & "Hay " & inventario & " $" & NumberFormat2(estePrecio,1,2,2,True)
|
|
lblNombre.Tag = idProducto
|
|
lblNombre.TextSize = 12
|
|
lblNombre.TextColor = xui.Color_Black
|
|
lblNombre.Gravity = Gravity.LEFT + Gravity.CENTER_VERTICAL
|
|
pnlProducto.AddView(lblNombre, 10dip, 10dip, pnlProducto.Width * 0.75 - 20dip, 50dip)
|
|
|
|
pnlProducto.Tag = estePrecio
|
|
|
|
pnlSecundario1.AddView(pnlProducto, 0, numberOfViews * 70dip, pnlSecundario1.Width, 70dip)
|
|
pnlSecundario1.Height = (numberOfViews * 70dip) + 70dip
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub GenerarPanelesP2(nombreProd As String, inventario As String, precio As String, idProducto As String, numberOfViews As Int)
|
|
If Not(pnlSecundario2.IsInitialized) Then
|
|
Return
|
|
End If
|
|
|
|
Private estePrecio As String = precio
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto.Initialize("pnlProducto")
|
|
pnlProducto.SetLayout(0, 0, pnlSecundario2.Width, 50dip)
|
|
|
|
Dim lblNombre As Label
|
|
lblNombre.Initialize("lblNombre")
|
|
lblNombre.Text = nombreProd & CRLF & "Hay " & inventario & " $" & NumberFormat2(estePrecio,1,2,2,True)
|
|
lblNombre.Tag = idProducto
|
|
|
|
lblNombre.TextSize = 12
|
|
lblNombre.TextColor = xui.Color_Black
|
|
lblNombre.Gravity = Gravity.LEFT + Gravity.CENTER_VERTICAL
|
|
pnlProducto.AddView(lblNombre, 10dip, 10dip, pnlProducto.Width * 0.75 - 20dip, 50dip)
|
|
|
|
Dim btnWidth As Int = pnlProducto.Width * 0.25 / 3
|
|
Dim lblWidth As Int = btnWidth
|
|
Dim spacing As Int = 5dip
|
|
|
|
Dim btnMenos As Button
|
|
btnMenos.Initialize("btnVars1Menos")
|
|
btnMenos.Tag = pnlProducto
|
|
btnMenos.Text = $"-"$
|
|
btnMenos.TextSize = 20
|
|
btnMenos.Color = Colors.RGB(185, 106, 106)
|
|
btnMenos.TextColor = xui.Color_White
|
|
pnlProducto.AddView(btnMenos, pnlProducto.Width - btnWidth - spacing * 2 - lblWidth - btnWidth, 10dip, btnWidth, pnlProducto.Height - 10dip)
|
|
|
|
Dim lblValue As Label
|
|
lblValue.Initialize("lblValue")
|
|
lblValue.Text = "0"
|
|
lblValue.TextColor = xui.Color_Black
|
|
lblValue.Gravity = Gravity.CENTER
|
|
lblValue.TextSize = 12
|
|
pnlProducto.AddView(lblValue, btnMenos.Left + btnMenos.Width + spacing, 10dip, lblWidth, pnlProducto.Height - 10dip)
|
|
|
|
Dim btnMas As Button
|
|
btnMas.Initialize("btnVars1Mas")
|
|
btnMas.Tag = pnlProducto
|
|
btnMas.Text = $"+"$
|
|
btnMas.TextSize = 20
|
|
btnMas.Color = Colors.RGB(133, 185, 106)
|
|
btnMas.TextColor = xui.Color_White
|
|
pnlProducto.AddView(btnMas, lblValue.Left + lblValue.Width + spacing, 10dip, btnWidth, pnlProducto.Height - 10dip)
|
|
|
|
pnlProducto.Tag = estePrecio
|
|
|
|
pnlSecundario2.AddView(pnlProducto, 0, numberOfViews * 70dip, pnlSecundario2.Width, 70dip)
|
|
pnlSecundario2.Height = (numberOfViews * 70dip) + 70dip
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub GenerarPanelesP3(nombreProd As String, inventario As String, precio As String, idProducto As String, numberOfViews As Int)
|
|
If Not(pnlSecundario3.IsInitialized) Then
|
|
Return
|
|
End If
|
|
|
|
Private estePrecio As String = precio
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto.Initialize("pnlProducto")
|
|
pnlProducto.SetLayout(0, 0, pnlSecundario3.Width, 50dip)
|
|
|
|
Dim lblNombre As Label
|
|
lblNombre.Initialize("lblNombre")
|
|
lblNombre.Text = nombreProd & CRLF & "Hay " & inventario & " $" & NumberFormat2(estePrecio,1,2,2,True)
|
|
lblNombre.Tag = idProducto
|
|
lblNombre.TextSize = 12
|
|
lblNombre.TextColor = xui.Color_Black
|
|
lblNombre.Gravity = Gravity.LEFT + Gravity.CENTER_VERTICAL
|
|
pnlProducto.AddView(lblNombre, 10dip, 10dip, pnlProducto.Width * 0.75 - 20dip, 50dip)
|
|
|
|
Dim btnWidth As Int = pnlProducto.Width * 0.25 / 3
|
|
Dim lblWidth As Int = btnWidth
|
|
Dim spacing As Int = 5dip
|
|
|
|
Dim btnMenos As Button
|
|
btnMenos.Initialize("btnVars2Menos")
|
|
btnMenos.Tag = pnlProducto
|
|
btnMenos.Text = $"-"$
|
|
btnMenos.TextSize = 20
|
|
btnMenos.Color = Colors.RGB(185, 106, 106)
|
|
btnMenos.TextColor = xui.Color_White
|
|
pnlProducto.AddView(btnMenos, pnlProducto.Width - btnWidth - spacing * 2 - lblWidth - btnWidth, 10dip, btnWidth, pnlProducto.Height - 10dip)
|
|
|
|
Dim lblValue As Label
|
|
lblValue.Initialize("lblValue")
|
|
lblValue.Text = "0"
|
|
lblValue.TextColor = xui.Color_Black
|
|
lblValue.Gravity = Gravity.CENTER
|
|
lblValue.TextSize = 12
|
|
pnlProducto.AddView(lblValue, btnMenos.Left + btnMenos.Width + spacing, 10dip, lblWidth, pnlProducto.Height - 10dip)
|
|
|
|
Dim btnMas As Button
|
|
btnMas.Initialize("btnVars2Mas")
|
|
btnMas.Tag = pnlProducto
|
|
btnMas.Text = $"+"$
|
|
btnMas.TextSize = 20
|
|
btnMas.Color = Colors.RGB(133, 185, 106)
|
|
btnMas.TextColor = xui.Color_White
|
|
pnlProducto.AddView(btnMas, lblValue.Left + lblValue.Width + spacing, 10dip, btnWidth, pnlProducto.Height - 10dip)
|
|
|
|
pnlProducto.Tag = estePrecio
|
|
|
|
pnlSecundario3.AddView(pnlProducto, 0, numberOfViews * 70dip, pnlSecundario3.Width, 70dip)
|
|
pnlSecundario3.Height = (numberOfViews * 70dip) + 70dip
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub GenerarPanelesP4(nombreProd As String, inventario As String, precio As String, idProducto As String, numberOfViews As Int)
|
|
If Not(pnlSecundario4.IsInitialized) Then
|
|
Return
|
|
End If
|
|
|
|
Private estePrecio As String = precio
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto.Initialize("pnlProducto")
|
|
pnlProducto.SetLayout(0, 0, pnlSecundario4.Width, 50dip)
|
|
|
|
Dim lblNombre As Label
|
|
lblNombre.Initialize("lblNombre")
|
|
lblNombre.Text = nombreProd & CRLF & "Hay " & inventario & " $" & NumberFormat2(estePrecio,1,2,2,True)
|
|
lblNombre.Tag = idProducto
|
|
lblNombre.TextSize = 12
|
|
lblNombre.TextColor = xui.Color_Black
|
|
lblNombre.Gravity = Gravity.LEFT + Gravity.CENTER_VERTICAL
|
|
pnlProducto.AddView(lblNombre, 10dip, 10dip, pnlProducto.Width * 0.75 - 20dip, 50dip)
|
|
|
|
Dim btnWidth As Int = pnlProducto.Width * 0.25 / 3
|
|
Dim lblWidth As Int = btnWidth
|
|
Dim spacing As Int = 5dip
|
|
|
|
Dim btnMenos As Button
|
|
btnMenos.Initialize("btnVars3Menos")
|
|
btnMenos.Tag = pnlProducto
|
|
btnMenos.Text = $"-"$
|
|
btnMenos.TextSize = 20
|
|
btnMenos.Color = Colors.RGB(185, 106, 106)
|
|
btnMenos.TextColor = xui.Color_White
|
|
pnlProducto.AddView(btnMenos, pnlProducto.Width - btnWidth - spacing * 2 - lblWidth - btnWidth, 10dip, btnWidth, pnlProducto.Height - 10dip)
|
|
|
|
Dim lblValue As Label
|
|
lblValue.Initialize("lblValue")
|
|
lblValue.Text = "0"
|
|
lblValue.TextColor = xui.Color_Black
|
|
lblValue.Gravity = Gravity.CENTER
|
|
lblValue.TextSize = 12
|
|
pnlProducto.AddView(lblValue, btnMenos.Left + btnMenos.Width + spacing, 10dip, lblWidth, pnlProducto.Height - 10dip)
|
|
|
|
Dim btnMas As Button
|
|
btnMas.Initialize("btnVars3Mas")
|
|
btnMas.Tag = pnlProducto
|
|
btnMas.Text = $"+"$
|
|
btnMas.TextSize = 20
|
|
btnMas.Color = Colors.RGB(133, 185, 106)
|
|
btnMas.TextColor = xui.Color_White
|
|
pnlProducto.AddView(btnMas, lblValue.Left + lblValue.Width + spacing, 10dip, btnWidth, pnlProducto.Height - 10dip)
|
|
|
|
pnlProducto.Tag = estePrecio
|
|
|
|
pnlSecundario4.AddView(pnlProducto, 0, numberOfViews * 70dip, pnlSecundario4.Width, 70dip)
|
|
pnlSecundario4.Height = (numberOfViews * 70dip) + 70dip
|
|
|
|
AjustarScroll
|
|
|
|
If VerificarCondicionesParabtnGuardaPromo Then
|
|
btnGuardaPromo.Visible = True
|
|
Else
|
|
btnGuardaPromo.Visible = False
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub AjustarScroll
|
|
Dim baseHeight As Int = 0
|
|
|
|
If productosFijos > 0 And pnlSecundario1.Visible Then
|
|
etCantidadProductos.Top = baseHeight
|
|
etLimiteSuma_Sub_pnl1.Top = etCantidadProductos.Top
|
|
baseHeight = baseHeight + etCantidadProductos.Height
|
|
|
|
pnlSecundario1.Top = baseHeight
|
|
baseHeight = baseHeight + pnlSecundario1.Height
|
|
End If
|
|
|
|
If variablesRequeridas1 > 0 And pnlSecundario2.Visible Then
|
|
etCantidadProductos2.Top = baseHeight
|
|
etLimiteSuma_Sub_pnl2.Top = etCantidadProductos2.Top
|
|
baseHeight = baseHeight + etCantidadProductos2.Height
|
|
|
|
pnlSecundario2.Top = baseHeight
|
|
baseHeight = baseHeight + pnlSecundario2.Height
|
|
End If
|
|
|
|
If variablesRequeridas2 > 0 And pnlSecundario3.Visible Then
|
|
etCantidadProductos3.Top = baseHeight
|
|
etLimiteSuma_Sub_pnl3.Top = etCantidadProductos3.Top
|
|
baseHeight = baseHeight + etCantidadProductos3.Height
|
|
|
|
pnlSecundario3.Top = baseHeight
|
|
baseHeight = baseHeight + pnlSecundario3.Height
|
|
End If
|
|
|
|
If variablesRequeridas3 > 0 And pnlSecundario4.Visible Then
|
|
etCantidadProductos4.Top = baseHeight
|
|
etLimiteSuma_Sub_pnl4.Top = etCantidadProductos4.Top
|
|
baseHeight = baseHeight + etCantidadProductos4.Height
|
|
|
|
pnlSecundario4.Top = baseHeight
|
|
baseHeight = baseHeight + pnlSecundario4.Height
|
|
End If
|
|
|
|
scrollView.Panel.Height = baseHeight
|
|
|
|
pnlProdTot.Top = Root.Height - pnlProdTot.Height
|
|
End Sub
|
|
|
|
Private Sub btnGuardaPromo_Click
|
|
Log("Iniciando btnGuardaPromo_Click...")
|
|
' Guardamos Encabezado
|
|
Subs.guardaProductoSinGestion(Encabezado, 0, lblSumPromo.Text, Encabezado, Encabezado, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
|
|
If productosFijos > 0 Then
|
|
Log("Guardando productos fijos...")
|
|
For i = 0 To pnlSecundario1.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario1.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim cantidad As Int = productosFijos
|
|
' Dim idProducto As String = pnlProducto.Tag ' Asegúrate de que esto sea correcto
|
|
Log(">>>>>>> ESTE DEBE SER EL ID DEL PRODUCTO" & pnlSecundario1.Tag)
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
Private idProducto As String = lblNombre.tag
|
|
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
|
|
If cantidad > 0 Then
|
|
Subs.guardaProductoSinGestion(estaPromo, precioProducto, cantidad, nomProd(0), idProducto, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
End If
|
|
Next
|
|
Else
|
|
Log("No hay productos fijos para guardar.")
|
|
End If
|
|
|
|
If variablesRequeridas1 > 0 Then
|
|
Log("Guardando productos variables (Grupo 1)...")
|
|
For i = 0 To pnlSecundario2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario2.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValue.Text.As(Int)
|
|
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Log(">>>>>>> ESTE DEBE SER EL ID DEL PRODUCTO:" & lblNombre.tag)
|
|
Private idProducto As String = lblNombre.tag
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
|
|
If cantidad > 0 Then
|
|
Log($"Guardando producto variable (Grupo 1): ${nombreProducto}, Cantidad: ${cantidad}, Precio: ${precioProducto}"$)
|
|
Subs.guardaProductoSinGestion(estaPromo, precioProducto, cantidad, nomProd(0), idProducto, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
End If
|
|
Next
|
|
Else
|
|
Log("No hay productos variables (Grupo 1) para guardar.")
|
|
End If
|
|
|
|
If variablesRequeridas2 > 0 Then
|
|
Log("Guardando productos variables (Grupo 2)...")
|
|
For i = 0 To pnlSecundario3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario3.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValue.Text.As(Int)
|
|
' Dim idProducto As String = pnlProducto.Tag
|
|
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Private idProducto As String = lblNombre.tag
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
|
|
If cantidad > 0 Then
|
|
Log($"Guardando producto variable (Grupo 2): ${nombreProducto}, Cantidad: ${cantidad}, Precio: ${precioProducto}"$)
|
|
Subs.guardaProductoSinGestion(estaPromo, precioProducto, cantidad, nomProd(0), idProducto, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
End If
|
|
Next
|
|
Else
|
|
Log("No hay productos variables (Grupo 2) para guardar.")
|
|
End If
|
|
|
|
If variablesRequeridas3 > 0 Then
|
|
Log("Guardando productos variables (Grupo 3)...")
|
|
For i = 0 To pnlSecundario4.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario4.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValue.Text.As(Int)
|
|
' Dim idProducto As String = pnlProducto.Tag
|
|
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
Private idProducto As String = lblNombre.tag
|
|
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
|
|
If cantidad > 0 Then
|
|
Log($"Guardando producto variable (Grupo 3): ${nombreProducto}, Cantidad: ${cantidad}, Precio: ${precioProducto}"$)
|
|
Subs.guardaProductoSinGestion(estaPromo, precioProducto, cantidad, nomProd(0), idProducto, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
End If
|
|
Next
|
|
Else
|
|
Log("No hay productos variables (Grupo 3) para guardar.")
|
|
End If
|
|
|
|
Log("Marcando bTerminarClicked como True...")
|
|
B4XPages.MainPage.bTerminarClicked = True
|
|
|
|
Log("Navegando a la página de productos...")
|
|
B4XPages.ShowPage("productos")
|
|
|
|
Log("Ejecutando b_terminar1_Click en la página de productos...")
|
|
B4XPages.MainPage.productos.b_terminar1_Click
|
|
|
|
Log("btnGuardaPromo_Click finalizado.")
|
|
End Sub
|
|
|
|
Private Sub btnContinuar_Click
|
|
Log("Iniciando btnContinuar_Click...")
|
|
'Guardamos Encabezado
|
|
Subs.guardaProductoSinGestion(Encabezado, 0, lblSumPromo.Text, Encabezado, Encabezado, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
' Guardar productos fijos (si existen)
|
|
If productosFijos > 0 Then
|
|
For i = 0 To pnlSecundario1.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario1.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim cantidad As Int = productosFijos
|
|
' Dim idProducto As String = pnlProducto.Tag
|
|
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
Private idProducto As String = lblNombre.tag
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
Subs.guardaProductoSinGestion(estaPromo, precioProducto, cantidad, nomProd(0), idProducto, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
Next
|
|
Else
|
|
Log("No hay productos fijos para guardar.")
|
|
End If
|
|
|
|
If variablesRequeridas1 > 0 Then
|
|
For i = 0 To pnlSecundario2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario2.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValue.Text.As(Int)
|
|
' Dim idProducto As String = pnlProducto.Tag
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
Private idProducto As String = lblNombre.tag
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
If cantidad > 0 Then
|
|
Subs.guardaProductoSinGestion(estaPromo, precioProducto, cantidad, nomProd(0), idProducto, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
End If
|
|
Next
|
|
Else
|
|
Log("No hay productos variables (Grupo 1) para guardar.")
|
|
End If
|
|
|
|
If variablesRequeridas2 > 0 Then
|
|
For i = 0 To pnlSecundario3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario3.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValue.Text.As(Int)
|
|
' Dim idProducto As String = pnlProducto.Tag
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
Private idProducto As String = lblNombre.tag
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
If cantidad > 0 Then
|
|
Subs.guardaProductoSinGestion(estaPromo, precioProducto, cantidad, nomProd(0), idProducto, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
End If
|
|
Next
|
|
Else
|
|
Log("No hay productos variables (Grupo 2) para guardar.")
|
|
End If
|
|
|
|
If variablesRequeridas3 > 0 Then
|
|
For i = 0 To pnlSecundario4.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario4.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValue.Text.As(Int)
|
|
' Dim idProducto As String = pnlProducto.Tag
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
Private idProducto As String = lblNombre.tag
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
If cantidad > 0 Then
|
|
Subs.guardaProductoSinGestion(estaPromo, precioProducto, cantidad, nomProd(0), idProducto, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
End If
|
|
Next
|
|
Else
|
|
Log("No hay productos variables (Grupo 3) para guardar.")
|
|
End If
|
|
|
|
Private prodspage As C_Productos
|
|
If prodspage.IsInitialized Then
|
|
prodspage.lv_catalogos.Visible = True
|
|
prodspage.lv_promos.Visible = False
|
|
prodspage.clv_productos.AsView.Visible = False
|
|
End If
|
|
B4XPages.MainPage.bTerminarClicked = True
|
|
B4XPages.ShowPage("productos")
|
|
|
|
Log("btnContinuar_Click finalizado.")
|
|
End Sub
|
|
|
|
Private Sub ActualizarVisibilidadBtnGuardaPromo
|
|
Dim condicionesCumplidas As Boolean = VerificarCondicionesParabtnGuardaPromo
|
|
|
|
If condicionesCumplidas Then
|
|
btnGuardaPromo.Visible = True
|
|
btnGuardaPromo.Enabled = True
|
|
btnContinuar.Visible = True
|
|
btnContinuar.Enabled = True
|
|
Else
|
|
btnGuardaPromo.Visible = False
|
|
btnGuardaPromo.Enabled = False
|
|
btnContinuar.Visible = False
|
|
btnContinuar.Enabled = False
|
|
End If
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub VerificarCondicionesParabtnGuardaPromo As Boolean
|
|
|
|
Dim hayProductosFijos As Boolean = (productosFijos > 0)
|
|
|
|
Dim hayVar1 As Boolean = (variablesRequeridas1 > 0)
|
|
Dim hayVar2 As Boolean = (variablesRequeridas2 > 0)
|
|
Dim hayVar3 As Boolean = (variablesRequeridas3 > 0)
|
|
|
|
If Not(hayProductosFijos) And Not(hayVar1) And Not(hayVar2) And Not(hayVar3) Then
|
|
Log("No hay valores mayores a 0, no se muestra el botón.")
|
|
Return False
|
|
End If
|
|
|
|
If hayVar1 Or hayVar2 Or hayVar3 Then
|
|
Dim condicionVar1 As Boolean = True
|
|
Dim condicionVar2 As Boolean = True
|
|
Dim condicionVar3 As Boolean = True
|
|
|
|
If hayVar1 Then
|
|
condicionVar1 = (sumaVar1Tot = variablesRequeridas1)
|
|
Log("Condición Var1: " & condicionVar1)
|
|
End If
|
|
|
|
If hayVar2 Then
|
|
condicionVar2 = (sumaVar2Tot = variablesRequeridas2)
|
|
Log("Condición Var2: " & condicionVar2)
|
|
End If
|
|
|
|
If hayVar3 Then
|
|
condicionVar3 = (sumaVar3Tot = variablesRequeridas3)
|
|
Log("Condición Var3: " & condicionVar3)
|
|
End If
|
|
|
|
If condicionVar1 And condicionVar2 And condicionVar3 Then
|
|
Log("Todas las condiciones de variables requeridas se cumplen, se muestra el botón.")
|
|
Return True
|
|
Else
|
|
Log("No se cumplen todas las condiciones de variables requeridas, no se muestra el botón.")
|
|
Return False
|
|
End If
|
|
End If
|
|
|
|
If hayProductosFijos Then
|
|
' Log("Hay productos fijos y no hay variables requeridas, se muestra el botón.")
|
|
Return True
|
|
End If
|
|
|
|
Log("No hay valores mayores a 0, no se muestra el botón.")
|
|
Return False
|
|
End Sub
|
|
|
|
Private Sub SumarValoresLblValue As Int
|
|
Dim total As Int = 0
|
|
|
|
If pnlSecundario1.IsInitialized Then
|
|
total = total + productosFijos
|
|
End If
|
|
|
|
If pnlSecundario2.IsInitialized Then
|
|
For i = 0 To pnlSecundario2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario2.GetView(i)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
total = total + lblValue.Text.As(Int)
|
|
Next
|
|
End If
|
|
|
|
If pnlSecundario3.IsInitialized Then
|
|
For i = 0 To pnlSecundario3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario3.GetView(i)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
total = total + lblValue.Text.As(Int)
|
|
Next
|
|
End If
|
|
|
|
If pnlSecundario4.IsInitialized Then
|
|
For i = 0 To pnlSecundario4.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario4.GetView(i)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
total = total + lblValue.Text.As(Int)
|
|
Next
|
|
End If
|
|
|
|
Return total
|
|
End Sub
|
|
|
|
Private Sub CalcularTotalValor As Float
|
|
Dim total As Float = 0
|
|
|
|
If pnlSecundario1.IsInitialized And productosFijos > 0 Then
|
|
For i = 0 To pnlSecundario1.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario1.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
|
|
total = total + (precioProducto * productosFijos)
|
|
Next
|
|
End If
|
|
|
|
If pnlSecundario2.IsInitialized Then
|
|
For i = 0 To pnlSecundario2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario2.GetView(i)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValue.Text.As(Int)
|
|
If cantidad > 0 Then
|
|
total = total + (pnlProducto.Tag.As(Float) * cantidad)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If pnlSecundario3.IsInitialized Then
|
|
For i = 0 To pnlSecundario3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario3.GetView(i)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValue.Text.As(Int)
|
|
If cantidad > 0 Then
|
|
total = total + (pnlProducto.Tag.As(Float) * cantidad)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If pnlSecundario4.IsInitialized Then
|
|
For i = 0 To pnlSecundario4.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlSecundario4.GetView(i)
|
|
Dim lblValue As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValue.Text.As(Int)
|
|
If cantidad > 0 Then
|
|
total = total + (pnlProducto.Tag.As(Float) * cantidad)
|
|
End If
|
|
Next
|
|
End If
|
|
Return total
|
|
End Sub
|
|
|
|
Private Sub ActualizarTotalValor
|
|
Dim total As Float = CalcularTotalValor
|
|
lblTotalValor.Text = NumberFormat(total, 1, 2)
|
|
End Sub
|
|
|