From 052185423cfe043fbf4fd9d9e385c3e2f1ebbe6c Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 9 Jan 2025 13:24:34 -0700 Subject: [PATCH] --FIX edicion de precios y ordenamiento --- Ventas/Ventas.aspx.vb | 122 +++++++++++++++++++++++++++++++++++------- 1 file changed, 104 insertions(+), 18 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index c935eefec..f58c09d83 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -9161,6 +9161,9 @@ Partial Class Ventas Cantidad = GvPS.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDecimal PU = (GvPS.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDecimal).RoundSQL(6) + Dim CantidadOriginal As Decimal = GvPS.Rows(e.RowIndex).DataKey("Cantidad").ToDecimal() + Dim TotalOriginal As Decimal = GvPS.Rows(e.RowIndex).DataKey("Total").ToDecimal() + If Cantidad <= 0 Then Alert("La cantidad debe ser mayor a cero", TipoMensaje.MsgAdvertencia) Exit Sub @@ -9176,8 +9179,62 @@ Partial Class Ventas Exit Sub End If - If UsuarioActual.CveEmpresa = 140 OrElse DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then - ObjDescuento = CalcularDescuentos(TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero(), Cantidad, PU) + Dim DdlUM As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida") + Dim DdlCla As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlClasificacion") + Dim DdlSP As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto") + + Dim DrProducto = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePSNuevo).FiltroPrimero("") + + Dim CveUMPS As Integer = DrProducto("CveUnidadMedida").ToString().ToEntero() + Dim CveClasificacion As Integer = DrProducto("CveClasificacion").ToString().ToEntero() + + DdlUM.SelectedValueExist(CveUMPS) + + Dim RecalcularPromociones As Boolean = False + Dim RegeneraPrecio As Boolean = False + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + RecalcularPromociones = True + End If + + If DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then + RecalcularPromociones = True + End If + + If Not GvPS.Rows(e.RowIndex).FCTextBox("TxtPrecio").Enabled Then + If CvePSAnterior <> CvePSNuevo Then + RegeneraPrecio = True + End If + + If Cantidad <> CantidadOriginal Then + RegeneraPrecio = True + End If + + If RegeneraPrecio Then + Dim CvePrecioLista As Integer = -1 + + If UsuarioActual.Empresa.Funcionalidad(109) = "1" OrElse UsuarioActual.Empresa.Funcionalidad(360) = "1" Then + CvePrecioLista = GvPS.Rows(e.RowIndex).FCDropDownList("DdlPrecioListaEdit").SelectedValue.ToEntero() + Else + CvePrecioLista = GvPS.Rows(e.RowIndex).DataKey("CvePrecioLista").ToEntero() + End If + + Dim ObjPrecioSugerido As Modelos.MPrecioSugerido = CalculaPrecioSugerido(CvePSNuevo, CveClasificacion, CvePrecioListaSugerido:=CvePrecioLista) + + If ObjPrecioSugerido IsNot Nothing AndAlso ObjPrecioSugerido.PrecioSugerido > 0 Then + PU = ObjPrecioSugerido.PrecioSugerido + End If + + End If + End If + + If RecalcularPromociones Then + ObjDescuento = CalcularDescuentos(CvePSNuevo, Cantidad, PU) + Dim RegenerarPU As Boolean = False + + If ObjDescuento.EsPUModificado Then + PU = ObjDescuento.PU + End If End If 'SI ESTA HABILITADO LA OPCION DE DESCUENTO, SE AGREGO UN DESCUENTO MANUAL Y NO TIENE PROMOCION @@ -9191,19 +9248,6 @@ Partial Class Ventas Exit Sub End If - Dim DdlUM As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida") - Dim DdlCla As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlClasificacion") - Dim DdlSP As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto") - - Dim CantidadOriginal As Decimal = GvPS.Rows(e.RowIndex).DataKey("Cantidad").ToDecimal() - Dim TotalOriginal As Decimal = GvPS.Rows(e.RowIndex).DataKey("Total").ToDecimal() - - Dim DrProducto = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePSNuevo).FiltroPrimero("") - - Dim CveUMPS As Integer = DrProducto("CveUnidadMedida").ToString().ToEntero() - - DdlUM.SelectedValueExist(CveUMPS) - If Not ValidaAgregarPS(Cantidad, CvePSNuevo, DdlUM.SelectedValue.ToEntero(), PU, DrProducto("CveTipoPS").ToString().ToEntero(), DdlCla.SelectedValue.ToEntero(), DdlSubProyectoDatos.SelectedValue.ToEntero(), ObjDescuento, CantidadOriginal:=CantidadOriginal) Then Exit Sub End If @@ -9224,9 +9268,9 @@ Partial Class Ventas Dim ConsecutivoActual As Integer = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero() Dim OrdenOriginal As Integer = TmpDT.Rows(e.RowIndex)("Orden").ToString().ToEntero() - If DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then - ObjDescuento = CalcularDescuentos(CvePSNuevo, Cantidad, PU) - End If + 'If DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then + ' ObjDescuento = CalcularDescuentos(CvePSNuevo, Cantidad, PU) + 'End If Dim NumTurnos As Decimal = 0 If UsuarioActual.CveEmpresa.Contiene(7, 122) Then @@ -23947,6 +23991,27 @@ Partial Class Ventas TxtAtencionA.Enabled = True + GvPS.Columns(21).Visible = True + thOrden.Visible = True + + If GvPS.Columns(21).Visible Then + For Each GvRow As GridViewRow In GvPS.Rows + If GvRow.RowType = DataControlRowType.Header Then + GvRow.FCLinkButton("LnkOrdenarGvPS").Visible = True + End If + + If GvRow.RowType = DataControlRowType.DataRow Then + GvRow.FCTextBox("TxtOrden").Visible = True + + If GvRow.FCTextBox("TxtOrden").ToEntero() <= 0 Then + GvRow.FCTextBox("TxtOrden").Text = GvRow.DataKey("Consec") + End If + End If + Next + End If + + OrdenarPS(True) + UpCliente.Update() UPPVentas.Update() UpPS.Update() @@ -33121,6 +33186,27 @@ Partial Class Ventas imgCalendario.Visible = False End If + GvPS.Columns(21).Visible = True + thOrden.Visible = True + + If GvPS.Columns(21).Visible Then + For Each GvRow As GridViewRow In GvPS.Rows + If GvRow.RowType = DataControlRowType.Header Then + GvRow.FCLinkButton("LnkOrdenarGvPS").Visible = True + End If + + If GvRow.RowType = DataControlRowType.DataRow Then + GvRow.FCTextBox("TxtOrden").Visible = True + + If GvRow.FCTextBox("TxtOrden").ToEntero() <= 0 Then + GvRow.FCTextBox("TxtOrden").Text = GvRow.DataKey("Consec") + End If + End If + Next + End If + + OrdenarPS(True) + UpPS.Update() UPPDescuento.Update() UPObservaciones.Update()