-
This commit is contained in:
@@ -1776,6 +1776,17 @@ Partial Class PV
|
||||
Moneda = 1
|
||||
End If
|
||||
|
||||
'ELIMINA LOS DETALLES
|
||||
If Not OcurrioError Then
|
||||
Dim DtEliminados As DataTable = TmpDT.FiltraParametros("EliminarDB = True AND CveVentaDetalle > 0", "", {"CveVentaDetalle"})
|
||||
|
||||
For Each Dr1 As DataRow In DtEliminados.Rows
|
||||
If Not ObjVentas.RemoveVentasDetalle(CveVenta, Dr1("CveVentaDetalle").ToString.ToEntero) Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
'Actualizo los parametros de la venta
|
||||
If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDecimal, LblDescuentos.Text.ToDecimal, TxtIVA.Text.ToDecimal, TxtIEPS.Text.ToDecimal, TxtTotal.Text.ToDecimal, Moneda, TipoCambio, TxtFecha.Text.Trim.ToDate, TxtObsFact.Text.Trim,
|
||||
UsuarioActual.CveEmpresa, CveVenta, 0, 0,
|
||||
@@ -1789,7 +1800,7 @@ Partial Class PV
|
||||
'Cargo de nueva cuenta el detalle de Ventas (Conceptos)
|
||||
If Not OcurrioError Then
|
||||
Dim index As Integer = 0
|
||||
For Each Row As DataRow In TmpDT.Rows
|
||||
For Each Row As DataRow In TmpDT.FiltraParametros("EliminarDB = False").Rows
|
||||
Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString.ToEntero()
|
||||
If CveVentaDetalle > 0 Then
|
||||
If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal(), Row("ImporteIEPS").ToString.ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("Obs").ToString, UsuarioActual.CveUsuario) Then
|
||||
@@ -1834,32 +1845,46 @@ Partial Class PV
|
||||
Next
|
||||
End If
|
||||
|
||||
'RECARGA LOS DATOS
|
||||
ObjFactura.Dispose()
|
||||
ObjFactura = Nothing
|
||||
ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa)
|
||||
|
||||
'ELIMINA LOS DETALLES
|
||||
If Not OcurrioError Then
|
||||
Dim DtEliminados As DataTable = TmpDT.FiltraParametros("EliminarDB = True AND CveVentaDetalle > 0", "", {"CveVentaDetalle"})
|
||||
If ObjFactura Is Nothing Then
|
||||
OcurrioError = True
|
||||
Else
|
||||
TmpDT = ObjFactura.DtDetalle
|
||||
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
||||
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
||||
|
||||
For Each Dr1 As DataRow In DtEliminados.Rows
|
||||
If Not ObjVentas.RemoveVentasDetalle(CveVenta, Dr1("CveVentaDetalle").ToString.ToEntero) Then
|
||||
OcurrioError = True
|
||||
Dim NumRowsPS As Integer = 0
|
||||
Dim CantidadPS As Decimal = 0
|
||||
For Each GvRow As GridViewRow In GvPS.Rows
|
||||
If GvRow.RowType = DataControlRowType.DataRow Then
|
||||
NumRowsPS += 1
|
||||
CantidadPS += GvRow.DataKey("Cantidad").ToDecimal()
|
||||
End If
|
||||
Next
|
||||
|
||||
'VALIDA NUMERO DE REGISTROS
|
||||
If TmpDT.Rows.Count <> NumRowsPS Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
'VALIDA CANTIDAD DE REGISTROS
|
||||
If TmpDT.SUM("Cantidad") <> CantidadPS Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
'RECARGA LOS DATOS
|
||||
If ObjVentas.GetVentaDetalle(CveVenta) Then
|
||||
TmpDT = ObjVentas.DtResultados.Copy()
|
||||
ObjFactura.DtDetalle = TmpDT
|
||||
Else
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
'GUARDA USADOS
|
||||
If Not ObjVentas.EliminarUsados(CveVenta) Then
|
||||
If Not OcurrioError AndAlso Not ObjVentas.EliminarUsados(CveVenta) Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
If TmpDTRecepcionUsados IsNot Nothing Then
|
||||
If Not OcurrioError AndAlso TmpDTRecepcionUsados IsNot Nothing Then
|
||||
For Each drow As DataRow In TmpDTRecepcionUsados.Rows
|
||||
If Not ObjVentas.AddVentaUsado(CveVenta, drow("CvePS").ToString.ToEntero, drow("Cantidad").ToString.ToDecimal, drow("PU").ToString.ToDecimal, drow("CveBCIUsado").ToString.ToEntero, drow("CveModeloAuto").ToString.ToEntero) Then
|
||||
OcurrioError = True
|
||||
@@ -1869,11 +1894,11 @@ Partial Class PV
|
||||
End If
|
||||
|
||||
'GUARDAR AJUSTES'
|
||||
If Not ObjAcum.EliminarGarantiasDetalle(CveVenta) Then
|
||||
If Not OcurrioError AndAlso Not ObjAcum.EliminarGarantiasDetalle(CveVenta) Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
If TmpDTAjustes IsNot Nothing AndAlso TmpDTAjustes.Rows.Count > 0 Then
|
||||
If Not OcurrioError AndAlso TmpDTAjustes IsNot Nothing AndAlso TmpDTAjustes.Rows.Count > 0 Then
|
||||
For Each Dr As DataRow In TmpDTAjustes.Rows
|
||||
If Not ObjAcum.AddGarantiasDetalle(Dr("CveVentaDetalle").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("CveFolioGarantia").ToString.ToEntero, Dr("CveTipoUso").ToString.ToEntero,
|
||||
Dr("CodigoEnsamble").ToString, Dr("CodigoLinea").ToString, Dr("CodigoInspeccion").ToString, Dr("CveTipoDefecto").ToString.ToEntero,
|
||||
@@ -1884,11 +1909,11 @@ Partial Class PV
|
||||
End If
|
||||
|
||||
'GUARDAR POLIZA VIRTUAL
|
||||
If Not ObjAcum.EliminarPolizaVirtual(CveVenta) Then
|
||||
If Not OcurrioError AndAlso Not ObjAcum.EliminarPolizaVirtual(CveVenta) Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
If TmpDTPolizaVirtual IsNot Nothing Then
|
||||
If Not OcurrioError AndAlso TmpDTPolizaVirtual IsNot Nothing Then
|
||||
For Each drow As DataRow In TmpDTPolizaVirtual.Rows
|
||||
If ObjAcum.AddPolizaVirtual(CveVenta, drow("CveVentaDetalle").ToString().ToEntero(), drow("CvePS").ToString.ToEntero, drow("Cantidad").ToString.ToDecimal, drow("PU").ToString.ToDecimal, drow("Descuento").ToString.ToDecimal,
|
||||
drow("Total").ToString.ToDecimal, drow("TipoServicio").ToString.ToEntero, drow("TipoPoliza").ToString.ToEntero, drow("CveModeloAuto").ToString.ToEntero, drow("AnioVehiculo").ToString.ToEntero, CBool(drow("TieneUsado").ToString),
|
||||
@@ -2758,13 +2783,18 @@ Partial Class PV
|
||||
|
||||
#Region "GVPS"
|
||||
Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvPS.RowDeleting
|
||||
|
||||
Dim DbRow As DataRow = Nothing
|
||||
DbRow = TmpDT.Rows(e.RowIndex)
|
||||
|
||||
EliminarUsados(DbRow("Consec").ToString().ToEntero())
|
||||
Me.CveVentaDetalle = DbRow("CveVentaDetalle").ToString().ToEntero()
|
||||
|
||||
TmpDT.Rows.Remove(DbRow)
|
||||
If Me.CveVentaDetalle <= 0 Then
|
||||
EliminarUsados(DbRow("Consec").ToString().ToEntero())
|
||||
TmpDT.Rows.Remove(DbRow)
|
||||
Else
|
||||
EliminarUsados()
|
||||
DbRow("EliminarDB") = True
|
||||
End If
|
||||
|
||||
GvPS.DataSource = TmpDT.FiltraParametros("EliminarDB = False")
|
||||
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
|
||||
@@ -2774,6 +2804,9 @@ Partial Class PV
|
||||
|
||||
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
|
||||
|
||||
Me.CveVentaDetalle = -1
|
||||
|
||||
|
||||
UpContado.Update()
|
||||
End Sub
|
||||
Protected Sub GvPS_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvPS.RowDataBound
|
||||
|
||||
Reference in New Issue
Block a user