Generacion remision sin CveMedico,CveProcedimiento , FechaDeOS

This commit is contained in:
rakcsle
2023-12-22 17:05:34 -07:00
parent 34900fa1d4
commit cecf91c547
2 changed files with 158 additions and 42 deletions

View File

@@ -1275,10 +1275,12 @@
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-12">
<asp:GridView ID="GvSolicitarDevolucion" runat="server" AutoGenerateColumns="False" EmptyDataText="No se han capturado Historial"
DataKeyNames="CveVentaDetalle,Cantidad,CveAlmacenActual,CvePS,CveUM,PU,CveMovimientoDetalle,Lote,Serie,FechaCaducidad,AplicaSerie,AplicaLote,AplicaCaducidad,CodigoPS"
DataKeyNames="CveVentaDetalle,Cantidad,CveAlmacenActual,CvePS,CveUM,PU,CveMovimientoDetalle,Lote,Serie,FechaCaducidad,AplicaSerie,AplicaLote,AplicaCaducidad,CodigoPS,Descuento,Observaciones"
CssClass="table table-striped table-advance table-hover Widthall" GridLines="None" OnRowDataBound="GvSolicitarDevolucion_RowDataBound">
<Columns>
<asp:TemplateField>

View File

@@ -5,6 +5,8 @@ Imports Extensiones
Imports System.IO
Imports System.Data
Imports Telerik.Web.UI
Imports System.Data.SqlClient
Imports Stimulsoft.Report.StiOptions.Export
Partial Class OS_OrdenesServicios
Inherits ClsPaginas
@@ -3121,6 +3123,8 @@ Partial Class OS_OrdenesServicios
Dim CveSubProyectoPedido As Integer = DTSolicitudDev.FiltroPrimeroValor("CveSubProyecto").ToEntero
Dim CveVentaPedido As Integer = DTSolicitudDev.FiltroPrimeroValor("CveVenta").ToEntero
Dim CveAlmacenDestino As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, 10).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {CveSubProyectoPedido}").ToEntero
If Not CveAlmacenDestino > 0 Then
@@ -3130,55 +3134,61 @@ Partial Class OS_OrdenesServicios
Dim SbErroresDev As New StringBuilder
'Dim SbErroresDev As New StringBuilder
'Dim CantidadSeleccion As Integer = 0
For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
'For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
If GvRow.DataKey("Cantidad").ToDecimal > 0 Then
' If GvRow.DataKey("Cantidad").ToDecimal > 0 Then
Dim sbTemperror As New StringBuilder
Dim ErrorCountDev As Integer = 0
' Dim sbTemperror As New StringBuilder
' Dim ErrorCountDev As Integer = 0
sbTemperror.Append($"Producto: {GvRow.DataKey("CodigoPS") } requiere: ")
' sbTemperror.Append($"Producto: {GvRow.DataKey("CodigoPS") } requiere: ")
If Boolean.Parse(GvRow.DataKey("AplicaSerie")) Then
If GvRow.FCTextBox("TxtSerie").Text.Trim = String.Empty Then
sbTemperror.Append($" Serie, ")
ErrorCountDev = ErrorCountDev + 1
End If
End If
' If Boolean.Parse(GvRow.DataKey("AplicaSerie")) Then
' If GvRow.FCTextBox("TxtSerie").Text.Trim = String.Empty Then
' sbTemperror.Append($" Serie, ")
' ErrorCountDev = ErrorCountDev + 1
' End If
' End If
If Boolean.Parse(GvRow.DataKey("AplicaLote")) Then
If GvRow.FCTextBox("TxtLote").Text = String.Empty Then
sbTemperror.Append($" Lote, ")
ErrorCountDev = ErrorCountDev + 1
End If
End If
' If Boolean.Parse(GvRow.DataKey("AplicaLote")) Then
' If GvRow.FCTextBox("TxtLote").Text = String.Empty Then
' sbTemperror.Append($" Lote, ")
' ErrorCountDev = ErrorCountDev + 1
' End If
' End If
If Boolean.Parse(GvRow.DataKey("AplicaCaducidad")) Then
If Not IsDate(GvRow.FCTextBox("TxtFechaCaducidad").Text) Then
sbTemperror.Append($" Fecha de caducidad")
ErrorCountDev = ErrorCountDev + 1
End If
End If
' If Boolean.Parse(GvRow.DataKey("AplicaCaducidad")) Then
' If Not IsDate(GvRow.FCTextBox("TxtFechaCaducidad").Text) Then
' sbTemperror.Append($" Fecha de caducidad")
' ErrorCountDev = ErrorCountDev + 1
' End If
' End If
If ErrorCountDev > 0 Then
sbTemperror.Append($"<br/>")
SbErroresDev.AppendLine(sbTemperror.ToString)
End If
' If ErrorCountDev > 0 Then
' sbTemperror.Append($"<br/>")
' SbErroresDev.AppendLine(sbTemperror.ToString)
' End If
' CantidadSeleccion = CantidadSeleccion + 1
End If
' End If
Next
'Next
''If CantidadSeleccion = 0 Then
'' Alert($"No se selecciono nigun producto", TipoMensaje.MsgAdvertencia)
'' Exit Sub
''End If
If SbErroresDev.ToString.Length > 0 Then
Alert($"Se encontraron los siguientes errores: <br> {SbErroresDev.ToString}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'If SbErroresDev.ToString.Length > 0 Then
' Alert($"Se encontraron los siguientes errores: <br> {SbErroresDev.ToString}", TipoMensaje.MsgAdvertencia)
' Exit Sub
'End If
Dim PropcesoOK As Boolean = True
Dim ObjV As New ClsVentas
@@ -3204,11 +3214,25 @@ Partial Class OS_OrdenesServicios
Next
End If
Dim Respuesta = New RespuestaFacturacion()
If PropcesoOK Then
Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL())
If Not Respuesta.CveVenta > 0 Then
PropcesoOK = False
End If
End If
If PropcesoOK Then
Dim ObjInventario As New ClsInventarios(ObjV.IniciaTransacSQL())
Dim CveMovimiento As Integer = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaPedido, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino)
Dim CveMovimiento As Integer = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino)
Dim Folio As Integer = ObjInventario.Folio
If CveMovimiento > 0 Then
@@ -3242,7 +3266,7 @@ Partial Class OS_OrdenesServicios
If PropcesoOK Then
Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacenDestino, 9, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaPedido, CveSubProyectoPedido, -1, CveOS:=CveOS, CveMovimientoRelacionado:=CveMovimiento)
Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacenDestino, 9, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveMovimientoRelacionado:=CveMovimiento)
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
@@ -3272,7 +3296,7 @@ Partial Class OS_OrdenesServicios
Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL)
Dim LigaVenta As String = String.Format("Venta {2} en Folio: <a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a>", CveMovimiento, Folio, "Material utilizado")
If Not ObjEventos.AddEventoBitacora(LigaVenta, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaPedido, CveOS:=CveOS) Then
If Not ObjEventos.AddEventoBitacora(LigaVenta, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=Respuesta.CveVenta, CveOS:=CveOS) Then
PropcesoOK = False
End If
@@ -3285,7 +3309,7 @@ Partial Class OS_OrdenesServicios
End If
Else
Else
PropcesoOK = False
End If
@@ -3293,9 +3317,11 @@ Partial Class OS_OrdenesServicios
If PropcesoOK Then
'ObjV.RollBack()
ObjV.Commit()
Alert("La solicitud de Devolución de Almacén se guardó correctamente")
Alert($"Proceso finalizado correctamente Remision generada <a class=""Texto"" href=""/Ventas/Ventas.aspx?CveVenta={Respuesta.CveVenta}"">{Respuesta.SerieFolio}</a> ")
RegistraScript("$('#DVModalSolicitarDevolucion').modal('hide');")
Else
ObjV.RollBack()
@@ -3307,4 +3333,92 @@ Partial Class OS_OrdenesServicios
End Sub
Private Function GeneraRemision(CveVentaPedido As Integer, ByRef TransaccionSQL As SqlTransaction) As RespuestaFacturacion
Dim Respuesta = New RespuestaFacturacion()
Dim CveRemiocionGenerada As Integer = -1
Dim ObjVentas As New ClsVentas(TransaccionSQL)
Dim ProcesoOK As Boolean = True
Dim CveSubProyectoPedido As Integer = -1
Dim CveMoneda As Integer = -1
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Copy().Rows(0)
CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero
CveSubProyectoPedido = DbRowVenta("CveSubProyecto").ToString().ToEntero()
End If
Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, CveSubProyectoPedido, CveCliente, CveMoneda, "Ped")
If ObjFactura IsNot Nothing Then
If ProcesoOK Then
For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal
Dim CantidadDev As Decimal = GvRow.FCTextBox("TxtDev").Text.ToDecimal
Dim CantidadRegistro = Cantidad - CantidadDev
Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal
Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal
Dim Obs As String = GvRow.DataKey("Observaciones")
If Not ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido) Then
Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
ProcesoOK = False
Exit For
End If
Next
If ProcesoOK Then
ObjFactura.CalculaTotales()
Dim Resp As New Modelos.Factura.MMensajeFactura
Resp = ObjFactura.EmitirFactura(False, Transac:=TransaccionSQL)
If Resp.CveVenta > 0 Then
Respuesta.CveVenta = Resp.CveVenta
Respuesta.SerieFolio = Resp.SerieFolio
Else
ProcesoOK = False
End If
End If
End If
Else
ProcesoOK = False
End If
Return Respuesta
End Function
Friend Class RespuestaFacturacion
Public Property CveVenta As Integer = -1
Public Property SerieFolio As String = "-1"
Public Sub New()
End Sub
End Class
End Class