diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 38f0a6c74..fb94fa794 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -5459,7 +5459,9 @@ Partial Class Ventas DdlMetodoPago33.Enabled = True End If - If CveVenta <= 0 Or EsCreaApartirDe Or NuevaFactura = 1 Then + Dim CveCotizacion As Integer = IfNull(ViewState("CveCotizacion"), 0).ToString().ToEntero() + + If (CveVenta <= 0 AndAlso CveCotizacion <= 0) Or EsCreaApartirDe Or NuevaFactura = 1 Then CveMetodoPagoCliente = ObjCliente.CveMetodoPago @@ -6241,7 +6243,9 @@ Partial Class Ventas ViewState("CliNoInt") = ObjCliente.NoInt PlazoCobranza = ObjCliente.PlazoCobranza - If CveVenta <= 0 Then + Dim CveCotizacion As Integer = IfNull(ViewState("CveCotizacion"), 0).ToString().ToEntero() + + If CveVenta <= 0 AndAlso CveCotizacion <= 0 Then CveMetodoPagoCliente = ObjCliente.CveMetodoPago DdlMetodoPago33.SelectedValueExist(ObjCliente.CveMetodoPago33) @@ -21405,7 +21409,7 @@ Partial Class Ventas LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.ArchivoBinario = ObjetoPDF, .NombreArchivo = $"AcuseCancelacion{Serie}-{Folio}.pdf"}) If ObjMail.SendMail(EmpresaActual, Mail, Asunto, Cuerpo, MailCC, LSRutasMail, Displayname:=DisplayName) Then ResultadoMail = 1 - Alert("El acuse de cancelación ha sido envíado correctamente.") + Alert("El acuse de cancelación ha sido envíado correctamente.", JSBtnAceptar:="BtnRefrescarPagina();") Else ResultadoMail = 0 End If @@ -26497,6 +26501,12 @@ Partial Class Ventas End Sub Private Sub BtnEditarCotizacion_Click(sender As Object, e As EventArgs) Handles BtnEditarCotizacion.Click + Dim VaFacturarCotizacion As Boolean = False + 'SI CARGA UNA COTIZACION DEBE GUARDAR TAMBIEN + If IfNull(ViewState("CveCotizacion"), 0).ToString().ToEntero() > 0 Then + ViewState("CveVenta") = IfNull(ViewState("CveCotizacion"), 0).ToString().ToEntero() + VaFacturarCotizacion = True + End If If Not TmpDT.Rows.Count > 0 Then Alert("Es necesario agregar al menos un producto o servicio a la factura.", TipoMensaje.MsgAdvertencia) @@ -26567,14 +26577,14 @@ Partial Class Ventas End If End If - If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then - If ObjConta.ValorPolizaDescuadre > 0 Then - If ObjConta.ValorPolizaDescuadre = 2 Then - OcurrioError = True - MensajeError = ObjConta.MensajePolizaDescuadre - End If - End If - End If + 'If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then + ' If ObjConta.ValorPolizaDescuadre > 0 Then + ' If ObjConta.ValorPolizaDescuadre = 2 Then + ' OcurrioError = True + ' MensajeError = ObjConta.MensajePolizaDescuadre + ' End If + ' End If + 'End If If OcurrioError Then ObjVentas.RollBack() @@ -26590,7 +26600,12 @@ Partial Class Ventas 'GENERA PDF NUEVO GeneraPDFCotizacion(ChkEnviarFactura.Checked) - Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=" & CveVenta & "&&Tipo=Cot"";") + If VaFacturarCotizacion Then + Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/Ventas.aspx?CveCotizacion=" & CveVenta & """;") + Else + Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=" & CveVenta & "&&Tipo=Cot"";") + End If + End If ObjVentas.Dispose() @@ -26807,82 +26822,77 @@ Partial Class Ventas Private Function CalculaUsadosCotizacion(ByRef SbVentasDetalle As StringBuilder, ByVal DTSeleccionadas As DataTable, ByVal DtCotizaciones As DataTable) As List(Of MVentaDetalleCotizacion) Dim Retorno As New List(Of MVentaDetalleCotizacion) - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot", "Dev") Then + Dim DTTamanios As DataTable = GlobalDTAcumTamaños() - Dim DTTamanios As DataTable = GlobalDTAcumTamaños() + Dim DTCvePSCostos As DataTable = DTTamanios.FiltraParametros("", "", {"CvePSCargo"}) - Dim DTCvePSCostos As DataTable = DTTamanios.FiltraParametros("", "", {"CvePSCargo"}) + For Each Dr As DataRow In DTSeleccionadas.Rows + Dim tCantidad = If(ChkCotProductos.Checked, GvCotPS.Rows(IndiceGVCotDataKey(GvCotPS, Dr("CveVentaDetalle").ToString())).FCTextBox("TxtCantidadCot").Text.ToDecimal, Dr("Cantidad")).ToString().ToDecimal + Dr("Cantidad") = tCantidad + Retorno.Add(New MVentaDetalleCotizacion() With {.CveVentaDetalle = Dr("CveVentaDetalle").ToString().ToEntero(), .Cantidad = tCantidad}) - For Each Dr As DataRow In DTSeleccionadas.Rows - Dim tCantidad = If(ChkCotProductos.Checked, GvCotPS.Rows(IndiceGVCotDataKey(GvCotPS, Dr("CveVentaDetalle").ToString())).FCTextBox("TxtCantidadCot").Text.ToDecimal, Dr("Cantidad")).ToString().ToDecimal - Dr("Cantidad") = tCantidad + Next - Retorno.Add(New MVentaDetalleCotizacion() With {.CveVentaDetalle = Dr("CveVentaDetalle").ToString().ToEntero(), .Cantidad = tCantidad}) + Dim TmpDTCalculo As DataRow() = DTSeleccionadas.Rows.Cast(Of DataRow).ToArray() - Next + Dim DTPSTemp As New DataTable '= TmpDT.Clone - Dim TmpDTCalculo As DataRow() = DTSeleccionadas.Rows.Cast(Of DataRow).ToArray() + DTPSTemp.Columns.Add("CveVenta", GetType(Integer)) + DTPSTemp.Columns.Add("Cantidad", GetType(Integer)) + DTPSTemp.Columns.Add("CvePS", GetType(Integer)) + DTPSTemp.Columns.Add("PU", GetType(Decimal)) - Dim DTPSTemp As New DataTable '= TmpDT.Clone + For Each DrowPartidas As DataRow In TmpDTCalculo + Dim CveTamanioTemp As Integer = DrowPartidas("CveTamaño").ToString().ToEntero() + Dim CveVenta As Integer = DrowPartidas("CveVenta").ToString().ToEntero() - DTPSTemp.Columns.Add("CveVenta", GetType(Integer)) - DTPSTemp.Columns.Add("Cantidad", GetType(Integer)) - DTPSTemp.Columns.Add("CvePS", GetType(Integer)) - DTPSTemp.Columns.Add("PU", GetType(Decimal)) + If CveTamanioTemp > 0 Then - For Each DrowPartidas As DataRow In TmpDTCalculo - Dim CveTamanioTemp As Integer = DrowPartidas("CveTamaño").ToString().ToEntero() - Dim CveVenta As Integer = DrowPartidas("CveVenta").ToString().ToEntero() + Dim DTTamanioTemp As New DataTable + Dim CvePsTemp As Integer = DTTamanios.FiltraParametros($"CveTamaño = { CveTamanioTemp } ").Rows(0)("CvePSCargo").ToString().ToEntero() - If CveTamanioTemp > 0 Then + Dim Cargo As Decimal = DTTamanios.FiltroPrimeroValor("Cargo", $" CveTamaño = { CveTamanioTemp }").ToDecimal - Dim DTTamanioTemp As New DataTable - Dim CvePsTemp As Integer = DTTamanios.FiltraParametros($"CveTamaño = { CveTamanioTemp } ").Rows(0)("CvePSCargo").ToString().ToEntero() + If DTPSTemp.FiltraParametros($"CvePs = { CvePsTemp }").Rows.Count > 0 Then - Dim Cargo As Decimal = DTTamanios.FiltroPrimeroValor("Cargo", $" CveTamaño = { CveTamanioTemp }").ToDecimal + For Each dRowUpdate As DataRow In DTPSTemp.Rows - If DTPSTemp.FiltraParametros($"CvePs = { CvePsTemp }").Rows.Count > 0 Then + If (dRowUpdate("CvePS").ToString().ToEntero() = CvePsTemp) Then + dRowUpdate("Cantidad") = dRowUpdate("Cantidad").ToString().ToDecimal + DrowPartidas("Cantidad").ToString().ToDecimal + dRowUpdate("PU") = Cargo ' dRowUpdate("Total").ToString().ToDecimal + ImporteCargo + dRowUpdate("CveVenta") = CveVenta + End If + Next - For Each dRowUpdate As DataRow In DTPSTemp.Rows + DTPSTemp.AcceptChanges() - If (dRowUpdate("CvePS").ToString().ToEntero() = CvePsTemp) Then - dRowUpdate("Cantidad") = dRowUpdate("Cantidad").ToString().ToDecimal + DrowPartidas("Cantidad").ToString().ToDecimal - dRowUpdate("PU") = Cargo ' dRowUpdate("Total").ToString().ToDecimal + ImporteCargo - dRowUpdate("CveVenta") = CveVenta - End If - Next + Else + Dim dRowNuevo As DataRow = DTPSTemp.NewRow - DTPSTemp.AcceptChanges() - - Else - Dim dRowNuevo As DataRow = DTPSTemp.NewRow - - dRowNuevo("CvePS") = CvePsTemp - dRowNuevo("Cantidad") = DrowPartidas("Cantidad").ToString().ToDecimal - dRowNuevo("PU") = Cargo - dRowNuevo("CveVenta") = CveVenta - - DTPSTemp.Rows.Add(dRowNuevo) - DTPSTemp.AcceptChanges() - End If + dRowNuevo("CvePS") = CvePsTemp + dRowNuevo("Cantidad") = DrowPartidas("Cantidad").ToString().ToDecimal + dRowNuevo("PU") = Cargo + dRowNuevo("CveVenta") = CveVenta + DTPSTemp.Rows.Add(dRowNuevo) + DTPSTemp.AcceptChanges() End If - Next - For Each drowPsTamaños As DataRow In DTPSTemp.Rows + End If + Next - If drowPsTamaños("PU").ToString().ToDecimal > 0 Then + For Each drowPsTamaños As DataRow In DTPSTemp.Rows - Dim CveVentaDetalleUsado = DtCotizaciones.FiltroPrimeroValor("CveVentaDetalle", $"CveVenta = {drowPsTamaños("CveVenta")} AND CvePS = {drowPsTamaños("CvePS")}").ToEntero() - SbVentasDetalle.AppendFormat("{0},", CveVentaDetalleUsado) + If drowPsTamaños("PU").ToString().ToDecimal > 0 Then - Retorno.Add(New MVentaDetalleCotizacion() With {.CveVentaDetalle = CveVentaDetalleUsado, .Cantidad = drowPsTamaños("Cantidad").ToString().ToDecimal()}) + Dim CveVentaDetalleUsado = DtCotizaciones.FiltroPrimeroValor("CveVentaDetalle", $"CveVenta = {drowPsTamaños("CveVenta")} AND CvePS = {drowPsTamaños("CvePS")}").ToEntero() + SbVentasDetalle.AppendFormat("{0},", CveVentaDetalleUsado) - End If - Next + Retorno.Add(New MVentaDetalleCotizacion() With {.CveVentaDetalle = CveVentaDetalleUsado, .Cantidad = drowPsTamaños("Cantidad").ToString().ToDecimal()}) - End If + End If + Next Return Retorno End Function