Verificar existencias al editar

This commit is contained in:
2022-03-05 14:04:03 -07:00
parent a266afcda7
commit 908c644b42

View File

@@ -758,6 +758,15 @@ Partial Class PV
End Set
End Property
Private Property CantidadAntesEdicion As Decimal
Get
Return If(IsNothing(ViewState("CantidadAntesEdicion")), "0", ViewState("CantidadAntesEdicion").ToString()).ToDecimal()
End Get
Set(value As Decimal)
ViewState("CantidadAntesEdicion") = value
End Set
End Property
#End Region
#Region "PROPIEDADES CONTRATOS"
@@ -1071,6 +1080,7 @@ Partial Class PV
ViewState("ClienteRetIVA") = 0
ViewState("ClienteRetISR") = 0
ViewState("EnviarCorreoCliente") = False
Me.CantidadAntesEdicion = 0
HdnPorcentajeDescuentoMaximo.Value = If(UsuarioActual.DescuentoAutorizado > 0, UsuarioActual.DescuentoAutorizado, 15).ToString()
CveVentaDetalle = -1
EstablecioFolio = False
@@ -5125,7 +5135,15 @@ Partial Class PV
If DdlTipoComprobante.SelectedValue <> "Cot" Then
'VALIDA EXISTENCIA
If UsuarioActual.CveEmpresa.Contiene({1, 72, 80, 119, 140}) Then
If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS}") < TxtCantidad.Text.ToDouble Then
Dim CantidadAgregada As Decimal = TmpDT.SUMD("Cantidad", $"CvePS = {CvePS}")
If Modalidad = "U" Then
CantidadAgregada = CantidadAgregada - CantidadAntesEdicion + TxtCantidad.Text.ToDecimal()
Else
CantidadAgregada = CantidadAgregada + TxtCantidad.Text.ToDecimal()
End If
If Existencia < CantidadAgregada Then
Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia)
Return False
End If
@@ -5229,6 +5247,7 @@ Partial Class PV
End Sub
Private Sub CargaAgregar()
Modalidad = "A"
CantidadAntesEdicion = 0
LnkAgregarPS.Text = "Agregar"
CargaBCI()
LimpiaAgregar()
@@ -5268,6 +5287,7 @@ Partial Class PV
End If
DdlPSIndexChange(DdlPS.SelectedValue.ToEntero, DdlPS)
DdlUnidadMedida.SelectedValueExist(GvRow.DataKey("CveUM"))
CantidadAntesEdicion = GvRow.DataKey("Cantidad").ToDecimal()
TxtCantidad.Text = GvRow.DataKey("Cantidad")
'Dim TotalCargos As Decimal = 0
@@ -5324,6 +5344,9 @@ Partial Class PV
RegistraScript("$('#DivAddVenta').modal({backdrop: 'static', keyboard: false});", "EdicionVenta")
End Sub
Protected Sub LnkAgregarPS_Click(sender As Object, e As EventArgs)
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("")
If ChkAjuste.Checked Then
Dim FolioGarantia As MFolioGarantiaMensaje = ValidaFolioGarantia(DdlPSAjuste.SelectedValue.ToEntero(), DdlFolioGarantia.SelectedValue.ToEntero())
@@ -5337,25 +5360,34 @@ Partial Class PV
Exit Sub
End If
If String.IsNullOrEmpty(TxtAnioVehiculo.Text.Trim()) Then
Alert("El campo año esta vacío.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If DrPS IsNot Nothing Then
'SOLO DEBE AGREGAR POLIZA VIRTUAL SI ES ACUMULADOR
If DrPS("CveClasificacion").ToString().ToEntero().Contiene(20520, 20522, 20513, 20511, 20521, 20512, 20514, 20229) Then
If String.IsNullOrEmpty(TxtAnioVehiculo.Text.Trim()) Then
Alert("El campo año esta vacío.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TxtAnioVehiculo.Text.ToDecimal() < 1900 Then
Alert("El campo año debe ser mayor a 1900.", TipoMensaje.MsgAdvertencia)
Exit Sub
If TxtAnioVehiculo.Text.ToDecimal() < 1900 Then
Alert("El campo año debe ser mayor a 1900.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
Else
If Not String.IsNullOrEmpty(TxtAnioVehiculo.Text.Trim()) Then
If TxtAnioVehiculo.Text.ToDecimal() < 1900 Then
Alert("El año del vehiculo del vehículo no tiene el formato correcto.", TipoMensaje.MsgAdvertencia)
Exit Sub
If DrPS IsNot Nothing Then
'SOLO DEBE AGREGAR POLIZA VIRTUAL SI ES ACUMULADOR
If DrPS("CveClasificacion").ToString().ToEntero().Contiene(20520, 20522, 20513, 20511, 20521, 20512, 20514, 20229) Then
If Not String.IsNullOrEmpty(TxtAnioVehiculo.Text.Trim()) Then
If TxtAnioVehiculo.Text.ToDecimal() < 1900 Then
Alert("El año del vehiculo del vehículo no tiene el formato correcto.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
End If
End If
End If
If AgregarPS() Then