diff --git a/App_Code/ClsOP.vb b/App_Code/ClsOP.vb new file mode 100644 index 000000000..87bcf4845 --- /dev/null +++ b/App_Code/ClsOP.vb @@ -0,0 +1,384 @@ +Imports Extensiones +Imports System.Data +Imports System.Data.SqlClient +Imports Microsoft.VisualBasic + +Public Class ClsOP + Implements IDisposable + +#Region "Campos" + 'SQL + Private SqlConexion As SqlConnection + Private SqlAdapter As SqlDataAdapter + Private SqlCommand As SqlCommand + Private SqlTransacc As SqlTransaction + Private Data As DataTable + Protected DTSet As DataSet + + Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 + Private EsTransaccionCompartida As Boolean = False + + Public ReadOnly Property DtResultados() As DataTable + Get + DtResultados = Data + End Get + End Property + Public ReadOnly Property DTSetResultados() As DataSet + Get + Return DTSet + End Get + End Property +#End Region + + Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) + + If TransaccionCompartida Is Nothing Then + SqlConexion = New SqlConnection + SqlConexion.ConnectionString = ClsPaginas.UsuarioActualRutaDB + Try + SqlConexion.Open() + Catch ex As Exception + OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) + End Try + Else + SqlConexion = TransaccionCompartida.Connection + SqlTransacc = TransaccionCompartida + EsTransaccionCompartida = True + End If + + SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() + End Sub + Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) + With SqlAdapter.SelectCommand + .Parameters.Clear() + .CommandText = StrSQL + .CommandType = TipoComando + End With + If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + Data = New DataTable + End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + Try + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}?{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + CveConexion = 0 + End If + + End Sub +#End Region + Public Function IniciaTransacSQL() As SqlTransaction + If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() + Return SqlTransacc + End Function + Public Sub RollBack() + SqlTransacc.Rollback() + End Sub + Public Sub Commit() + SqlTransacc.Commit() + End Sub + +#Region "CONFIGURACION PRODUCTOS" + + + Public Function GetProductosOP(CveOP As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_ProductosGET") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOP", SqlDbType.Int).Value = CveOP + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los productos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function GetCIReceta(CvePS As Integer, CveUM As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_CostoIndirectoRecetaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la receta de ci del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddCI(Cantidad As Decimal, CvePS As Integer, CvePSMateriaPrima As Integer, CveUM As Integer, CveUMMateriaPrima As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_CIAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Cantidad", SqlDbType.SmallMoney).Value = Cantidad + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CvePSMateriaPrima", SqlDbType.Int).Value = CvePSMateriaPrima + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CveUMMateriaPrima", SqlDbType.Int).Value = CveUMMateriaPrima + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el costo indirecto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemoveCI(CveOPPS As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_CIRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOPPS", SqlDbType.Int).Value = CveOPPS + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el costo indirecto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetMOReceta(CvePS As Integer, CveUM As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_ManodeObraRecetaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la receta de mo del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddMO(Cantidad As Decimal, CvePS As Integer, CvePuesto As Integer, CveUM As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_MOAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Cantidad", SqlDbType.SmallMoney).Value = Cantidad + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CvePuesto", SqlDbType.Int).Value = CvePuesto + .Add("@CveUM", SqlDbType.Int).Value = CveUM + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la mano de obra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemoveMO(CveOPManoObra As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_MORemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOPManoObra", SqlDbType.Int).Value = CveOPManoObra + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la mano de obra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetMPReceta(CvePS As Integer, CveUM As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_MateriaPrimaRecetaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la receta de mp del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddMP(Cantidad As Decimal, CvePS As Integer, CvePSMateriaPrima As Integer, CveUM As Integer, CveUMMateriaPrima As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_MPAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Cantidad", SqlDbType.SmallMoney).Value = Cantidad + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CvePSMateriaPrima", SqlDbType.Int).Value = CvePSMateriaPrima + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CveUMMateriaPrima", SqlDbType.Int).Value = CveUMMateriaPrima + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la materia prima.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemoveMP(CveOPPS As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_MPRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOPPS", SqlDbType.Int).Value = CveOPPS + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la materia prima.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetConfiguracionProducto(CvePS As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_ConfiguracionProductoGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los productos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddUpManodeObraReceta(CvePS As Integer, CveUM As Integer, CveEmpresa As Integer, xmlpuestos As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_ManodeObraRecetaUp") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@xmlpuestos", SqlDbType.Xml).Value = xmlpuestos + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la mano de obra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddUpMateriaPrimaReceta(CvePS As Integer, CveUM As Integer, CveEmpresa As Integer, xmlproductos As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_MateriaPrimaRecetaUp") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@xmlproductos", SqlDbType.Xml).Value = xmlproductos + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la materia prima.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddUpCostoIndirectoReceta(CvePS As Integer, CveUM As Integer, CveEmpresa As Integer, xmlproductos As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_CostoIndirectoRecetaUp") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@xmlproductos", SqlDbType.Xml).Value = xmlproductos + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el costo indirecto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + +#End Region + +#Region "IDisposable Support" + ' IDisposable + Protected Overridable Sub Dispose(disposing As Boolean) + If Not Me.disposedValue Then + If disposing Then + + If Not Data Is Nothing Then Data.Dispose() : Data = Nothing + If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() : SqlAdapter = Nothing + If Not SqlCommand Is Nothing Then SqlCommand.Dispose() : SqlCommand = Nothing + If Not SqlTransacc Is Nothing Then SqlTransacc.Dispose() : SqlTransacc = Nothing + If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close() + If Not SqlConexion Is Nothing Then SqlConexion.Dispose() : SqlConexion = Nothing + + End If + End If + Me.disposedValue = True + End Sub + Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() + Dispose(True) + GC.SuppressFinalize(Me) + End Sub +#End Region + +End Class diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index b11a0195e..6e916f791 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -11096,6 +11096,10 @@ Public Class ClsPaginas PaginaDict.Add("/Transportes/CatRutas.aspx".ToUpper(), 604) PaginaDict.Add("/Transportes/RepViajesCalendario.aspx".ToUpper(), 605) #End Region + +#Region "Ordenes de Produccion" + PaginaDict.Add("/OP/CatConfiguracionProducto.aspx".ToUpper(), 790) +#End Region 'Antes de aquí. Application("GlobalSIGAppPaginas") = PaginaDict diff --git a/App_Code/ClsPuntoVenta.vb b/App_Code/ClsPuntoVenta.vb index 729fc7426..a0d04f707 100644 --- a/App_Code/ClsPuntoVenta.vb +++ b/App_Code/ClsPuntoVenta.vb @@ -400,11 +400,31 @@ Public Class ClsPuntoVenta End Try Return Retorno - End Function + End Function + + Public Function GetVta_EstadoCajas(CveCuenta As Integer, CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasEstadoCajasGet") + + SqlAdapter.SelectCommand.Parameters.Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + SqlAdapter.SelectCommand.Parameters.Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + SqlAdapter.SelectCommand.Parameters.Add("@FechaFin", SqlDbType.Date).Value = FechaFin + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los Cortes del Punto de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + #Region "IDisposable Support" - - - ' IDisposable + + + ' IDisposable Protected Overridable Sub Dispose(disposing As Boolean) If Not Me.disposedValue Then If disposing Then diff --git a/App_Code/ClsRH.vb b/App_Code/ClsRH.vb index 7617ad869..241ce2730 100644 --- a/App_Code/ClsRH.vb +++ b/App_Code/ClsRH.vb @@ -1555,8 +1555,8 @@ Public Class ClsRH Public Property SalarioDiarioSS As Decimal Public Property NumDiasAguinaldo As Integer Public Property PorPrimaVacacional As Decimal - 'Public Property Bono As Double Public Property CveMetodoPago As Integer + Public Property CveFormaPago As Integer Public Property MetodoPago As String Public Property MetodoPagoSAT As String Public Property CLABE As String @@ -1603,7 +1603,7 @@ Public Class ClsRH Public Function GetPersonal(CvePersonal As Integer, Codigo As String, Nombre As String, NSS As String, RFC As String, CveTurno As Integer, CvePuesto As Integer, CveDepartamento As Integer, CveRuta As Integer, CveEscolaridad As Integer, CveEstadoCivil As Integer, CveGenero As Integer, CveEstatusPersonal As Integer, CveSubProyecto As Integer, CveClienteAsignado As Integer, HorarioTrabajo As String, CveSupervisor As Integer, - CveTipoPeriodo As Integer, CveMetodoPago As Integer, CveTipoContrato As Integer, CveMotivoBaja As Integer, CveProyecto As Integer, + CveTipoPeriodo As Integer, CveFormaPago As Integer, CveTipoContrato As Integer, CveMotivoBaja As Integer, CveProyecto As Integer, FechaIFinContrato As String, FechaFFinContrato As String, FechaIIngreso As String, FechaFIngreso As String, CveEmpresa As Integer, Optional EsReserva As Integer = -1) As Boolean Dim Retorno As Boolean = False @@ -1628,7 +1628,7 @@ Public Class ClsRH .Add("@HorarioTrabajo", SqlDbType.VarChar).Value = HorarioTrabajo .Add("@CveSupervisor", SqlDbType.Int).Value = CveSupervisor .Add("@CveTipoPeriodo", SqlDbType.Int).Value = CveTipoPeriodo - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@CveFormaPago", SqlDbType.Int).Value = CveFormaPago .Add("@CveTipoContrato", SqlDbType.Int).Value = CveTipoContrato .Add("@CveMotivoBaja", SqlDbType.Int).Value = CveMotivoBaja .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto @@ -1668,8 +1668,9 @@ Public Class ClsRH 'Me.Bono = Data.Rows(0)("Bono").ToString.ToDouble Me.SalarioDiarioSS = Data.Rows(0)("SalarioDiarioSS").ToString.ToDecimal Me.NumDiasAguinaldo = Data.Rows(0)("NumDiasAguinaldo").ToString.ToEntero - Me.PorPrimaVacacional = Data.Rows(0)("PorPrimaVacacional").ToString.ToDecimal + Me.PorPrimaVacacional = Data.Rows(0)("PorPrimaVacacional").ToString.ToDecimal Me.CveMetodoPago = Data.Rows(0)("CveMetodoPago").ToString.ToEntero + Me.CveFormaPago = Data.Rows(0)("CveFormaPago").ToString.ToEntero Me.MetodoPago = Data.Rows(0)("MetodoPago").ToString Me.MetodoPagoSAT = Data.Rows(0)("MetodoPagoSAT").ToString @@ -1780,7 +1781,7 @@ Public Class ClsRH Public Function GetPersonal2(CvePersonal As Integer, Codigo As String, Nombre As String, NSS As String, RFC As String, CveTurno As Integer, CvePuesto As Integer, CveDepartamento As Integer, CveRuta As Integer, CveEscolaridad As Integer, CveEstadoCivil As Integer, CveGenero As Integer, CveEstatusPersonal As Integer, CveSubProyecto As Integer, CveClienteAsignado As Integer, HorarioTrabajo As String, CveSupervisor As Integer, - CveTipoPeriodo As Integer, CveMetodoPago As Integer, CveTipoContrato As Integer, CveMotivoBaja As Integer, CveProyecto As Integer, + CveTipoPeriodo As Integer, CveFormaPago As Integer, CveTipoContrato As Integer, CveMotivoBaja As Integer, CveProyecto As Integer, FechaIFinContrato As String, FechaFFinContrato As String, FechaIIngreso As String, FechaFIngreso As String, SqlStr As String, NCaracteristicas As Integer, CveEmpresa As Integer, Optional TopSelect As Integer = 10000, Optional EsReserva As Integer = -1) As Boolean @@ -1806,7 +1807,7 @@ Public Class ClsRH .Add("@HorarioTrabajo", SqlDbType.VarChar).Value = HorarioTrabajo .Add("@CveSupervisor", SqlDbType.Int).Value = CveSupervisor .Add("@CveTipoPeriodo", SqlDbType.Int).Value = CveTipoPeriodo - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@CveFormaPago", SqlDbType.Int).Value = CveFormaPago .Add("@CveTipoContrato", SqlDbType.Int).Value = CveTipoContrato .Add("@CveMotivoBaja", SqlDbType.Int).Value = CveMotivoBaja .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto @@ -1846,7 +1847,7 @@ Public Class ClsRH Me.SalarioDiarioSS = Data.Rows(0)("SalarioDiarioSS").ToString.ToDecimal Me.NumDiasAguinaldo = Data.Rows(0)("NumDiasAguinaldo").ToString.ToEntero Me.PorPrimaVacacional = Data.Rows(0)("PorPrimaVacacional").ToString.ToDecimal - Me.CveMetodoPago = Data.Rows(0)("CveMetodoPago").ToString.ToEntero + Me.CveFormaPago = Data.Rows(0)("CveFormaPago").ToString.ToEntero Me.MetodoPago = Data.Rows(0)("MetodoPago").ToString Me.MetodoPagoSAT = Data.Rows(0)("MetodoPagoSAT").ToString @@ -1975,7 +1976,7 @@ Public Class ClsRH Return Retorno End Function Public Function AddPersonal(Codigo As String, APaterno As String, AMaterno As String, Nombres As String, Correo As String, FechaIngreso As Date, CveTipoPeriodo As Integer, NumeroSS As String, SeInscribioSS As Boolean, SalarioDiarioPago As Double, SalarioDiario As Double, SDI As Double, - SalarioDiarioSS As Double, Bono As Double, NumDiasAguinaldo As Integer, PorPrimaVacacional As Double, CveMetodoPago As Integer, FechaInicioContrato As Date, FechaFinContrato As String, + SalarioDiarioSS As Double, Bono As Double, NumDiasAguinaldo As Integer, PorPrimaVacacional As Double, CveFormaPago As Integer, FechaInicioContrato As Date, FechaFinContrato As String, CveTipoContrato As Integer, Ubicacion As String, CveTurno As Integer, CvePuesto As Integer, CveDepartamento As Integer, CveRuta As Integer, CveEscolaridad As Integer, CveEstadoCivil As Integer, CveGenero As Integer, CveMotivoBaja As Integer, FechaBaja As String, CveEstatusPersonal As Integer, FechaNacimiento As Date, LugarNacimiento As String, Calle As String, NumExt As String, NumInt As String, Colonia As String, CP As String, Ciudad As String, CveEstado As Integer, Telefono As String, TelefonoEmergencia As String, Celular As String, RFC As String, CURP As String, CredencialElector As String, @@ -2008,7 +2009,7 @@ Public Class ClsRH .Add("@Bono", SqlDbType.Money).Value = Bono .Add("@NumDiasAguinaldo", SqlDbType.Int).Value = NumDiasAguinaldo .Add("@PorPrimaVacacional", SqlDbType.Float).Value = PorPrimaVacacional - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@CveFormaPago", SqlDbType.Int).Value = CveFormaPago .Add("@FechaInicioContrato", SqlDbType.Date).Value = FechaInicioContrato .Add("@FechaFinContrato", SqlDbType.VarChar).Value = FechaFinContrato .Add("@CveTipoContrato", SqlDbType.Int).Value = CveTipoContrato @@ -2130,7 +2131,7 @@ Public Class ClsRH Public Function UpdatePersonal(Codigo As String, APaterno As String, AMaterno As String, Nombres As String, Correo As String, FechaIngreso As Date, CveTipoPeriodo As Integer, NumeroSS As String, SeInscribioSS As Boolean, SalarioDiarioPago As Double, SalarioDiario As Double, SDI As Double, - SalarioDiarioSS As Double, Bono As Double, NumDiasAguinaldo As Integer, PorPrimaVacacional As Double, CveMetodoPago As Integer, FechaInicioContrato As Date, FechaFinContrato As String, + SalarioDiarioSS As Double, Bono As Double, NumDiasAguinaldo As Integer, PorPrimaVacacional As Double, CveFormaPago As Integer, FechaInicioContrato As Date, FechaFinContrato As String, CveTipoContrato As Integer, Ubicacion As String, CveTurno As Integer, CvePuesto As Integer, CveDepartamento As Integer, CveRuta As Integer, CveEscolaridad As Integer, CveEstadoCivil As Integer, CveGenero As Integer, CveMotivoBaja As Integer, FechaBaja As String, CveEstatusPersonal As Integer, FechaNacimiento As Date, LugarNacimiento As String, Calle As String, NumExt As String, NumInt As String, Colonia As String, CP As String, Ciudad As String, CveEstado As Integer, Telefono As String, TelefonoEmergencia As String, Celular As String, RFC As String, CURP As String, CredencialElector As String, @@ -2165,7 +2166,7 @@ Public Class ClsRH .Add("@Bono", SqlDbType.Money).Value = Bono .Add("@NumDiasAguinaldo", SqlDbType.Int).Value = NumDiasAguinaldo .Add("@PorPrimaVacacional", SqlDbType.Float).Value = PorPrimaVacacional - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@CveFormaPago", SqlDbType.Int).Value = CveFormaPago .Add("@FechaInicioContrato", SqlDbType.Date).Value = FechaInicioContrato .Add("@FechaFinContrato", SqlDbType.VarChar).Value = FechaFinContrato .Add("@CveTipoContrato", SqlDbType.Int).Value = CveTipoContrato diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx index 991711e94..c3cf8e2f1 100644 --- a/Compras/Compras.aspx +++ b/Compras/Compras.aspx @@ -1783,6 +1783,7 @@ <%----%> + @@ -1945,8 +1946,8 @@ - - + + <%-- --%> @@ -5942,7 +5943,7 @@ } function ClickDeudorChk(Chk, Obj, total, saldo,txtOtrIngEgs) { - debugger; + total = parseFloat(parseFloat(total).toFixed(2)); saldo = parseFloat(parseFloat(saldo).toFixed(2)); @@ -6227,7 +6228,7 @@ function chkAnt(t, txt, importe, TotalSaldoCompra, CveMonedaAnticipo, TCAnticipo, CveMonedaOriginal, TCCompra, txtComision) { var Total = ToDouble($get('TxtTotal').value); - debugger; + var txtvalue = ToDouble(txt.value); var ImportePago, ImporteCompra; @@ -6336,7 +6337,7 @@ } } - debugger; + let saldoVal = saldo; if (CveMonedaAnticipo == 1 && CveMonedaOriginal == 2) { saldoVal = ToDouble(saldo / TCAnticipo) @@ -6674,7 +6675,7 @@ - function CalculaTotalOCEdit(PS, CantidadOriginal, TxtCantidad, TxtPU, TxtTotal, IEPSOriginal, HdnIEPS, IVAOriginal, HdnIVA, RetIVAOriginal, HdnRetIVA, RetISROriginal, HdnRetISR, IEPSIVAOriginal, HdnIEPSIVA, DescuentoOriginal, HdnDescuento, IVAPorcentaje, RetIVAPorcentaje, RetISRPorcentaje, IEPSPSPorcentaje, IEPSPSIVAPorcentaje) { + function CalculaTotalOCEdit(PS, CantidadOriginal, PUOriginal, TxtCantidad, TxtPU, TxtTotal, IEPSOriginal, HdnIEPS, IVAOriginal, HdnIVA, RetIVAOriginal, HdnRetIVA, RetISROriginal, HdnRetISR, IEPSIVAOriginal, HdnIEPSIVA, DescuentoOriginal, HdnDescuento, IVAPorcentaje, RetIVAPorcentaje, RetISRPorcentaje, IEPSPSPorcentaje, IEPSPSIVAPorcentaje) { //var Proporcional = ((ToDouble(TxtCantidad.value) * 100) / CantidadOriginal) / 100; @@ -6702,8 +6703,7 @@ TxtTotal.value = FormatoNumero(Total - ToDouble(HdnDescuento.value), 2); //RECALCULA IMPORTES GENERALES - CalculaTotalesOC(); - + CalculaTotalesOC(); } function ValidaImporteCero(PS, TxtCantidad, TxtPU) { @@ -6749,7 +6749,7 @@ }); //Amortizacion = ToDouble($get('C_Tab_TabGenerales_LblAmortizacion').innerText); - + SumaTotal = SumaSubTotal + SumaIVA + SumaIEPS - SumaRetIVA - SumaRetISR; if ($get("C_Tab_TabOC_LbSubTotalOC1")) { @@ -6780,7 +6780,7 @@ $get("C_Tab_TabOC_LblRetISROC1").innerText = FormatoNumero(SumaRetISR, 2); } if ($get("C_Tab_TabOC_LbTotalOC1")) { - $get("C_Tab_TabOC_LbTotalOC1").innerText = FormatoNumero(SumaTotal, 2); + $get("C_Tab_TabOC_LbTotalOC1").value = FormatoNumero(SumaTotal, 2); } } @@ -6976,7 +6976,7 @@ return;//Evita que se ejecute la rutina cuando se presiona Tap (cuando se salta de interes a ambas si se ejecuta se limpian los valores de capital e interes) } - debugger; + let TotalCompra = 0; let ImporteAmortizado = 0; diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index d8c2d3080..13cfbd3eb 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -13,7 +13,6 @@ Imports MoreLinq Imports System.Data.SqlClient Imports ClsPaginas Imports Microsoft.Reporting.WebForms -Imports DocumentFormat.OpenXml.Math Partial Class Compras_Compras Inherits ClsPaginas @@ -283,6 +282,15 @@ Partial Class Compras_Compras End Set End Property + Private Property PermisoVinculacionImporteDiferente As Boolean + Get + Return CType(ViewState("PermisoVinculacionImporteDiferente"), Boolean) + End Get + Set(value As Boolean) + ViewState("PermisoVinculacionImporteDiferente") = value + End Set + End Property + Private Property NuevaValidacionXML As Integer Get Return ViewState("NuevaValidacionXML").ToString.ToEntero @@ -1260,6 +1268,7 @@ Partial Class Compras_Compras 'ImgBtnBuscarOC.Attributes.Add("data-placement", "top") EsGrupoDiaz = If(UsuarioActual.Empresa.Funcionalidad(382) = "1", True, False) TienePermisoKardex = If(UsuarioActual.TienePermisoPagina(224), True, False) + LbTotalOC1.Attributes.Add(“readonly”, “readonly”) CargaDatosAgregarPS() TieneAnticiposXML = False @@ -1670,6 +1679,14 @@ Partial Class Compras_Compras InicializaDTProrrateoGasolina() End If + + If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + If Request("SaldarRNC") IsNot Nothing AndAlso Request("SaldarRNC").ToString.ToEntero = 1 Then + SaldaConRNC() + End If + + End If + End If 'SE OCUPAN AFUERA DEL POSTBACK ?? @@ -1702,6 +1719,79 @@ Partial Class Compras_Compras End Sub + + Private Sub SaldaConRNC() + + If CompraSaldo > 0 Then + ImporteRNC = CompraSaldo.ToDecimal + Dim ErrorSaldoRNC As Boolean = False + Dim ObjCompras As New ClsCompras + Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL) + ObjCompras.IniciaTransacSQL() + ObjCompras.IniciaTransacSQL() + + If UsuarioActual.Empresa.Funcionalidad(574) = "1" AndAlso (ImporteRNC > 0 Or ImporteRNCProntoPago > 0) Then + + + Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal + + Dim CompraSaldar As New Compra + CompraSaldar.CveCompra = CveCompra + CompraSaldar.CveTipoConceptoProveedor = CveTipoConcepto + CompraSaldar.CveProveedor = CveProveedor + CompraSaldar.CveMoneda = DdlMoneda.SelectedValue.ToEntero + CompraSaldar.Fecha = TxtFecha.Text.ToDate + CompraSaldar.SerieFolio = TxtSerie.Text.Trim & "-" & TxtFolio.Text.Trim + CompraSaldar.ProveedorNombre = HplProveedor.Text + CompraSaldar.TC = TipoCambio + CompraSaldar.Total = TxtTotal.Text.ToDecimal + CompraSaldar.IVA = TxtIVA.Text.ToDecimal + CompraSaldar.IVADeducible = TxtIVA.Text.ToDecimal + CompraSaldar.IEPS = TxtIEPS.Text.ToDecimal + CompraSaldar.RetIVA = TxtRetIVA.Text.ToDecimal + CompraSaldar.RetISR = TxtRetISR.Text.ToDecimal + CompraSaldar.CveConceptoRetISR = DdlRetISRConcepto.SelectedValue.ToEntero + CompraSaldar.CveConceptoRetIVA = DdlRetIVAConcepto.SelectedValue.ToEntero + CompraSaldar.PorcentajeIVA = PorcentajeIVA + CompraSaldar.UsuarioActual = UsuarioActual + CompraSaldar.CveSubProyecto = TmpDT.FiltroPrimeroValor("CveSubProyecto", " CveSubProyecto > 0").ToEntero + CompraSaldar.EsImportacion = chkImportacion.Checked + + Dim FolioFijo As Integer = 0 + 'cheque + If DdlTipoTransaccion.SelectedValue = "1" AndAlso UsuarioActual.CveEmpresa <> 119 Then FolioFijo = TxtFolio.Text.ToEntero + Dim ConceptoPoliza As String = String.Format("{0} - {1}{2} - {3}", NombreProveedor, TxtSerie.Text, TxtFolio.Text, TxtDescripcion.Text.Trim) + + Dim CvePrePolizaSaldar = ObjConta.AddPrePolizas("Compras/SaldarRNC", 53, ImporteRNC.RoundSQL(2), ImporteRNC.RoundSQL(2), DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa)) + + If CvePrePolizaSaldar > 0 Then + ImporteRNC = ImporteRNC.RoundSQL(2) + If PorcentajeIVA > 0 Then + ImporteRNC = ((ImporteRNC) / (1 + PorcentajeIVA)) + End If + + If Not GeneraRNC(ObjCompras.IniciaTransacSQL, CveCompra, CompraSaldar, ObjConta, CvePrePolizaSaldar, DdlProveedor.SelectedValue.ToEntero, DdlProveedor.SelectedItem.Text, TxtFecha.Text.ToDate, $"Remisión Nota de Crédito {TxtDescripcion.Text}", DdlMoneda.SelectedValue.ToEntero, TxtTC.Text.ToDecimal, + TxtSerie.Text, TxtFolio.Text, RedondearSaldado:=True) Then + ErrorSaldoRNC = True + End If + End If + + + End If + + If ErrorSaldoRNC Then + ObjCompras.RollBack() + Else + ObjCompras.Commit() + End If + + ObjCompras.Dispose() + ObjConta.Dispose() + End If + + + End Sub + Private Sub ConfiguraseleccionRemisionNotaCredito() Dim AutoSelRNC As Boolean = False @@ -2090,6 +2180,10 @@ Partial Class Compras_Compras If TxtFolio.Text.Trim = "" Then TxtFolio.Enabled = True : TxtSerie.Enabled = True + If UsuarioActual.TienePermisoProceso(242) Then + PermisoVinculacionImporteDiferente = True + End If + If UsuarioActual.TienePermisoProceso(112) Then PermisoEdicionManual = True TxtSubTotal.Enabled = True @@ -15233,15 +15327,25 @@ Partial Class Compras_Compras Protected Sub GvOC1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvOC1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then - Dim JSCambiaScript As String = $"CalculaTotalOCEdit('{e.Row.DBCampo("PS").Replace("'", "").Replace(vbLf, " ").Replace(vbCrLf, " ")}', {e.Row.DBCampo("Cantidad").ToString.ToDouble}, {e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID}, {e.Row.FCTextBox("TxtTotalOC1").ClientID}, {e.Row.DBCampo("IEPSPS").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1IEPSImporte").ClientID}, {e.Row.DBCampo("IVA").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1IVA").ClientID},{e.Row.DBCampo("RetIVA").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1RetIVA").ClientID},{e.Row.DBCampo("RetISR").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1RetISR").ClientID},{e.Row.DBCampo("IEPSPS").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1IEPSIVA").ClientID},{e.Row.DBCampo("Descuento")},{e.Row.FCHiddenField("HdnOC1Descuento").ClientID},{e.Row.DBCampo("IVAPorcentaje").ToString.ToDouble},{e.Row.DBCampo("RetIVAPorcentaje").ToString.ToDouble},{e.Row.DBCampo("RetISRPorcentaje").ToString.ToDouble},{e.Row.DBCampo("IEPSPSPorcentaje").ToString.ToDouble},{e.Row.DBCampo("IEPSPSIVAPorcentaje").ToString.ToDouble});" + Dim JSCambiaScript As String = $"CalculaTotalOCEdit('{e.Row.DBCampo("PS").Replace("'", "").Replace(vbLf, " ").Replace(vbCrLf, " ")}', {e.Row.DBCampo("Cantidad").ToDouble},{e.Row.DBCampo("PU").ToDouble}, {e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID}, {e.Row.FCTextBox("TxtTotalOC1").ClientID}, {e.Row.DBCampo("IEPSPS").ToDouble},{e.Row.FCHiddenField("HdnOC1IEPSImporte").ClientID}, {e.Row.DBCampo("IVA").ToDouble},{e.Row.FCHiddenField("HdnOC1IVA").ClientID},{e.Row.DBCampo("RetIVA").ToDouble},{e.Row.FCHiddenField("HdnOC1RetIVA").ClientID},{e.Row.DBCampo("RetISR").ToDouble},{e.Row.FCHiddenField("HdnOC1RetISR").ClientID},{e.Row.DBCampo("IEPSPS").ToDouble},{e.Row.FCHiddenField("HdnOC1IEPSIVA").ClientID},{e.Row.DBCampo("Descuento")},{e.Row.FCHiddenField("HdnOC1Descuento").ClientID},{e.Row.DBCampo("IVAPorcentaje").ToDouble},{e.Row.DBCampo("RetIVAPorcentaje").ToString.ToDouble},{e.Row.DBCampo("RetISRPorcentaje").ToDouble},{e.Row.DBCampo("IEPSPSPorcentaje").ToDouble},{e.Row.DBCampo("IEPSPSIVAPorcentaje").ToDouble});" e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", $"LimitaCantidadOC({e.Row.DBCampo("CantidadPendienteVincular")}, this);{JSCambiaScript}") e.Row.FCTextBox("TxtPU").Attributes.Add("onkeyup", JSCambiaScript) e.Row.FCTextBox("TxtCantidad").Attributes.Add("onblur", $"ValidaImporteCero('{e.Row.DBCampo("PS").Replace("'", "")}',{e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID});") e.Row.FCTextBox("TxtPU").Attributes.Add("onblur", $"ValidaImporteCero('{e.Row.DBCampo("PS").Replace("'", "")}',{e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID});") - RegistraScript(JSCambiaScript) + 'activo el rangevalidator para cambios Proc.242 + If Not PermisoVinculacionImporteDiferente Then + Dim tdif As Decimal = 10D ' solo 10 permitido a nivel total + 'If e.Row.DBCampo("Total").ToDecimal > tdif Then + ' e.Row.FCRangeValidator("RValPU").MinimumValue = ((e.Row.DBCampo("Total").ToDecimal - tdif) / e.Row.DBCampo("Cantidad").ToDecimal).ToString("F6") + 'Else + ' e.Row.FCRangeValidator("RValPU").MinimumValue = "0.00" + 'End If + e.Row.FCRangeValidator("RValPU").MaximumValue = ((e.Row.DBCampo("Total").ToDecimal + tdif) / e.Row.DBCampo("Cantidad").ToDecimal).ToString("F6") + End If + If e.Row.DataKey("FolioREQ").ToString.Trim.Length > 0 Then Dim LblOC As Label = e.Row.FCLabel("LblOC") LblOC.Attributes.Add("data-toggle", "tooltip") @@ -19143,7 +19247,7 @@ Partial Class Compras_Compras CompraActual.Fecha = TxtFecha.Text.ToDate CompraActual.SerieFolio = TxtSerie.Text.Trim & "-" & TxtFolio.Text.Trim CompraActual.ProveedorNombre = HplProveedor.Text - CompraActual.TC = TipoCambio + CompraActual.TC = TipoCambioOriginal CompraActual.Total = TxtTotal.Text.ToDecimal CompraActual.IVA = TxtIVA.Text.ToDecimal CompraActual.IVADeducible = TxtIVA.Text.ToDecimal @@ -19157,7 +19261,8 @@ Partial Class Compras_Compras CompraActual.CveSubProyecto = tCveSubProyeto CompraActual.EsImportacion = chkImportacion.Checked - If Not GeneraRNC(ObjCompras.IniciaTransacSQL, CveCompra, CompraActual, objConta, CvePrePoliza, DdlProveedor.SelectedValue.ToEntero, DdlProveedor.SelectedItem.Text, TxtFecha.Text.ToDate, $"Remisión Nota de Crédito {TxtDescripcion.Text}", DdlMoneda.SelectedValue.ToEntero, TxtTC.Text.ToDecimal, + If Not GeneraRNC(ObjCompras.IniciaTransacSQL, CveCompra, CompraActual, objConta, CvePrePoliza, DdlProveedor.SelectedValue.ToEntero, DdlProveedor.SelectedItem.Text, TxtFecha.Text.ToDate, + $"Remisión Nota de Crédito {TxtDescripcion.Text}", DdlMoneda.SelectedValue.ToEntero, TipoCambioOriginal, TxtSerie.Text, TxtFolio.Text, EsDRMN:=True) Then TieneError = True End If @@ -21920,7 +22025,8 @@ Partial Class Compras_Compras #Region "PRONTO PAGO" Public Function GeneraRNC(ByRef sqltransaccion As SqlTransaction, CveCompraRegistrada As Integer, ByRef CompraActual As Compra, ByRef ObjConta As ClsContabilidad, CvePrePoliza As Integer, - CveProveedor As Integer, NombreProveedor As String, Fecha As Date, Descripcion As String, CveMoneda As Integer, TipoCambio As Decimal, Serie As String, Folio As String, Optional EsDRMN As Boolean = False, Optional TmpListadoPS As DataTable = Nothing) As Boolean + CveProveedor As Integer, NombreProveedor As String, Fecha As Date, Descripcion As String, CveMoneda As Integer, TipoCambio As Decimal, Serie As String, Folio As String, + Optional EsDRMN As Boolean = False, Optional TmpListadoPS As DataTable = Nothing, Optional RedondearSaldado As Boolean = False) As Boolean CveCompraDRMC = -1 Dim respuesta As Boolean = True Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal @@ -21945,19 +22051,20 @@ Partial Class Compras_Compras If PSRow IsNot Nothing Then Dim CompraRNC As New ClsCompraManagerCompras(UsuarioActual) With { - .TipoDocto = "RNC", - .CveProveedor = CveProveedor, - .CveTipoProveedor = CveTipoProveedor, - .CveTipoConceptoProveedor = CveTipoConcepto, - .Descripcion = Descripcion, - .NombreProveedor = NombreProveedor, - .Fecha = Fecha, - .CveMoneda = CveMoneda, - .TipoCambio = If(CveMoneda = 1, 1, TipoCambio), - .Serie = $"D-{Serie}", - .Folio = Folio, - .CveCompraAmortizacion = CveCompraRegistrada - } + .TipoDocto = "RNC", + .CveProveedor = CveProveedor, + .CveTipoProveedor = CveTipoProveedor, + .CveTipoConceptoProveedor = CveTipoConcepto, + .Descripcion = Descripcion, + .NombreProveedor = NombreProveedor, + .Fecha = Fecha, + .CveMoneda = CveMoneda, + .TipoCambio = If(CveMoneda = 1, 1, TipoCambio), + .Serie = $"D-{Serie}", + .Folio = Folio, + .CveCompraAmortizacion = CveCompraRegistrada, + .CveCompraRelacionada = CveCompraRegistrada + } 'Dim CveTipoPS As Integer = PSRow("CveTipoPS").ToString.ToEntero 'If PSRow("CvePSCargo").ToString <> "" Then @@ -21969,11 +22076,13 @@ Partial Class Compras_Compras Dim PS As String = PSRow("PSCodigo").ToString Dim CveUM As Integer = PSRow("CveUnidadMedida").ToString.ToEntero Dim UM As String = PSRow("UnidadMedida").ToString - Dim IVARNC As Decimal = (ImporteRNC * PorcentajeIVA).RoundSQL(2) - CompraRNC.ConfiguraRegistroRapido(CvePS_RNC, CveUM, UM, CveClasificacion, Clasificacion, PS, CveSubProyectoPrincipal, SubProyecto, ImporteRNC, IVARNC, (ImporteRNC + IVARNC), PorcentajeIVA) + Dim IVARNC As Decimal = (ImporteRNC * PorcentajeIVA).RoundSQL(2) + Dim TotalRNC As Decimal = If(RedondearSaldado, (ImporteRNC + IVARNC).RoundSQL(2), (ImporteRNC + IVARNC)) + + CompraRNC.ConfiguraRegistroRapido(CvePS_RNC, CveUM, UM, CveClasificacion, Clasificacion, PS, CveSubProyectoPrincipal, SubProyecto, ImporteRNC, IVARNC, TotalRNC, PorcentajeIVA) If CompraRNC.AddCompra(sqltransaccion) Then - Dim tImporteRNC = ImporteRNC + IVARNC ' le agrego el importe del iva + Dim tImporteRNC = TotalRNC ' le agrego el importe del iva Dim Pago As New CompraPago Pago.ImportePago = tImporteRNC Pago.CveMonedaPago = CompraActual.CveMoneda @@ -21992,19 +22101,20 @@ Partial Class Compras_Compras If respuesta AndAlso ImporteRNCProntoPago > 0 Then Dim CompraRNCProntoPago As New ClsCompraManagerCompras(UsuarioActual) With { - .TipoDocto = "RNC", - .CveProveedor = CveProveedor, - .CveTipoProveedor = CveTipoProveedor, - .CveTipoConceptoProveedor = CveTipoConcepto, - .Descripcion = Descripcion, - .NombreProveedor = NombreProveedor, - .Fecha = Fecha, - .CveMoneda = CveMoneda, - .TipoCambio = If(CveMoneda = 1, 1, TipoCambio), - .Serie = $"PP-{Serie}", - .Folio = $"{Folio}", - .CveCompraAmortizacion = CveCompraRegistrada - } + .TipoDocto = "RNC", + .CveProveedor = CveProveedor, + .CveTipoProveedor = CveTipoProveedor, + .CveTipoConceptoProveedor = CveTipoConcepto, + .Descripcion = Descripcion, + .NombreProveedor = NombreProveedor, + .Fecha = Fecha, + .CveMoneda = CveMoneda, + .TipoCambio = If(CveMoneda = 1, 1, TipoCambio), + .Serie = $"PP-{Serie}", + .Folio = $"{Folio}", + .CveCompraAmortizacion = CveCompraRegistrada, + .CveCompraRelacionada = CveCompraRegistrada + } Dim IVARNCProntoPago As Decimal = (ImporteRNCProntoPago * PorcentajeIVA).RoundSQL(2) CompraRNCProntoPago.ConfiguraRegistroRapido(CvePS_RNC, CveUM, UM, CveClasificacion, Clasificacion, PS, CveSubProyectoPrincipal, SubProyecto, ImporteRNCProntoPago, (ImporteRNCProntoPago + IVARNCProntoPago), IVARNCProntoPago, PorcentajeIVA) @@ -22026,6 +22136,11 @@ Partial Class Compras_Compras End If End If + If RedondearSaldado And respuesta Then + Alert("Saldado correctamente") + End If + + Return respuesta End Function @@ -22841,6 +22956,8 @@ Public Class ClsCompraManagerCompras Public Property CveIE As Integer = -1 Public Property CveCompraAmortizacion As Integer = -1 + Public Property CveCompraRelacionada As Integer = -1 + Public Sub New(UsuarioActual As Usuario) Errores = New StringBuilder @@ -24479,7 +24596,8 @@ Public Class ClsCompraManagerCompras AplicoPromocion:=Me.AplicoPromocion, PorcentajeIVA:=Me.PorcentajeIVA, CveMetodoPago:=Me.CveMetodoPago, CveRetIVAConcepto:=Me.CveRetIVAConcepto, CveConceptoContableAlmacen:=Me.CveConceptoContableAlmacen, CveRetISRConcepto:=Me.CveRetISRConcepto, NoDeducible:=Me.NoDeducible, CveTipoCompra:=Me.CveTipoCompra, TotalOriginal:=Me.TotalOriginal, CveTipoConcepto:=Me.CveTipoConcepto, - EsImportacion:=Me.EsImportacion, CveFactura:=Me.CveFactura, CveSubProyecto:=Me.CveSubProyectoPrincipal, DoctosRelacionados:=Me.DocumentosRelacionadosUUIDSString, CveFolioGarantia:=Me.CveFolioGarantia) Then + EsImportacion:=Me.EsImportacion, CveFactura:=Me.CveFactura, CveSubProyecto:=Me.CveSubProyectoPrincipal, DoctosRelacionados:=Me.DocumentosRelacionadosUUIDSString, CveFolioGarantia:=Me.CveFolioGarantia, + CveCompraRelacionada:=CveCompraRelacionada) Then Me.CveCompra = ObjCompras.CveCompra Else respuesta = False diff --git a/CxC/RepCxC.aspx b/CxC/RepCxC.aspx index 00b590813..e77222e90 100644 --- a/CxC/RepCxC.aspx +++ b/CxC/RepCxC.aspx @@ -780,7 +780,7 @@
- +
diff --git a/CxC/RepCxC.aspx.vb b/CxC/RepCxC.aspx.vb index c50f6046b..fde84a39d 100644 --- a/CxC/RepCxC.aspx.vb +++ b/CxC/RepCxC.aspx.vb @@ -861,13 +861,18 @@ Partial Class RepCxC DdlTipo.SelectedValueExist(gvRow.DataKey("Tipo")) TxtRI.Text = gvRow.DataKey("RangoInicial") TxtRF.Text = gvRow.DataKey("RangoFinal") - TxtRObjetivo.Text = gvRow.DataKey("Objetivo").ToString.ToDecimal.ToString("###.00") + TxtRObjetivo.Text = gvRow.DataKey("Objetivo").ToString.ToDecimal.ToString("###.00") + If Not TxtRF.Text.ToDouble > 0 Then ChkMayor.Checked = True TxtRF.Enabled = False + CambioChecked() Else ChkMayor.Checked = False - End If + TxtRF.Enabled = True + End If + + RegistraScript("$('#DivPersonalizarRangoEditar').modal()") UpPersonalizarRangoEditar.Update() End Sub diff --git a/OP/CatConfiguracionProducto.aspx b/OP/CatConfiguracionProducto.aspx new file mode 100644 index 000000000..360b2c6f8 --- /dev/null +++ b/OP/CatConfiguracionProducto.aspx @@ -0,0 +1,256 @@ +<%@ Page Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="CatConfiguracionProducto.aspx.vb" Inherits="OP_CatConfiguracionProducto" %> + + + + + + + Configuración de productos + + + + + + +
  • + +
  • +
    +
    +
    + + + + + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + +
    + + diff --git a/OP/CatConfiguracionProducto.aspx.vb b/OP/CatConfiguracionProducto.aspx.vb new file mode 100644 index 000000000..5a9d5c678 --- /dev/null +++ b/OP/CatConfiguracionProducto.aspx.vb @@ -0,0 +1,612 @@ +Imports System.Data +Imports Extensiones + +Partial Class OP_CatConfiguracionProducto + Inherits ClsPaginas + +#Region "PROPIEDADES" + + Private Property CvePS As Integer + Get + If Not ViewState("CvePS") Is Nothing Then + Return ViewState("CvePS").ToString.ToEntero + Else + Return -1 + End If + End Get + Set(value As Integer) + ViewState("CvePS") = value + End Set + End Property + + Private Property CveUM As Integer + Get + If Not ViewState("CveUM") Is Nothing Then + Return ViewState("CveUM").ToString.ToEntero + Else + Return -1 + End If + End Get + Set(value As Integer) + ViewState("CveUM") = value + End Set + End Property + + Private Property DtMP As DataTable + Get + Return CType(ViewState("DtMP"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMP") = value + End Set + End Property + + Private Property DtMO As DataTable + Get + Return CType(ViewState("DtMO"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMO") = value + End Set + End Property + + Private Property DtCI As DataTable + Get + Return CType(ViewState("DtCI"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtCI") = value + End Set + End Property + + Private Property DtEliminados As DataTable + Get + Return CType(ViewState("DtEliminados"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtEliminados") = value + End Set + End Property + +#End Region + + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not Page.IsPostBack Then + CreaDtEliminados() + CargarListadoPrincipal() + CargarCombos() + End If + End Sub + +#Region "CARGAS" + + Private Sub CargarListadoPrincipal() + Using clsOp As New ClsOP() + If clsOp.GetConfiguracionProducto(-1, UsuarioActual.CveEmpresa) Then + GvProductos.DataSource = clsOp.DtResultados + GvProductos.DataBind() + End If + clsOp.Dispose() + UpDatos.Update() + End Using + End Sub + + Private Sub CreaDtEliminados() + DtEliminados = New DataTable + DtEliminados.Columns.Add("Cve", GetType(Integer)) + End Sub + + Private Sub CargarCombos() + + DdlPuesto.DataSource = GlobalDTRHPuestos(UsuarioActual.CveEmpresa) + DdlPuesto.DataBind() + DdlPuesto.Items.Insert(0, New ListItem("Seleccione", "-1")) + + DdlProductoConfigurar.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlProductoConfigurar.SelectedText = "Seleccione" + DdlProductoConfigurar.SelectedValue = "-1" + Else + DdlProductoConfigurar.ddl.Items.Clear() + DdlProductoConfigurar.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlProductoConfigurar.ddl.DataBind() + DdlProductoConfigurar.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + DdlMateriaPrima.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlMateriaPrima.SelectedText = "Seleccione" + DdlMateriaPrima.SelectedValue = "-1" + Else + DdlMateriaPrima.ddl.Items.Clear() + DdlMateriaPrima.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlMateriaPrima.ddl.DataBind() + DdlMateriaPrima.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + DdlProducto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlProducto.SelectedText = "Seleccione" + DdlProducto.SelectedValue = "-1" + Else + DdlProducto.ddl.Items.Clear() + DdlProducto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlProducto.ddl.DataBind() + DdlProducto.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + UpMateriaPrima.Update() + UpManoObra.Update() + UpCostoIndirecto.Update() + End Sub + + Protected Sub DdlPS_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlMateriaPrima.selectedindexchange + DdlPSChange() + End Sub + + Private Sub DdlPSChange() + If DdlMateriaPrima.SelectedValue.ToEntero > 0 Then + Dim PS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=DdlMateriaPrima.SelectedValue.ToEntero).FiltroPrimero("") + + If PS IsNot Nothing Then + DdlUM.Items.Clear() + DdlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) + DdlUM.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlUM.DataBind() + DdlUM.SelectedValueExist(PS("CveUnidadMedida").ToString) + End If + Else + DdlUM.Items.Clear() + DdlUM.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlUM.SelectedValue = "-1" + End If + UpMateriaPrima.Update() + End Sub + + Protected Sub DdlPSConfigurar_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlProductoConfigurar.selectedindexchange + DdlPSConfigurarChange() + End Sub + + Private Sub DdlPSConfigurarChange() + If DdlProductoConfigurar.SelectedValue.ToEntero > 0 Then + Dim PS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=DdlProductoConfigurar.SelectedValue.ToEntero).FiltroPrimero("") + + If PS IsNot Nothing Then + DdlUMConfigurar.Items.Clear() + DdlUMConfigurar.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) + DdlUMConfigurar.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlUMConfigurar.DataBind() + DdlUMConfigurar.SelectedValueExist(PS("CveUnidadMedida").ToString) + End If + Else + DdlUMConfigurar.Items.Clear() + DdlUMConfigurar.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlUMConfigurar.SelectedValue = "-1" + End If + UpMateriaPrima.Update() + End Sub + +#End Region + +#Region "MATERIA PRIMA" + + Protected Sub BtnMateriaPrima_Click(ByVal sender As Object, ByVal e As EventArgs) + + DdlProductoConfigurar.SelectedText = "Seleccione" + DdlProductoConfigurar.SelectedValue = "-1" + + DdlMateriaPrima.SelectedText = "Seleccione" + DdlMateriaPrima.SelectedValue = "-1" + + DdlUMConfigurar.SelectedValueExist("-1") + DdlUM.SelectedValueExist("-1") + + TxtCantidadMateriaPrima.Text = String.Empty + + DtEliminados.Rows.Clear() + + DivProductoConfigurar.Visible = False + DivUMConfigurar.Visible = False + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + CvePS = GvRow.DataKey("CvePS").ToEntero() + CveUM = GvRow.DataKey("CveUM").ToEntero() + Using clsOp As New ClsOP() + If clsOp.GetMPReceta(CvePS, CveUM, UsuarioActual.CveEmpresa) Then + DtMP = clsOp.DtResultados.FiltraParametros("ISNULL(CveOPPS,0) > 0").Copy() + GvMateriaPrima.DataSource = DtMP + GvMateriaPrima.DataBind() + End If + clsOp.Dispose() + UpMateriaPrima.Update() + End Using + RegistraScript(String.Format("$('#{0}').modal('show');", "divAddMateriaPrima")) + End Sub + + Protected Sub BtnEliminarMateriaPrima_Click(ByVal sender As Object, ByVal e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim CveOPPS = GvRow.DataKey("CveOPPS").ToEntero + Dim Index = GvRow.RowIndex + DtMP.Rows.RemoveAt(Index) + + If CveOPPS > 0 Then + Dim dr As DataRow = DtEliminados.NewRow + dr("Cve") = CveOPPS + DtEliminados.Rows.Add(dr) + End If + + GvMateriaPrima.DataSource = DtMP + GvMateriaPrima.DataBind() + + UpMateriaPrima.Update() + End Sub + + Protected Sub BtnAgregarMateriaPrima_Click(ByVal sender As Object, ByVal e As EventArgs) + + If Not DdlMateriaPrima.SelectedValue.ToEntero() > 0 Then + Alert("Es necesario seleccionar una materia prima.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlUM.SelectedValue.ToEntero() > 0 Then + Alert("Es necesario seleccionar una unidad de medida.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If String.IsNullOrEmpty(TxtCantidadMateriaPrima.Text) Or Not TxtCantidadMateriaPrima.Text.ToDecimal() > 0 Then + Alert("Es necesario ingresar una cantidad mayor a 0.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim dr As DataRow = DtMP.NewRow + dr("CveOPPS") = -1 + dr("CvePSMateriaPrima") = DdlMateriaPrima.SelectedValue.ToEntero() + dr("CveUMMateriaPrima") = DdlUM.SelectedValue.ToEntero() + dr("productoMateriaPrima") = DdlMateriaPrima.SelectedText + dr("UnidadMedidaMateriaPrima") = DdlUM.SelectedItem.Text + dr("Cantidad") = TxtCantidadMateriaPrima.Text.ToDecimal() + dr("CvePS") = CvePS + dr("CveUM") = CveUM + + DtMP.Rows.Add(dr) + + GvMateriaPrima.DataSource = DtMP + GvMateriaPrima.DataBind() + + DdlProductoConfigurar.SelectedText = "Seleccione" + DdlProductoConfigurar.SelectedValue = "-1" + + DdlMateriaPrima.SelectedText = "Seleccione" + DdlMateriaPrima.SelectedValue = "-1" + + DdlUMConfigurar.SelectedValueExist("-1") + DdlUM.SelectedValueExist("-1") + + TxtCantidadMateriaPrima.Text = String.Empty + + UpMateriaPrima.Update() + + End Sub + + Protected Sub BtnAgregarProducto_Click(ByVal sender As Object, ByVal e As EventArgs) + + DdlProductoConfigurar.SelectedText = "Seleccione" + DdlProductoConfigurar.SelectedValue = "-1" + + DdlMateriaPrima.SelectedText = "Seleccione" + DdlMateriaPrima.SelectedValue = "-1" + + DdlUMConfigurar.SelectedValueExist("-1") + DdlUM.SelectedValueExist("-1") + + TxtCantidadMateriaPrima.Text = String.Empty + + DtEliminados.Rows.Clear() + + CvePS = -1 + CveUM = -1 + + Using clsOp As New ClsOP() + If clsOp.GetMPReceta(CvePS, CveUM, UsuarioActual.CveEmpresa) Then + DtMP = clsOp.DtResultados.FiltraParametros("ISNULL(CveOPPS,0) = 0").Copy() + DtMP.Rows.Clear() + GvMateriaPrima.DataSource = DtMP + GvMateriaPrima.DataBind() + End If + clsOp.Dispose() + End Using + + DivProductoConfigurar.Visible = True + DivUMConfigurar.Visible = True + RegistraScript(String.Format("$('#{0}').modal('show');", "divAddMateriaPrima")) + UpMateriaPrima.Update() + End Sub + +#End Region + +#Region "MANO OBRA" + + Protected Sub BtnManoObra_Click(ByVal sender As Object, ByVal e As EventArgs) + + DdlPuesto.SelectedValueExist("-1") + + TxtHoras.Text = String.Empty + + DtEliminados.Rows.Clear() + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + CvePS = GvRow.DataKey("CvePS").ToEntero + CveUM = GvRow.DataKey("CveUM").ToEntero + Using clsOp As New ClsOP() + If clsOp.GetMOReceta(CvePS, CveUM, UsuarioActual.CveEmpresa) Then + DtMO = clsOp.DtResultados.FiltraParametros("ISNULL(CveOPManoObra,0) > 0").Copy() + GvManoObra.DataSource = DtMO + GvManoObra.DataBind() + End If + clsOp.Dispose() + UpManoObra.Update() + End Using + RegistraScript(String.Format("$('#{0}').modal('show');", "divAddManoObra")) + End Sub + + Protected Sub BtnEliminarManoObra_Click(ByVal sender As Object, ByVal e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim CveOPManoObra = GvRow.DataKey("CveOPManoObra").ToEntero + Dim Index = GvRow.RowIndex + DtMO.Rows.RemoveAt(Index) + + If CveOPManoObra > 0 Then + Dim dr As DataRow = DtEliminados.NewRow + dr("Cve") = CveOPManoObra + DtEliminados.Rows.Add(dr) + End If + + GvManoObra.DataSource = DtMO + GvManoObra.DataBind() + + UpManoObra.Update() + End Sub + + Protected Sub BtnAgregarManoObra_Click(ByVal sender As Object, ByVal e As EventArgs) + If Not DdlPuesto.SelectedValue.ToEntero() > 0 Then + Alert("Es necesario seleccionar un puesto.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If String.IsNullOrEmpty(TxtHoras.Text) Or Not TxtHoras.Text.ToDecimal() > 0 Then + Alert("Es necesario ingresar una cantidad mayor a 0.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim dr As DataRow = DtMO.NewRow + dr("CveOPManoObra") = -1 + dr("CvePuesto") = DdlPuesto.SelectedValue.ToEntero() + dr("Puesto") = DdlPuesto.SelectedItem.Text + dr("Cantidad") = TxtHoras.Text.ToDecimal() + dr("CvePS") = CvePS + dr("CveUM") = CveUM + + DtMO.Rows.Add(dr) + + GvManoObra.DataSource = DtMO + GvManoObra.DataBind() + + DdlPuesto.SelectedValueExist("-1") + + TxtHoras.Text = String.Empty + + UpManoObra.Update() + End Sub + +#End Region + +#Region "COSTO INDIRECTO" + + Protected Sub BtnCostoIndirecto_Click(ByVal sender As Object, ByVal e As EventArgs) + + DdlProducto.SelectedText = "Seleccione" + DdlProducto.SelectedValue = "-1" + + TxtCosto.Text = String.Empty + + DtEliminados.Rows.Clear() + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + CvePS = GvRow.DataKey("CvePS").ToEntero + CveUM = GvRow.DataKey("CveUM").ToEntero + Using clsOp As New ClsOP() + If clsOp.GetCIReceta(CvePS, CveUM, UsuarioActual.CveEmpresa) Then + DtCI = clsOp.DtResultados.FiltraParametros("ISNULL(CveOPPS,0) > 0").Copy() + GvCostoIndirecto.DataSource = DtCI + GvCostoIndirecto.DataBind() + End If + clsOp.Dispose() + UpCostoIndirecto.Update() + End Using + RegistraScript(String.Format("$('#{0}').modal('show');", "divAddCostoIndirecto")) + End Sub + + Protected Sub BtnEliminarCostoIndirecto_Click(ByVal sender As Object, ByVal e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim CveOPPS = GvRow.DataKey("CveOPPS").ToEntero + Dim Index = GvRow.RowIndex + DtCI.Rows.RemoveAt(Index) + + If CveOPPS > 0 Then + Dim dr As DataRow = DtEliminados.NewRow + dr("Cve") = CveOPPS + DtEliminados.Rows.Add(dr) + End If + + GvCostoIndirecto.DataSource = DtCI + GvCostoIndirecto.DataBind() + + UpCostoIndirecto.Update() + End Sub + + Protected Sub BtnAgregarCostoIndirecto_Click(ByVal sender As Object, ByVal e As EventArgs) + If Not DdlProducto.SelectedValue.ToEntero() > 0 Then + Alert("Es necesario seleccionar un producto.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If String.IsNullOrEmpty(TxtCosto.Text) Or Not TxtCosto.Text.ToDecimal() > 0 Then + Alert("Es necesario ingresar un costo mayor a 0.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim dr As DataRow = DtCI.NewRow + dr("CveOPPS") = -1 + dr("CvePSMateriaPrima") = DdlProducto.SelectedValue.ToEntero() + dr("productoMateriaPrima") = DdlProducto.SelectedText + dr("Cantidad") = TxtCosto.Text.ToDecimal() + dr("CvePS") = CvePS + dr("CveUM") = CveUM + + DtCI.Rows.Add(dr) + + GvCostoIndirecto.DataSource = DtCI + GvCostoIndirecto.DataBind() + + DdlProducto.SelectedText = "Seleccione" + DdlProducto.SelectedValue = "-1" + + TxtCosto.Text = String.Empty + + UpCostoIndirecto.Update() + End Sub + +#End Region + +#Region "GUARDADOS" + + Protected Sub BtnGuardarMP_Click(sender As Object, e As EventArgs) + + If Not DtMP.Rows.Count > 0 Then + Alert("Es necesario que agregue al menos una materia prima.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlProductoConfigurar.SelectedValue.ToEntero() > 0 Then + Alert("Es necesario seleccionar el producto a configurar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlUM.SelectedValue.ToEntero() > 0 Then + Alert("Es necesario seleccionar la unidad de medida a configurar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim GuardadoCorrecto As Boolean = True + Dim clsOp As New ClsOP() + clsOp.IniciaTransacSQL() + + If DivProductoConfigurar.Visible Then + + For Each Dr As DataRow In DtMP.Rows + If Not Dr("CveOPPS").ToString().ToEntero() > 0 Then + If Not clsOp.AddMP(Dr("Cantidad").ToString().ToDecimal(), DdlProductoConfigurar.SelectedValue.ToEntero(), Dr("CvePSMateriaPrima").ToString().ToEntero(), DdlUM.SelectedValue.ToEntero(), Dr("CveUMMateriaPrima").ToString().ToEntero()) Then + GuardadoCorrecto = False + End If + End If + Next + + Else + For Each Dr As DataRow In DtMP.Rows + If Not Dr("CveOPPS").ToString().ToEntero() > 0 Then + If Not clsOp.AddMP(Dr("Cantidad").ToString().ToDecimal(), Dr("CvePS").ToString().ToEntero(), Dr("CvePSMateriaPrima").ToString().ToEntero(), Dr("CveUM").ToString().ToEntero(), Dr("CveUMMateriaPrima").ToString().ToEntero()) Then + GuardadoCorrecto = False + End If + End If + Next + + For Each Dr As DataRow In DtEliminados.Rows + If Not clsOp.RemoveMP(Dr("Cve").ToString().ToEntero()) Then + GuardadoCorrecto = False + End If + Next + End If + + If GuardadoCorrecto Then + clsOp.Commit() + Alert("Materia Prima Guardada Correctamente", TipoMensaje.MsgInformacion) + CargarListadoPrincipal() + RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddMateriaPrima"), "jsHideModalMP") + Else + clsOp.RollBack() + Alert("Ocurrió un error al guardar la Materia Prima", TipoMensaje.MsgError) + End If + + End Sub + + Protected Sub BtnGuardarMO_Click(sender As Object, e As EventArgs) + + Dim GuardadoCorrecto As Boolean = True + + Dim clsOp As New ClsOP() + clsOp.IniciaTransacSQL() + + For Each Dr As DataRow In DtMO.Rows + If Not Dr("CveOPManoObra").ToString().ToEntero() > 0 Then + If Not clsOp.AddMO(Dr("Cantidad").ToString().ToDecimal(), Dr("CvePS").ToString().ToEntero(), Dr("CvePuesto").ToString().ToEntero(), Dr("CveUM").ToString().ToEntero()) Then + GuardadoCorrecto = False + End If + End If + Next + + For Each Dr As DataRow In DtEliminados.Rows + If Not clsOp.RemoveMO(Dr("Cve").ToString().ToEntero()) Then + GuardadoCorrecto = False + End If + Next + + If GuardadoCorrecto Then + clsOp.Commit() + Alert("Mano de Obra Guardada Correctamente", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddManoObra"), "jsHideModalMO") + Else + clsOp.RollBack() + Alert("Ocurrió un error al guardar la Mano de Obra", TipoMensaje.MsgError) + End If + + End Sub + + Protected Sub BtnGuardarCI_Click(sender As Object, e As EventArgs) + + Dim GuardadoCorrecto As Boolean = True + + Dim clsOp As New ClsOP() + clsOp.IniciaTransacSQL() + + For Each Dr As DataRow In DtCI.Rows + If Not Dr("CveOPPS").ToString().ToEntero() > 0 Then + If Not clsOp.AddCI(Dr("Cantidad").ToString().ToDecimal(), Dr("CvePS").ToString().ToEntero(), Dr("CvePSMateriaPrima").ToString().ToEntero(), Dr("CveUM").ToString().ToEntero(), Dr("CveUMMateriaPrima").ToString().ToEntero()) Then + GuardadoCorrecto = False + End If + End If + Next + + For Each Dr As DataRow In DtEliminados.Rows + If Not clsOp.RemoveCI(Dr("Cve").ToString().ToEntero()) Then + GuardadoCorrecto = False + End If + Next + + If GuardadoCorrecto Then + clsOp.Commit() + Alert("Costo Indirecto Guardado Correctamente", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddCostoIndirecto"), "jsHideModalCI") + Else + clsOp.RollBack() + Alert("Ocurrió un error al guardar el Costo Indirecto", TipoMensaje.MsgError) + End If + + End Sub + +#End Region + +End Class diff --git a/RH/CatPersonal.aspx b/RH/CatPersonal.aspx index 7508c99b0..cdb0add16 100644 --- a/RH/CatPersonal.aspx +++ b/RH/CatPersonal.aspx @@ -141,13 +141,11 @@