-- mejoras en tipos de venta

This commit is contained in:
2024-09-20 12:32:10 -07:00
parent 0d4add5d3c
commit 4ed9e71aeb

View File

@@ -454,7 +454,7 @@ Partial Class OS_OrdenesServicios
End If End If
End If End If
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then
BtnCancelar.Text = "Cancelar Cirugía" BtnCancelar.Text = "Cancelar Cirugía"
HplRegresar.NavigateUrl = "/OS/RepOSMedicas.aspx" HplRegresar.NavigateUrl = "/OS/RepOSMedicas.aspx"
@@ -2980,12 +2980,12 @@ Partial Class OS_OrdenesServicios
End Sub End Sub
Protected Sub LnkAccionesMaterialUtilizado_Click(sender As Object, e As EventArgs) Protected Sub LnkAccionesMaterialUtilizado_Click(sender As Object, e As EventArgs)
If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then
LnkModalMaterialUtilizado.Visible = True LnkModalMaterialUtilizado.Visible = True
DTSolicitudDev = New DataTable DTSolicitudDev = New DataTable
Dim Opcion As Integer = If(DdlTipoVenta.SelectedValue.Contiene("2", "3"), 2, 1) Dim Opcion As Integer = If(DdlTipoVenta.SelectedValue.Contiene("2", "3"), 2, 1)
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
@@ -3000,7 +3000,7 @@ Partial Class OS_OrdenesServicios
End Select End Select
Dim ObjOS As New ClsOS Dim ObjOS As New ClsOS
If ObjOS.GetOrdenesServicioDevolucionMaterial(CveOS, If(UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1, CvePedido, CveVenta), Opcion, UsuarioActual.CveEmpresa) Then If ObjOS.GetOrdenesServicioDevolucionMaterial(CveOS, If(UsuarioActual.Empresa.Funcionalidad(578) = "1", CvePedido, CveVenta), Opcion, UsuarioActual.CveEmpresa) Then
DTSolicitudDev = ObjOS.DtResultados DTSolicitudDev = ObjOS.DtResultados
GvMU.DataSource = DTSolicitudDev GvMU.DataSource = DTSolicitudDev
GvMU.Columns(3).Visible = DTSolicitudDev.MIN("Serie") <> "" GvMU.Columns(3).Visible = DTSolicitudDev.MIN("Serie") <> ""
@@ -3019,18 +3019,16 @@ Partial Class OS_OrdenesServicios
LnkModalMaterialUtilizado.Visible = False LnkModalMaterialUtilizado.Visible = False
End If End If
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
TxtPacienteModal.Text = TxtPaciente.Text TxtPacienteModal.Text = TxtPaciente.Text
TxtEpisodioModal.Text = TxtIdentificadorCliente.Text TxtEpisodioModal.Text = TxtIdentificadorCliente.Text
TxtFolioRemisionModal.Text = TxtFolioAdicional.Text TxtFolioRemisionModal.Text = TxtFolioAdicional.Text
End If
If DdlTipoVenta.SelectedValue.ToEntero = 5 Then If DdlTipoVenta.SelectedValue.ToEntero = 5 Then
DvTxtFolioRemisionModal.Visible = False DvTxtFolioRemisionModal.Visible = False
Else Else
DvTxtFolioRemisionModal.Visible = True DvTxtFolioRemisionModal.Visible = True
End If End If
End If
UpModalMaterialUtilizado.Update() UpModalMaterialUtilizado.Update()
End Sub End Sub
@@ -3048,7 +3046,10 @@ Partial Class OS_OrdenesServicios
Dim ProcesoOK As Boolean = True Dim ProcesoOK As Boolean = True
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then
Dim CveAlmacenDestino As Integer = -1
Dim CveSubProyectoPedido As Integer
'---------------- INICIO VALIDACIONES -----------------
If TxtPacienteModal.Text.Trim.Length = 0 Then If TxtPacienteModal.Text.Trim.Length = 0 Then
Alert("Debe de proporcionar el paciente.", TipoMensaje.MsgAdvertencia) Alert("Debe de proporcionar el paciente.", TipoMensaje.MsgAdvertencia)
Exit Sub Exit Sub
@@ -3058,7 +3059,6 @@ Partial Class OS_OrdenesServicios
Alert("Debe de proporcionar el episodio.", TipoMensaje.MsgAdvertencia) Alert("Debe de proporcionar el episodio.", TipoMensaje.MsgAdvertencia)
Exit Sub Exit Sub
End If End If
End If
Dim TieneArchivos As Boolean = False Dim TieneArchivos As Boolean = False
Dim Filesgral As List(Of Archivo) = AnexoManerialUtilizado.getfiles().Archivos Dim Filesgral As List(Of Archivo) = AnexoManerialUtilizado.getfiles().Archivos
@@ -3071,32 +3071,37 @@ Partial Class OS_OrdenesServicios
Exit Sub Exit Sub
End If End If
Dim CveAlmacenActual As Integer = DTSolicitudDev.FiltroPrimeroValor("CveAlmacenActual").ToEntero
Dim CveMoneda As Integer = DTSolicitudDev.FiltroPrimeroValor("CveMoneda").ToEntero
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
Dim CveVentaRemisionGenerada As Integer = -1
If DdlTipoVenta.SelectedValue.ToEntero = 5 Then
Dim TotalSeleccionado As Decimal = 0 Dim TotalSeleccionado As Decimal = 0
For Each GVRow As GridViewRow In GvMU.Rows For Each GVRow As GridViewRow In GvMU.Rows
TotalSeleccionado = TotalSeleccionado + GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal TotalSeleccionado = TotalSeleccionado + GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal
Next Next
If DdlTipoVenta.SelectedValue = "5" Then
If TotalSeleccionado = 0 Then If TotalSeleccionado = 0 Then
Alert("No se seleccionó ningun material", TipoMensaje.MsgAdvertencia) Alert("No se seleccionó ningun material", TipoMensaje.MsgAdvertencia)
Exit Sub Exit Sub
End If End If
Else Else
CveSubProyectoPedido = DTSolicitudDev.FiltroPrimeroValor("CveSubProyecto").ToEntero
CveAlmacenDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa, 10).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {CveSubProyectoPedido}").ToEntero
If Not CveAlmacenDestino > 0 Then If Not CveAlmacenDestino > 0 Then
Alert("No se encontró almacen de entrega por adelantado", TipoMensaje.MsgAdvertencia) Alert("No se encontró almacen de entrega por adelantado", TipoMensaje.MsgAdvertencia)
Exit Sub Exit Sub
End If End If
End If End If
If TotalSeleccionado > 0 AndAlso Not TxtFolioRemisionModal.Text.Trim.Length > 0 Then
Alert("El campo Folio es requerido por favor ingréselo.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'---------------- FIN VALIDACIONES -----------------
Dim CveAlmacenActual As Integer = DTSolicitudDev.FiltroPrimeroValor("CveAlmacenActual").ToEntero
Dim CveMoneda As Integer = DTSolicitudDev.FiltroPrimeroValor("CveMoneda").ToEntero
Dim CveVentaPedido As Integer = DTSolicitudDev.FiltroPrimeroValor("CveVenta").ToEntero
Dim CveVentaRemisionGenerada As Integer = -1
Dim ObjV As New ClsVentas Dim ObjV As New ClsVentas
Dim ObjOS As New ClsOS(ObjV.IniciaTransacSQL()) Dim ObjOS As New ClsOS(ObjV.IniciaTransacSQL())
@@ -3155,28 +3160,27 @@ Partial Class OS_OrdenesServicios
End If End If
End If End If
End If End If
'asigno la cveventa, como concluido
If ProcesoOK Then
If Not ObjOS.UpdateVentaOS(CveVenta, CveOS, UsuarioActual.CveEmpresa, TxtPacienteModal.Text.Trim, TxtEpisodioModal.Text.Trim, FolioAdicional:=TxtFolioRemisionModal.Text.Trim) Then
ProcesoOK = False
End If
End If
Else Else
ProcesoOK = False ProcesoOK = False
End If End If
Dim DT_Ventas_Detalles As DataTable = DTSolicitudDev.FiltraParametros("", "", {"CantidadPedido", "CvePS", "CveVentaDetalle"}) Dim DT_Ventas_Detalles As DataTable = DTSolicitudDev.FiltraParametros("", "", {"CantidadPedido", "CvePS", "CveVentaDetalle"})
DT_Ventas_Detalles.Columns.Add("CantidadUsada", GetType(Decimal)) DT_Ventas_Detalles.Columns.Add("CantidadUsada", GetType(Decimal))
DT_Ventas_Detalles.AcceptChanges() DT_Ventas_Detalles.AcceptChanges()
For Each dRow As DataRow In DT_Ventas_Detalles.Rows For Each dRow As DataRow In DT_Ventas_Detalles.Rows
For Each gvRow As GridViewRow In GvMU.Rows For Each gvRow As GridViewRow In GvMU.Rows
Dim CantidadUsada As Decimal = gvRow.FCTextBox("TxtUtilizado").Text.ToDecimal Dim CantidadUsada As Decimal = gvRow.FCTextBox("TxtUtilizado").Text.ToDecimal
If dRow("CvePS").ToString.ToDecimal = gvRow.DataKey("CvePS").ToDecimal AndAlso CantidadUsada > 0 Then If dRow("CvePS").ToString.ToDecimal = gvRow.DataKey("CvePS").ToDecimal AndAlso CantidadUsada > 0 Then
dRow("CantidadUsada") = dRow("CantidadUsada").ToString.ToDecimal + CantidadUsada dRow("CantidadUsada") = dRow("CantidadUsada").ToString.ToDecimal + CantidadUsada
End If End If
Next Next
Next Next
For Each dRow As DataRow In DT_Ventas_Detalles.Rows For Each dRow As DataRow In DT_Ventas_Detalles.Rows
@@ -3188,14 +3192,16 @@ Partial Class OS_OrdenesServicios
End If End If
End If End If
Next Next
Else Else
'' otros opciones <> 5
If ProcesoOK Then If ProcesoOK Then
Dim AplicaDevolucion As Boolean = False Dim AplicaDevolucion As Boolean = False
Dim StrCveVentasDetalle As New StringBuilder
For Each GvRow As GridViewRow In GvMU.Rows For Each GvRow As GridViewRow In GvMU.Rows
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
StrCveVentasDetalle.AppendFormat("{0},", CveVentaDetalle)
If CantidadDev > 0 AndAlso CveVentaDetalle > 0 Then If CantidadDev > 0 AndAlso CveVentaDetalle > 0 Then
AplicaDevolucion = True AplicaDevolucion = True
@@ -3206,7 +3212,6 @@ Partial Class OS_OrdenesServicios
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
GenerarRemisionMovimientos = True GenerarRemisionMovimientos = True
End If End If
@@ -3216,9 +3221,15 @@ Partial Class OS_OrdenesServicios
ProcesoOK = False ProcesoOK = False
End If End If
End If End If
' obtiene las ventasdetalle del pedido/rem, para recorrerlas y si hay alguna solo solicitada pero no surtida, que no siga pendiente de surtir.
If ProcesoOK AndAlso ObjV.GetVentaDetalle(CveVentaPedido) Then
Dim DtVentasDetalle As DataTable = ObjV.DtResultados
Dim dtt As DataTable = DtVentasDetalle.FiltraParametros($"CveVentaDetalle NOT IN ({StrCveVentasDetalle.ToString} -1)")
For Each dr As DataRow In dtt.Rows
ObjInventario.UpdateEstatusAlmacen(dr("CveVentaDetalle").ToString.ToEntero, 1) 'para no surtirse
Next
End If
End If End If
'ProcesoOK = False
Dim Respuesta As New RespuestaFacturacion() Dim Respuesta As New RespuestaFacturacion()
Dim DtVentaDetalle As New DataTable Dim DtVentaDetalle As New DataTable
@@ -3226,14 +3237,6 @@ 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 GenerarRemisionMovimientos AndAlso ProcesoOK Then
If Not TxtFolioRemisionModal.Text.Trim.Length > 0 Then
Alert("El campo Folio es requerido por favor ingréselo.", TipoMensaje.MsgAdvertencia)
ProcesoOK = False
GenerarRemisionMovimientos = False
End If
End If
If GenerarRemisionMovimientos AndAlso ProcesoOK Then If GenerarRemisionMovimientos AndAlso ProcesoOK Then
Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL()) Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL())
@@ -3283,7 +3286,6 @@ Partial Class OS_OrdenesServicios
ProcesoOK = False ProcesoOK = False
Exit For Exit For
End If End If
Dim Serie As String = drr("Serie").ToString Dim Serie As String = drr("Serie").ToString
Dim Lote As String = drr("Lote").ToString Dim Lote As String = drr("Lote").ToString
Dim FechaCaducidad As DateTime = drr("FechaCaducidad").ToString.ToDate Dim FechaCaducidad As DateTime = drr("FechaCaducidad").ToString.ToDate
@@ -3350,7 +3352,6 @@ Partial Class OS_OrdenesServicios
ProcesoOK = False ProcesoOK = False
End If End If
End If End If
End If End If
Else Else
ProcesoOK = False ProcesoOK = False
@@ -3368,7 +3369,6 @@ Partial Class OS_OrdenesServicios
End If End If
End If End If
If ProcesoOK Then If ProcesoOK Then
If Not ObjOS.UpdateVentaOS(-1, CveOS, UsuarioActual.CveEmpresa, TxtPacienteModal.Text.Trim, TxtEpisodioModal.Text.Trim) Then If Not ObjOS.UpdateVentaOS(-1, CveOS, UsuarioActual.CveEmpresa, TxtPacienteModal.Text.Trim, TxtEpisodioModal.Text.Trim) Then
ProcesoOK = False ProcesoOK = False
@@ -3401,7 +3401,7 @@ Partial Class OS_OrdenesServicios
End If End If
ObjV.Dispose() ObjV.Dispose()
End If
End Sub End Sub
@@ -3609,13 +3609,10 @@ Partial Class OS_OrdenesServicios
End Class End Class
Protected Sub LnkActualizarUsaurioAtendio_Click(sender As Object, e As EventArgs) Protected Sub LnkActualizarUsaurioAtendio_Click(sender As Object, e As EventArgs)
If DdlUsuarioAtendio.SelectedValue.ToEntero > 0 Then If DdlUsuarioAtendio.SelectedValue.ToEntero > 0 Then
Dim ObjOS As New ClsOS Dim ObjOS As New ClsOS
ObjOS.IniciaTransacSQL() ObjOS.IniciaTransacSQL()
Dim ProcesoOk As Boolean = True Dim ProcesoOk As Boolean = True
For Each GvRow As GridViewRow In GvPS.Rows For Each GvRow As GridViewRow In GvPS.Rows
@@ -3637,13 +3634,10 @@ Partial Class OS_OrdenesServicios
Alert($"Se presento un error al actualizar el técnico.") Alert($"Se presento un error al actualizar el técnico.")
CargaHistorial() CargaHistorial()
End If End If
Else Else
Alert("Debe de seleccionar un ténico para actualziar", TipoMensaje.MsgAdvertencia) Alert("Debe de seleccionar un ténico para actualziar", TipoMensaje.MsgAdvertencia)
End If End If
End Sub End Sub
Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound
@@ -3692,7 +3686,6 @@ Partial Class OS_OrdenesServicios
Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs) Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs)
Dim CveEstatusOrdenServicioCancelacion As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", " TipoEstatus = 5 ").ToEntero Dim CveEstatusOrdenServicioCancelacion As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", " TipoEstatus = 5 ").ToEntero
Dim CveAlmacenDevolucion As Integer Dim CveAlmacenDevolucion As Integer
Dim CveMotivoCancelacion As Integer = GlobalDTMotivosCancelacionEmpresa(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMotivoCancelacion", "CveSATMotivoCancelacion IN (3)").ToEntero Dim CveMotivoCancelacion As Integer = GlobalDTMotivosCancelacionEmpresa(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMotivoCancelacion", "CveSATMotivoCancelacion IN (3)").ToEntero
@@ -3710,9 +3703,7 @@ Partial Class OS_OrdenesServicios
Dim ObjFacturaCancelacion As New Modelos.Factura(UsuarioActual, CvePedido, UsuarioActual.CveEmpresa, EsCancelacion:=True, VerificaAlmacen:=True) Dim ObjFacturaCancelacion As New Modelos.Factura(UsuarioActual, CvePedido, UsuarioActual.CveEmpresa, EsCancelacion:=True, VerificaAlmacen:=True)
Try Try
Dim resp As Modelos.Factura.MCancelacionVentaMensaje = Nothing Dim resp As Modelos.Factura.MCancelacionVentaMensaje = Nothing
If ObjFacturaCancelacion IsNot Nothing AndAlso ObjFacturaCancelacion.CveVenta > 0 Then If ObjFacturaCancelacion IsNot Nothing AndAlso ObjFacturaCancelacion.CveVenta > 0 Then
Dim SWatch As New Stopwatch Dim SWatch As New Stopwatch
@@ -3728,16 +3719,11 @@ Partial Class OS_OrdenesServicios
Alert($"Se presento un error al cancelar la orden de servicio, {resp.Mensaje}".ToString(), TipoMensaje.MsgError) Alert($"Se presento un error al cancelar la orden de servicio, {resp.Mensaje}".ToString(), TipoMensaje.MsgError)
Else Else
Alert($"la orden de servicio se cancelada correctamente, {resp.Mensaje}", resp.TipoMensaje, " location.reload(true); ") Alert($"la orden de servicio se cancelada correctamente, {resp.Mensaje}", resp.TipoMensaje, " location.reload(true); ")
Dim objGeneral As New ClsGenerales Dim objGeneral As New ClsGenerales
objGeneral.AddHistorialBitacora(256, -1, -1, -1, CveOS, -1, -1, -1, "Cancelada", DdlEstatusOS.SelectedItem.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "", "", "") objGeneral.AddHistorialBitacora(256, -1, -1, -1, CveOS, -1, -1, -1, "Cancelada", DdlEstatusOS.SelectedItem.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "", "", "")
objGeneral.Dispose() objGeneral.Dispose()
End If End If
End If End If
Catch ex As Exception Catch ex As Exception
Alert("Se presento un error al cancelar la orden de servicio") Alert("Se presento un error al cancelar la orden de servicio")
End Try End Try