diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index ed0cddaef..a4ba539f8 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -160,6 +160,7 @@ Public Class ClsClientes Public Property CodigoRegimenFiscal As String Public Property RegimenFiscal As String Public Property RepresentanteLegal As String + Public Property CveAlmacenAsignado As Integer #End Region @@ -406,6 +407,8 @@ Public Class ClsClientes _RegimenFiscal = Data(0)("RegimenFiscal").ToString _CodigoRegimenFiscal = Data(0)("CodigoRegimenFiscal").ToString _RepresentanteLegal = Data(0)("RepresentanteLegal").ToString + Me.CveAlmacenAsignado = Data(0)("CveAlmacenAsignado").ToString.ToEntero + End If Retorno = True diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index 086af8b9c..1fe41381d 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -6141,6 +6141,25 @@ Public Class ClsInventarios Return Retorno End Function + Public Function UpdatePedidoDetalleCantidad(CveVentaDetalle As Integer, Cantidad As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetalleCantidadUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la cantidad de pedido.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + #Region " IDisposable Support " ' IDisposable Protected Overridable Sub Dispose(ByVal disposing As Boolean) @@ -6169,6 +6188,8 @@ Public Class ClsInventarios Dispose(True) GC.SuppressFinalize(Me) End Sub + + #End Region End Class diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 45c401eb8..2db30fb66 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -6359,6 +6359,31 @@ Public Class ClsVentas Return Retorno End Function #End Region + + + Public Function GetVentasMedicasIndicadoresRep(Grupo As Integer, FechaI As Date, FechaF As Date, CveCliente As Integer, CveMedico As Integer, CveProcedimiento As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasMedicasIndicadoresRepGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Grupo", SqlDbType.Int).Value = Grupo + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveMedico", SqlDbType.Int).Value = CveMedico + .Add("@CveProcedimiento", SqlDbType.Int).Value = CveProcedimiento + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de ultilidades.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + + End Function + #Region "IDisposable Support" diff --git a/Compras/ReembolsosComprobaciones.aspx.vb b/Compras/ReembolsosComprobaciones.aspx.vb index aec735a45..164479187 100644 --- a/Compras/ReembolsosComprobaciones.aspx.vb +++ b/Compras/ReembolsosComprobaciones.aspx.vb @@ -659,9 +659,11 @@ Partial Class Compras_ReembolsosComprobaciones 'registramos el nuevo IE If CveCajaChica > 0 Then + + Dim ImporIEPago As Decimal = ImporteMovto + gvr.FCTextBox("TxtComision").Text.ToDecimal CveIEPago = 0 Dim FolioIENew As String = ObjIE.GetNextFolio(CveCajaChica, 6).ToString - CveIEPago = ObjIE.AddBancos_IE(CveCajaChica, 6, If(ChkReembolsarSinBancos.Checked, TxtFechaPrePoliza.Text.ToDate, TxtFechaDocumento.Text.ToDate), FolioIENew, gvr.DataKey("Proveedor"), ImporteMovto, CveMoneda, 0.0, $"{gvr.DataKey("Proveedor")} F:{gvr.DataKey("SerieFolio")} {If(DdlPersonal.Visible, DdlPersonal.SelectedItem.Text, DdlCajaChica.SelectedItem.Text)}", "", False, True, -1, CvePrePolizaPago, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FueConciliado:=If(ChkReembolsarSinBancos.Checked Or CveCajaChica > 0, True, False)) + CveIEPago = ObjIE.AddBancos_IE(CveCajaChica, 6, If(ChkReembolsarSinBancos.Checked, TxtFechaPrePoliza.Text.ToDate, TxtFechaDocumento.Text.ToDate), FolioIENew, gvr.DataKey("Proveedor"), ImporIEPago, CveMoneda, 0.0, $"{gvr.DataKey("Proveedor")} F:{gvr.DataKey("SerieFolio")} {If(DdlPersonal.Visible, DdlPersonal.SelectedItem.Text, DdlCajaChica.SelectedItem.Text)}", "", False, True, -1, CvePrePolizaPago, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FueConciliado:=If(ChkReembolsarSinBancos.Checked Or CveCajaChica > 0, True, False)) TipoCambioPago = 1 Else CveIEPago = CveIERegistrado diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index 499a952eb..dc0b50a52 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -2,14 +2,15 @@ Option Explicit On Imports System.Data +Imports System.Data.SqlClient Imports System.IO Imports Extensiones Imports Microsoft.Reporting.WebForms Partial Class Inventarios_EntregaAlmacen - Inherits ClsPaginas - + Inherits ClsPaginas + #Region "PROPIEDADES" Private Property CveVentaAD As Integer Get @@ -317,13 +318,25 @@ Partial Class Inventarios_EntregaAlmacen Set(value As Boolean) ViewState("CargaBitacora") = value End Set - End Property - - - - + End Property + + + Private Property PedidoBloqueCantidad As Boolean + Get + If ViewState("PedidoBloqueCantidad") Is Nothing Then + ViewState("PedidoBloqueCantidad") = False + End If + Return Boolean.Parse(ViewState("PedidoBloqueCantidad").ToString) + End Get + Set(value As Boolean) + ViewState("PedidoBloqueCantidad") = value + End Set + End Property + + + #End Region - + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then @@ -339,9 +352,9 @@ Partial Class Inventarios_EntregaAlmacen End If End If - End Sub - - + End Sub + + #Region " INICIALIZA VALORES " Private Sub InicializaValores() TipoEstatus = -1 @@ -412,11 +425,11 @@ Partial Class Inventarios_EntregaAlmacen CreaDtDetalleLote() CargaPendientes() LimpiaCampos() - End Sub - + End Sub + #End Region - - + + #Region " CARGA PARAMETROS - EXCLUSIVO USO AD " Private Sub CargaParametrosAD() @@ -434,9 +447,9 @@ Partial Class Inventarios_EntregaAlmacen BtnGuardar.Visible = False End If - End Sub + End Sub #End Region - + #Region " CARGA PENDIENTES POR SURTIR " Protected Sub DdlCliente_SelectedIndexChanged(sender As Object, e As EventArgs) CargaFolios() @@ -552,11 +565,11 @@ Partial Class Inventarios_EntregaAlmacen End Select UpPendientes.Update() End If - End Sub - + End Sub + #End Region - - + + #Region " CARGA VENTA POR SURTIR " Protected Sub BtnSurtir_Click(sender As Object, e As EventArgs) @@ -644,7 +657,7 @@ Partial Class Inventarios_EntregaAlmacen EsDevolucionVenta = drE("EsDevolucionVenta").ToString().ToEntero() TipoDocto = DtDatos.Rows(0)("TipoDocto").ToString() - TipoMovimiento = If(TipoDocto.Contiene({"Rem", "Ing", "Ped", "PeC", "Ant"}) And (EsDevolucionVenta = 0 Or CveVentaAD > 0), 1, 2) + TipoMovimiento = If(TipoDocto.Contiene({"Rem", "Ped", "Ing", "Ped", "PeC", "Ant"}) And (EsDevolucionVenta = 0 Or CveVentaAD > 0), 1, 2) LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString() HLFolio.Text = drE("SerieFolio").ToString() @@ -663,8 +676,8 @@ Partial Class Inventarios_EntregaAlmacen LbObservacionesAlmacen.Text = drE("ObservacionesAlmacen").ToString() CveVentaSurtir = CveVenta CveOSSurtir = CveOS - CveAlmacenTraspasoDestino = drE(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "CveAlmacenTraspasoOrigen", "CveAlmacenTraspasoDestino")).ToString().ToEntero() - CveAlmacenTraspasoOrigen = drE(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "CveAlmacenTraspasoDestino", "CveAlmacenTraspasoOrigen")).ToString().ToEntero() + CveAlmacenTraspasoDestino = drE(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem" And TipoDocto <> "Ped", "CveAlmacenTraspasoOrigen", "CveAlmacenTraspasoDestino")).ToString().ToEntero() + CveAlmacenTraspasoOrigen = drE(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem" And TipoDocto <> "Ped", "CveAlmacenTraspasoDestino", "CveAlmacenTraspasoOrigen")).ToString().ToEntero() CveContrato = drE("CveContrato").ToString().ToEntero() CveVendedor = drE("CveVendedor").ToString().ToEntero() CveCliente = drE("CveCliente").ToString().ToEntero() @@ -693,7 +706,7 @@ Partial Class Inventarios_EntregaAlmacen GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario" End If - If CveAlmacenTraspasoDestino > 0 And Not (TipoMovimiento = 2 And TipoDocto = "Rem") Then + If CveAlmacenTraspasoDestino > 0 And Not (TipoMovimiento = 2 And TipoDocto.Contiene("Rem", "Ped")) Then DivTipoCambioAdvertencia.Visible = True LtTipoCambioAdvertencia.Text = $"Los productos seran Trasladados al Almacen: {GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoDestino}")}" Else @@ -701,7 +714,7 @@ Partial Class Inventarios_EntregaAlmacen End If 'DEVOLUCION REMISION - If TipoMovimiento = 2 And TipoDocto = "Rem" And Not CveAlmacenTraspasoDestino > 0 Then + If TipoMovimiento = 2 And TipoDocto.Contiene("Rem", "Ped") And Not CveAlmacenTraspasoDestino > 0 Then Alert("La remisión que se intenta devolver presenta inconsistencias. Comuniquese con servicio tecnico SIG.", TipoMensaje.MsgError) BtnGuardar.Visible = False End If @@ -833,6 +846,14 @@ Partial Class Inventarios_EntregaAlmacen UpGenerales.Update() If CveAlmacen <= 0 Then CargaGvDatos() + + + If EsDevolucionVenta = 1 AndAlso CveOSSurtir > 0 AndAlso TipoMovimiento = 2 AndAlso TipoDocto = "Ped" Then + PedidoBloqueCantidad = True + End If + + + End Sub Private Sub CargaTraspasoPorSurtir(CveTraspaso As Integer) LbSurtida.Visible = False @@ -995,9 +1016,11 @@ Partial Class Inventarios_EntregaAlmacen End Sub Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - 'código temporal + If e.Row.RowType = DataControlRowType.DataRow Then + + + + 'código temporal Dim AplicaSerie As Boolean = CBool(e.Row.DBCampo("AplicaSerie")) If AplicaSerie Then @@ -1119,8 +1142,14 @@ Partial Class Inventarios_EntregaAlmacen 'SI ES TRASPASO OBLIGATORIO SURTIR TODO If TipoEntrega = 2 Then e.Row.FCCheckBox("cbInv").Enabled = False - End If - + End If + + If PedidoBloqueCantidad Then + e.Row.FCTextBox("TbCantidadF").Enabled = False + End If + + + End If End Sub @@ -1135,14 +1164,14 @@ Partial Class Inventarios_EntregaAlmacen GvDocs.DataBind() End If - End Sub - - + End Sub + + #End Region - - + + #Region " AGREGAR " - + Protected Sub BtnSerie_Click(sender As Object, e As EventArgs) Dim Argumentos As String() = CType(sender, Button).CommandArgument.Split("°"c) @@ -1169,10 +1198,10 @@ Partial Class Inventarios_EntregaAlmacen UpSerie.Update() End If - End Sub - + End Sub + #Region " AGREGA POR SERIE/LOTE " - + Private Sub CreaDtDetalle() If DtDatosDetalle Is Nothing Then DtDatosDetalle = New DataTable @@ -1365,7 +1394,7 @@ Partial Class Inventarios_EntregaAlmacen End If If Tipo < 3 Then - CargaSerie(True, cargaMasivo) + CargaSerie(True, CargaMasivo) End If End Sub @@ -1387,7 +1416,7 @@ Partial Class Inventarios_EntregaAlmacen ActualizaBitacora() CargaSerie() - End Sub + End Sub #End Region #Region "Bitacora" Private Sub ActualizaBitacora(Optional Eliminar As Boolean = False) @@ -1431,11 +1460,11 @@ Partial Class Inventarios_EntregaAlmacen Else Alert("No hay bitácora para recuperar.", TipoMensaje.ToastInformacion) End If - End Sub - + End Sub + #End Region #Region " AGREGA CON LOTE BATCH " - + Private Sub CreaDtDetalleLote() If DtDatosDetalleLote Is Nothing Then DtDatosDetalleLote = New DataTable @@ -1624,9 +1653,9 @@ Partial Class Inventarios_EntregaAlmacen End Try DtDatosDetalleLote.AcceptChanges() CargaLote() - End Sub + End Sub #End Region - + #Region " AGREGA CON TXT | CODIGO - SERIE " Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs) @@ -1758,12 +1787,12 @@ Partial Class Inventarios_EntregaAlmacen End If TxtCantidadEspecialDiv.Text = "1" - End Sub + End Sub #End Region - + #End Region - - + + #Region " GUARDAR " Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) @@ -1849,7 +1878,7 @@ Partial Class Inventarios_EntregaAlmacen End If If EsDevolucionVenta = 1 Or TipoDocto.Contiene({"Ped"}) Then - If Not (EsDevolucionVenta = 1 And TipoDocto.Contiene("Rem")) Then ' condicion si hay una devolucion de remision, no verifique la totalidad surtido + If Not (EsDevolucionVenta = 1 And TipoDocto.Contiene("Rem", "Ped")) Then ' condicion si hay una devolucion de remision, no verifique la totalidad surtido For Each Gvr As GridViewRow In GvDatos.Rows If Not Gvr.FCCheckBox("cbInv").Checked Or (Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadC").ToString().ToDecimal) Then Alert("Es necesario surtir todos los productos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) @@ -1864,9 +1893,9 @@ Partial Class Inventarios_EntregaAlmacen Dim EsInterno As Integer = -1 - If TipoDocto = "Ped" Then - EsInterno = If(Me.EsInterno, 1, 0) - End If + 'If TipoDocto = "Ped" Then + ' EsInterno = If(Me.EsInterno, 1, 0) + 'End If Dim ObjInventario As New ClsInventarios Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) @@ -2007,9 +2036,9 @@ Partial Class Inventarios_EntregaAlmacen Dim CantidadSalidaSinCosto As Decimal = 0 '' COMIENZA: SIN COSTO - If TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(587) = "1" AndAlso TipoMovimiento = 1 Then + If TipoDocto.Contiene("Ing", "Rem", "Ped") AndAlso UsuarioActual.Empresa.Funcionalidad(587) = "1" AndAlso TipoMovimiento = 1 Then - Dim CveConceptoSalidaSinCosto As Integer = If(TipoDocto.Contiene("Rem"), 8, 40) + Dim CveConceptoSalidaSinCosto As Integer = If(TipoDocto.Contiene("Rem", "Ped"), 8, 40) For Each Dr As DataRow In DtDatos.Rows If Dr("CantidadGV").ToString().ToDecimal > 0 Then @@ -2128,7 +2157,7 @@ Partial Class Inventarios_EntregaAlmacen Next 'ENTRADA POR TRASPASO A ENTREGA POR ADELANTADO - If TipoDocto = "Rem" AndAlso Not ErrorMovInv Then + If TipoDocto.Contiene("Rem", "Ped") AndAlso Not ErrorMovInv Then For Each Dr1 As DataRow In DtTraspasos.Select("CveTipoAlmacen = 26") CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString().ToEntero() @@ -2164,7 +2193,7 @@ Partial Class Inventarios_EntregaAlmacen Next End If - If Not ErrorMovInv AndAlso CveMovimientoSalida > 0 AndAlso TipoDocto.Contiene("Rem") Then + If Not ErrorMovInv AndAlso CveMovimientoSalida > 0 AndAlso TipoDocto.Contiene("Rem", "Ped") Then Dim CvePrePolizaSinCosto As Integer = ObjConta.AddPrePolizas("EA/SinCost", 53, 0, 0, 1, TxtFecha.Text.ToDate, "Entrega", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If CvePrePolizaSinCosto > 0 Then @@ -2415,7 +2444,7 @@ Partial Class Inventarios_EntregaAlmacen Dim TotalGarantia As Decimal = 0 ' COMIENZA: GARANTIAS - If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoMovimiento = 1 Then + If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Rem", "Ped") AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoMovimiento = 1 Then Dim CveAlmacenGarantia As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveTipoAlmacen:=6).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() Dim DtGarantias As DataTable = Nothing @@ -2527,7 +2556,7 @@ Partial Class Inventarios_EntregaAlmacen CantidadPendientePorSalir = CantidadPendientePorSalir - CantidadEntradaSinCosto End If 'si el alamcen del que salio, es el mismo que entra, no hay traspasos. - If CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero() And TipoDocto <> "Rem" Then CveAlmacenTraspasoDestino = 0 + If CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero() And TipoDocto <> "Rem" And TipoDocto <> "Ped" Then CveAlmacenTraspasoDestino = 0 If Not ErrorMovInv AndAlso CantidadPendientePorSalir > 0 Then Dim ConceptoMovimiento As Integer = 3 @@ -2537,13 +2566,13 @@ Partial Class Inventarios_EntregaAlmacen Dim Almacen1 As Integer = DdlAlmacen.SelectedValue.ToEntero() Dim tCveAlmacenTraspasoDestino As Integer = CveAlmacenTraspasoDestino - If TipoDocto = "Rem" AndAlso tCveAlmacenTraspasoDestino = 0 Then + If TipoDocto.Contiene("Rem", "Ped") AndAlso tCveAlmacenTraspasoDestino = 0 Then ErrorMovInv = True TextoError.AppendFormat("Ocurrió un error. no se tiene definido el almacen destino") End If 'DEVOLUCION REMISION - If TipoMovimiento = 2 And TipoDocto = "Rem" Then + If TipoMovimiento = 2 And TipoDocto.Contiene("Rem", "Ped") Then ConceptoMovimiento = 8 Almacen1 = CveAlmacenTraspasoDestino tCveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero() @@ -3012,8 +3041,8 @@ Partial Class Inventarios_EntregaAlmacen - If EsDevolucionVenta = 1 AndAlso CveOSSurtir > 0 AndAlso TipoMovimiento = 2 Then - If Not CierreOS(CveOSSurtir) Then + If EsDevolucionVenta = 1 AndAlso CveOSSurtir > 0 AndAlso TipoMovimiento = 2 AndAlso TipoDocto = "Ped" Then + If Not CierreOS(CveOSSurtir, CveMovimiento, ObjInventario.IniciaTransacSQL) Then ErrorMovInv = True Alert("Error al finalizar orden de servicio", TipoMensaje.MsgError) End If @@ -3074,7 +3103,7 @@ Partial Class Inventarios_EntregaAlmacen End If 'SI NO ES GARANTIA MANDA A RECIBIR AL USADO - If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoDocto = "Rem" AndAlso CveMovimientoGarantia <= 0 Then + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoDocto.Contiene("Rem", "Ped") AndAlso CveMovimientoGarantia <= 0 Then Msg.AppendFormat("

Recibir Usado: Ir a Recepción de Usados", CveVentaSurtir) End If @@ -3667,160 +3696,160 @@ Partial Class Inventarios_EntregaAlmacen CargaGvDatos() UpDatos.Update() - End Sub - + End Sub + #End Region - + #Region " TRASPASO - TRANSITORIO " Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs) TxtResponsable.Text = "" DivTransitorio2.Visible = ChkTransitorio.Checked - End Sub + End Sub #End Region - + #Region "SECCION ALMACEN" - 'Private Sub CreaDtSeccionAlmacen() - ' DtSeccionAlmacen = New DataTable - ' DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) - ' DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer)) - ' DtSeccionAlmacen.Columns.Add("CveSeccionAlmacen", GetType(Integer)) - ' DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer)) - ' DtSeccionAlmacen.Columns.Add("SeccionAlmacen", GetType(String)) - ' DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) - 'End Sub - 'Private Sub CargaDdlAlmacen() - ' DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) - ' DdlSeccionAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) - ' DdlSeccionAlmacen.DataBind() - 'End Sub - 'Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) - ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - - ' If Not DdlAlmacen.SelectedValue.ToEntero() > 0 Then - ' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - - ' CantidadTotal = gvRow.FCTextBox("TbCantidadF").Text.ToDecimal - ' IndexSeccionAlmacen = gvRow.RowIndex - ' CvePS = gvRow.DataKey("CvePS").ToEntero() - ' CargaSeccionAlmacen() - ' RegistraScript("$('#DModalSeccionAlmacen').modal()") - 'End Sub - - 'Private Sub CargaSeccionAlmacen() - ' Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") - ' GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}") - ' GvSeccion.DataBind() - - ' TxtCantidadSeccion.Text = "" - ' DdlSeccionAlmacen.SelectedIndex = 0 - ' Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion - ' If CantidadRestante = 0 Then - ' RVTxtCantidad.MaximumValue = "1" - ' TxtCantidadSeccion.Enabled = False - ' Else - ' RVTxtCantidad.MaximumValue = CantidadRestante.ToString() - ' TxtCantidadSeccion.Enabled = True - ' End If - - ' If CantidadTotalSeccion > 0 Then - ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = False - ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "Cuenta con sección almacen" - - ' Else - ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = True - ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "" - - ' End If - - ' If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then - ' DdlAlmacen.Enabled = False - ' DdlAlmacen.ToolTip = "Cuenta con sección almacen" - ' Else - ' DdlAlmacen.Enabled = True - ' DdlAlmacen.ToolTip = "" - ' End If - - ' UpModalSeccionAlmacen.Update() - ' UpDatos.Update() - ' UpGenerales.Update() - 'End Sub - - 'Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) - - ' Dim ObjInv As New ClsInventarios - ' Dim CantidadDisponible As Decimal = 0 - ' If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacen.SelectedValue.ToEntero(), DdlAlmacen.SelectedValue.ToEntero(), - ' CvePS, UsuarioActual.CveEmpresa) Then - ' If ObjInv.DtResultados.Rows.Count > 0 Then - ' CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString().ToDecimal - ' End If - ' End If - ' ObjInv.Dispose() - - ' CantidadDisponible -= DtSeccionAlmacen.FiltraParametros($"CvePS = {CvePS} AND CveSeccionAlmacen = {DdlSeccionAlmacen.SelectedValue}").SUMD("CantidadSeccionAlmacen") - - ' If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then - ' Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: {CantidadDisponible}", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - - ' Dim Row As DataRow = Nothing - ' DtSeccionAlmacen.AcceptChanges() - ' Row = DtSeccionAlmacen.NewRow - ' Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal - ' Row("IndexSeccionAlmacen") = IndexSeccionAlmacen - ' Row("CveSeccionAlmacen") = DdlSeccionAlmacen.SelectedValue.ToEntero() - ' Row("SeccionAlmacen") = DdlSeccionAlmacen.SelectedItem.Text - ' Row("CvePS") = CvePS - ' Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 - ' DtSeccionAlmacen.Rows.Add(Row) - ' DtSeccionAlmacen.AcceptChanges() - ' CargaSeccionAlmacen() - 'End Sub - - 'Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs) - ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - ' Dim Index As Integer = 0 - ' For Each Dr As DataRow In DtSeccionAlmacen.Rows - ' If Dr("Consec").ToString().ToEntero() = gvRow.DataKey("Consec").ToEntero() Then - ' Exit For - ' End If - ' Index += 1 - ' Next - ' DtSeccionAlmacen.Rows.RemoveAt(Index) - ' DtSeccionAlmacen.AcceptChanges() - ' CargaSeccionAlmacen() - 'End Sub - - 'Protected Sub LnkVerSecciones_Click(sender As Object, e As EventArgs) - ' If Not CveVentaSurtir > 0 Then - ' Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - - ' If Not DdlAlmacen.SelectedValue.ToEntero() > 0 Then - ' Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - - ' Dim ObjInv As New ClsInventarios - ' If ObjInv.GetExistenciaSeccionAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa) Then - ' GvVerSeccionesAlmacen.DataSource = ObjInv.DtResultados - ' End If - ' ObjInv.Dispose() - ' GvVerSeccionesAlmacen.DataBind() - ' UpVerSeccionesAlmacen.Update() - ' RegistraScript("$('#ModalVerSeccionesAlmacen').modal()") - 'End Sub - + 'Private Sub CreaDtSeccionAlmacen() + ' DtSeccionAlmacen = New DataTable + ' DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) + ' DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer)) + ' DtSeccionAlmacen.Columns.Add("CveSeccionAlmacen", GetType(Integer)) + ' DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer)) + ' DtSeccionAlmacen.Columns.Add("SeccionAlmacen", GetType(String)) + ' DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) + 'End Sub + 'Private Sub CargaDdlAlmacen() + ' DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) + ' DdlSeccionAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) + ' DdlSeccionAlmacen.DataBind() + 'End Sub + 'Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) + ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + ' If Not DdlAlmacen.SelectedValue.ToEntero() > 0 Then + ' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen.", TipoMensaje.MsgAdvertencia) + ' Exit Sub + ' End If + + ' CantidadTotal = gvRow.FCTextBox("TbCantidadF").Text.ToDecimal + ' IndexSeccionAlmacen = gvRow.RowIndex + ' CvePS = gvRow.DataKey("CvePS").ToEntero() + ' CargaSeccionAlmacen() + ' RegistraScript("$('#DModalSeccionAlmacen').modal()") + 'End Sub + + 'Private Sub CargaSeccionAlmacen() + ' Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") + ' GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}") + ' GvSeccion.DataBind() + + ' TxtCantidadSeccion.Text = "" + ' DdlSeccionAlmacen.SelectedIndex = 0 + ' Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion + ' If CantidadRestante = 0 Then + ' RVTxtCantidad.MaximumValue = "1" + ' TxtCantidadSeccion.Enabled = False + ' Else + ' RVTxtCantidad.MaximumValue = CantidadRestante.ToString() + ' TxtCantidadSeccion.Enabled = True + ' End If + + ' If CantidadTotalSeccion > 0 Then + ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = False + ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "Cuenta con sección almacen" + + ' Else + ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = True + ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "" + + ' End If + + ' If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then + ' DdlAlmacen.Enabled = False + ' DdlAlmacen.ToolTip = "Cuenta con sección almacen" + ' Else + ' DdlAlmacen.Enabled = True + ' DdlAlmacen.ToolTip = "" + ' End If + + ' UpModalSeccionAlmacen.Update() + ' UpDatos.Update() + ' UpGenerales.Update() + 'End Sub + + 'Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) + + ' Dim ObjInv As New ClsInventarios + ' Dim CantidadDisponible As Decimal = 0 + ' If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacen.SelectedValue.ToEntero(), DdlAlmacen.SelectedValue.ToEntero(), + ' CvePS, UsuarioActual.CveEmpresa) Then + ' If ObjInv.DtResultados.Rows.Count > 0 Then + ' CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString().ToDecimal + ' End If + ' End If + ' ObjInv.Dispose() + + ' CantidadDisponible -= DtSeccionAlmacen.FiltraParametros($"CvePS = {CvePS} AND CveSeccionAlmacen = {DdlSeccionAlmacen.SelectedValue}").SUMD("CantidadSeccionAlmacen") + + ' If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then + ' Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: {CantidadDisponible}", TipoMensaje.MsgAdvertencia) + ' Exit Sub + ' End If + + ' Dim Row As DataRow = Nothing + ' DtSeccionAlmacen.AcceptChanges() + ' Row = DtSeccionAlmacen.NewRow + ' Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal + ' Row("IndexSeccionAlmacen") = IndexSeccionAlmacen + ' Row("CveSeccionAlmacen") = DdlSeccionAlmacen.SelectedValue.ToEntero() + ' Row("SeccionAlmacen") = DdlSeccionAlmacen.SelectedItem.Text + ' Row("CvePS") = CvePS + ' Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 + ' DtSeccionAlmacen.Rows.Add(Row) + ' DtSeccionAlmacen.AcceptChanges() + ' CargaSeccionAlmacen() + 'End Sub + + 'Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs) + ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + ' Dim Index As Integer = 0 + ' For Each Dr As DataRow In DtSeccionAlmacen.Rows + ' If Dr("Consec").ToString().ToEntero() = gvRow.DataKey("Consec").ToEntero() Then + ' Exit For + ' End If + ' Index += 1 + ' Next + ' DtSeccionAlmacen.Rows.RemoveAt(Index) + ' DtSeccionAlmacen.AcceptChanges() + ' CargaSeccionAlmacen() + 'End Sub + + 'Protected Sub LnkVerSecciones_Click(sender As Object, e As EventArgs) + ' If Not CveVentaSurtir > 0 Then + ' Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia) + ' Exit Sub + ' End If + + ' If Not DdlAlmacen.SelectedValue.ToEntero() > 0 Then + ' Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia) + ' Exit Sub + ' End If + + ' Dim ObjInv As New ClsInventarios + ' If ObjInv.GetExistenciaSeccionAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa) Then + ' GvVerSeccionesAlmacen.DataSource = ObjInv.DtResultados + ' End If + ' ObjInv.Dispose() + ' GvVerSeccionesAlmacen.DataBind() + ' UpVerSeccionesAlmacen.Update() + ' RegistraScript("$('#ModalVerSeccionesAlmacen').modal()") + 'End Sub + #End Region - + #Region "DIVIDIR" - + Protected Sub Dividir(sender As Object, e As EventArgs) Dim index2 As Integer = 0 @@ -3901,11 +3930,11 @@ Partial Class Inventarios_EntregaAlmacen index2 += 1 Next - End Sub - - + End Sub + + #End Region - + #Region " GUIAS - SABE QUE ES PORQUE NO VEO QUE SE UTILIZE EN ALGUNA PARTE - EN MIRAS DE ELIMINAR - IPP 24 AGOSTO 2017 " Private Sub BtnNumeroGuia_Click(sender As Object, e As EventArgs) Handles BtnNumeroGuia.Click Dim Objeto As New ClsInventarios @@ -3939,11 +3968,11 @@ Partial Class Inventarios_EntregaAlmacen End If - End Sub + End Sub #End Region - + #Region "SUGERENCIAS" - + Protected Sub BtnVerSugerencias_Click(sender As Object, e As EventArgs) If Not CveVentaSurtir > 0 Then Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia) @@ -4043,12 +4072,12 @@ Partial Class Inventarios_EntregaAlmacen params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario)) ImprimirPDF("Empresas/Grales/Formatos/RepEntregaAlmacenSugerencia.rdlc", DtDatosSugerencias, params, "Equipo GPS") - End Sub - + End Sub + #End Region - + #Region "TipoEntrega" - + Protected Sub EntregaRadioGroup_Click(sender As Object, e As EventArgs) If RbEntregaExterna.Checked Then RegistraScript($"AbrirVentana('/General/PopUpPaqueteriasGuias.aspx?CveVenta={CveVentaSurtir}',800,547,'N')") @@ -4075,9 +4104,9 @@ Partial Class Inventarios_EntregaAlmacen ElseIf RbEntregaInterna.Checked Then 'RegistraScript("$('#ModalPaqueteriaInterna').modal('show')") End If - End Sub + End Sub #End Region - + #Region "Cliente entrega personal" Private Sub ClienteEntregaPersonal(CveCliente As Integer) Dim ObjVentas As New ClsVentas() @@ -4092,11 +4121,11 @@ Partial Class Inventarios_EntregaAlmacen End If ObjVentas.Dispose() UpClentesPersonalEntrega.Update() - End Sub + End Sub #End Region - + #Region "sugerir caducidad" - + Private Sub SugiereLoteCaducidad(CveAlmacen As Integer) Dim TempDT As New DataTable Dim DtLotesCaducidad As New DataTable @@ -4228,16 +4257,42 @@ Partial Class Inventarios_EntregaAlmacen End Sub - Private Function CierreOS(CveOSCerrar As Integer) As Boolean + Private Function CierreOS(CveOSCerrar As Integer, CveMovimientoGenerado As Integer, ByRef TransaccionSql As SqlTransaction) As Boolean Dim Respuesta As Boolean = True Dim CveOSEstatusFinalizada As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 4").ToEntero If CveOSEstatusFinalizada > 0 Then - Dim ObjOS As New ClsOS() + + Dim ObjOS As New ClsOS(TransaccionSql) + Respuesta = ObjOS.UpdateOrdenesServiciosEstatus(CveOSEstatusFinalizada, UsuarioActual.CveUsuario, CveOSCerrar) - ObjOS.Dispose() + + If Respuesta Then + + Dim ObjInventario As New ClsInventarios(ObjOS.IniciaTransacSQL) + + If ObjInventario.GetMovimientosDetalle(CveMovimientoGenerado, UsuarioActual.CveEmpresa) Then + + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + + Dim CveVentaDetalle As Integer = Dr("CveVentaDetalle").ToString().ToEntero() + Dim Cantidad As Decimal = Dr("Cantidad").ToString().ToDecimal + + If CveVentaDetalle > 0 Then + If Not ObjInventario.UpdatePedidoDetalleCantidad(CveVentaDetalle, Cantidad) Then + Respuesta = False + Exit For + End If + Else + Respuesta = False + End If + + Next + End If + End If + Else Alert("No se pudo obtener el estado para finalizar la orden de servicio.") Respuesta = False diff --git a/OS/OrdenesServicios.aspx b/OS/OrdenesServicios.aspx index 77742a9bf..3427d48b7 100644 --- a/OS/OrdenesServicios.aspx +++ b/OS/OrdenesServicios.aspx @@ -806,7 +806,7 @@ - + @@ -1278,13 +1278,13 @@
Cant. - + diff --git a/OS/OrdenesServicios.aspx.vb b/OS/OrdenesServicios.aspx.vb index 5dcc1b11f..735ee02a9 100644 --- a/OS/OrdenesServicios.aspx.vb +++ b/OS/OrdenesServicios.aspx.vb @@ -291,6 +291,17 @@ Partial Class OS_OrdenesServicios ViewState("ClienteMail") = value End Set End Property + + Private Property DTSolicitudDev As DataTable + Get + Return If(ViewState("DTSolicitudDev") Is Nothing, New DataTable, DirectCast(ViewState("DTSolicitudDev"), DataTable)) + End Get + Set(value As DataTable) + ViewState("DTSolicitudDev") = value + End Set + End Property + + #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load @@ -1932,7 +1943,7 @@ Partial Class OS_OrdenesServicios e.Row.FCLabel("LtlCuentaEquipoS").Visible = False End If - If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(578) = "1" Then e.Row.FCHtmlTableRow("TREspecificaiones").Visible = False End If @@ -3042,20 +3053,21 @@ Partial Class OS_OrdenesServicios LnkModalSolicitarDevolucion.Visible = True GvSolicitarDevolucion.DataSource = Nothing + DTSolicitudDev = New DataTable Dim ObjOS As New ClsOS - Dim DTTemp As New DataTable + If ObjOS.GetOrdenesServicioDevolucionMaterial(CveOS, CveVenta, UsuarioActual.CveEmpresa) Then - DTTemp = ObjOS.DtResultados - GvSolicitarDevolucion.DataSource = DTTemp + DTSolicitudDev = ObjOS.DtResultados + GvSolicitarDevolucion.DataSource = DTSolicitudDev End If ObjOS.Dispose() GvSolicitarDevolucion.DataBind() - Dim EsDevolucionVenta As Boolean = (DTTemp.FiltroPrimeroValor("EsDevolucionVenta", "").ToEntero > 0) + Dim EsDevolucionVenta As Boolean = (DTSolicitudDev.FiltroPrimeroValor("EsDevolucionVenta", "").ToEntero > 0) RegistraScript("$('#DVModalSolicitarDevolucion').modal();") @@ -3077,6 +3089,18 @@ Partial Class OS_OrdenesServicios Protected Sub LnkModalSolicitarDevolucion_Click(sender As Object, e As EventArgs) + 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 + + If Not CveAlmacenDestino > 0 Then + Alert("No se encontro almacen de entrega por adelantado") + Exit Sub + End If + Dim PropcesoOK As Boolean = True Dim ObjV As New ClsVentas ObjV.IniciaTransacSQL() @@ -3101,6 +3125,76 @@ Partial Class OS_OrdenesServicios Next 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) + + If CveMovimiento > 0 Then + + For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows + + Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal + Dim CantidadDev As Decimal = GvRow.FCTextBox("TxtDev").Text.ToDecimal + Dim CantidadRegistro = Cantidad - CantidadDev + Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero + Dim CveUM As Integer = GvRow.DataKey("CveUM").ToEntero + Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal + Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero + Dim CveMovimientoDetalle As Integer = GvRow.DataKey("CveMovimientoDetalle").ToEntero + Dim Lote As String = GvRow.DataKey("Lote") + Dim Serie As String = GvRow.DataKey("Serie") + Dim FechaCaducidad As DateTime = GvRow.DataKey("FechaCaducidad").ToDateTime + + If CantidadRegistro > 0 Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadRegistro, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then + Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia) + PropcesoOK = False + Exit For + End If + End If + + Next + + 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) + + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + + For Each dRow As DataRow In ObjInventario.DtResultados.Rows + + Dim Cantidad As Decimal = dRow("Cantidad").ToString.ToDecimal + Dim CvePS As Integer = dRow("CvePS").ToString.ToEntero + Dim CveUM As Integer = dRow("CveUM").ToString.ToEntero + Dim PU As Decimal = dRow("PU").ToString.ToDecimal + Dim CveVentaDetalle As Integer = dRow("CveVentaDetalle").ToString.ToEntero + Dim CveMovimientoDetalle As Integer = dRow("CveMovimientoDetalle").ToString.ToEntero + Dim Lote As String = dRow("Lote").ToString + Dim Serie As String = dRow("Serie").ToString + Dim FechaCaducidad As DateTime = dRow("FechaCaducidad").ToString.ToDateTime + + 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) + PropcesoOK = False + Exit For + End If + + Next + + Else + PropcesoOK = False + End If + + End If + + Else + PropcesoOK = False + End If + + End If + If PropcesoOK Then 'ObjV.RollBack() diff --git a/Ventas/CatMedicos.aspx b/Ventas/CatMedicos.aspx index 2628fe2f3..8b00cb48e 100644 --- a/Ventas/CatMedicos.aspx +++ b/Ventas/CatMedicos.aspx @@ -14,116 +14,297 @@ - +
  • +
  • + Excel +
  • + + +
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - - + -
    -
    + - - - - - - - + + - - - - - - - - - - - - - - - - - - - <%-- - - - - --%> - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    +
    + + +
    +
    +
    - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - +
    + Fecha Inicio: + +
    +
    +
    + + + + +
    + + + + + + +
    +
    + Fecha Fin: + +
    +
    +
    + + + + +
    + + + + + + +
    - - + +
    + +
    + + + +
    + + Médico + Procedimiento + Clientes + +
    +
    +
    +
    + +
    +
    +
    + + + + +
    +
    + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    + +
    +
    + + + + + + + + + + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + +
    +
    + +
    +
    + + + + - +
    + <%----%> +
    +<%-- --%> diff --git a/Ventas/CatMedicos.aspx.vb b/Ventas/CatMedicos.aspx.vb index db3a0496c..d24d594b1 100644 --- a/Ventas/CatMedicos.aspx.vb +++ b/Ventas/CatMedicos.aspx.vb @@ -2,7 +2,7 @@ Option Strict On Imports Extensiones - +Imports Microsoft.Extensions.Primitives Partial Class Ventas_CatMedicos Inherits ClsPaginas @@ -21,7 +21,9 @@ Partial Class Ventas_CatMedicos Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then + CargaCombos() CargaDatos() + BtnConsultar_Click(Nothing, Nothing) End If End Sub @@ -41,8 +43,12 @@ Partial Class Ventas_CatMedicos GvDatos.DataBind() + ValidaExcelTab() + UpDatos.Update() + + End Sub Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click @@ -134,8 +140,6 @@ Partial Class Ventas_CatMedicos TxtCelular.Text = "" TxtEspecialidad.Text = "" - - DVEstatus.Visible = False ChkEstatus.Checked = True @@ -177,4 +181,95 @@ Partial Class Ventas_CatMedicos +#Region "INDICADORES" + + Private Sub CargaCombos() + + + Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + If EsWS Then + DdlClientes.setEsWebService(True) + Else + DdlClientes.setEsWebService(False) + DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + DdlClientes.DataBind() + DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + End If + + + + txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString + txtFechaF.Text = NowADS().ToShortDateString + + DdlMedico.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") + DdlMedico.DataBind() + + DdlProcedimiento.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") + DdlProcedimiento.DataBind() + + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + + + Dim objVentas As New ClsVentas + Dim CveCliente As Integer = If(DdlClientes.SelectedValue.ToEntero > 0, DdlClientes.SelectedValue.ToEntero, -1) + If objVentas.GetVentasMedicasIndicadoresRep(DdlGrupo.SelectedValue.ToEntero, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, CveCliente, DdlMedico.SelectedValue.ToEntero, DdlProcedimiento.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + GvIndicadores.DataSource = objVentas.DtResultados + End If + + objVentas.Dispose() + + GvIndicadores.DataBind() + + ValidaExcelTab() + + UpIndicadores.Update() + + + + End Sub + + +#End Region + + +#Region "EXCEL" + + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + + + If Tabs.ActiveTabIndex = 0 Then + Dim SbFiltros As New StringBuilder() + SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|") + SbFiltros.Append($"Grupo:{DdlGrupo.SelectedItem.Text}, Médico: {DdlMedico.SelectedItem.Text}, Procedimiento: {DdlProcedimiento.SelectedItem.Text}") + GvIndicadores.ExportToExcelGembox("IndicadoresMedicos", UsuarioActual, "Indicadores Médicos", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString()) + Else + GvDatos.Columns(10).Visible = False + Dim SbFiltros As New StringBuilder() + SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|") + GvDatos.ExportToExcelGembox("CatMedicos", UsuarioActual, "Catálogo de Médicos", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString()) + GvDatos.Columns(10).Visible = True + End If + + + End Sub + + Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) + End Sub + + + Sub ValidaExcelTab() + If Tabs.ActiveTabIndex = 0 Then + LnkExportar.Visible = GvDatos.Rows.Count > 0 + Else + LnkExportar.Visible = GvIndicadores.Rows.Count > 0 + End If + End Sub + + + +#End Region + + End Class diff --git a/Ventas/CatProcedimientos.aspx b/Ventas/CatProcedimientos.aspx index 90624dd83..83fe3f29a 100644 --- a/Ventas/CatProcedimientos.aspx +++ b/Ventas/CatProcedimientos.aspx @@ -20,73 +20,264 @@ Agregar Procedimiento +
  • + Excel +
  • + + + -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - - + + -
    -
    + + -
    - - - - - - <%-- - - - - --%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    -
    - - + + +
    +
    +
    + + +
    +
    +
    - - +
    + Fecha Inicio: + +
    +
    +
    + + + + +
    + + + + + + +
    +
    + Fecha Fin: + +
    +
    +
    + + + + +
    + + + + + + +
    + + + +
    + +
    + + + +
    + + Médico + Procedimiento + Clientes + +
    + + + + + + +
    +
    +
    + +
    +
    +
    + + + + + +
    +
    + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + +
    +
    + + + + <%--CveClave Grupo Total nVentas Utilidad SerieFolio Fecha--%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    + + +
    + + + + + + + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    + + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    + + +
    - Fecha cirugía: + Fecha De Orden:
    @@ -8484,7 +8488,7 @@ - + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 651b1fbea..9abe03094 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2312,6 +2312,18 @@ Partial Class Ventas #End Region + Public Property CveAlmacenAsignado As Integer + Get + If ViewState("CveAlmacenAsignado") Is Nothing Then + ViewState("CveAlmacenAsignado") = -1 + End If + Return ViewState("CveAlmacenAsignado").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveAlmacenAsignado") = value + End Set + End Property + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then @@ -6803,6 +6815,10 @@ Partial Class Ventas Else Alert("Ocurrió un error al cargar los datos del cliente. Por favor vuelva a intentar.", TipoMensaje.MsgError) End If + + + CveAlmacenAsignado = ObjCliente.CveAlmacenAsignado + End If ObjCliente.Dispose() @@ -13092,7 +13108,7 @@ Partial Class Ventas End If 'ASIGNA EL VALOR DEL ALMACEN AL PEDIDO - If factura.TipoDocto = "Ped" Then + If factura.TipoDocto = "Ped" And EsVentaMedica = False Then If CveAlmacenTraspasoDestino <= 0 Then CveAlmacenTraspasoDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 10 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString().ToEntero() End If @@ -13103,9 +13119,14 @@ Partial Class Ventas End If End If - If UsuarioActual.CveEmpresa.Contiene(186) AndAlso EsVentaMedica AndAlso RBLTipoVenta.SelectedValue.ToEntero <> 2 Then - CveAlmacenTraspasoDestino = 1031 'FIXME OIC 2023-12-12 Por definir almacen + + If CveAlmacenAsignado <= 0 Then + ErrorList.Add("Ocurrió un error al seleccionar el almacen de entrega por adelantado de la sucursal.") + Else + CveAlmacenTraspasoDestino = CveAlmacenAsignado + End If + End If Dim TotalImpuestoLocal As Double = 0 @@ -34922,6 +34943,8 @@ Partial Class Ventas + + 'Property SucursalOrigenCP As Modelos.SucursalModel ' Get ' If ViewState("SucursalOrigenCP") Is Nothing Then @@ -36026,9 +36049,8 @@ Partial Class Ventas TdFechaOS2.Visible = True ChkRequiereTecnico.Checked = True ChkRequiereTecnico.Enabled = False - DdlTipoComprobante.SelectedValueExist("Rem") + DdlTipoComprobante.SelectedValueExist("Ped") Else - DdlTipoComprobante.SelectedValueExist("Ing") End If DdlTipoComprobante.Enabled = False