-- mejora para SMS

This commit is contained in:
2024-04-25 08:04:02 -07:00
parent 3ca779216a
commit 55b11bd627
2 changed files with 88 additions and 58 deletions

View File

@@ -2991,19 +2991,14 @@ Partial Class OS_OrdenesServicios
Select Case DdlTipoVenta.SelectedValue.ToEntero Select Case DdlTipoVenta.SelectedValue.ToEntero
Case 1, 2 ' *Fuera de liena *pago directo Case 1, 2 ' *Fuera de liena *pago directo
Opcion = 1 Opcion = 1
Exit Select
Case 3 ' por el momento ya no se usa Case 3 ' por el momento ya no se usa
Opcion = 2 Opcion = 2
Exit Select
Case 5 ' consignacion uso Case 5 ' consignacion uso
Opcion = 3 Opcion = 3
Exit Select
Case 6 ' a vista uso de material Case 6 ' a vista uso de material
Opcion = 4 Opcion = 4
Exit Select
Case Else Case Else
Opcion = 1 Opcion = 1
Exit Select
End Select End Select
Dim ObjOS As New ClsOS Dim ObjOS As New ClsOS
@@ -3080,7 +3075,7 @@ Partial Class OS_OrdenesServicios
TotalSeleccionado = TotalSeleccionado + GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal TotalSeleccionado = TotalSeleccionado + GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal
Next Next
If TotalSeleccionado = 0 Then If TotalSeleccionado = 0 Then
Alert("No se selecciono ningun material", TipoMensaje.MsgAdvertencia) Alert("No se seleccionó ningun material", TipoMensaje.MsgAdvertencia)
Exit Sub Exit Sub
End If End If
Else Else
@@ -3096,38 +3091,45 @@ Partial Class OS_OrdenesServicios
Dim ObjOS As New ClsOS(ObjV.IniciaTransacSQL()) Dim ObjOS As New ClsOS(ObjV.IniciaTransacSQL())
Dim ObjInventario As New ClsInventarios(ObjV.IniciaTransacSQL()) Dim ObjInventario As New ClsInventarios(ObjV.IniciaTransacSQL())
Dim ObjConta As New ClsContabilidad(ObjV.IniciaTransacSQL()) Dim ObjConta As New ClsContabilidad(ObjV.IniciaTransacSQL())
Dim GenrarRemisionMovimientos As Boolean = False Dim GenerarRemisionMovimientos As Boolean = False
If DdlTipoVenta.SelectedValue.ToEntero = 5 Then If DdlTipoVenta.SelectedValue = "5" Then 'Consignación - Uso Material
'genera una salida de almacen.
Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="OS/MatUtilConsig")
Dim Folio As Integer = ObjInventario.Folio
For Each GVRow As GridViewRow In GvMU.Rows If CveMovimientoSalida > 0 Then
Dim CantidadRegistro As Decimal = GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal For Each GVRow As GridViewRow In GvMU.Rows
Dim CvePS As Integer = GVRow.DataKey("CvePS").ToEntero Dim CantidadRegistro As Decimal = GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal
Dim CvePS As Integer = GVRow.DataKey("CvePS").ToEntero
If CantidadRegistro > 0 Then If CantidadRegistro > 0 Then
Dim Serie As String = If(GVRow.DataKey("Serie") = "", "-1", GVRow.DataKey("Serie")) Dim Serie As String = GVRow.DataKey("Serie")
Dim Lote As String = If(GVRow.DataKey("Lote") = "", "-1", GVRow.DataKey("Lote")) Dim Lote As String = GVRow.DataKey("Lote")
Dim FechaCaducidad As DateTime = If(GVRow.DataKey("FechaCaducidad") = "", MinFecha, GVRow.DataKey("FechaCaducidad").ToDate) Dim CveUM As Integer = GVRow.DataKey("CveUM").ToEntero
If Not ObjOS.AddOrdenesServicioMateriales(CveOS, CvePS, CantidadRegistro, Serie, Lote, FechaCaducidad, UsuarioActual.CveUsuario) Then Dim FechaCaducidad As DateTime = GVRow.DataKey("FechaCaducidad").ToDate
Alert("Ocurrió un error al guardar el material.", TipoMensaje.MsgAdvertencia) If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadRegistro, CveUM, CvePS, 0, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then
ProcesoOK = False Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia)
Exit For ProcesoOK = False
Exit For
End If
End If End If
End If Next
Next If ProcesoOK Then
If ProcesoOK Then Dim CveOSEstatusFinalizada As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 4").ToEntero
Dim CveOSEstatusFinalizada As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 4").ToEntero If CveOSEstatusFinalizada > 0 Then
If CveOSEstatusFinalizada > 0 Then If Not ObjOS.UpdateOrdenesServiciosEstatus(CveOSEstatusFinalizada, UsuarioActual.CveUsuario, CveOS) Then
If Not ObjOS.UpdateOrdenesServiciosEstatus(CveOSEstatusFinalizada, UsuarioActual.CveUsuario, CveOS) Then ProcesoOK = False
End If
Else
Alert("No se pudo obtener el estado para finalizar la orden de servicio.")
ProcesoOK = False ProcesoOK = False
End If End If
Else
Alert("No se pudo obtener el estado para finalizar la orden de servicio.")
ProcesoOK = False
End If End If
Else
ProcesoOK = False
End If End If
Else Else
If ProcesoOK Then If ProcesoOK Then
Dim AplicaDevolucion As Boolean = False Dim AplicaDevolucion As Boolean = False
@@ -3135,20 +3137,19 @@ Partial Class OS_OrdenesServicios
Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero
Dim CantidadDev As Decimal = GvRow.DataKey("Cantidad").ToDecimal - GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal Dim CantidadDev As Decimal = GvRow.DataKey("Cantidad").ToDecimal - GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal
If CantidadDev > 0 Then If CantidadDev > 0 AndAlso CveVentaDetalle > 0 Then
AplicaDevolucion = True AplicaDevolucion = True
If Not ObjV.UpdateVentasDetalleCantidadDevolucion(CveVentaDetalle, CantidadDev) Then If Not ObjV.UpdateVentasDetalleCantidadDevolucion(CveVentaDetalle, CantidadDev) Then
ProcesoOK = False ProcesoOK = False
GenrarRemisionMovimientos = False GenerarRemisionMovimientos = False
AplicaDevolucion = False AplicaDevolucion = False
Exit For Exit For
End If End If
End If End If
If GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal > 0 Then If GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal > 0 Then
GenrarRemisionMovimientos = True GenerarRemisionMovimientos = True
End If End If
Next Next
If AplicaDevolucion Then If AplicaDevolucion Then
If Not ObjV.UpdateVentasDevolucionAlmacen(1, CveVentaPedido) Then If Not ObjV.UpdateVentasDevolucionAlmacen(1, CveVentaPedido) Then
@@ -3162,29 +3163,36 @@ Partial Class OS_OrdenesServicios
Dim ImporteAlmacen As Decimal Dim ImporteAlmacen As Decimal
Dim Fecha As DateTime = ClsPaginas.NowADS() Dim Fecha As DateTime = ClsPaginas.NowADS()
If GenrarRemisionMovimientos AndAlso ProcesoOK Then If GenerarRemisionMovimientos AndAlso ProcesoOK Then
If Not TxtFolioRemisionModal.Text.Trim.Length > 0 Then If Not TxtFolioRemisionModal.Text.Trim.Length > 0 Then
Alert("El campo Folio es requerido por favor ingreselo.", TipoMensaje.MsgAdvertencia) Alert("El campo Folio es requerido por favor ingréselo.", TipoMensaje.MsgAdvertencia)
ProcesoOK = False ProcesoOK = False
GenrarRemisionMovimientos = False GenerarRemisionMovimientos = False
End If End If
End If End If
If GenrarRemisionMovimientos AndAlso ProcesoOK Then If GenerarRemisionMovimientos AndAlso ProcesoOK Then
Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL()) Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL())
If Respuesta.CveVenta > 0 Then If Respuesta.CveVenta > 0 Then
If ObjV.GetVentaDetalle(Respuesta.CveVenta) Then If ObjV.GetVentaDetalle(Respuesta.CveVenta) Then
Dim dtClon As DataTable = ObjV.DtResultados.Copy Dim dtClon As DataTable = ObjV.DtResultados.Copy
dtClon.DefaultView.Sort = "CveVentaDetalle ASC" dtClon.DefaultView.Sort = "CveVentaDetalle ASC"
DtVentaDetalle = dtClon.DefaultView.ToTable() Dim dtmat As DataTable = dtClon.DefaultView.ToTable()
'una vez registrada, asocia los lotes/cad con el cveventadetalle para que se surta así
DtVentaDetalle = Respuesta.dtdetalle
For i = 0 To dtmat.Rows.Count - 1
If DtVentaDetalle.Rows(i)("CvePS").ToString = dtmat.Rows(i)("CvePS").ToString Then
DtVentaDetalle.Rows(i)("CveVentaDetalle") = dtmat.Rows(i)("CveVentaDetalle")
End If
Next
End If End If
Else Else
ProcesoOK = False ProcesoOK = False
End If End If
End If End If
If GenrarRemisionMovimientos AndAlso ProcesoOK Then If GenerarRemisionMovimientos AndAlso ProcesoOK Then
CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="OS/MatUtil") CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="OS/MatUtil")
Dim Folio As Integer = ObjInventario.Folio Dim Folio As Integer = ObjInventario.Folio
@@ -3192,17 +3200,17 @@ Partial Class OS_OrdenesServicios
If CveMovimientoSalida > 0 Then If CveMovimientoSalida > 0 Then
Dim IndexMov1 As Integer = 0 Dim IndexMov1 As Integer = 0
For Each GvRow As GridViewRow In GvMU.Rows For Each drr As DataRow In DtVentaDetalle.Rows
Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal Dim Cantidad As Decimal = drr("Cantidad").ToString.ToDecimal
Dim CantidadRegistro As Decimal = GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal 'Dim CantidadRegistro As Decimal = GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero Dim CvePS As Integer = drr("CvePS").ToString.ToEntero
Dim CveUM As Integer = GvRow.DataKey("CveUM").ToEntero Dim CveUM As Integer = drr("CveUM").ToString.ToEntero
Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal Dim PU As Decimal = drr("PU").ToString.ToDecimal
If CantidadRegistro > 0 Then If Cantidad > 0 Then
Dim CveVentaDetalle As Integer = DtVentaDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePadre = {GvRow.DataKey("CveVentaDetalle")}").ToEntero Dim CveVentaDetalle As Integer = drr("CveVentaDetalle").ToString.ToEntero 'DtVentaDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePadre = {GvRow.DataKey("CveVentaDetalle")}").ToEntero
Dim CveMovimientoDetalle As Integer = GvRow.DataKey("CveMovimientoDetalle").ToEntero Dim CveMovimientoDetalle As Integer = -1 'GvRow.DataKey("CveMovimientoDetalle").ToEntero
If CveVentaDetalle <= 0 Then If CveVentaDetalle <= 0 Then
Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia) Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia)
@@ -3210,10 +3218,10 @@ Partial Class OS_OrdenesServicios
Exit For Exit For
End If End If
Dim Serie As String = GvRow.DataKey("Serie") Dim Serie As String = "" 'GvRow.DataKey("Serie")
Dim Lote As String = GvRow.DataKey("Lote") Dim Lote As String = drr("Lote").ToString
Dim FechaCaducidad As DateTime = GvRow.DataKey("FechaCaducidad").ToDate Dim FechaCaducidad As DateTime = drr("FechaCaducidad").ToString.ToDate
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadRegistro, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then
Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia) Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia)
ProcesoOK = False ProcesoOK = False
Exit For Exit For
@@ -3312,7 +3320,7 @@ Partial Class OS_OrdenesServicios
Dim Liga As String = $" document.location.href=""/OS/OrdenesServicios.aspx?CveOS={CveOS}""; " Dim Liga As String = $" document.location.href=""/OS/OrdenesServicios.aspx?CveOS={CveOS}""; "
Alert("El material utilizado se guardó correctamente", TipoMensaje.MsgInformacion, Liga) Alert("El material utilizado se guardó correctamente", TipoMensaje.MsgInformacion, Liga)
Else Else
If GenrarRemisionMovimientos = False Then If GenerarRemisionMovimientos = False Then
Alert("El material sera recibido en almacén.") Alert("El material sera recibido en almacén.")
Else Else
Alert("El material utilizado se guardó correctamente") Alert("El material utilizado se guardó correctamente")
@@ -3401,6 +3409,16 @@ Partial Class OS_OrdenesServicios
ObjFactura.Episodio = TxtEpisodioModal.Text.Trim ObjFactura.Episodio = TxtEpisodioModal.Text.Trim
ObjFactura.Alfa1 = TxtFolioRemisionModal.Text.Trim ObjFactura.Alfa1 = TxtFolioRemisionModal.Text.Trim
Dim TmpDTMat As New DataTable
TmpDTMat.Columns.Add("Consec", GetType(Integer))
TmpDTMat.Columns.Add("CvePS", GetType(Integer))
TmpDTMat.Columns.Add("CveUM", GetType(Integer))
TmpDTMat.Columns.Add("Cantidad", GetType(Integer))
TmpDTMat.Columns.Add("PU", GetType(Decimal))
TmpDTMat.Columns.Add("Lote", GetType(String))
TmpDTMat.Columns.Add("FechaCaducidad", GetType(Date))
TmpDTMat.Columns.Add("CveVentaDetalle", GetType(Integer))
For Each GvRow As GridViewRow In GvMU.Rows For Each GvRow As GridViewRow In GvMU.Rows
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
@@ -3409,8 +3427,17 @@ Partial Class OS_OrdenesServicios
Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal
Dim Obs As String = GvRow.DataKey("Observaciones") Dim Obs As String = GvRow.DataKey("Observaciones")
If CantidadRegistro > 0 Then If CantidadRegistro > 0 Then
If Not ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=GvRow.DataKey("CveVentaDetalle").ToEntero) Then If ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=GvRow.DataKey("CveVentaDetalle").ToEntero) Then
Dim drp As DataRow = TmpDTMat.NewRow
drp("CvePS") = CvePS
drp("Cantidad") = CantidadRegistro
drp("PU") = PU
drp("Lote") = GvRow.DataKey("Lote")
drp("FechaCaducidad") = GvRow.DataKey("FechaCaducidad").ToDate
TmpDTMat.Rows.Add(drp)
Else
Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia) Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
ProcesoOK = False ProcesoOK = False
Exit For Exit For
@@ -3426,6 +3453,7 @@ Partial Class OS_OrdenesServicios
If Resp.CveVenta > 0 Then If Resp.CveVenta > 0 Then
Respuesta.CveVenta = Resp.CveVenta Respuesta.CveVenta = Resp.CveVenta
Respuesta.SerieFolio = Resp.SerieFolio Respuesta.SerieFolio = Resp.SerieFolio
Respuesta.dtdetalle = TmpDTMat
Else Else
ProcesoOK = False ProcesoOK = False
End If End If
@@ -3442,6 +3470,7 @@ Partial Class OS_OrdenesServicios
Friend Class RespuestaFacturacion Friend Class RespuestaFacturacion
Public Property CveVenta As Integer = -1 Public Property CveVenta As Integer = -1
Public Property SerieFolio As String = "-1" Public Property SerieFolio As String = "-1"
Public Property dtdetalle As DataTable = Nothing
Public Sub New() Public Sub New()
End Sub End Sub

View File

@@ -13691,14 +13691,14 @@ Partial Class Ventas
Else Else
CveAlmacenTraspasoDestino = drr("CveAlmacenAsignado").ToString.ToEntero '' cuando Fuera de Línea CveAlmacenTraspasoDestino = drr("CveAlmacenAsignado").ToString.ToEntero '' cuando Fuera de Línea
End If End If
End If
End If End If
End If
If Not CveAlmacenTraspasoDestino > 0 Then If Not CveAlmacenTraspasoDestino > 0 Then ' para consignación es salida directa
CveAlmacenTraspasoDestino = CveAlmacenAsignado CveAlmacenTraspasoDestino = CveAlmacenAsignado
End If End If
If RBLTipoVenta.SelectedValue.ToEntero = 2 Then If RBLTipoVenta.SelectedValue = "2" Then
If Not ChkRequiereTecnico.Checked Then If Not ChkRequiereTecnico.Checked Then
CveAlmacenTraspasoDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 10 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString().ToEntero() CveAlmacenTraspasoDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 10 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString().ToEntero()
End If End If
@@ -13712,6 +13712,7 @@ Partial Class Ventas
ErrorList.Add("Ocurrió un error al seleccionar el almacen de resguardo del cliente.") ErrorList.Add("Ocurrió un error al seleccionar el almacen de resguardo del cliente.")
End If End If
End If End If
End If End If
Dim TotalImpuestoLocal As Double = 0 Dim TotalImpuestoLocal As Double = 0