mirror of
https://github.com/KeymonSoft/Intmex_Multiventa.git
synced 2026-04-17 12:56:08 +00:00
1841 lines
66 KiB
QBasic
1841 lines
66 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 lblFijosRequeridos As Label
|
|
Private lblVariablesRequeridas1 As Label
|
|
Private lblVariablesRequeridas2 As Label
|
|
Private lblVariablesRequeridas3 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 pnlFijos As Panel
|
|
Private pnlVariables1 As Panel
|
|
Private pnlVariables2 As Panel
|
|
Private pnlVariables3 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
|
|
' Dim etVar1HasFocus As Boolean = False
|
|
' Dim etVar2HasFocus As Boolean = False
|
|
' Dim etVar3HasFocus As Boolean = False
|
|
|
|
' Dim lblNombre As Label
|
|
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)
|
|
|
|
lblFijosRequeridos.Initialize("lblFijosRequeridos")
|
|
lblFijosRequeridos.TextColor = xui.Color_Black
|
|
lblFijosRequeridos.TextSize = 12
|
|
lblFijosRequeridos.Color = xui.Color_LightGray
|
|
lblFijosRequeridos.Gravity = Gravity.CENTER
|
|
lblFijosRequeridos.SingleLine = True
|
|
|
|
pnlFijos.Initialize("pnlFijos")
|
|
pnlContainer.AddView(pnlFijos, 5dip, lblFijosRequeridos.Top + lblFijosRequeridos.Height + 10dip, pnlContainer.Width - 10dip, 100dip)
|
|
pnlFijos.Color = xui.Color_White
|
|
pnlFijos.Tag = "pnlFijos"
|
|
|
|
lblVariablesRequeridas1.Initialize("lblVariablesRequeridas1")
|
|
lblVariablesRequeridas1.TextColor = xui.Color_Black
|
|
lblVariablesRequeridas1.TextSize = 12
|
|
lblVariablesRequeridas1.Color = xui.Color_LightGray
|
|
lblVariablesRequeridas1.Gravity = Gravity.CENTER
|
|
lblVariablesRequeridas1.SingleLine = True
|
|
|
|
pnlVariables1.Initialize("pnlVariables1")
|
|
pnlContainer.AddView(pnlVariables1, 5dip, lblVariablesRequeridas1.Top + lblVariablesRequeridas1.Height + 10dip, pnlContainer.Width - 10dip, 100dip)
|
|
pnlVariables1.Color = xui.Color_White
|
|
pnlVariables1.Tag = "pnlVariables1"
|
|
|
|
lblVariablesRequeridas2.Initialize("lblVariablesRequeridas2")
|
|
lblVariablesRequeridas2.TextSize = 12
|
|
lblVariablesRequeridas2.Color = xui.Color_LightGray
|
|
lblVariablesRequeridas2.Gravity = Gravity.CENTER
|
|
lblVariablesRequeridas2.TextColor = xui.Color_Black
|
|
lblVariablesRequeridas2.SingleLine = True
|
|
|
|
pnlVariables2.Initialize("pnlVariables2")
|
|
pnlContainer.AddView(pnlVariables2, 5dip, lblVariablesRequeridas2.Top + lblVariablesRequeridas2.Height + 10dip, pnlContainer.Width - 10dip, 100dip)
|
|
pnlVariables2.Color = xui.Color_White
|
|
pnlVariables2.Tag = "pnlVariables2"
|
|
|
|
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 ancholblFijosRequeridos As Int = anchoTotal * 0.65
|
|
Dim anchoEtLimiteSuma As Int = anchoTotal - ancholblFijosRequeridos
|
|
|
|
pnlContainer.AddView(lblFijosRequeridos, 10dip, 10dip, ancholblFijosRequeridos, 50dip)
|
|
pnlContainer.AddView(etLimiteSuma_Sub_pnl1, lblFijosRequeridos.Left + lblFijosRequeridos.Width + 10dip, 10dip, anchoEtLimiteSuma, 50dip)
|
|
|
|
pnlContainer.AddView(lblVariablesRequeridas1, 10dip, lblFijosRequeridos.Top + lblFijosRequeridos.Height + 10dip, ancholblFijosRequeridos, 50dip)
|
|
pnlContainer.AddView(etLimiteSuma_Sub_pnl2, lblVariablesRequeridas1.Left + lblVariablesRequeridas1.Width + 10dip, lblVariablesRequeridas1.Top, anchoEtLimiteSuma, 50dip)
|
|
|
|
pnlContainer.AddView(lblVariablesRequeridas2, 10dip, lblVariablesRequeridas1.Top + lblVariablesRequeridas1.Height + 10dip, ancholblFijosRequeridos, 50dip)
|
|
pnlContainer.AddView(etLimiteSuma_Sub_pnl3, lblVariablesRequeridas2.Left + lblVariablesRequeridas2.Width + 10dip, lblVariablesRequeridas2.Top, anchoEtLimiteSuma, 50dip)
|
|
|
|
lblVariablesRequeridas3.Initialize("lblVariablesRequeridas3")
|
|
lblVariablesRequeridas3.TextSize = 12
|
|
lblVariablesRequeridas3.Color = xui.Color_LightGray
|
|
lblVariablesRequeridas3.Gravity = Gravity.CENTER
|
|
lblVariablesRequeridas3.TextColor = xui.Color_Black
|
|
lblVariablesRequeridas3.SingleLine = True
|
|
|
|
etLimiteSuma_Sub_pnl4.Initialize("etLimiteSuma_Sub_pnl4")
|
|
etLimiteSuma_Sub_pnl4.TextColor = xui.Color_Black
|
|
etLimiteSuma_Sub_pnl4.SingleLine = True
|
|
|
|
pnlVariables3.Initialize("pnlVariables3")
|
|
pnlContainer.AddView(pnlVariables3, 5dip, lblVariablesRequeridas3.Top + lblVariablesRequeridas3.Height + 10dip, pnlContainer.Width - 10dip, 100dip)
|
|
pnlVariables3.Color = xui.Color_White
|
|
pnlVariables3.Tag = "pnlVariables3"
|
|
|
|
pnlContainer.AddView(lblVariablesRequeridas3, 10dip, lblVariablesRequeridas2.Top + lblVariablesRequeridas2.Height + 10dip, ancholblFijosRequeridos, 50dip)
|
|
pnlContainer.AddView(etLimiteSuma_Sub_pnl4, lblVariablesRequeridas3.Left + lblVariablesRequeridas3.Width + 10dip, lblVariablesRequeridas3.Top, anchoEtLimiteSuma, 50dip)
|
|
|
|
If VerificarCondicionesParabtnGuardaPromo Then
|
|
btnGuardaPromo.Visible = True
|
|
Else
|
|
btnGuardaPromo.Visible = False
|
|
End If
|
|
B4XPage_Appear
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub B4XPage_Appear
|
|
lblFijosRequeridos.Text = "0"
|
|
lblVariablesRequeridas1.Text = "0"
|
|
lblVariablesRequeridas2.Text = "0"
|
|
lblVariablesRequeridas3.Text = "0"
|
|
|
|
lblSumaTotal.Text = "0"
|
|
|
|
productosFijos = 0
|
|
variablesRequeridas1= 0
|
|
variablesRequeridas2= 0
|
|
variablesRequeridas3= 0
|
|
|
|
sumaVar1Tot = 0
|
|
sumaVar2Tot = 0
|
|
sumaVar3Tot = 0
|
|
|
|
If pnlFijos.IsInitialized Then pnlFijos.RemoveAllViews
|
|
If pnlVariables1.IsInitialized Then pnlVariables1.RemoveAllViews
|
|
If pnlVariables2.IsInitialized Then pnlVariables2.RemoveAllViews
|
|
If pnlVariables3.IsInitialized Then pnlVariables3.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
|
|
CalcularTotalVariables
|
|
CalcularTotalFijos
|
|
|
|
lblSumaTotal.Text = SumarFijos + SumarVariables1 +SumarVariables2 + SumarVariables3
|
|
|
|
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
|
|
lblFijosRequeridos.Visible = False
|
|
etLimiteSuma_Sub_pnl1.Visible = False
|
|
pnlFijos.Visible = False
|
|
End If
|
|
Else
|
|
productosFijos = 0
|
|
End If
|
|
productosFijos_Iniciales = productosFijos
|
|
End Sub
|
|
|
|
Private Sub ObtenerVariablesRequeridas(promo As String)
|
|
Log("Esto es promo: " & promo)
|
|
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}' ORDER BY CAT_GP_NOMBRE"$)
|
|
|
|
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
|
|
lblVariablesRequeridas1.Visible = False
|
|
etLimiteSuma_Sub_pnl2.Visible = False
|
|
pnlVariables1.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
|
|
lblVariablesRequeridas2.Visible = False
|
|
etLimiteSuma_Sub_pnl3.Visible = False
|
|
pnlVariables2.Visible = False
|
|
End If
|
|
|
|
If cursorVariablesReq.GetInt("CAT_GP_VARREQ3") <> 0 And cursorVariablesReq.GetString("CAT_GP_VARREQ3") <> " " Then
|
|
variablesRequeridas3 = cursorVariablesReq.GetInt("CAT_GP_VARREQ3")
|
|
lblVariablesRequeridas3.Visible = True
|
|
etLimiteSuma_Sub_pnl4.Visible = True
|
|
pnlVariables3.Visible = True
|
|
Else
|
|
lblVariablesRequeridas3.Visible = False
|
|
etLimiteSuma_Sub_pnl4.Visible = False
|
|
pnlVariables3.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
|
|
Log("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" & estaPromo & "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
|
|
esteCliente = cliente
|
|
Private mp As Map = Subs.traePromo(promo, cliente)
|
|
|
|
Log("Esto es el minimo? <<<<<<<<" & Subs.MaxPromQuery(promo))
|
|
|
|
lblMaxPromo.Text = Subs.MaxPromQuery(promo)
|
|
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 pnlFijos.IsInitialized Then pnlFijos.RemoveAllViews
|
|
If pnlVariables1.IsInitialized Then pnlVariables1.RemoveAllViews
|
|
If pnlVariables2.IsInitialized Then pnlVariables2.RemoveAllViews
|
|
If pnlVariables3.IsInitialized Then pnlVariables3.RemoveAllViews
|
|
|
|
Dim nombrePromo As String = lblNomPromo.Text
|
|
Dim nomPromo() As String = Regex.Split("\r\n|\n", nombrePromo)
|
|
Log("Esto es nombre promo? <<<<<<<<<<<|" & nomPromo(1) & "|")
|
|
Encabezado = nomPromo(1)
|
|
Log("Esto es encabezado? |" & Encabezado)
|
|
|
|
' Dim promoText As String = lblNomPromo.Text.Trim()
|
|
' Dim idPromo() As String = Regex.Split(":", promoText)
|
|
' Log("Esto es idPromo? | <<<<<<<<<<<<<<<<<<|" & idPromo(1).Trim() & "|")
|
|
|
|
If productosFijos > 0 Then
|
|
pnlFijos.Visible = True
|
|
lblFijosRequeridos.Visible = True
|
|
|
|
Private pzs2 As Cursor = Starter.skmt.ExecQuery($"select sum(CAT_DP_PZAS) as suma from cat_detalles_paq where cat_dp_tipo = '0' and cat_dp_id = '${estaPromo}'"$)
|
|
If pzs2.RowCount > 0 Then
|
|
' For i = 0 To pzs2.RowCount - 1
|
|
pzs2.Position = 0
|
|
Log(pzs2.GetString("suma"))
|
|
' totalCant = totalCant + pzs2.GetString("CAT_DP_PZAS")
|
|
' Log(totalCant)
|
|
' Next
|
|
End If
|
|
lblFijosRequeridos.Text = "Productos fijos: " & (pzs2.GetString("suma") * lblSumPromo.Text)
|
|
Log("Aqui deberia mostrar la cantidad de fijos: " & pzs2.GetString("suma"))
|
|
|
|
lblFijosRequeridos.Left = 0
|
|
lblFijosRequeridos.Width = Root.Width
|
|
Dim cursorProdFijo As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_GP_NOMBRE, CAT_DP_PZAS, 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 order BY CAT_GP_NOMBRE"$)
|
|
If cursorProdFijo.RowCount > 0 Then
|
|
For i = 0 To cursorProdFijo.RowCount - 1
|
|
cursorProdFijo.Position = i
|
|
GenerarFijos(cursorProdFijo.GetString("CAT_GP_NOMBRE"), cursorProdFijo.GetString("CAT_DP_PZAS"), cursorProdFijo.GetString("CAT_DP_PRECIO"), cursorProdFijo.GetString("CAT_DP_IDPROD"), i, promo)
|
|
Next
|
|
End If
|
|
Else
|
|
pnlFijos.Visible = False
|
|
lblFijosRequeridos.Text = $"No hay productos Fijos"$
|
|
lblFijosRequeridos.Visible = False
|
|
End If
|
|
|
|
If variablesRequeridas1 > 0 Then
|
|
pnlVariables1.Visible = True
|
|
lblVariablesRequeridas1.Visible = True
|
|
lblVariablesRequeridas1.Text = $"Primeros Variables Requeridos: '${variablesRequeridas1}'"$
|
|
lblVariablesRequeridas1.Left = 0
|
|
lblVariablesRequeridas1.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 ORDER BY CAT_GP_NOMBRE "$)
|
|
If cursorNomProductosVar1.RowCount > 0 Then
|
|
For i = 0 To cursorNomProductosVar1.RowCount - 1
|
|
cursorNomProductosVar1.Position = i
|
|
GenerarVariables1(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
|
|
pnlVariables1.Visible = False
|
|
lblVariablesRequeridas1.Visible = False
|
|
End If
|
|
|
|
If variablesRequeridas2 > 0 Then
|
|
pnlVariables2.Visible = True
|
|
lblVariablesRequeridas2.Visible = True
|
|
lblVariablesRequeridas2.Text = $"Segundos Variables Requeridos: '${variablesRequeridas2}'"$
|
|
lblVariablesRequeridas2.Left = 0
|
|
lblVariablesRequeridas2.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 ORDER BY CAT_GP_NOMBRE "$)
|
|
If cursorNomProductosVar2.RowCount > 0 Then
|
|
For i = 0 To cursorNomProductosVar2.RowCount - 1
|
|
cursorNomProductosVar2.Position = i
|
|
GenerarVariables2(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
|
|
pnlVariables2.Visible = False
|
|
lblVariablesRequeridas2.Visible = False
|
|
End If
|
|
|
|
If variablesRequeridas3 > 0 Then
|
|
pnlVariables3.Visible = True
|
|
lblVariablesRequeridas3.Visible = True
|
|
lblVariablesRequeridas3.Text = $"Tercer Variables Requeridas: '${variablesRequeridas3}'"$
|
|
lblVariablesRequeridas3.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 ORDER BY CAT_GP_NOMBRE "$)
|
|
If cursorNomProductosVar3.RowCount > 0 Then
|
|
For i = 0 To cursorNomProductosVar3.RowCount - 1
|
|
cursorNomProductosVar3.Position = i
|
|
GenerarVariables3(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
|
|
pnlVariables3.Visible = False
|
|
lblVariablesRequeridas3.Visible = False
|
|
End If
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub btnMenosPromo_Click
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = False
|
|
|
|
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
|
|
|
|
sumaVar1Tot = 0
|
|
sumaVar2Tot = 0
|
|
sumaVar3Tot = 0
|
|
|
|
If pnlVariables1.IsInitialized Then
|
|
For i = 0 To pnlVariables1.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables1.GetView(i)
|
|
Dim lblValueVar1 As Label = pnlProducto.GetView(2)
|
|
lblValueVar1.Text = "0"
|
|
Next
|
|
End If
|
|
|
|
If pnlVariables2.IsInitialized Then
|
|
For i = 0 To pnlVariables2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables2.GetView(i)
|
|
Dim lblValueVar2 As Label = pnlProducto.GetView(2)
|
|
lblValueVar2.Text = "0"
|
|
Next
|
|
End If
|
|
|
|
If pnlVariables3.IsInitialized Then
|
|
For i = 0 To pnlVariables3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables3.GetView(i)
|
|
Dim lblValueVar3 As Label = pnlProducto.GetView(2)
|
|
lblValueVar3.Text = "0"
|
|
Next
|
|
End If
|
|
|
|
' Obtener la suma de productos fijos y multiplicar por currentValue
|
|
Private pzs2 As Cursor = Starter.skmt.ExecQuery($"select sum(CAT_DP_PZAS) as suma from cat_detalles_paq where cat_dp_tipo = '0' and cat_dp_id = '${estaPromo}'"$)
|
|
If pzs2.RowCount > 0 Then
|
|
pzs2.Position = 0
|
|
Dim sumaPzas As Int = pzs2.GetInt("suma")
|
|
lblFijosRequeridos.Text = "Productos fijos: " & (sumaPzas * currentValue) ' Multiplicar por currentValue
|
|
End If
|
|
|
|
lblVariablesRequeridas1.Text = $"Primeros Variables Requeridos: '${variablesRequeridas1}'"$
|
|
lblVariablesRequeridas2.Text = $"Segundos Variables Requeridos: '${variablesRequeridas2}'"$
|
|
lblVariablesRequeridas3.Text = $"Tercer Variables Requeridas: '${variablesRequeridas3}'"$
|
|
|
|
RecalcularSumas
|
|
Log("Esto recalcula la reta:<<<<<<<<<<<<< " & RecalcularSumas)
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
CalcularTotalVariables
|
|
CalcularTotalFijos
|
|
'Este for hace que la cantidad de la etiqueta de los fijos cambie con el menos
|
|
For i = 0 To pnlFijos.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlFijos.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim cantidad As Int = 0
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
' Log(">>>>>>>>>>>>>Esto es nombre: " & nombreProducto & " <<<<<<<<<<<<<<<")
|
|
' Log("Precio: " & precioProducto)
|
|
' Log("Cantidad: " & cantidad)
|
|
Private idProducto As String = lblNombre.tag
|
|
|
|
Dim cursorProductosFijos As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_DP_PZAS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID = '${estaPromo}' AND CAT_DP_TIPO = '0' and cat_dp_idprod = '${idProducto}'"$)
|
|
If cursorProductosFijos.RowCount > 0 Then
|
|
cursorProductosFijos.Position = 0
|
|
cantidad = cursorProductosFijos.GetString("CAT_DP_PZAS")
|
|
End If
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
' Log("Esto es el nombre del producto? <<<<<<<<<<<<<<<<<<<<<<<|" &nomProd(0) & "|>>>>>>>>>>>>>>>>>>>>><<")
|
|
lblNombre.Text = nomProd(0) & CRLF & "Cant: " & (cantidad * lblSumPromo.Text)& " $" & NumberFormat2(precioProducto,1,2,2,True)
|
|
Next
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub btnSumaPromo_Click
|
|
Log("Aqui entro al clikear")
|
|
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = False
|
|
|
|
Dim currentValue As Int = lblSumPromo.Text.As(Int)
|
|
Dim maxValue As Int = lblMaxPromo.Text.As(Int)
|
|
Log("Esto es MaxValue: " & maxValue & "<<<<<<<<<<<<<<<<<<<<<<")
|
|
Log("Esto es currentValue: " & currentValue)
|
|
Log("Esto es maxValue: " & maxValue)
|
|
Log("Esto es estaPromo: " & estaPromo)
|
|
|
|
If currentValue < maxValue Then
|
|
|
|
Log("Esto es currentValue despues del if: " & currentValue)
|
|
Log("Esto es maxValue despues del if: " & maxValue)
|
|
currentValue = currentValue + 1
|
|
Log("Esto es una suma de mi label?: " & (currentValue))
|
|
End If
|
|
|
|
lblSumPromo.Text = currentValue
|
|
|
|
' Actualizar las variables requeridas
|
|
productosFijos = productosFijos_Iniciales * currentValue
|
|
variablesRequeridas1 = variablesRequeridas1_Inicial * currentValue
|
|
variablesRequeridas2 = variablesRequeridas2_Inicial * currentValue
|
|
variablesRequeridas3 = variablesRequeridas3_Inicial * currentValue
|
|
|
|
' Reiniciar las sumas totales
|
|
sumaVar1Tot = 0
|
|
sumaVar2Tot = 0
|
|
sumaVar3Tot = 0
|
|
|
|
' Forzar la actualización de los EditText
|
|
If pnlVariables1.IsInitialized Then
|
|
For i = 0 To pnlVariables1.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables1.GetView(i)
|
|
Dim lblValueVar1 As Label = pnlProducto.GetView(2)
|
|
lblValueVar1.Text = "0" ' Reiniciar el valor
|
|
Next
|
|
End If
|
|
|
|
If pnlVariables2.IsInitialized Then
|
|
For i = 0 To pnlVariables2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables2.GetView(i)
|
|
Dim lblValueVar2 As Label = pnlProducto.GetView(2)
|
|
lblValueVar2.Text = "0" ' Reiniciar el valor
|
|
Next
|
|
End If
|
|
|
|
If pnlVariables3.IsInitialized Then
|
|
For i = 0 To pnlVariables3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables3.GetView(i)
|
|
Dim lblValueVar3 As Label = pnlProducto.GetView(2)
|
|
lblValueVar3.Text = "0" ' Reiniciar el valor
|
|
Next
|
|
End If
|
|
|
|
' Actualizar las etiquetas
|
|
|
|
' Obtener la suma de productos fijos y multiplicar por currentValue
|
|
Private pzs2 As Cursor = Starter.skmt.ExecQuery($"select sum(CAT_DP_PZAS) as suma from cat_detalles_paq where cat_dp_tipo = '0' and cat_dp_id = '${estaPromo}'"$)
|
|
If pzs2.RowCount > 0 Then
|
|
pzs2.Position = 0
|
|
Dim sumaPzas As Int = pzs2.GetInt("suma")
|
|
lblFijosRequeridos.Text = "Productos fijos: " & (sumaPzas * currentValue) ' Multiplicar por currentValue
|
|
End If
|
|
|
|
lblVariablesRequeridas1.Text = $"Primeros Variables Requeridos: '${variablesRequeridas1}'"$
|
|
lblVariablesRequeridas2.Text = $"Segundos Variables Requeridos: '${variablesRequeridas2}'"$
|
|
lblVariablesRequeridas3.Text = $"Tercer Variables Requeridas: '${variablesRequeridas3}'"$
|
|
'Este for cambia la cantidad en la etiqueta de los fijos
|
|
For i = 0 To pnlFijos.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlFijos.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim cantidad As Int = 0
|
|
Dim lblNombre As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre.Text
|
|
' Log(">>>>>>>>>>>>>Esto es nombre: " & nombreProducto & " <<<<<<<<<<<<<<<")
|
|
' Log("Precio: " & precioProducto)
|
|
' Log("Cantidad: " & cantidad)
|
|
Private idProducto As String = lblNombre.tag
|
|
|
|
Dim cursorProductosFijos As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_DP_PZAS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID = '${estaPromo}' AND CAT_DP_TIPO = '0' and cat_dp_idprod = '${idProducto}'"$)
|
|
If cursorProductosFijos.RowCount > 0 Then
|
|
cursorProductosFijos.Position = 0
|
|
cantidad = cursorProductosFijos.GetString("CAT_DP_PZAS")
|
|
End If
|
|
Dim nomProd() As String = Regex.Split("\r\n|\n", nombreProducto)
|
|
' Log("Esto es el nombre del producto? <<<<<<<<<<<<<<<<<<<<<<<|" &nomProd(0) & "|>>>>>>>>>>>>>>>>>>>>><<")
|
|
lblNombre.Text = nomProd(0) & CRLF & "Cant: " & (cantidad * lblSumPromo.Text)& " $" & NumberFormat2(precioProducto,1,2,2,True)
|
|
Next
|
|
|
|
' Recalcular sumas y actualizar la interfaz
|
|
RecalcularSumas
|
|
Log("Esto recalcula la suma:<<<<<<<<<<<<< " & RecalcularSumas)
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
CalcularTotalVariables
|
|
CalcularTotalFijos
|
|
End Sub
|
|
|
|
Private Sub btnVars1Mas_Click
|
|
' Dim totalVar1 As Int = 0
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = False
|
|
Log("Iniciamos boton mas")
|
|
Log("Variables requeridas = " & variablesRequeridas1)
|
|
Log(sumaVar1Tot.As(Int) > variablesRequeridas1.As(Int))
|
|
If sumaVar1Tot.As(Int) >= variablesRequeridas1.As(Int) Then
|
|
Log("Entramos al primer if")
|
|
ToastMessageShow("No se pueden agregar más productos, ya se alcanzó el máximo.", True)
|
|
Return
|
|
End If
|
|
Log("Termiamos boton mas")
|
|
sumaVar1Tot = SumarVariables1
|
|
|
|
Dim pnlProducto As Panel = Sender.As(View).Parent
|
|
Dim lblValueVar1 As Label = pnlProducto.GetView(2)
|
|
Dim currentValue As Int = lblValueVar1.Text.As(Int)
|
|
|
|
currentValue = currentValue + 1
|
|
lblValueVar1.Text = currentValue
|
|
sumaVar1Tot = sumaVar1Tot + 1
|
|
|
|
RecalcularSumas
|
|
End Sub
|
|
|
|
Private Sub btnVars1Menos_Click
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = False
|
|
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
|
|
|
|
RecalcularSumas
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnVars2Mas_Click
|
|
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = False
|
|
|
|
If sumaVar2Tot >= variablesRequeridas2 Then
|
|
ToastMessageShow("No se pueden agregar más productos, ya se alcanzó el máximo.", True)
|
|
Return
|
|
End If
|
|
|
|
Dim pnlProducto As Panel = Sender.As(View).Parent
|
|
Dim lblValueVar2 As Label = pnlProducto.GetView(2)
|
|
Dim currentValue As Int = lblValueVar2.Text.As(Int)
|
|
|
|
currentValue = currentValue + 1
|
|
lblValueVar2.Text = currentValue
|
|
sumaVar2Tot = sumaVar2Tot + 1
|
|
|
|
RecalcularSumas
|
|
End Sub
|
|
|
|
Private Sub btnVars2Menos_Click
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = False
|
|
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
|
|
|
|
RecalcularSumas
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnVars3Mas_Click
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = False
|
|
|
|
If sumaVar3Tot >= variablesRequeridas3 Then
|
|
ToastMessageShow("No se pueden agregar más productos, ya se alcanzó el máximo.", True)
|
|
Return
|
|
End If
|
|
|
|
Dim pnlProducto As Panel = Sender.As(View).Parent
|
|
Dim lblValueVar3 As Label = pnlProducto.GetView(2)
|
|
Dim currentValue As Int = lblValueVar3.Text.As(Int)
|
|
|
|
currentValue = currentValue + 1
|
|
lblValueVar3.Text = currentValue
|
|
sumaVar3Tot = sumaVar3Tot + 1
|
|
|
|
RecalcularSumas
|
|
End Sub
|
|
|
|
Private Sub btnVars3Menos_Click
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = False
|
|
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
|
|
|
|
RecalcularSumas
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GenerarFijos(nombreProd As String, inventario As String, precio As String, idProducto As String, numberOfViews As Int, estaPromoA As String)
|
|
If Not(pnlFijos.IsInitialized) Then
|
|
Return
|
|
End If
|
|
|
|
Log($"${idProducto}, ${nombreProd}, ${inventario}, ${precio}"$)
|
|
|
|
Private estePrecio As String = precio
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto.Initialize("pnlProducto")
|
|
pnlProducto.SetLayout(0, 0, pnlFijos.Width, 70dip)
|
|
|
|
Private estePrecio As String = precio
|
|
Private cantidad As Int = 0
|
|
|
|
Private pzs As Cursor = Starter.skmt.ExecQuery($"select CAT_DP_PZAS from cat_detalles_paq where cat_dp_idprod = '${idProducto}' and cat_dp_id = '${estaPromoA}'"$)
|
|
If pzs.RowCount > 0 Then
|
|
pzs.Position = 0
|
|
Log("============================== " & pzs.GetString("CAT_DP_PZAS"))
|
|
cantidad = pzs.GetString("CAT_DP_PZAS") * lblSumPromo.Text.As(Int) ' Multiplicamos por el número de promos
|
|
End If
|
|
|
|
Dim lblNombre As Label
|
|
lblNombre.Initialize("lblNombre")
|
|
|
|
lblNombre.Text = nombreProd & CRLF & "Cant: " & (cantidad * lblSumPromo.Text)& " $" & 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
|
|
|
|
pnlFijos.AddView(pnlProducto, 0, numberOfViews * 70dip, pnlFijos.Width, 70dip)
|
|
pnlFijos.Height = (numberOfViews * 70dip) + 70dip
|
|
|
|
' Private totalCant As Int = 0
|
|
Private pzs2 As Cursor = Starter.skmt.ExecQuery($"select sum(CAT_DP_PZAS) as suma from cat_detalles_paq where cat_dp_tipo = '0' and cat_dp_id = '${estaPromoA}'"$)
|
|
If pzs2.RowCount > 0 Then
|
|
' For i = 0 To pzs2.RowCount - 1
|
|
pzs2.Position = 0
|
|
Log(pzs2.GetString("suma"))
|
|
' totalCant = totalCant + pzs2.GetString("CAT_DP_PZAS")
|
|
' Log(totalCant)
|
|
' Next
|
|
End If
|
|
lblFijosRequeridos.Text = "Productos fijos: " & (pzs2.GetString("suma") * lblSumPromo.Text)
|
|
SumarFijos
|
|
pzs.Close
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub GenerarVariables1(nombreProd As String, inventario As String, precio As String, idProducto As String, numberOfViews As Int)
|
|
If Not(pnlVariables1.IsInitialized) Then Return
|
|
|
|
Private estePrecio As String = precio
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto.Initialize("pnlProducto")
|
|
pnlProducto.SetLayout(0, 0, pnlVariables1.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 lblValueVar1 As Label
|
|
lblValueVar1.Initialize("lblValueVar1") ' Asignar el evento TextChanged aquí
|
|
' lblValueVar1.InputType = lblValueVar1.INPUT_TYPE_NUMBERS
|
|
' lblValueVar1.Hint = "0"
|
|
lblValueVar1.Text = "0"
|
|
lblValueVar1.TextColor = xui.Color_Black
|
|
lblValueVar1.Gravity = Gravity.CENTER
|
|
lblValueVar1.TextSize = 12
|
|
lblValueVar1.Tag = pnlProducto ' Asignar el panel como tag
|
|
pnlProducto.AddView(lblValueVar1, 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, lblValueVar1.Left + lblValueVar1.Width + spacing, 10dip, btnWidth, pnlProducto.Height - 10dip)
|
|
|
|
pnlProducto.Tag = estePrecio
|
|
|
|
pnlVariables1.AddView(pnlProducto, 0, numberOfViews * 70dip, pnlVariables1.Width, 70dip)
|
|
pnlVariables1.Height = (numberOfViews * 70dip) + 70dip
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub GenerarVariables2(nombreProd As String, inventario As String, precio As String, idProducto As String, numberOfViews As Int)
|
|
If Not(pnlVariables2.IsInitialized) Then Return
|
|
|
|
Private estePrecio As String = precio
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto.Initialize("pnlProducto")
|
|
pnlProducto.SetLayout(0, 0, pnlVariables2.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 lblValueVar2 As Label
|
|
lblValueVar2.Initialize("lblValueVar2")
|
|
' lblValueVar2.InputType = lblValueVar2.INPUT_TYPE_NUMBERS
|
|
' lblValueVar2.Hint = "0"
|
|
lblValueVar2.Text = "0"
|
|
lblValueVar2.TextColor = xui.Color_Black
|
|
lblValueVar2.Gravity = Gravity.CENTER
|
|
lblValueVar2.TextSize = 12
|
|
lblValueVar2.Tag = pnlProducto
|
|
pnlProducto.AddView(lblValueVar2, 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, lblValueVar2.Left + lblValueVar2.Width + spacing, 10dip, btnWidth, pnlProducto.Height - 10dip)
|
|
|
|
pnlProducto.Tag = estePrecio
|
|
|
|
pnlVariables2.AddView(pnlProducto, 0, numberOfViews * 70dip, pnlVariables2.Width, 70dip)
|
|
pnlVariables2.Height = (numberOfViews * 70dip) + 70dip
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
Private Sub GenerarVariables3(nombreProd As String, inventario As String, precio As String, idProducto As String, numberOfViews As Int)
|
|
If Not(pnlVariables3.IsInitialized) Then Return
|
|
|
|
Private estePrecio As String = precio
|
|
|
|
Dim pnlProducto As Panel
|
|
pnlProducto.Initialize("pnlProducto")
|
|
pnlProducto.SetLayout(0, 0, pnlVariables3.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 lblValueVar3 As Label
|
|
lblValueVar3.Initialize("lblValueVar3")
|
|
' lblValueVar3.InputType = lblValueVar3.INPUT_TYPE_NUMBERS
|
|
' lblValueVar3.Hint = "0"
|
|
lblValueVar3.Text = "0"
|
|
lblValueVar3.TextColor = xui.Color_Black
|
|
lblValueVar3.Gravity = Gravity.CENTER
|
|
lblValueVar3.TextSize = 12
|
|
lblValueVar3.Tag = pnlProducto
|
|
pnlProducto.AddView(lblValueVar3, 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, lblValueVar3.Left + lblValueVar3.Width + spacing, 10dip, btnWidth, pnlProducto.Height - 10dip)
|
|
|
|
pnlProducto.Tag = estePrecio
|
|
|
|
pnlVariables3.AddView(pnlProducto, 0, numberOfViews * 70dip, pnlVariables3.Width, 70dip)
|
|
pnlVariables3.Height = (numberOfViews * 70dip) + 70dip
|
|
|
|
AjustarScroll
|
|
End Sub
|
|
|
|
'Private Sub lblValueVar1_TextChanged (Old As String, New As String)
|
|
' Dim totalVar1 As Int = 0
|
|
' If New = "" Or New = Null Then New = 0
|
|
' If Old = "" Or Old = Null Then Old = 0
|
|
' If New = "-" Then New = 0
|
|
' etVar1HasFocus = True
|
|
' totalVar1 = SumarVariables1
|
|
' If etVar1HasFocus = True Then
|
|
'' Log("Entramos a 1er If")
|
|
' Dim variablesRequeridas1int As Int = New
|
|
' If New = "" Then
|
|
'' Log("Entramos a 2do If")
|
|
' New = 0
|
|
' End If
|
|
' If New < 0 Then
|
|
'' Log("Entramos a 3er If")
|
|
' New = 0
|
|
' Else
|
|
'' Log("Entramos a else")
|
|
' If totalVar1 <= variablesRequeridas1 Then
|
|
'
|
|
' Else If totalVar1 > variablesRequeridas1 Then
|
|
' variablesRequeridas1int = variablesRequeridas1 - sumaVar1Tot
|
|
' If variablesRequeridas1int < 1 Then variablesRequeridas1int = 0
|
|
'' isProgrammaticChange = True
|
|
' Log("Ponemos valor en tal desde extChanged " & variablesRequeridas1int)
|
|
' Sender.As(EditText).Text = variablesRequeridas1int
|
|
' End If
|
|
' End If
|
|
' sumaVar1Tot = totalVar1
|
|
' RecalcularSumas
|
|
' End If
|
|
'' Log("Salimos")
|
|
'End Sub
|
|
'
|
|
'Private Sub lblValueVar2_TextChanged (Old As String, New As String)
|
|
' If isProgrammaticChange Then
|
|
' isProgrammaticChange = False
|
|
' Return
|
|
' End If
|
|
'
|
|
' Log("---------------------------------")
|
|
' Dim totalVar2 As Int = 0
|
|
'
|
|
' If pnlVariables2.IsInitialized Then
|
|
' For i = 0 To pnlVariables2.NumberOfViews - 1
|
|
' Dim pnlProducto As Panel = pnlVariables2.GetView(i)
|
|
' Dim lblValueVar2 As EditText = pnlProducto.GetView(2)
|
|
' If lblValueVar2.Text = "" Then
|
|
' lblValueVar2.Text = 0
|
|
' End If
|
|
' Log("Esto es total var2Antes : "&totalVar2)
|
|
' Log("Esto es ET2: "&lblValueVar2.Text.As(Int))
|
|
' totalVar2 = totalVar2 + lblValueVar2.Text.As(Int)
|
|
' Log("Esto es total var2: "&totalVar2)
|
|
' Next
|
|
' End If
|
|
'
|
|
' etVar2HasFocus = True
|
|
' Log("Esto es El focus2: " & etVar2HasFocus)
|
|
' If etVar2HasFocus = True And etVar1HasFocus = False And etVar3HasFocus = False Then
|
|
' If New = "" Or New = Null Then New = 0
|
|
' If Old = "" Or Old = Null Then Old = 0
|
|
' If New = "-" Then New = 0
|
|
' Dim variablesRequeridas2int As Int = New
|
|
' If New = "" Then
|
|
' New = 0
|
|
' End If
|
|
' If New < 0 Then
|
|
' New = 0
|
|
' Else
|
|
'' Log("---------------------------------")
|
|
' Log("Variables Requeridas2: " & variablesRequeridas2)
|
|
' Log("Valor EditText2: " & totalVar2)
|
|
' Log(totalVar2 <= variablesRequeridas2)
|
|
' If totalVar2 <= variablesRequeridas2 Then
|
|
'' Log("---------------------------------")
|
|
' Log("Estoy entrando aca")
|
|
' Else If totalVar2 > variablesRequeridas2 Then
|
|
' variablesRequeridas2int = variablesRequeridas2 - sumaVar2Tot
|
|
' If variablesRequeridas2int < 1 Then variablesRequeridas2int = 0
|
|
' isProgrammaticChange = True
|
|
' Sender.As(EditText).Text = variablesRequeridas2int
|
|
' End If
|
|
' End If
|
|
' sumaVar2Tot = totalVar2
|
|
' RecalcularSumas
|
|
' End If
|
|
'End Sub
|
|
'
|
|
'Private Sub lblValueVar3_TextChanged (Old As String, New As String)
|
|
' If isProgrammaticChange Then
|
|
' isProgrammaticChange = False
|
|
' Return
|
|
' End If
|
|
'
|
|
' Log("---------------------------------")
|
|
' Dim totalVar3 As Int = 0
|
|
'
|
|
' If pnlVariables3.IsInitialized Then
|
|
' For i = 0 To pnlVariables3.NumberOfViews - 1
|
|
' Dim pnlProducto As Panel = pnlVariables3.GetView(i)
|
|
' Dim lblValueVar3 As EditText = pnlProducto.GetView(2)
|
|
' If lblValueVar3.Text = "" Then
|
|
' lblValueVar3.Text = 0
|
|
' End If
|
|
' Log("Esto es total var3Antes : "& totalVar3)
|
|
' Log("Esto es ET3: "& lblValueVar3.Text.As(Int))
|
|
' totalVar3 = totalVar3 + lblValueVar3.Text.As(Int)
|
|
' Log("Esto es total var3: "&totalVar3)
|
|
' Next
|
|
' End If
|
|
'
|
|
' etVar3HasFocus = True
|
|
' Log("Esto es El focus3: " & etVar3HasFocus)
|
|
' If etVar3HasFocus = True And etVar1HasFocus = False And etVar2HasFocus = False Then
|
|
' If New = "" Or New = Null Then New = 0
|
|
' If Old = "" Or Old = Null Then Old = 0
|
|
' If New = "-" Then New = 0
|
|
' Dim variablesRequeridas3int As Int = New
|
|
' If New = "" Then
|
|
' New = 0
|
|
' End If
|
|
' If New < 0 Then
|
|
' New = 0
|
|
' Else
|
|
'' Log("---------------------------------")
|
|
' Log("Variables Requeridas3: " & variablesRequeridas3)
|
|
' Log("Valor EditText3: " & totalVar3)
|
|
' Log(totalVar3 <= variablesRequeridas3)
|
|
' If totalVar3 <= variablesRequeridas3 Then
|
|
'' Log("---------------------------------")
|
|
' Log("Estoy entrando aca")
|
|
' Else If totalVar3 > variablesRequeridas3 Then
|
|
' variablesRequeridas3int = variablesRequeridas3 - sumaVar3Tot
|
|
' Log(variablesRequeridas3)
|
|
' Log("Valor EditText3: " & totalVar3)
|
|
' Log(sumaVar3Tot)
|
|
' Log(variablesRequeridas3int)
|
|
' Log("Estoy entrando aqui Var3")
|
|
' If variablesRequeridas3int < 1 Then variablesRequeridas3int = 0
|
|
' isProgrammaticChange = True
|
|
' Sender.As(EditText).Text = variablesRequeridas3int
|
|
' End If
|
|
' End If
|
|
' sumaVar3Tot = totalVar3
|
|
' RecalcularSumas
|
|
' End If
|
|
'End Sub
|
|
'
|
|
'Sub lblValueVar1_FocusChanged (HasFocus As Boolean)
|
|
' etVar1HasFocus = HasFocus
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = False
|
|
' Log("FocusChanged: " & HasFocus)
|
|
' If HasFocus Then
|
|
' Log("El EditText tiene el foco.")
|
|
' Else
|
|
' Log("El EditText perdió el foco.")
|
|
' End If
|
|
'End Sub
|
|
'
|
|
'Sub lblValueVar2_FocusChanged (HasFocus As Boolean)
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = HasFocus
|
|
' etVar3HasFocus = False
|
|
' Log("FocusChanged: " & HasFocus)
|
|
' If HasFocus Then
|
|
' Log("El EditText tiene el foco.")
|
|
' Else
|
|
' Log("El EditText perdió el foco.")
|
|
' End If
|
|
'End Sub
|
|
'
|
|
'Sub lblValueVar3_FocusChanged (HasFocus As Boolean)
|
|
' etVar1HasFocus = False
|
|
' etVar2HasFocus = False
|
|
' etVar3HasFocus = HasFocus
|
|
' Log("FocusChanged: " & HasFocus)
|
|
' If HasFocus Then
|
|
' Log("El EditText tiene el foco.")
|
|
' Else
|
|
' Log("El EditText perdió el foco.")
|
|
' End If
|
|
'End Sub
|
|
|
|
Private Sub RecalcularSumas
|
|
lblSumaTotal.Text = NumberFormat2((SumarFijos + SumarVariables1 + SumarVariables2 + SumarVariables3), 1, 0, 0, False)
|
|
Log($"${lblFijosRequeridos.Text} + ${SumarVariables1} + ${SumarVariables2}"$)
|
|
ActualizarTotalValor
|
|
ActualizarVisibilidadBtnGuardaPromo
|
|
End Sub
|
|
|
|
Private Sub AjustarScroll
|
|
Dim baseHeight As Int = 0
|
|
|
|
If productosFijos > 0 And pnlFijos.Visible Then
|
|
lblFijosRequeridos.Top = baseHeight
|
|
etLimiteSuma_Sub_pnl1.Top = lblFijosRequeridos.Top
|
|
baseHeight = baseHeight + lblFijosRequeridos.Height
|
|
|
|
pnlFijos.Top = baseHeight
|
|
baseHeight = baseHeight + pnlFijos.Height
|
|
End If
|
|
|
|
If variablesRequeridas1 > 0 And pnlVariables1.Visible Then
|
|
lblVariablesRequeridas1.Top = baseHeight
|
|
etLimiteSuma_Sub_pnl2.Top = lblVariablesRequeridas1.Top
|
|
baseHeight = baseHeight + lblVariablesRequeridas1.Height
|
|
|
|
pnlVariables1.Top = baseHeight
|
|
baseHeight = baseHeight + pnlVariables1.Height
|
|
End If
|
|
|
|
If variablesRequeridas2 > 0 And pnlVariables2.Visible Then
|
|
lblVariablesRequeridas2.Top = baseHeight
|
|
etLimiteSuma_Sub_pnl3.Top = lblVariablesRequeridas2.Top
|
|
baseHeight = baseHeight + lblVariablesRequeridas2.Height
|
|
|
|
pnlVariables2.Top = baseHeight
|
|
baseHeight = baseHeight + pnlVariables2.Height
|
|
End If
|
|
|
|
If variablesRequeridas3 > 0 And pnlVariables3.Visible Then
|
|
lblVariablesRequeridas3.Top = baseHeight
|
|
etLimiteSuma_Sub_pnl4.Top = lblVariablesRequeridas3.Top
|
|
baseHeight = baseHeight + lblVariablesRequeridas3.Height
|
|
|
|
pnlVariables3.Top = baseHeight
|
|
baseHeight = baseHeight + pnlVariables3.Height
|
|
End If
|
|
|
|
scrollView.Panel.Height = baseHeight
|
|
|
|
pnlProdTot.Top = Root.Height - pnlProdTot.Height
|
|
End Sub
|
|
|
|
Private Sub btnGuardaPromo_Click
|
|
Subs.guardaProductoSinGestion(estaPromo, 0, lblSumPromo.Text, Encabezado, estaPromo, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
' Log("Esto es encabezado>>>>>>>>>>" & Encabezado)
|
|
If productosFijos > 0 Then
|
|
Log("Guardando productos fijos...")
|
|
For i = 0 To pnlFijos.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlFijos.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim cantidad As Int = productosFijos
|
|
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)
|
|
Log("Esto es el nombre del producto? <<<<<<<<<<<<<<<<<<<<<<<|" &nomProd(1) & "|")
|
|
Private pzs As Cursor = Starter.skmt.ExecQuery($"select CAT_DP_PZAS from cat_detalles_paq where cat_dp_idprod = '${idProducto}' and cat_dp_id = '${estaPromo}'"$)
|
|
If pzs.RowCount > 0 Then
|
|
pzs.Position = 0
|
|
Log("============================== " & pzs.GetString("CAT_DP_PZAS"))
|
|
cantidad = pzs.GetString("CAT_DP_PZAS")
|
|
End If
|
|
Dim cursorProductosFijos As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_DP_PZAS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID = '${estaPromo}' AND CAT_DP_TIPO = '0' and cat_dp_idprod = '${idProducto}'"$)
|
|
|
|
If cursorProductosFijos.RowCount > 0 Then
|
|
cursorProductosFijos.Position = 0
|
|
cantidad = cursorProductosFijos.GetString("CAT_DP_PZAS") * lblSumPromo.Text
|
|
End If
|
|
Log("Esto debe ser cantidad: " & cantidad)
|
|
|
|
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 pnlVariables1.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables1.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValueVar1 As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValueVar1.Text.As(Int)
|
|
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 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 pnlVariables2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables2.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValueVar2 As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValueVar2.Text.As(Int)
|
|
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 pnlVariables3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables3.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValueVar3 As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValueVar3.Text.As(Int)
|
|
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
|
|
Subs.guardaProductoSinGestion(estaPromo, 0, lblSumPromo.Text, Encabezado, estaPromo, Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
|
' Log(Encabezado)
|
|
If productosFijos > 0 Then
|
|
For i = 0 To pnlFijos.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlFijos.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim cantidad As Int = 0
|
|
|
|
Dim lblNombre2 As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre2.Text
|
|
Private idProducto As String = lblNombre2.tag
|
|
|
|
'Este for hace que la cantidad de la etiqueta de los fijos cambie con el menos
|
|
|
|
Dim cursorProductosFijos As Cursor = Starter.skmt.ExecQuery($"SELECT CAT_DP_PZAS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID = '${estaPromo}' AND CAT_DP_TIPO = '0' and cat_dp_idprod = '${idProducto}'"$)
|
|
If cursorProductosFijos.RowCount > 0 Then
|
|
cursorProductosFijos.Position = 0
|
|
cantidad = cursorProductosFijos.GetString("CAT_DP_PZAS") * lblSumPromo.Text
|
|
End If
|
|
Log("Esto debe ser cantidad: " & cantidad)
|
|
|
|
|
|
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)
|
|
Log("" & 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 pnlVariables1.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables1.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValueVar1 As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValueVar1.Text.As(Int)
|
|
Dim lblNombre3 As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre3.Text
|
|
Private idProducto As String = lblNombre3.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 pnlVariables2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables2.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValueVar2 As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValueVar2.Text.As(Int)
|
|
Dim lblNombre4 As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre4.Text
|
|
Private idProducto As String = lblNombre4.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 pnlVariables3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables3.GetView(i)
|
|
Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
Dim lblValueVar3 As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValueVar3.Text.As(Int)
|
|
Dim lblNombre5 As Label = pnlProducto.GetView(0)
|
|
Dim nombreProducto As String = lblNombre5.Text
|
|
Private idProducto As String = lblNombre5.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 = (SumarVariables1 = variablesRequeridas1)
|
|
' Log("Condición Var1: " & condicionVar1)
|
|
End If
|
|
|
|
If hayVar2 Then
|
|
condicionVar2 = (SumarVariables2 = variablesRequeridas2)
|
|
' Log("Condición Var2: " & condicionVar2)
|
|
End If
|
|
|
|
If hayVar3 Then
|
|
condicionVar3 = (SumarVariables3 = 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
|
|
Return True
|
|
End If
|
|
|
|
' Log("No hay valores mayores a 0, no se muestra el botón.")
|
|
Return False
|
|
End Sub
|
|
|
|
Private Sub SumarFijos As Int
|
|
' Log("Aqui entro cuando?<<<<<<<<<<<<<<<<<<<<<<<<<<")
|
|
Private fijos As Int = 0
|
|
Private textoOriginal As String = lblFijosRequeridos.Text.Trim
|
|
' Log("Que es este texto? : <<<<<<<<<<<<<<<<<<<<<<<<<<" & textoOriginal)
|
|
If textoOriginal.Length > 0 Then
|
|
Private partes() As String = Regex.Split(" ", textoOriginal)
|
|
|
|
If partes.Length > 2 Then
|
|
Private posibleNumero As String = partes(2).Trim.Replace("'", "")
|
|
|
|
If posibleNumero.Length > 0 And IsNumber(posibleNumero) Then
|
|
fijos = posibleNumero
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Log("Estos son los fijos: " & fijos)
|
|
Return fijos
|
|
End Sub
|
|
|
|
Private Sub SumarVariables1 As Int
|
|
Dim totalVar1 As Int = 0
|
|
|
|
If pnlVariables1.IsInitialized Then
|
|
For i = 0 To pnlVariables1.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables1.GetView(i)
|
|
Dim lblValueVar1 As Label = pnlProducto.GetView(2)
|
|
If lblValueVar1.Text = "" Or lblValueVar1.Text = "-" Or lblValueVar1.Text = " " Then
|
|
lblValueVar1.Text = 0
|
|
End If
|
|
totalVar1 = totalVar1 + lblValueVar1.Text.As(Int)
|
|
Next
|
|
End If
|
|
|
|
Log("Total variables 1= " & totalVar1)
|
|
Return totalVar1
|
|
End Sub
|
|
|
|
Private Sub SumarVariables2 As Int
|
|
Dim totalVar2 As Int = 0
|
|
|
|
If pnlVariables2.IsInitialized Then
|
|
For i = 0 To pnlVariables2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables2.GetView(i)
|
|
Dim lblValueVar2 As Label = pnlProducto.GetView(2)
|
|
If lblValueVar2.Text = "" Then
|
|
lblValueVar2.Text = 0
|
|
End If
|
|
totalVar2 = totalVar2 + lblValueVar2.Text.As(Int)
|
|
Next
|
|
End If
|
|
|
|
Return totalVar2
|
|
End Sub
|
|
|
|
Private Sub SumarVariables3 As Int
|
|
Dim totalVar3 As Int = 0
|
|
|
|
If pnlVariables3.IsInitialized Then
|
|
For i = 0 To pnlVariables3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables3.GetView(i)
|
|
Dim lblValueVar3 As Label = pnlProducto.GetView(2)
|
|
If lblValueVar3.Text = "" Then
|
|
lblValueVar3.Text = 0
|
|
End If
|
|
totalVar3 = totalVar3 + lblValueVar3.Text.As(Int)
|
|
Next
|
|
End If
|
|
|
|
Return totalVar3
|
|
End Sub
|
|
|
|
Private Sub CalcularTotalValor As Float
|
|
Dim total As Float = 0
|
|
|
|
' If pnlFijos.IsInitialized And productosFijos > 0 Then
|
|
' For i = 0 To pnlFijos.NumberOfViews - 1
|
|
' Dim pnlProducto As Panel = pnlFijos.GetView(i)
|
|
' Dim precioProducto As Float = pnlProducto.Tag.As(Float)
|
|
'
|
|
' Log($"---------->>> ${precioProducto}, ${Regex.Split(" ", lblFijosRequeridos.text)(2)}"$)
|
|
'
|
|
' total = total + (precioProducto * Regex.Split(" ", lblFijosRequeridos.text)(2))
|
|
' Next
|
|
' End If
|
|
Private tot As Cursor = Starter.skmt.ExecQuery($"select (cat_dp_precio * cat_dp_pzas) as total from cat_detalles_paq where cat_dp_tipo = '0' and cat_dp_id = '${estaPromo}'"$)
|
|
Private x As String = 0
|
|
If tot.RowCount > 0 Then
|
|
For i = 0 To tot.RowCount - 1
|
|
tot.Position = i
|
|
x = x + tot.GetString("total")
|
|
Next
|
|
Log("Que valor tiene x? ------------><<<<<" & x)
|
|
total = x
|
|
End If
|
|
' Log("=====================>>>> " & x)
|
|
|
|
If pnlVariables1.IsInitialized Then
|
|
For i = 0 To pnlVariables1.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables1.GetView(i)
|
|
Dim lblValueVar1 As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValueVar1.Text.As(Int)
|
|
If cantidad > 0 Then
|
|
total = total + (pnlProducto.Tag.As(Float) * cantidad)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If pnlVariables2.IsInitialized Then
|
|
For i = 0 To pnlVariables2.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables2.GetView(i)
|
|
Dim lblValueVar2 As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValueVar2.Text.As(Int)
|
|
If cantidad > 0 Then
|
|
total = total + (pnlProducto.Tag.As(Float) * cantidad)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If pnlVariables3.IsInitialized Then
|
|
For i = 0 To pnlVariables3.NumberOfViews - 1
|
|
Dim pnlProducto As Panel = pnlVariables3.GetView(i)
|
|
Dim lblValueVar3 As Label = pnlProducto.GetView(2)
|
|
Dim cantidad As Int = lblValueVar3.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 * lblSumPromo.Text
|
|
' lblTotalValor.Text = NumberFormat(total, 1, 2)
|
|
' Log("Esto es calcular valor: -------------------->" & CalcularTotalValor)
|
|
' Log("En que momento hago esto?: -------------------->" & lblTotalValor.Text)
|
|
'End Sub
|
|
|
|
private Sub ActualizarTotalValor
|
|
Private soloFijos As Cursor = Starter.skmt.ExecQuery($"select CAT_DP_ID from cat_detalles_paq where cat_dp_tipo = '0' and cat_dp_id = '${estaPromo}'"$)
|
|
|
|
Dim totalFijos As Float = 0
|
|
Dim totalVariables As Float = 0
|
|
|
|
If soloFijos.RowCount > 0 Then
|
|
' Calcular fijos
|
|
totalFijos = CalcularTotalFijos ' Necesitarías una función específica para fijos
|
|
Log("Total de fijos: " & totalFijos & "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
|
|
|
|
' Calcular variables por separado
|
|
totalVariables = CalcularTotalVariables ' Función específica para variables
|
|
Else
|
|
' Solo hay variables
|
|
totalVariables = CalcularTotalValor
|
|
End If
|
|
|
|
Dim totalGeneral As Float = totalFijos + totalVariables
|
|
lblTotalValor.Text = NumberFormat(totalGeneral, 1, 2)
|
|
End Sub
|
|
|
|
Private Sub CalcularTotalFijos As Float
|
|
Dim total As Float = 0
|
|
|
|
' Consulta para obtener solo los productos fijos (tipo '0')
|
|
Dim cursorFijos As Cursor = Starter.skmt.ExecQuery("SELECT cat_dp_precio as precio FROM cat_detalles_paq WHERE cat_dp_tipo = '0' AND cat_dp_id = '" & estaPromo & "'")
|
|
|
|
If cursorFijos.RowCount > 0 Then
|
|
For i = 0 To cursorFijos.RowCount - 1
|
|
cursorFijos.Position = i
|
|
Dim precio As String = cursorFijos.GetString("precio")
|
|
|
|
Private pzs2 As Cursor = Starter.skmt.ExecQuery($"select sum(CAT_DP_PZAS) as suma from cat_detalles_paq where cat_dp_tipo = '0' and cat_dp_id = '${estaPromo}'"$)
|
|
If pzs2.RowCount > 0 Then
|
|
pzs2.Position = 0
|
|
' Log(pzs2.GetString("suma") & "En este ejemplo debe ser un 7 <<<<<<<<<<<<<<<<<<<<")
|
|
End If
|
|
lblFijosRequeridos.Text = "Productos fijos: " & (pzs2.GetString("suma") * lblSumPromo.Text)
|
|
|
|
total = (precio * pzs2.GetString("suma") * lblSumPromo.Text)
|
|
' Log("Esto es por lo que debe multiplicarse: " & pzs2.GetString("suma") & "Esto es precio: " & precio)
|
|
Next
|
|
End If
|
|
|
|
cursorFijos.Close
|
|
|
|
Return total
|
|
End Sub
|
|
|
|
Private Sub CalcularTotalVariables As Float
|
|
Dim total As Float = 0
|
|
Dim precioVar1 As Float = 0
|
|
Dim precioVar2 As Float = 0
|
|
Dim precioVar3 As Float = 0
|
|
|
|
' Consulta para obtener los productos variables (tipo '1', '2' o '3')
|
|
Dim cursorVariables As Cursor = Starter.skmt.ExecQuery("SELECT cat_dp_precio as precio, cat_dp_tipo as tipo FROM cat_detalles_paq WHERE cat_dp_tipo <> '0' AND cat_dp_id = '" & estaPromo & "'")
|
|
|
|
If cursorVariables.RowCount > 0 Then
|
|
' Primero: Recopilamos los precios por tipo
|
|
For i = 0 To cursorVariables.RowCount - 1
|
|
cursorVariables.Position = i
|
|
Dim precio As String = cursorVariables.GetString("precio")
|
|
Dim tipoVariable As String = cursorVariables.GetString("tipo")
|
|
|
|
Select tipoVariable
|
|
Case "1"
|
|
precioVar1 = precio
|
|
Case "2"
|
|
precioVar2 = precio
|
|
Case "3"
|
|
precioVar3 = precio
|
|
End Select
|
|
Next
|
|
|
|
' Segundo: Aplicamos las cantidades una sola vez
|
|
Dim cantidadVar1 As Int = SumarVariables1
|
|
Dim cantidadVar2 As Int = SumarVariables2
|
|
Dim cantidadVar3 As Int = SumarVariables3
|
|
|
|
If cantidadVar1 > 0 Then
|
|
total = total + (precioVar1 * cantidadVar1)
|
|
Log("Precio Var1: " & precioVar1 & " x " & cantidadVar1 & " = " & (precioVar1 * cantidadVar1))
|
|
End If
|
|
|
|
If cantidadVar2 > 0 Then
|
|
total = total + (precioVar2 * cantidadVar2)
|
|
Log("Precio Var2: " & precioVar2 & " x " & cantidadVar2 & " = " & (precioVar2 * cantidadVar2))
|
|
End If
|
|
|
|
If cantidadVar3 > 0 Then
|
|
total = total + (precioVar3 * cantidadVar3)
|
|
Log("Precio Var3: " & precioVar3 & " x " & cantidadVar3 & " = " & (precioVar3 * cantidadVar3))
|
|
End If
|
|
End If
|
|
|
|
cursorVariables.Close
|
|
|
|
Log("Total final de variables: " & total)
|
|
Return total
|
|
End Sub |