Esempio n. 1
0
        public Boolean ActualizarAlmLote(int ID_LOTE, int ID_DOCUMENTO, int ID_PRODUCTO, int ID_BODEGA, DateTime FECHA_REGISTRO,
                                         int ENTRADAS, int SALIDAS, Decimal COSTO, String TALLA, String ACTIVO, Conexion conexion)
        {
            Int32   cantidadRegistrosActualizados = 0;
            String  sql         = null;
            String  informacion = null;
            Boolean ejecutar    = true;

            tools _tools = new tools();

            sql = "USP_ALM_LOTE_ACTUALIZAR ";

            #region validaciones

            if (ID_LOTE != 0)
            {
                sql         += ID_LOTE + ", ";
                informacion += "ID_LOTE= '" + ID_LOTE.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_LOTE no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_DOCUMENTO != 0)
            {
                sql         += ID_DOCUMENTO + ", ";
                informacion += "ID_DOCUMENTO= '" + ID_DOCUMENTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_DOCUMENTO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_PRODUCTO != 0)
            {
                sql         += ID_PRODUCTO + ", ";
                informacion += "ID_PRODUCTO= '" + ID_PRODUCTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_PRODUCTO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_BODEGA != 0)
            {
                sql         += ID_BODEGA + ", ";
                informacion += "ID_BODEGA= '" + ID_BODEGA.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_BODEGA no puede ser nulo\n";
                ejecutar      = false;
            }
            if (!(String.IsNullOrEmpty(FECHA_REGISTRO.ToString())))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_REGISTRO) + "', ";
                informacion += "FECHA_REGISTRO= '" + FECHA_REGISTRO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo FECHA_REGISTRO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ENTRADAS != 0)
            {
                sql         += ENTRADAS + ", ";
                informacion += "ENTRADAS= '" + ENTRADAS.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ENTRADAS no puede ser nulo\n";
                ejecutar      = false;
            }
            if (SALIDAS != 0)
            {
                sql         += SALIDAS + ", ";
                informacion += "SALIDAS= '" + SALIDAS.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "SALIDAS= '0', ";
            }

            if (COSTO != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(COSTO) + ", ";
                informacion += "COSTO= '" + COSTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo COSTO no puede ser nulo\n";
                ejecutar      = false;
            }

            sql         += "'" + Usuario + "', ";
            informacion += "USU_MOD= '" + Usuario.ToString() + "', ";


            if (!(String.IsNullOrEmpty(TALLA)))
            {
                sql         += "'" + TALLA + "', ";
                informacion += "TALLA= '" + TALLA.ToString() + "', ";
            }
            else
            {
                sql         += "'N/A', ";
                informacion += "TALLA= 'N/A', ";
            }
            if (!(String.IsNullOrEmpty(ACTIVO)))
            {
                sql         += "'" + ACTIVO + "' ";
                informacion += "ACTIVO= '" + ACTIVO + "' ";
            }
            else
            {
                sql         += "'S' ";
                informacion += "ACTIVO = 'S' ";
            }
            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    cantidadRegistrosActualizados = conexion.ExecuteNonQuery(sql);
                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.ALM_LOTE, tabla.ACCION_ACTUALIZAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
            }

            if (cantidadRegistrosActualizados > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public Decimal AdicionarDetalleServicio(Decimal ID_Servicio, Decimal ID_Servicio_Completario, Decimal AIU, Decimal IVA, Decimal VALOR, Conexion conexion)
        {
            String  sql         = null;
            String  ID_SERVICIO = null;
            String  informacion = null;
            Boolean ejecutar    = true;

            tools _tools = new tools();


            sql = "usp_detalle_servicio_adicionar ";

            #region validaciones

            sql         += ID_Servicio + ", ";
            informacion += "ID_SERVICIO = '" + ID_Servicio + "' ";

            if (ID_Servicio_Completario != 0)
            {
                sql         += ID_Servicio_Completario + ", ";
                informacion += "ID_SERVICIO_COMPLETARIO = '" + ID_Servicio_Completario + "' ";
            }
            else
            {
                MensajeError += "El campo ID_SERVICIO_COMPLETARIO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (AIU != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(AIU) + ", ";
                informacion += "AIU = '" + AIU + "' ";
            }
            else
            {
                sql         += "0, ";
                informacion += "AIU = 0 ";
            }

            if (IVA != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(IVA) + ", ";
                informacion += "IVA = '" + IVA + "' ";
            }
            else
            {
                sql         += "0, ";
                informacion += "IVA = 0 ";
            }

            if (VALOR != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(VALOR) + ", ";
                informacion += "VALOR = '" + VALOR + "' ";
            }
            else
            {
                sql         += "0, ";
                informacion += "VALOR = 0 ";
            }

            sql         += "'S', null";
            informacion += "ACIVO = 'S', FECHA_INACTIVO = NULL ";

            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    ID_SERVICIO = conexion.ExecuteScalar(sql);

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.VEN_DETALLE_SERVICIO, tabla.ACCION_ADICIONAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
            }

            if (!(String.IsNullOrEmpty(ID_SERVICIO)))
            {
                return(Convert.ToDecimal(ID_SERVICIO));
            }
            else
            {
                return(0);
            }
        }
        public Boolean ActualizarDetalleServicio(Decimal ID_DETALLE_SERVICIO, Decimal ID_SERVICIO, Decimal ID_SERVICIO_COMPLEMENTARIO, Decimal AIU, Decimal IVA, Decimal VALOR, String ACTIVO, Conexion conexion)
        {
            Int32   cantidadRegistrosActualizados = 0;
            String  sql         = null;
            String  informacion = null;
            Boolean ejecutar    = true;

            tools _tools = new tools();

            sql = "usp_detalle_servicio_actualizar ";


            #region validaciones
            if (ID_DETALLE_SERVICIO != 0)
            {
                sql         += ID_DETALLE_SERVICIO + ", ";
                informacion += "ID_DETALLE_SERVICIO = " + ID_DETALLE_SERVICIO.ToString() + ", ";
            }
            else
            {
                MensajeError = "El campo ID_DETALLE_SERVICIO no puede ser 0\n";
                ejecutar     = false;
            }
            if (ID_SERVICIO != 0)
            {
                sql         += ID_SERVICIO + ", ";
                informacion += "ID_SERVICIO = " + ID_SERVICIO.ToString() + ", ";
            }
            else
            {
                MensajeError = "El campo ID_SERVICIO no puede ser 0\n";
                ejecutar     = false;
            }
            if (ID_SERVICIO_COMPLEMENTARIO != 0)
            {
                sql         += ID_SERVICIO_COMPLEMENTARIO + ", ";
                informacion += "ID_SERVICIO_COMPLEMENTARIO = " + ID_SERVICIO_COMPLEMENTARIO.ToString() + ", ";
            }
            else
            {
                MensajeError = "El campo ID_SERVICIO_COMPLEMENTARIO no puede ser 0\n";
                ejecutar     = false;
            }

            if (AIU != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(AIU) + ", ";
                informacion += "AIU = '" + AIU + "' ";
            }
            else
            {
                sql         += "0, ";
                informacion += "AIU = 0 ";
            }
            if (IVA != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(IVA) + ", ";
                informacion += "IVA = '" + IVA + "' ";
            }
            else
            {
                sql         += "0, ";
                informacion += "IVA = 0 ";
            }
            if (VALOR != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(VALOR) + ", ";
                informacion += "VALOR = '" + VALOR + "' ";
            }
            else
            {
                sql         += "0, ";
                informacion += "VALOR = 0 ";
            }
            sql         += "'" + ACTIVO + "', ";
            informacion += "ACTIVO = '" + ACTIVO + "' ";

            if (ACTIVO.Equals("N"))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(System.DateTime.Now) + "'";
                informacion += "FECHA_INACTIVO = '" + _tools.obtenerStringConFormatoFechaSQLServer(System.DateTime.Now) + "'";
            }
            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    cantidadRegistrosActualizados = conexion.ExecuteNonQuery(sql);
                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.VEN_DETALLE_SERVICIO, tabla.ACCION_ACTUALIZAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
            }

            if (cantidadRegistrosActualizados > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        private void Adicionar(Decimal ID_EMPLEADO, DateTime FECHA_LIQUIDACION, String CASO_SEVERO, Conexion conexion, Boolean PAZYSALVO, Int32 DIAS_DESCONTAR_LPS,
                               Decimal VALOR_DESCONTAR_BASES, String OBSERVACIONES, Boolean NO_LABORO)
        {
            tools  _tools = new tools();
            String sql    = null;


            sql  = "usp_liq_lps_empleado_adicionar ";
            sql += ID_EMPLEADO.ToString() + ", ";
            sql += ID_PERIODO.ToString() + ", ";
            sql += "'" + Liquidaciones.LIQUIDACION + "', ";
            sql += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_LIQUIDACION) + "', ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(BaseCesantias) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(BasePrima) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(BaseVacaciones) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(Cesantias) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(InteresesCesantias) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(Prima) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(Vacaciones) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalLiquidacion) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalDevengadoMemorando) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalDeduccionesMemorando) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(NetoLiquidado) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalAnticipos) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalDescuentos) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(NetoPagar) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(PromedioCesantias) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(DiasCesantias) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(PromedioPrima) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(DiasPrima) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(PromedioVacaciones) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(DiasVacaciones) + ", ";
            sql += "'" + CASO_SEVERO + "', ";
            sql += "'" + Estados.LIQUIDADO.ToString() + "',";
            sql += "'" + PAZYSALVO + "', ";
            sql += "'" + Usuario + "', ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(DIAS_DESCONTAR_LPS) + ", ";
            sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(VALOR_DESCONTAR_BASES) + ", ";
            sql += "'" + OBSERVACIONES + "', ";
            sql += "'" + NO_LABORO + "'";
            try
            {
                IDLPSEMPLEADO = Convert.ToInt32(conexion.ExecuteScalar(sql));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Esempio n. 5
0
        public Decimal AdicionarAlmDocumentosParaFactura(int ID_EMPLEADO,
                                                         int DOCUMENTO_ORIGEN,
                                                         String TIPO_DOC,
                                                         String ORIGEN,
                                                         String NUMERO_DOCUMENTO,
                                                         DateTime FECHA_DOCUMENTO,
                                                         DateTime FECHA_VENCE,
                                                         int ID_BODEGA_DESTINO,
                                                         Decimal VALOR,
                                                         String ESTADO,
                                                         String OBSERVACION_JUSTIFICACION,
                                                         Conexion _dato,
                                                         int ID_PROVEEDOR)
        {
            String  sql           = null;
            String  identificador = null;
            String  informacion   = null;
            Boolean ejecutar      = true;

            tools _tools = new tools();

            sql = "USP_ALM_DOCUMENTOS_ADICIONAR_PARA_FACTURA ";

            #region validaciones
            if (ID_EMPLEADO != 0)
            {
                sql         += ID_EMPLEADO + ", ";
                informacion += "ID_EMPLEADO = '" + ID_EMPLEADO.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "ID_EMPLEADO = '0', ";
            }

            if (DOCUMENTO_ORIGEN != 0)
            {
                sql         += DOCUMENTO_ORIGEN + ", ";
                informacion += "DOCUMENTO_ORIGEN  = '" + DOCUMENTO_ORIGEN.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "DOCUMENTO_ORIGEN = '0', ";
            }

            if (!(String.IsNullOrEmpty(TIPO_DOC)))
            {
                sql         += "'" + TIPO_DOC + "', ";
                informacion += "TIPO_DOC= '" + TIPO_DOC.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo TIPO_DOC no puede ser nulo\n";
                ejecutar      = false;
            }

            if (!(String.IsNullOrEmpty(ORIGEN)))
            {
                sql         += "'" + ORIGEN + "', ";
                informacion += "ORIGEN= '" + ORIGEN.ToString() + "', ";
            }
            else
            {
                sql         += "'null', ";
                informacion += "ORIGEN= 'null', ";
            }

            if (!(String.IsNullOrEmpty(NUMERO_DOCUMENTO)))
            {
                sql         += "'" + NUMERO_DOCUMENTO + "', ";
                informacion += "NUMERO_DOCUMENTO= '" + NUMERO_DOCUMENTO.ToString() + "', ";
            }
            else
            {
                sql         += "'null', ";
                informacion += "NUMERO_DOCUMENTO= 'null', ";
            }

            if (!(String.IsNullOrEmpty(FECHA_DOCUMENTO.ToString())))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_DOCUMENTO) + "', ";
                informacion += "FECHA_DOCUMENTO= '" + FECHA_DOCUMENTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo FECHA_DOCUMENTO no puede ser nulo\n";
                ejecutar      = false;
            }

            if (!(String.IsNullOrEmpty(FECHA_VENCE.ToString())))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_VENCE) + "', ";
                informacion += "FECHA_VENCE= '" + FECHA_VENCE.ToString() + "', ";
            }
            else
            {
                sql         += "'01011990', ";
                informacion += "FECHA_VENCE= '01011990', ";
            }

            if (ID_BODEGA_DESTINO != 0)
            {
                sql         += ID_BODEGA_DESTINO + ", ";
                informacion += "ID_BODEGA_DESTINO= '" + ID_BODEGA_DESTINO.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "ID_BODEGA_DESTINO = 0, ";
            }

            if (VALOR != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(VALOR) + ", ";
                informacion += "VALOR = '" + VALOR.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "VALOR = 0, ";
            }

            if (!(String.IsNullOrEmpty(ESTADO)))
            {
                sql         += "'" + ESTADO + "', ";
                informacion += "ESTADO= '" + ESTADO.ToString() + "', ";
            }
            else
            {
                sql         += "null, ";
                informacion += "ESTADO= 'null', ";
            }

            if (!(String.IsNullOrEmpty(OBSERVACION_JUSTIFICACION)))
            {
                sql         += "'" + OBSERVACION_JUSTIFICACION + "', ";
                informacion += "OBSERVACION_JUSTIFICACION= '" + OBSERVACION_JUSTIFICACION.ToString() + "', ";
            }
            else
            {
                sql         += "null, ";
                informacion += "OBSERVACION_JUSTIFICACION= 'null', ";
            }

            sql         += "'" + Usuario + "', ";
            informacion += "USU_CRE= '" + Usuario.ToString() + "', ";

            if (ID_PROVEEDOR != 0)
            {
                sql         += ID_PROVEEDOR;
                informacion += "ID_PROVEEDOR = '" + ID_PROVEEDOR.ToString() + "'";
            }
            else
            {
                sql         += "0";
                informacion += "ID_PROVEEDOR = '0'";
            }
            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    identificador = _dato.ExecuteScalar(sql);

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.ALM_DOCUMENTOS, tabla.ACCION_ADICIONAR, sql, informacion, _dato);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
            }

            if (!(String.IsNullOrEmpty(identificador)))
            {
                return(Convert.ToDecimal(identificador));
            }
            else
            {
                return(0);
            }
        }
        public Boolean ActualizarConRegExamenesEmpleado(int REGISTRO,
                                                        int ID_ORDEN,
                                                        int ID_EXAMEN,
                                                        Decimal COSTO,
                                                        String VALIDADO,
                                                        DateTime FECHA_EXAMEN)
        {
            Int32   cantidadRegistrosActualizados = 0;
            String  sql         = null;
            String  informacion = null;
            Boolean ejecutar    = true;

            tools _tools = new tools();

            sql = "USP_CON_REG_EXAMENES_EMPLEADO_ACTUALIZAR ";

            #region validaciones
            if (REGISTRO != 0)
            {
                sql         += REGISTRO + ", ";
                informacion += "REGISTRO = '" + REGISTRO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo REGISTRO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_ORDEN != 0)
            {
                sql         += ID_ORDEN + ", ";
                informacion += "ID_ORDEN = '" + ID_ORDEN.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_ORDEN no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_EXAMEN != 0)
            {
                sql         += ID_EXAMEN + ", ";
                informacion += "ID_EXAMEN = '" + ID_EXAMEN.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_EXAMEN no puede ser nulo\n";
                ejecutar      = false;
            }
            if (COSTO != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(COSTO) + ", ";
                informacion += "COSTO = '" + COSTO.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "COSTO = '0', ";
            }
            if (!(String.IsNullOrEmpty(VALIDADO)))
            {
                sql         += "'" + VALIDADO + "', ";
                informacion += "VALIDADO = '" + VALIDADO.ToString() + "', ";
            }
            else
            {
                sql         += "'N', ";
                informacion += "VALIDADO = 'N', ";
            }
            if (!(String.IsNullOrEmpty(FECHA_EXAMEN.ToString())))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_EXAMEN) + "', ";
                informacion += "FECHA_EXAMEN = '" + FECHA_EXAMEN.ToString() + "', ";
            }

            sql         += "'" + Usuario + "' ";
            informacion += "USU_MOD= '" + Usuario.ToString() + "' ";

            #endregion validaciones

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    cantidadRegistrosActualizados = conexion.ExecuteNonQuery(sql);
                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.CON_REG_EXAMENES_EMPLEADO, tabla.ACCION_ACTUALIZAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            if (cantidadRegistrosActualizados > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
        public Boolean Liquidar(Decimal ID_EMPRESA, DateTime fechaLiquidacion, DataTable _empleados, DataTable _novedades)
        {
            Conexion conexion  = new Conexion(Empresa);
            DataSet  _dataSet  = new DataSet();
            DataView _dataView = new DataView();
            Boolean  liquidado = true;
            String   sql       = null;
            tools    _tools    = new tools();

            _periodoLps      = 0;
            _idPeriodoLps    = 0;
            IdEmpresa        = ID_EMPRESA;
            FechaLiquidacion = fechaLiquidacion;
            conexion.IniciarTransaccion();

            try
            {
                nomina.novedadNomina novedad = new novedadNomina(Empresa, Usuario);
                nomina.liquidacionPrestacionesSociales _liqLps = new liquidacionPrestacionesSociales(Empresa, Usuario);
                foreach (DataRow dataRowEmpleados in _empleados.Rows)
                {
                    CrearPeriodoLPS(Convert.ToInt32(dataRowEmpleados["ID_EMPLEADO"].ToString()), _periodoLps, conexion);
                    if (_idPeriodoLps > 0)
                    {
                        foreach (DataRow dataRowNovedades in _novedades.Rows)
                        {
                            if (Convert.ToInt32(dataRowNovedades["ID_EMPLEADO"].ToString()) == Convert.ToInt32(dataRowEmpleados["ID_EMPLEADO"].ToString()))
                            {
                                novedad.Adicionar(Convert.ToDecimal(dataRowEmpleados["ID_EMPLEADO"]),
                                                  Convert.ToInt32(dataRowNovedades["ID_CONCEPTO"]),
                                                  _idPeriodoLps,
                                                  Convert.ToDecimal(dataRowNovedades["CANTIDAD"].ToString()),
                                                  Convert.ToDecimal(dataRowNovedades["VALOR"]), "L", "ACTIVO", conexion);
                            }
                        }
                        Empleado           = ObtenerEmpleadoPorIdEmpleado(Convert.ToDecimal(dataRowEmpleados["ID_EMPLEADO"]), conexion);
                        DiasPendientesPago = ObtenerDiasPendientesPagar(Convert.ToDecimal(dataRowEmpleados["ID_EMPLEADO"]), FechaLiquidacion, conexion);

                        _liqLps.LiquidarNovedades(ID_EMPRESA, Convert.ToDecimal(dataRowEmpleados["ID_EMPLEADO"].ToString()), Empleado["ID_CIUDAD"].ToString(),
                                                  Convert.ToDecimal(Empleado["ID_CENTRO_C"]), Convert.ToDecimal(Empleado["ID_SUB_C"]), _idPeriodoLps, DiasPendientesPago, conexion);

                        _liqLps.InactivarEmpleado(Convert.ToDecimal(dataRowEmpleados["ID_EMPLEADO"].ToString()), FechaLiquidacion, conexion);
                        _liqLps.ActivarSolicitudIngreso(Convert.ToDecimal(dataRowEmpleados["ID_EMPLEADO"].ToString()), conexion);

                        DataTable _dataTable_1 = new DataTable();

                        Decimal Cesantias          = 0;
                        Decimal InteresesCesantias = 0;
                        Decimal Prima          = 0;
                        Decimal Vacaciones     = 0;
                        Decimal BaseCesantias  = 0;
                        Decimal BasePrima      = 0;
                        Decimal BaseVacaciones = 0;

                        sql          = "usp_lps_liquidar " + dataRowEmpleados["ID_EMPLEADO"].ToString() + ", '" + _tools.obtenerStringConFormatoFechaSQLServer(FechaLiquidacion) + "'";
                        _dataSet     = conexion.ExecuteReaderConTransaccion(sql);
                        _dataView    = _dataSet.Tables[0].DefaultView;
                        _dataTable_1 = _dataView.Table;

                        if (_dataTable_1.Rows.Count > 0)
                        {
                            foreach (DataRow dataRow in _dataTable_1.Rows)
                            {
                                if (dataRow["Descripcion"].Equals("CESANTIAS"))
                                {
                                    Cesantias = !String.IsNullOrEmpty(dataRow["Valor"].ToString()) ? Convert.ToDecimal(dataRow["Valor"]) : 0;
                                }
                                if (dataRow["Descripcion"].Equals("INTERESES DE CESANTIAS"))
                                {
                                    InteresesCesantias = !String.IsNullOrEmpty(dataRow["Valor"].ToString()) ? Convert.ToDecimal(dataRow["Valor"]) : 0;
                                }
                                if (dataRow["Descripcion"].Equals("PRIMA"))
                                {
                                    Prima = !String.IsNullOrEmpty(dataRow["Valor"].ToString()) ? Convert.ToDecimal(dataRow["Valor"]) : 0;
                                }
                                if (dataRow["Descripcion"].Equals("VACACIONES"))
                                {
                                    Vacaciones = !String.IsNullOrEmpty(dataRow["Valor"].ToString()) ? Convert.ToDecimal(dataRow["Valor"]) : 0;
                                }

                                if (dataRow["Descripcion"].Equals("BASE CESANTIAS"))
                                {
                                    BaseCesantias = !String.IsNullOrEmpty(dataRow["Valor"].ToString()) ? Convert.ToDecimal(dataRow["Valor"]) : 0;
                                }
                                if (dataRow["Descripcion"].Equals("BASE PRIMA"))
                                {
                                    BasePrima = !String.IsNullOrEmpty(dataRow["Valor"].ToString()) ? Convert.ToDecimal(dataRow["Valor"]) : 0;
                                }
                                if (dataRow["Descripcion"].Equals("BASE VACACIONES"))
                                {
                                    BaseVacaciones = !String.IsNullOrEmpty(dataRow["Valor"].ToString()) ? Convert.ToDecimal(dataRow["Valor"]) : 0;
                                }
                            }
                        }
                        Decimal TotalLiquidacion = Cesantias + InteresesCesantias + Prima + Vacaciones;

                        DataTable _dataTable_2 = new DataTable();

                        sql          = "usp_lps_memorando " + dataRowEmpleados["ID_EMPLEADO"].ToString() + ", " + _idPeriodoLps.ToString() + "";
                        _dataSet     = conexion.ExecuteReaderConTransaccion(sql);
                        _dataView    = _dataSet.Tables[0].DefaultView;
                        _dataTable_2 = _dataView.Table;

                        Decimal _decimal = 0;
                        Decimal TotalDevengadoMemorando   = 0;
                        Decimal TotalDeduccionesMemorando = 0;

                        if (_dataTable_2.Rows.Count > 0)
                        {
                            foreach (DataRow dataRow in _dataTable_2.Rows)
                            {
                                TotalDevengadoMemorando   += Decimal.TryParse(dataRow["DEVENGADOS"].ToString(), out _decimal) ? Convert.ToDecimal(dataRow["DEVENGADOS"]) : 0;
                                TotalDeduccionesMemorando += Decimal.TryParse(dataRow["DEDUCCIONES"].ToString(), out _decimal) ? Convert.ToDecimal(dataRow["DEDUCCIONES"]) : 0;
                            }
                        }

                        DataTable _dataTable_3 = new DataTable();

                        sql          = "usp_lps_anticipos " + dataRowEmpleados["ID_EMPLEADO"].ToString();
                        _dataSet     = conexion.ExecuteReaderConTransaccion(sql);
                        _dataView    = _dataSet.Tables[0].DefaultView;
                        _dataTable_3 = _dataView.Table;

                        Decimal TotalAnticipos = 0;

                        if (_dataTable_3.Rows.Count > 0)
                        {
                            foreach (DataRow dataRow in _dataTable_3.Rows)
                            {
                                TotalAnticipos += Decimal.TryParse(dataRow["VALOR"].ToString(), out _decimal) ? Convert.ToDecimal(dataRow["VALOR"]) : 0;
                            }
                        }

                        DataTable _dataTable_4 = new DataTable();

                        sql          = "usp_lps_obtenerCreditosPorIdEmpleado " + dataRowEmpleados["ID_EMPLEADO"].ToString();
                        _dataSet     = conexion.ExecuteReaderConTransaccion(sql);
                        _dataView    = _dataSet.Tables[0].DefaultView;
                        _dataTable_4 = _dataView.Table;

                        Decimal TotalDescuentos = 0;

                        if (_dataTable_4.Rows.Count > 0)
                        {
                            foreach (DataRow dataRow in _dataTable_4.Rows)
                            {
                                TotalAnticipos += Decimal.TryParse(dataRow["SALDO"].ToString(), out _decimal) ? Convert.ToDecimal(dataRow["SALDO"]) : 0;
                            }
                        }

                        Decimal NetoLiquidado = (TotalLiquidacion + TotalDevengadoMemorando) - TotalDeduccionesMemorando;

                        Decimal NetoPagar = NetoLiquidado - (TotalAnticipos + TotalDescuentos);

                        sql  = "usp_liq_lps_empleado_adicionar ";
                        sql += dataRowEmpleados["ID_EMPLEADO"].ToString() + ", ";
                        sql += _idPeriodoLps.ToString() + ", ";
                        sql += "'MASIVA', ";
                        sql += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FechaLiquidacion) + "', ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(BaseCesantias) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(BasePrima) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(BaseVacaciones) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(Cesantias) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(InteresesCesantias) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(Prima) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(Vacaciones) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalLiquidacion) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalDevengadoMemorando) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalDeduccionesMemorando) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(NetoLiquidado) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalAnticipos) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalDescuentos) + ", ";
                        sql += _tools.convierteComaEnPuntoParaDecimalesEnSQL(NetoPagar) + ", ";
                        sql += "'', ";
                        sql += "'" + Estados.LIQUIDADO.ToString() + "',";
                        sql += "'', ";
                        sql += "'" + Usuario + "'";

                        Int32 IDLPSEMPLEADO = Convert.ToInt32(conexion.ExecuteScalar(sql).ToString());
                    }
                }
            }
            catch (Exception e)
            {
                liquidado = false;
                conexion.DeshacerTransaccion();
                MensajeError = e.Message;
            }
            finally
            {
                if (liquidado)
                {
                    conexion.AceptarTransaccion();
                }
                else
                {
                    conexion.DeshacerTransaccion();
                    MensajeError = "Error en el proceso de liquidacion masiva de LPS";
                }
            }
            return(liquidado);
        }
        public Decimal AdicionarCondicionContratacion(Decimal ID_EMPRESA, String DOC_TRAB, Decimal ID_PERFIL, Decimal RIESGO, String OBS_CTE)
        {
            String  registro    = null;
            String  sql         = null;
            String  informacion = null;
            Boolean ejecutar    = true;

            tools _tools = new tools();

            sql = "usp_ven_p_contratacion_adicionar ";

            if (ID_EMPRESA != 0)
            {
                sql         += ID_EMPRESA + ", ";
                informacion += "ID_EMPRESA = " + ID_EMPRESA.ToString() + ", ";
            }
            else
            {
                MensajeError = "El campo ID EMPRESA no puede ser 0\n";
                ejecutar     = false;
            }

            if (!(String.IsNullOrEmpty(DOC_TRAB)))
            {
                sql         += "'" + DOC_TRAB + "', ";
                informacion += "DOC_TRAB = '" + DOC_TRAB.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo DOC_TRAB no puede ser nulo. \n";
                ejecutar      = false;
            }

            if (ID_PERFIL != 0)
            {
                sql         += ID_PERFIL + ", ";
                informacion += "ID_PERFIL = " + ID_PERFIL.ToString() + ", ";
            }
            else
            {
                MensajeError = "El campo ID_PERFIL no puede ser 0\n";
                ejecutar     = false;
            }

            if (RIESGO != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(RIESGO) + ", ";
                informacion += "RIESGO = " + _tools.convierteComaEnPuntoParaDecimalesEnSQL(RIESGO) + ", ";
            }
            else
            {
                MensajeError = "El campo RIESGO no puede ser 0\n";
                ejecutar     = false;
            }

            if (!(String.IsNullOrEmpty(OBS_CTE)))
            {
                sql         += "'" + OBS_CTE + "', ";
                informacion += "OBS_CTE = '" + OBS_CTE.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo OBS_CTE no puede ser nulo. \n";
                ejecutar      = false;
            }

            sql         += "'" + Usuario + "' ";
            informacion += "USU_CRE = '" + Usuario.ToString() + "'";

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    registro = conexion.ExecuteScalar(sql);
                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.VEN_P_CONTRATACION, tabla.ACCION_ADICIONAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            if (!(String.IsNullOrEmpty(registro)))
            {
                return(Convert.ToDecimal(registro));
            }
            else
            {
                return(0);
            }
        }
Esempio n. 9
0
        public Decimal AdicionarServicio(String Nombre_Servicio, Decimal AIU, Decimal IVA, Decimal VALOR, String observaciones, Conexion conexion)
        {
            String  sql         = null;
            String  ID_SERVICIO = null;
            String  informacion = null;
            Boolean ejecutar    = true;

            tools _tools = new tools();

            sql = "usp_servicio_adicionar ";

            #region validaciones

            if (!(String.IsNullOrEmpty(Nombre_Servicio)))
            {
                sql         += "'" + Nombre_Servicio + "', ";
                informacion += "NOMBRE_SERVICIO = '" + Nombre_Servicio.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo NOMBRE_SERVICIO no puede ser nulo\n";
                ejecutar      = false;
            }

            if (AIU != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(AIU) + ", ";
                informacion += "AIU = '" + AIU + "' ";
            }
            else
            {
                sql         += "0, ";
                informacion += "AIU = 0 ";
            }

            if (IVA != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(IVA) + ", ";
                informacion += "IVA = '" + IVA + "' ";
            }
            else
            {
                sql         += "0, ";
                informacion += "IVA = 0 ";
            }

            if (VALOR != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(VALOR) + ",";
                informacion += "VALOR = '" + VALOR + "' ";
            }
            else
            {
                sql         += "0,";
                informacion += "VALOR = 0 ";
            }
            if (!(String.IsNullOrEmpty(observaciones)))
            {
                sql         += "'" + observaciones + "'";
                informacion += "observaciones = '" + observaciones.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo observaciones no puede ser nulo\n";
                ejecutar      = false;
            }
            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    ID_SERVICIO = conexion.ExecuteScalar(sql);

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.VEN_SERVICIO, tabla.ACCION_ADICIONAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
            }

            if (!(String.IsNullOrEmpty(ID_SERVICIO)))
            {
                return(Convert.ToDecimal(ID_SERVICIO));
            }
            else
            {
                return(0);
            }
        }
Esempio n. 10
0
        public Decimal AdicionarAlmInventarioTemp(int ID_DOCUMENTO, int ID_PRODUCTO, int ID_BODEGA, int ID_LOTE, int ID_EQUIPO, String TALLA,
                                                  int CANTIDAD, Decimal COSTO, DateTime FECHA, String MOVIMIENTO, Conexion conexion)
        {
            String  sql           = null;
            String  identificador = null;
            String  informacion   = null;
            Boolean ejecutar      = true;

            tools _tools = new tools();

            sql = "USP_ALM_INVENTARIO_TEMP_ADICIONAR ";

            #region validaciones
            if (ID_DOCUMENTO != 0)
            {
                sql         += ID_DOCUMENTO + ", ";
                informacion += "ID_DOCUMENTO= '" + ID_DOCUMENTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_DOCUMENTO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_PRODUCTO != 0)
            {
                sql         += ID_PRODUCTO + ", ";
                informacion += "ID_PRODUCTO= '" + ID_PRODUCTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_PRODUCTO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_BODEGA != 0)
            {
                sql         += ID_BODEGA + ", ";
                informacion += "ID_BODEGA= '" + ID_BODEGA.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_BODEGA no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_LOTE != 0)
            {
                sql         += ID_LOTE + ", ";
                informacion += "ID_LOTE = '" + ID_LOTE.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_LOTE no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_EQUIPO != 0)
            {
                sql         += ID_EQUIPO + ", ";
                informacion += "ID_EQUIPO= '" + ID_EQUIPO.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "ID_EQUIPO= '0', ";
            }
            if (!(String.IsNullOrEmpty(TALLA)))
            {
                sql         += "'" + TALLA + "', ";
                informacion += "TALLA= '" + TALLA.ToString() + "', ";
            }
            else
            {
                sql         += "'" + TALLA + "', ";
                informacion += "TALLA= '" + TALLA.ToString() + "', ";
            }
            if (CANTIDAD != 0)
            {
                sql         += CANTIDAD + ", ";
                informacion += "CANTIDAD= '" + CANTIDAD.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "CANTIDAD= '0', ";
            }

            if (COSTO != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(COSTO) + ", ";
                informacion += "COSTO= '" + COSTO.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "COSTO= '0', ";
            }
            if (!(String.IsNullOrEmpty(FECHA.ToString())))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA) + "', ";
                informacion += "FECHA= '" + FECHA.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo FECHA no puede ser nulo\n";
                ejecutar      = false;
            }

            if (!(String.IsNullOrEmpty(MOVIMIENTO)))
            {
                sql         += "'" + MOVIMIENTO + "', ";
                informacion += "MOVIMIENTO= '" + MOVIMIENTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo MOVIMIENTO no puede ser nulo\n";
                ejecutar      = false;
            }


            sql         += "'" + Usuario + "' ";
            informacion += "USU_CRE= '" + Usuario.ToString() + "' ";



            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    identificador = conexion.ExecuteScalar(sql);

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.ALM_INVENTARIO, tabla.ACCION_ADICIONAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
            }

            if (!(String.IsNullOrEmpty(identificador)))
            {
                return(Convert.ToDecimal(identificador));
            }
            else
            {
                return(0);
            }
        }
Esempio n. 11
0
        private void Adicionar(Conexion Datos)
        {
            tools  Tools = new tools();
            string sql   = null;

            sql  = "usp_lps_adicionar ";
            sql += IdEmpleado.ToString();
            sql += ", '" + TipoLps + "'";
            sql += ", " + IdPeriodo.ToString();
            sql += ", '" + Tools.obtenerStringConFormatoFechaSQLServer(FechaLiquidacion) + "'";
            sql += ", " + DiasVinculacion.ToString();

            sql += ", " + PeriodoContableCesantias.ToString();
            sql += ", " + PeriodoContablePrima.ToString();
            sql += ", " + PeriodoContablePrima.ToString();

            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(AcumuladoCesantias);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(AcumuladoPrima);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(AcumuladoVacaciones);

            sql += ", " + DiasLiquidacionCesantias.ToString();
            sql += ", " + DiasLiquidacionPrima.ToString();
            sql += ", " + DiasLiquidacionVacaciones.ToString();

            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(BaseCesantias);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(BasePrima);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(BaseVacaciones);

            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(LiquidacionCesantias);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(LiquidacionInteresesCesantias);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(LiquidacionPrima);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(LiquidacionVacaciones);

            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalLiquidacion);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalDevengadoMemo);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalDeducidoMemo);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(NetoLiquidacion);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalAnticipos);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalCreditos);
            sql += ", " + Tools.convierteComaEnPuntoParaDecimalesEnSQL(TotalPagar);
            sql += ", '" + Usuario + "'";
            sql += ", '" + Estado + "'";
            sql += ", " + NoLaboro;

            IdLpsEmpleado = Convert.ToInt32(Datos.ExecuteScalar(sql));
        }
        public Boolean ActualizarNomConceptosEmpleados(int REGISTRO, int ID_EMPLEADO, int ID_CONCEPTO, int CAN_PRE, Decimal VAL_PRE, String LIQ_Q_1, String LIQ_Q_2)
        {
            Int32   cantidadRegistrosActualizados = 0;
            String  sql         = null;
            String  informacion = null;
            Boolean ejecutar    = true;

            tools _tools = new tools();

            sql = "usp_nom_conceptos_empleados_actualizar ";

            if (REGISTRO != 0)
            {
                sql         += REGISTRO + ", ";
                informacion += "REGISTRO= '" + REGISTRO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo REGISTRO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_EMPLEADO != 0)
            {
                sql         += ID_EMPLEADO + ", ";
                informacion += "ID_EMPLEADO = '" + ID_EMPLEADO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_EMPLEADO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_CONCEPTO != 0)
            {
                sql         += ID_CONCEPTO + ", ";
                informacion += "ID_CONCEPTO = '" + ID_CONCEPTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_CONCEPTO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (CAN_PRE != 0)
            {
                sql         += CAN_PRE + ", ";
                informacion += "CAN_PRE = '" + CAN_PRE.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo CAN_PRE no puede ser nulo\n";
                ejecutar      = false;
            }
            if (VAL_PRE != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(VAL_PRE) + ", ";
                informacion += "VAL_PRE = '" + VAL_PRE.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo VAL_PRE no puede ser nulo\n";
                ejecutar      = false;
            }
            if (!(String.IsNullOrEmpty(LIQ_Q_1)))
            {
                sql         += "'" + LIQ_Q_1 + "', ";
                informacion += "LIQ_Q_1= '" + LIQ_Q_1.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo LIQ_Q_1 no puede ser nulo\n";
                ejecutar      = false;
            }
            if (!(String.IsNullOrEmpty(LIQ_Q_2)))
            {
                sql         += "'" + LIQ_Q_2 + "', ";
                informacion += "LIQ_Q_2= '" + LIQ_Q_2.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo LIQ_Q_2 no puede ser nulo\n";
                ejecutar      = false;
            }
            sql         += "'" + Usuario + "' ";
            informacion += "USU_MOD = '" + Usuario.ToString() + "' ";


            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    cantidadRegistrosActualizados = conexion.ExecuteNonQuery(sql);
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.NOM_CONCEPTOS_EMPLEADO, tabla.ACCION_ACTUALIZAR, sql, informacion, conexion);
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            if (cantidadRegistrosActualizados > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public Decimal AdicionarNomConceptosEmpleados(int ID_EMPLEADO, int ID_CONCEPTO, int CAN_PRE, Decimal VAL_PRE, String LIQ_Q_1, String LIQ_Q_2)
        {
            String  sql           = null;
            String  identificador = null;
            String  informacion   = null;
            Boolean ejecutar      = true;

            tools _tools = new tools();

            sql = "usp_nom_conceptos_empleados_adicionar ";

            if (ID_EMPLEADO != 0)
            {
                sql         += ID_EMPLEADO + ", ";
                informacion += "ID_EMPLEADO = '" + ID_EMPLEADO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_EMPLEADO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_CONCEPTO != 0)
            {
                sql         += ID_CONCEPTO + ", ";
                informacion += "ID_CONCEPTO = '" + ID_CONCEPTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_CONCEPTO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (CAN_PRE != 0)
            {
                sql         += CAN_PRE + ", ";
                informacion += "CAN_PRE = '" + CAN_PRE.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo CAN_PRE no puede ser nulo\n";
                ejecutar      = false;
            }
            if (VAL_PRE != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(VAL_PRE) + ", ";
                informacion += "VAL_PRE = '" + VAL_PRE.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo VAL_PRE no puede ser nulo\n";
                ejecutar      = false;
            }
            if (!(String.IsNullOrEmpty(LIQ_Q_1)))
            {
                sql         += "'" + LIQ_Q_1 + "', ";
                informacion += "LIQ_Q_1= '" + LIQ_Q_1.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo LIQ_Q_1 no puede ser nulo\n";
                ejecutar      = false;
            }
            if (!(String.IsNullOrEmpty(LIQ_Q_2)))
            {
                sql         += "'" + LIQ_Q_2 + "', ";
                informacion += "LIQ_Q_2= '" + LIQ_Q_2.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo LIQ_Q_2 no puede ser nulo\n";
                ejecutar      = false;
            }

            sql         += "'" + Usuario + "' ";
            informacion += "USU_CRE= '" + Usuario.ToString() + "' ";

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    identificador = conexion.ExecuteScalar(sql);

                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.NOM_CONCEPTOS_EMPLEADO, tabla.ACCION_ADICIONAR, sql, informacion, conexion);
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            if (!(String.IsNullOrEmpty(identificador)))
            {
                return(Convert.ToDecimal(identificador));
            }
            else
            {
                return(0);
            }
        }
        public Boolean ActualizarConRegExamenesEmpleadoConArchivo(Decimal REGISTRO,
                                                                  Decimal ID_ORDEN,
                                                                  Decimal ID_EXAMEN,
                                                                  Decimal COSTO,
                                                                  String VALIDADO,
                                                                  DateTime FECHA_EXAMEN,
                                                                  byte[] ARCHIVO_EXAMEN,
                                                                  String ARCHIVO_EXTENSION,
                                                                  Decimal ARCHIVO_TAMANO,
                                                                  String ARCHIVO_TYPE,
                                                                  Conexion conexion)
        {
            String  informacion = null;
            Boolean ejecutar    = true;
            Int32   registro    = 0;

            tools _tools = new tools();

            String sql = "USP_CON_REG_EXAMENES_EMPLEADO_ACTUALIZAR ";

            #region validaciones
            if (REGISTRO != 0)
            {
                sql         += REGISTRO + ", ";
                informacion += "REGISTRO = '" + REGISTRO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo REGISTRO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_ORDEN != 0)
            {
                sql         += ID_ORDEN + ", ";
                informacion += "ID_ORDEN = '" + ID_ORDEN.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_ORDEN no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_EXAMEN != 0)
            {
                sql         += ID_EXAMEN + ", ";
                informacion += "ID_EXAMEN = '" + ID_EXAMEN.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_EXAMEN no puede ser nulo\n";
                ejecutar      = false;
            }
            if (COSTO != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(COSTO) + ", ";
                informacion += "COSTO = '" + COSTO.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "COSTO = '0', ";
            }
            if (!(String.IsNullOrEmpty(VALIDADO)))
            {
                sql         += "'" + VALIDADO + "', ";
                informacion += "VALIDADO = '" + VALIDADO.ToString() + "', ";
            }
            else
            {
                sql         += "'N', ";
                informacion += "VALIDADO = 'N', ";
            }
            if (!(String.IsNullOrEmpty(FECHA_EXAMEN.ToString())))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_EXAMEN) + "', ";
                informacion += "FECHA_EXAMEN = '" + FECHA_EXAMEN.ToString() + "', ";
            }

            sql         += "'" + Usuario + "' ";
            informacion += "USU_MOD = '" + Usuario.ToString() + "' ";

            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    registro = conexion.ExecuteNonQueryParaActualizarConRegExamenesEmpleadoConArchivo(REGISTRO, ID_ORDEN, ID_EXAMEN, COSTO, VALIDADO, FECHA_EXAMEN, Usuario, ARCHIVO_EXAMEN, ARCHIVO_EXTENSION, ARCHIVO_TAMANO, ARCHIVO_TYPE);

                    if (registro == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        #region auditoria
                        auditoria _auditoria = new auditoria(Empresa);
                        _auditoria.Adicionar(Usuario, tabla.CON_REG_EXAMENES_EMPLEADO, tabla.ACCION_ACTUALIZAR, sql, informacion, conexion);
                        #endregion auditoria

                        return(true);
                    }
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Esempio n. 15
0
        public Decimal AdicionarAlmLote(int ID_DOCUMENTO,
                                        int ID_PRODUCTO,
                                        int ID_BODEGA,
                                        DateTime FECHA_REGISTRO,
                                        int ENTRADAS,
                                        int SALIDAS,
                                        Decimal COSTO,
                                        String TALLA,
                                        String ACTIVO,
                                        Conexion conexion,
                                        String REEMBOLSO)
        {
            String  sql           = null;
            String  identificador = null;
            String  informacion   = null;
            Boolean ejecutar      = true;

            tools _tools = new tools();

            sql = "USP_ALM_LOTE_ADICIONAR ";

            #region validaciones

            if (ID_DOCUMENTO != 0)
            {
                sql         += ID_DOCUMENTO + ", ";
                informacion += "ID_DOCUMENTO = '" + ID_DOCUMENTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_DOCUMENTO no puede ser nulo\n";
                ejecutar      = false;
            }

            if (ID_PRODUCTO != 0)
            {
                sql         += ID_PRODUCTO + ", ";
                informacion += "ID_PRODUCTO= '" + ID_PRODUCTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_PRODUCTO no puede ser nulo\n";
                ejecutar      = false;
            }

            if (ID_BODEGA != 0)
            {
                sql         += ID_BODEGA + ", ";
                informacion += "ID_BODEGA= '" + ID_BODEGA.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_BODEGA no puede ser nulo\n";
                ejecutar      = false;
            }

            if (!(String.IsNullOrEmpty(FECHA_REGISTRO.ToString())))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_REGISTRO) + "', ";
                informacion += "FECHA_REGISTRO = '" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_REGISTRO) + "', ";
            }
            else
            {
                MensajeError += "El campo FECHA_REGISTRO no puede ser nulo\n";
                ejecutar      = false;
            }

            if (ENTRADAS != 0)
            {
                sql         += ENTRADAS + ", ";
                informacion += "ENTRADAS = '" + ENTRADAS.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "ENTRADAS = '0', ";
            }

            if (SALIDAS != 0)
            {
                sql         += SALIDAS + ", ";
                informacion += "SALIDAS = '" + SALIDAS.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "SALIDAS = '0', ";
            }

            if (COSTO != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(COSTO) + ", ";
                informacion += "COSTO = '" + _tools.convierteComaEnPuntoParaDecimalesEnSQL(COSTO) + "', ";
            }
            else
            {
                MensajeError += "El campo COSTO no puede ser nulo\n";
                ejecutar      = false;
            }

            sql         += "'" + Usuario + "', ";
            informacion += "USU_CRE = '" + Usuario.ToString() + "', ";

            if (!(String.IsNullOrEmpty(TALLA)))
            {
                if ((TALLA == "N/A") || (TALLA == "NA"))
                {
                    sql         += "'N/A', ";
                    informacion += "TALLA= 'N/A', ";
                }
                else
                {
                    sql         += "'" + TALLA + "', ";
                    informacion += "TALLA = '" + TALLA.ToString() + "', ";
                }
            }
            else
            {
                sql         += "'N/A', ";
                informacion += "TALLA= 'N/A', ";
            }

            if (!(String.IsNullOrEmpty(ACTIVO)))
            {
                sql         += "'" + ACTIVO + "', ";
                informacion += "ACTIVO= '" + ACTIVO + "', ";
            }
            else
            {
                sql         += "'S', ";
                informacion += "ACTIVO = 'S', ";
            }

            if (String.IsNullOrEmpty(REEMBOLSO) == false)
            {
                sql += "'" + REEMBOLSO + "'";
            }
            else
            {
                ejecutar     = false;
                MensajeError = "El campo REEMBOLSO no puede ser vacio.";
            }

            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    identificador = conexion.ExecuteScalar(sql);

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.ALM_LOTE, tabla.ACCION_ADICIONAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
            }

            if (!(String.IsNullOrEmpty(identificador)))
            {
                return(Convert.ToDecimal(identificador));
            }
            else
            {
                return(0);
            }
        }
        public Decimal Adicionar(String CLASE_INCAPACIDAD, Decimal ID_CONCEPTO, Decimal ID_CONCEPTO_TRES_DIAS, Decimal PORCENTAJE)
        {
            String  sql                    = null;
            String  ID                     = null;
            String  informacion            = null;
            Boolean ejecutar               = true;
            Boolean ejecutadoCorrectamente = true;

            sql = "usp_par_incapacidades_adicionar ";

            #region validaciones
            if (!(String.IsNullOrEmpty(CLASE_INCAPACIDAD)))
            {
                sql         += "'" + CLASE_INCAPACIDAD + "', ";
                informacion += "CLASE_INCAPACIDAD = '" + CLASE_INCAPACIDAD + "', ";
            }
            else
            {
                MensajeError += "El campo CLASE_INCAPACIDAD no puede ser nulo\n";
                ejecutar      = false;
            }

            if (ID_CONCEPTO != 0)
            {
                sql         += "'" + ID_CONCEPTO + "', ";
                informacion += "ID_CONCEPTO = '" + ID_CONCEPTO + "', ";
            }
            else
            {
                MensajeError += "El campo ID_CONCEPTO no puede ser cero\n";
                ejecutar      = false;
            }

            if (ID_CONCEPTO_TRES_DIAS != 0)
            {
                sql         += "'" + ID_CONCEPTO_TRES_DIAS + "', ";
                informacion += "ID_CONCEPTO_TRES_DIAS = '" + ID_CONCEPTO_TRES_DIAS + "', ";
            }
            else
            {
                MensajeError += "El campo ID_CONCEPTO_TRES_DIAS no puede ser cero\n";
                ejecutar      = false;
            }

            tools _tools = new tools();

            if (PORCENTAJE != 0)
            {
                sql         += "'" + _tools.convierteComaEnPuntoParaDecimalesEnSQL(PORCENTAJE) + "', ";
                informacion += "PORCENTAJE = '" + _tools.convierteComaEnPuntoParaDecimalesEnSQL(PORCENTAJE) + "', ";
            }
            else
            {
                MensajeError += "El campo PORCENTAJE no puede ser cero\n";
                ejecutar      = false;
            }

            sql         += "'" + Usuario + "' ";
            informacion += "USU_CRE = '" + Usuario.ToString() + "' ";
            #endregion validaciones

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                conexion.IniciarTransaccion();
                try
                {
                    #region adicionar
                    ID = conexion.ExecuteScalar(sql);
                    #endregion adicionar

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    if (!(_auditoria.Adicionar(Usuario, tabla.PAR_INCAPACIDADES, tabla.ACCION_ADICIONAR, sql, informacion, conexion)))
                    {
                        ejecutadoCorrectamente = false;
                    }
                    #endregion auditoria

                    conexion.AceptarTransaccion();
                }
                catch (Exception e)
                {
                    conexion.DeshacerTransaccion();
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            if (!(String.IsNullOrEmpty(ID)))
            {
                return(Convert.ToDecimal(ID));
            }
            else
            {
                return(0);
            }
        }
        public Decimal AdicionarConRegEntregasServiciosComplementarios(int ID_ASIGNACION_SC, int ID_PRODUCTO, DateTime FECHA, String TALLA, int CANTIDAD_ENTREGADA,
                                                                       int CANTIDAD_A_ENTREGAR, String ESTADO, Decimal COSTO, Decimal AIU, Decimal IVA, Decimal VALOR, String FACTURADO, String NUMERO_FACTURA, Conexion conexion)
        {
            String  sql           = null;
            String  identificador = null;
            String  informacion   = null;
            Boolean ejecutar      = true;

            tools _tools = new tools();

            sql = "USP_CON_REG_ENTREGAS_SERVICIOS_COMPLEMENTARIOS_ADICIONAR ";

            #region validaciones

            if (ID_ASIGNACION_SC != 0)
            {
                sql         += ID_ASIGNACION_SC + ", ";
                informacion += "ID_ASIGNACION_SC = '" + ID_ASIGNACION_SC.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_ASIGNACION_SC no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_PRODUCTO != 0)
            {
                sql         += ID_PRODUCTO + ", ";
                informacion += "ID_PRODUCTO = '" + ID_PRODUCTO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_PRODUCTO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (!(String.IsNullOrEmpty(FECHA.ToString())))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA) + "', ";
                informacion += "FECHA= '" + FECHA.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo FECHA no puede ser nulo\n";
                ejecutar      = false;
            }
            if (!(String.IsNullOrEmpty(TALLA)))
            {
                sql         += "'" + TALLA + "', ";
                informacion += "TALLA= '" + TALLA.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo TALLA no puede ser nulo\n";
                ejecutar      = false;
            }
            if (CANTIDAD_ENTREGADA != 0)
            {
                sql         += CANTIDAD_ENTREGADA + ", ";
                informacion += "CANTIDAD_ENTREGADA = '" + CANTIDAD_ENTREGADA.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo CANTIDAD_ENTREGADA no puede ser nulo\n";
                ejecutar      = false;
            }
            if (CANTIDAD_A_ENTREGAR != 0)
            {
                sql         += CANTIDAD_A_ENTREGAR + ", ";
                informacion += "CANTIDAD_A_ENTREGAR = '" + CANTIDAD_A_ENTREGAR.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo CANTIDAD_A_ENTREGAR no puede ser nulo\n";
                ejecutar      = false;
            }
            if (!(String.IsNullOrEmpty(ESTADO)))
            {
                sql         += "'" + ESTADO + "', ";
                informacion += "ESTADO= '" + ESTADO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ESTADO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (COSTO != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(COSTO) + ", ";
                informacion += "COSTO = '" + COSTO.ToString() + "', ";
            }
            else
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(COSTO) + ", ";
                informacion += "COSTO = '" + COSTO.ToString() + "', ";
            }
            if (AIU != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(AIU) + ", ";
                informacion += "AIU = '" + AIU.ToString() + "', ";
            }
            else
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(AIU) + ", ";
                informacion += "AIU = '" + AIU.ToString() + "', ";
            }
            if (IVA != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(IVA) + ", ";
                informacion += "IVA = '" + IVA.ToString() + "', ";
            }
            else
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(IVA) + ", ";
                informacion += "IVA = '" + IVA.ToString() + "', ";
            }
            if (VALOR != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(VALOR) + ", ";
                informacion += "VALOR = '" + VALOR.ToString() + "', ";
            }
            else
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(VALOR) + ", ";
                informacion += "VALOR = '" + VALOR.ToString() + "', ";
            }
            if (!(String.IsNullOrEmpty(FACTURADO)))
            {
                sql         += "'" + FACTURADO + "', ";
                informacion += "FACTURADO= '" + FACTURADO.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo FACTURADO no puede ser nulo\n";
                ejecutar      = false;
            }
            if (!(String.IsNullOrEmpty(NUMERO_FACTURA)))
            {
                sql         += "'" + NUMERO_FACTURA + "', ";
                informacion += "NUMERO_FACTURA= '" + NUMERO_FACTURA.ToString() + "', ";
            }
            else
            {
                sql         += "null, ";
                informacion += "NUMERO_FACTURA= '" + NUMERO_FACTURA.ToString() + "', ";
            }
            sql         += "'" + Usuario + "' ";
            informacion += "USU_CRE= '" + Usuario.ToString() + "', ";

            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    identificador = conexion.ExecuteScalar(sql);

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.CON_REG_ENTREGAS_SERVICIOS_COMPLEMENTARIOS, tabla.ACCION_ADICIONAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
            }

            if (!(String.IsNullOrEmpty(identificador)))
            {
                return(Convert.ToDecimal(identificador));
            }
            else
            {
                return(0);
            }
        }
        public Decimal AdicionarConRegExamenesEmpleado(int ID_ORDEN, int ID_EXAMEN, Decimal COSTO, String VALIDADO, DateTime FECHA_EXAMEN, Conexion conexion)
        {
            String  sql           = null;
            Decimal identificador = 0;
            String  informacion   = null;
            Boolean ejecutar      = true;

            tools _tools = new tools();

            sql = "USP_CON_REG_EXAMENES_EMPLEADO_ADICIONAR ";

            #region validaciones
            if (ID_ORDEN != 0)
            {
                sql         += ID_ORDEN + ", ";
                informacion += "ID_ORDEN = '" + ID_ORDEN.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_ORDEN no puede ser nulo\n";
                ejecutar      = false;
            }
            if (ID_EXAMEN != 0)
            {
                sql         += ID_EXAMEN + ", ";
                informacion += "ID_EXAMEN = '" + ID_EXAMEN.ToString() + "', ";
            }
            else
            {
                MensajeError += "El campo ID_EXAMEN no puede ser nulo\n";
                ejecutar      = false;
            }
            if (COSTO != 0)
            {
                sql         += _tools.convierteComaEnPuntoParaDecimalesEnSQL(COSTO) + ", ";
                informacion += "COSTO = '" + COSTO.ToString() + "', ";
            }
            else
            {
                sql         += "0, ";
                informacion += "COSTO = '0', ";
            }
            if (!(String.IsNullOrEmpty(VALIDADO)))
            {
                sql         += "'" + VALIDADO + "', ";
                informacion += "VALIDADO = '" + VALIDADO.ToString() + "', ";
            }
            else
            {
                sql         += "'N', ";
                informacion += "VALIDADO = 'N', ";
            }

            if (!(String.IsNullOrEmpty(FECHA_EXAMEN.ToString())))
            {
                sql         += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_EXAMEN) + "', ";
                informacion += "FECHA_EXAMEN = '" + FECHA_EXAMEN.ToString() + "', ";
            }

            sql         += "'" + Usuario + "' ";
            informacion += "USU_CRE= '" + Usuario.ToString() + "' ";
            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    identificador = Convert.ToDecimal(conexion.ExecuteScalar(sql));

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.CON_REG_EXAMENES_EMPLEADO, tabla.ACCION_ADICIONAR, sql, informacion, conexion);
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    MensajeError  = e.Message;
                    identificador = 0;
                }
            }

            return(identificador);
        }