示例#1
0
        public DataTable ObtenerTodos()
        {
            Conexion conexion = new Conexion(Empresa);
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            Boolean ejecutar = true;

            sql = "usp_paises_obtenerTodos";

            if (ejecutar == true)
            {
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }
            return _dataTable;
        }
        public DataTable ObtenerPuc(String CLASE_PUC)
        {
            Conexion conexion = new Conexion(Empresa);
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;

            sql = "usp_ObtenerCodigosContables ";

            if (!(String.IsNullOrEmpty(CLASE_PUC)))
            {
                sql += "'" + CLASE_PUC + "', ";
            }

            try
            {
                _dataSet = conexion.ExecuteReader(sql);
                _dataView = _dataSet.Tables[0].DefaultView;
                _dataTable = _dataView.Table;
            }
            catch (Exception e)
            {
                MensajeError = e.Message;
            }
            finally
            {
                conexion.Desconectar();
            }
            return _dataTable;
        }
示例#3
0
        public DataTable ObtenerTodosLosDocumentos()
        {
            Conexion conexion = new Conexion(Empresa);
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;

            sql = "usp_sel_reg_documentos_obtenerTodos ";

            try
            {
                _dataSet = conexion.ExecuteReader(sql);
                _dataView = _dataSet.Tables[0].DefaultView;
                _dataTable = _dataView.Table;
            }
            catch (Exception e)
            {
                MensajeError = e.Message;
            }
            finally
            {
                conexion.Desconectar();
            }

            return _dataTable;
        }
        public DataTable ObtenerCentroCosto(String CLASE)
        {
            Conexion conexion = new Conexion(Empresa);
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;

            sql = "usp_ObtenerCentroCosto ";

            try
            {
                _dataSet = conexion.ExecuteReader(sql);
                _dataView = _dataSet.Tables[0].DefaultView;
                _dataTable = _dataView.Table;
            }
            catch (Exception e)
            {
                MensajeError = e.Message;
            }
            finally
            {
                conexion.Desconectar();
            }
            return _dataTable;
        }
        public DataTable ListarCentrosDeCosto()
        {
            Conexion conexion = new Conexion(Empresa);
            DataTable dataTable = new DataTable();
            string sql = null;

            sql = "select distinct NOM_CC from VEN_CC_EMPRESAS";
            try
            {
                DataSet _dataSet = conexion.ExecuteReader(sql);
                dataTable = _dataSet.Tables[0].DefaultView.Table;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conexion.Desconectar();
            }
            return dataTable;
        }
示例#6
0
        public DataTable ObtenerCarteraCritica(string periodoContable)
        {
            Conexion datos = new Conexion(Empresa);
            DataSet dataSet = new DataSet();
            String sql = null;

            sql = "usp_comercial_cartera_critica ";
            sql += periodoContable;

            try
            {
                dataSet = datos.ExecuteReader(sql);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                datos.Desconectar();
            }
            return dataSet.Tables[0].DefaultView.Table;
        }
        public DataTable ObtenerConRegExamenesEmpleadoPorRegistro(int REGISTRO)
        {
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;

            sql = "USP_CON_REG_EXAMENES_EMPLEADO_OBTENER_POR_REGISTRO ";

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

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;

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

            return _dataTable;
        }
        public Decimal ObtenerAlmRegProductosProveedorPorProductoProveedor(int ID_PRODUCTO, int ID_PROVEEDOR)
        {
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;
            String identificador = null;

            sql = "USP_ALM_REG_PRODUCTOS_PROVEEDOR_OBTENER_REGISTRO_POR_PRODUCTO_PROVEEDOR ";

            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_PROVEEDOR != 0)
            {
                sql += ID_PROVEEDOR + " ";
                informacion += "ID_PROVEEDOR = '" + ID_PROVEEDOR.ToString() + "'";
            }
            else
            {
                MensajeError += "El campo ID_PROVEEDOR no puede ser nulo\n";
                ejecutar = false;
            }

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

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

            if (!(String.IsNullOrEmpty(identificador))) return Convert.ToDecimal(identificador);
            else return 0;
        }
        public DataTable ObtenerAlmRegProductosProveedorPorProductoRegional(int ID_PRODUCTO, String ID_CIUDAD)
        {
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            Boolean ejecutar = true;

            sql = "USP_ALM_REG_PRODUCTOS_PROVEEDOR_OBTENER_PROVEEDORES_POR_EXAMEN_POR_REGIONAL ";

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

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

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            return _dataTable;
        }
        public Boolean ActualizarConRegContratosImpresos(int REGISTRO, String CONTRATO_IMPRESO, String CLAUSULAS_IMPRESO)
        {
            Int32 cantidadRegistrosActualizados = 0;
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;

            tools _tools = new tools();

            sql = "usp_con_reg_contratos_actualizar_impresion ";

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

            if (String.IsNullOrEmpty(CONTRATO_IMPRESO) == false)
            {
                sql += "'" + CONTRATO_IMPRESO + "', ";
                informacion += "CONTRATO_IMPRESO = '" + CONTRATO_IMPRESO + "', ";
            }
            else
            {
                sql += "NULL, ";
                informacion += "CONTRATO_IMPRESO = NULL, ";
            }

            if (String.IsNullOrEmpty(CLAUSULAS_IMPRESO) == false)
            {
                sql += "'" + CLAUSULAS_IMPRESO + "' ";
                informacion += "CLAUSULAS_IMPRESO = '" + CLAUSULAS_IMPRESO + "' ";
            }
            else
            {
                sql += "NULL ";
                informacion += "CLAUSULAS_IMPRESO = NULL ";
            }

            #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_CONTRATOS, 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;
        }
        public DataTable ObtenerPorRegistro(Decimal REGISTRO)
        {
            Conexion conexion = new Conexion(Empresa);
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            sql = "usp_ven_d_nomina_incapacidades_ObtenerPorRegistro '" + REGISTRO + "'";

            try
            {
                _dataSet = conexion.ExecuteReader(sql);
                _dataView = _dataSet.Tables[0].DefaultView;
                _dataTable = _dataView.Table;
            }
            catch (Exception e)
            {
                MensajeError = e.Message;
            }
            finally
            {
                conexion.Desconectar();
            }

            return _dataTable;
        }
        public Boolean AdicionarAlmRegProductosProveedor(Decimal ID_PROVEEDOR,
            List<producto> listaProductos)
        {
            Boolean resultado = true;

            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            try
            {
                producto _producto = new producto(Empresa, Usuario);
                DataTable tablaProductosProveedor = ObtenerAlmRegProductosProveedorPorIdProveedor(ID_PROVEEDOR, conexion);
                Boolean verificador = true;
                foreach (DataRow fila in tablaProductosProveedor.Rows)
                {
                    verificador = true;
                    foreach (producto infoProdProv in listaProductos)
                    {
                        if (infoProdProv.REGISTRO_P_P == Convert.ToDecimal(fila["REGISTRO_P_P"]))
                        {
                            verificador = false;
                            break;
                        }
                    }

                    if (verificador == true)
                    {
                        if (EliminarRegistroAlmRegProductoProveedor(Convert.ToDecimal(fila["REGISTRO_P_P"]), conexion) == false)
                        {
                            conexion.DeshacerTransaccion();
                            resultado = false;
                            break;
                        }
                    }
                }

                if (resultado == true)
                {
                    foreach (producto infoProdProv in listaProductos)
                    {
                        if (infoProdProv.REGISTRO_P_P == 0)
                        {
                            if (AdicionarAlmRegProdProv(infoProdProv.ID_PRODUCTO, ID_PROVEEDOR, conexion) <= 0)
                            {
                                conexion.DeshacerTransaccion();
                                resultado = false;
                                break;
                            }
                        }
                    }
                }

                if (resultado == true)
                {
                    conexion.AceptarTransaccion();
                }
            }
            catch (Exception ex)
            {
                MensajeError = ex.Message;
                conexion.DeshacerTransaccion();
                resultado = false;
            }
            finally
            {
                conexion.Desconectar();
            }

            return resultado;
        }
        public DataTable ObtenerAlmRegProductosProveedorPorIdProveedor(Decimal ID_PROVEEDOR)
        {
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            Boolean ejecutar = true;

            sql = "usp_alm_reg_productos_proveedor_por_id_proveedor ";

            if (ID_PROVEEDOR != 0)
            {
                sql += ID_PROVEEDOR;
            }
            else
            {
                MensajeError += "El campo ID_PROVEEDOR no puede ser nulo\n";
                ejecutar = false;
            }

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            return _dataTable;
        }
        public String ElaborarContrato(int id_requerimiento, int id_solicitud, int id_empresa, int id_centro_Costo, int id_sub_cc, String ciudad,
            int ID_SERVICIO_RESPECTIVO, int servicio, int id_ARP, int id_caja_c, int id_EPS, int id_Pensiones, Decimal riesgo, String pensionado,
            String Clase_Contrato, String Tipo_Contrato, String Tipo_Pago, DateTime fecha_Inicia, DateTime fecha_termina, String sal_int,
            Decimal Salario, String vigente, String activo, String liquidado, String pago_Liquidacion, int id_entidad, String Num_Cuenta, String Forma_pago,
            String PAGO_DIAS_PRODUCTIVIDAD, String SENA_PRODICTIVO, String SENA_ELECTIVO, String PRACTICANTE_UNIVERSITARIO, Decimal VALOR_NOMINA, Decimal VALOR_CONTRATO,
            DateTime FECHA_INICIO_PERIODO, DateTime FECHA_FIN_PERIODO, String Periodo_Pago, String tipo_Cuenta, string descripcion_salario, decimal idPerfil)
        {
            String datosG = "";
            int id_perfil = 0;
            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            try
            {
                requisicion _req = new requisicion(Empresa, Usuario);
                DataTable tablaReq = _req.ObtenerComRequerimientoPorIdRequerimiento(Convert.ToDecimal(id_requerimiento), conexion);

                DataRow filaReq = tablaReq.Rows[0];
                id_perfil = Convert.ToInt32(filaReq["REGISTRO_PERFIL"].ToString());
                usuario _empleado = new usuario(Empresa);
                radicacionHojasDeVida _sol = new radicacionHojasDeVida(Empresa, Usuario);

                Decimal idEmpleado = _empleado.AdicionarNomEmpleados(0, id_solicitud, id_empresa, id_centro_Costo, id_sub_cc, fecha_Inicia, Salario,
                    pensionado, activo, liquidado, riesgo, id_ARP, id_caja_c, id_EPS, id_Pensiones, "C", id_entidad, Num_Cuenta, sal_int, ciudad, id_perfil, tipo_Cuenta, descripcion_salario, Forma_pago, conexion);

                if (idEmpleado <= 0)
                {
                    _mensaje_error = "\n El empleado no fue creado, " + _empleado.MensajeError;
                    conexion.DeshacerTransaccion();
                }
                else
                {
                    registroContrato _contrato = new registroContrato(Empresa, Usuario);

                    Decimal id_Contrato = 0;
                    /* revisado por cambio en riesgo */
                    id_Contrato = _contrato.AdicionarConRegContratos(Convert.ToInt32(idEmpleado), id_requerimiento, id_solicitud, id_centro_Costo,
                        id_sub_cc, Clase_Contrato, fecha_Inicia, fecha_termina, vigente, pago_Liquidacion, sal_int, Tipo_Contrato,
                        ID_SERVICIO_RESPECTIVO, ciudad, servicio, conexion, PAGO_DIAS_PRODUCTIVIDAD, SENA_PRODICTIVO, SENA_ELECTIVO, PRACTICANTE_UNIVERSITARIO,
                        VALOR_NOMINA, VALOR_CONTRATO, FECHA_INICIO_PERIODO, FECHA_FIN_PERIODO, Periodo_Pago);

                    if (String.IsNullOrEmpty(_contrato.MensajeError))
                    {
                        _empleado.ActualizarNomEmpleados(Convert.ToInt32(idEmpleado), Convert.ToInt32(id_Contrato), id_solicitud, id_empresa, id_centro_Costo, id_sub_cc, fecha_Inicia, Salario,
                        pensionado, activo, liquidado, riesgo, id_ARP, id_caja_c, id_EPS, id_Pensiones, "C", id_entidad, Num_Cuenta, sal_int, ciudad, id_perfil, Forma_pago, conexion);

                        if (String.IsNullOrEmpty(_empleado.MensajeError))
                        {

                            if (_sol.ActualizarEstadoProcesoRegSolicitudesIngreso(id_requerimiento, id_solicitud, "CONTRATADO", Usuario, conexion))
                            {
                                if (_sol.ActualizarEstadoRegSolicitudesIngreso(id_requerimiento, id_solicitud, "CONTRATADO", conexion))
                                {
                                    datosG = id_Contrato + "," + idEmpleado;

                                    try
                                    {
                                        conexion.ExecuteNonQuery("usp_ESC_CRT_ENTREGAS_SC_adicionar " + idEmpleado + ", '" + Usuario + "'");
                                        conexion.ExecuteNonQuery("usp_empleado_clausulas_contratar " + idEmpleado + ", " + idPerfil + ", '" + Usuario + "'");

                                        Int32 requerimientoActualizado = Convert.ToInt32(conexion.ExecuteScalar("usp_comprobar_cierre_requisicion_por_sistema " + id_requerimiento.ToString() + ", '" + Usuario + "'"));

                                        if (requerimientoActualizado <= 0)
                                        {
                                            conexion.DeshacerTransaccion();
                                            MensajeError = "El empleado no fue creado, Ocurrio un error al momento de determinar si la requisición debe ser cuplida por sistema.";
                                        }
                                        else
                                        {
                                            conexion.AceptarTransaccion();
                                        }
                                    }
                                    catch
                                    {
                                        _mensaje_error += "\n No fue posible registrar los servicios complementarios o clausulas para el perfil contratado " + _sol.MensajeError;
                                        conexion.AceptarTransaccion();
                                    }
                                }
                                else
                                {
                                    _mensaje_error += "\n No fue posible actualizar el estado de la solicitud: " + _sol.MensajeError;
                                    conexion.DeshacerTransaccion();
                                }
                            }
                            else
                            {
                                _mensaje_error += "\n No fue posible actualizar el estado del proceso de la soliciutd: " + _sol.MensajeError;
                                conexion.DeshacerTransaccion();
                            }

                        }
                        else
                        {
                            _mensaje_error += "\n Se presentó el siguiente error en la actualización del empleado: " + _empleado.MensajeError;
                            conexion.DeshacerTransaccion();
                        }
                    }
                    else
                    {
                        _mensaje_error += "\n Se presentó el siguiente error en la creación del contrato: " + _contrato.MensajeError;
                        conexion.DeshacerTransaccion();
                    }
                }
            }
            catch (Exception e)
            {
                MensajeError = e.Message;
                conexion.DeshacerTransaccion();
            }
            finally
            {
                conexion.Desconectar();
            }

            return datosG;
        }
        public DataTable ObtenerPorNombre(String NOMBRE)
        {
            Conexion conexion = new Conexion(Empresa);
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;

            sql = "usp_con_ent_afp_obtenerPorNombre ";

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

            if (ejecutar)
            {
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.CON_ENT_F_PENSIONES, tabla.ACCION_CONSULTAR.ToString(), sql, informacion, conexion);
                    #endregion auditoria

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

            return _dataTable;
        }
        public DataTable ObtenerPorNumIdentificacionTodos(String NUM_DOC_IDENTIDAD)
        {
            Conexion conexion = new Conexion(Empresa);
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;

            sql = "usp_con_reg_contratos_Obtener_contrato_por_num_id ";

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

            if (ejecutar)
            {
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.CON_REG_CONTRATOS, tabla.ACCION_CONSULTAR.ToString(), sql, informacion, conexion);
                    #endregion auditoria

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

            return _dataTable;
        }
        public Boolean ActualizarContratoDesdeAuditoria(Decimal ID_CONTRATO,
            Decimal ID_EMPLEADO,
            Decimal RIESGO,
            String TIPO_CONTRATO,
            Decimal ID_PERFIL,
            Decimal ID_SUB_C,
            Decimal ID_CENTRO_C,
            String ID_CIUDAD,
            String PAGO_DIAS_PRODUCTIVIDAD,
            Decimal VALOR_NOMINA,
            Decimal VALOR_CONTRATO,
            Decimal SALARIO,
            String SAL_INT,
            String FORMA_PAGO,
            Decimal ID_ENTIDAD,
            String NUM_CUENTA,
            Decimal ID_SOLICITUD,
            Boolean ACTUALIZAR_ESTADO_PROCESO,
            String TIPO_CUENTA,
            DateTime FECHA_INICIO_PERIODO,
            DateTime FECHA_FIN_PERIODO,
            String PERIODO_PAGO,
            String CLASE_CONTRATO,
            String CONTROL_CONTRATO,
            String CHEQUE_REG)
        {
            Boolean verificador = true;

            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            DataTable tablaResultadoNomina = new DataTable();

            try
            {
                tablaResultadoNomina = ComprobarRestriccionNomina(ID_EMPLEADO, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C, conexion);

                if (tablaResultadoNomina.Rows.Count <= 0)
                {
                    conexion.DeshacerTransaccion();
                    verificador = false;
                    MensajeError = "No se puedieron determinar las restriciones de nomina. No se pudo actualizar la información del contrato del trabajador seleccionado.";
                }
                else
                {
                    DataRow filaRestriccionesNomina = tablaResultadoNomina.Rows[0];

                    if (filaRestriccionesNomina["valorResultado"].ToString().ToUpper() == "ERROR")
                    {
                        conexion.DeshacerTransaccion();
                        verificador = false;
                        MensajeError = filaRestriccionesNomina["descripcionResultado"].ToString();
                    }
                    else
                    {
                        if (ActualizarConRegContratosAuditoria(ID_CONTRATO, TIPO_CONTRATO, PAGO_DIAS_PRODUCTIVIDAD, VALOR_NOMINA, VALOR_CONTRATO, FECHA_INICIO_PERIODO, FECHA_FIN_PERIODO, PERIODO_PAGO, CLASE_CONTRATO, CONTROL_CONTRATO, conexion) == false)
                        {
                            conexion.DeshacerTransaccion();
                            verificador = false;
                        }
                        else
                        {
                            if (ActualizarNomEmpleadosAuditoria(ID_EMPLEADO, SALARIO, RIESGO, ID_ENTIDAD, NUM_CUENTA, SAL_INT, ID_PERFIL, FORMA_PAGO, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C, conexion, TIPO_CUENTA, FECHA_INICIO_PERIODO, CHEQUE_REG) == false)
                            {
                                conexion.DeshacerTransaccion();
                                verificador = false;
                            }
                            else
                            {
                                auditoriaContratos _auditoriaContratos = new auditoriaContratos(Empresa, Usuario);
                                Decimal ID_AUDITORIA = _auditoriaContratos.AdicionarAuditoriaContratos(ID_EMPLEADO, tabla.CON_REG_CONTRATOS, ID_CONTRATO, DateTime.Now, conexion);

                                if (ID_AUDITORIA <= 0)
                                {
                                    conexion.DeshacerTransaccion();
                                    MensajeError = _auditoriaContratos.MensajeError;
                                    verificador = false;
                                }
                                else
                                {
                                    if (ACTUALIZAR_ESTADO_PROCESO == true)
                                    {
                                        radicacionHojasDeVida _radicacionHojasDeVida = new radicacionHojasDeVida(Empresa, Usuario);

                                        if (_radicacionHojasDeVida.ActualizarEstadoProcesoRegSolicitudesIngresoAuditoria(ID_SOLICITUD, tabla.VAR_ESTADO_PROCESO_CONTRATO, conexion) == false)
                                        {
                                            conexion.DeshacerTransaccion();
                                            MensajeError = _radicacionHojasDeVida.MensajeError;
                                            verificador = false;
                                        }
                                        else
                                        {
                                            conexion.AceptarTransaccion();
                                        }
                                    }
                                    else
                                    {
                                        conexion.AceptarTransaccion();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MensajeError = ex.Message;
                verificador = false;
            }
            finally
            {
                conexion.Desconectar();
            }

            return verificador;
        }
        public DataTable ObtenerNomEmpleadoPorIDSolicitudYFechaIngreso(int idSolicitud, DateTime fchIngreso)
        {
            tools _tools = new tools();

            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            Boolean ejecutar = true;

            sql = "usp_nom_empleados_obtener_contrato_por_id_solicitud_fch_ingreso ";

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

            sql += "'" + _tools.obtenerStringConFormatoFechaSQLServer(fchIngreso) + "'";

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            return _dataTable;
        }
        public DataTable ObtenerInformacionCotratosParaProximasEntregas()
        {
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            Boolean ejecutar = true;

            sql = "usp_nom_empleados_obtenerInformacionContratoParaProximasEntregas";

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            return _dataTable;
        }
        public DataTable ObtenerInformacionCotratoParaEntregas(Decimal ID_EMPLEADO)
        {
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            Boolean ejecutar = true;

            sql = "usp_nom_empleados_obtenerInformacionContratoPorIdEmpleado ";

            if (ID_EMPLEADO != 0)
            {
                sql += ID_EMPLEADO;
            }
            else
            {
                MensajeError += "El campo ID_EMPLEADO no puede ser nulo\n";
                ejecutar = false;
            }

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            return _dataTable;
        }
        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;
        }
        public DataTable ObtenerInformacionContratoPorVencer(Int32 VALOR)
        {
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            Boolean ejecutar = true;

            sql = "usp_con_reg_contratos_obtener_datos_unificados_contrato_por_vencer ";

            if (VALOR != 0)
            {
                sql += VALOR;
            }
            else
            {
                MensajeError += "El campo VALOR no puede ser nulo\n";
                ejecutar = false;
            }

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            if (_dataTable.Rows.Count > 0)
            {
                Int32 division = (VALOR / 3);
                Int32 rangoALTA = division;
                Int32 rangoMEDIA = division + division;
                Int32 rangoBAJA = VALOR;

                _dataTable.Columns.Add("ALERTA");

                DateTime fechaActual = DateTime.Now;
                DateTime fechaTermina;
                foreach (DataRow fila in _dataTable.Rows)
                {
                    fechaTermina = Convert.ToDateTime(fila["FECHA_TERMINA"]);
                    if (fechaTermina >= fechaActual)
                    {
                        if (fechaTermina <= (fechaActual.AddDays(rangoALTA)))
                        {
                            fila["ALERTA"] = "ALTA";
                        }
                        else
                        {
                            if (fechaTermina <= (fechaActual.AddDays(rangoMEDIA)))
                            {
                                fila["ALERTA"] = "MEDIA";
                            }
                            else
                            {
                                fila["ALERTA"] = "BAJA";
                            }
                        }
                    }
                }
            }

            return _dataTable;
        }
        public Boolean actualizarExamenesYFormaPago(List<examenesEmpleado> listaExamenes,
            Decimal ID_SOLICITUD,
            Decimal ID_ENTIDAD,
            String NUM_CUENTA,
            String FORMA_PAGO,
            String TIPO_CUENTA)
        {
            Boolean correcto = true;

            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            try
            {
                radicacionHojasDeVida _radicacionHojasDeVida = new radicacionHojasDeVida(Empresa, Usuario);
                autoRecomendaciones _auto = new autoRecomendaciones(Empresa, Usuario);

                if (_radicacionHojasDeVida.ActualizarEntidadNumCuenta(ID_SOLICITUD, ID_ENTIDAD, NUM_CUENTA, FORMA_PAGO, TIPO_CUENTA, conexion) == false)
                {
                    correcto = false;
                    MensajeError = _radicacionHojasDeVida.MensajeError;
                    conexion.DeshacerTransaccion();
                }
                else
                {
                    foreach (examenesEmpleado examen in listaExamenes)
                    {
                        if (examen.ARCHIVO_EXAMEN == null)
                        {
                            if (ActualizarConRegExamenesEmpleado(examen.registro, examen.IdOrden, examen.IdExamen, 0, "S", examen.Fecha, conexion) == false)
                            {
                                correcto = false;
                                conexion.DeshacerTransaccion();
                                break;
                            }
                        }
                        else
                        {
                            if (ActualizarConRegExamenesEmpleadoConArchivo(examen.registro, examen.IdOrden, examen.IdExamen, 0, "S", examen.Fecha, examen.ARCHIVO_EXAMEN, examen.ARCHIVO_EXTENSION, examen.ARCHIVO_TAMANO, examen.ARCHIVO_TYPE, conexion) == false)
                            {
                                correcto = false;
                                conexion.DeshacerTransaccion();
                                break;
                            }
                        }

                        if (correcto == true)
                        {
                            if (String.IsNullOrEmpty(examen.AutoRecomendacion) == false)
                            {
                                if (_auto.AdicionarConRegAutoRecomendaciones(examen.registro, examen.AutoRecomendacion, examen.Fecha, conexion) <= 0)
                                {
                                    correcto = false;
                                    MensajeError = _auto.MensajeError;
                                    conexion.DeshacerTransaccion();
                                    break;
                                }
                            }
                        }
                    }
                }

                if (correcto == true)
                {
                    conexion.AceptarTransaccion();
                }
            }
            catch (Exception ex)
            {
                conexion.DeshacerTransaccion();
                correcto = false;
                MensajeError = ex.Message;
            }
            finally
            {
                conexion.Desconectar();
            }

            return correcto;
        }
示例#24
0
        public void ObtenerPorProceso(Procesos proceso)
        {
            Conexion datos = new Conexion(Empresa);
            DataSet dataSet = new DataSet();
            DataView dataView = new DataView();
            DataTable dataTable = new DataTable();
            String sql = null;

            sql = "usp_oper_permisos_obtenerPorProceso ";
            sql += "'" + proceso.ToString() + "'";

            try
            {
                dataSet = datos.ExecuteReader(sql);
                dataView = dataSet.Tables[0].DefaultView;
                dataTable = dataView.Table;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                Cargar(dataTable, proceso.ToString());
                if (dataTable != null) dataTable.Dispose();
                if (dataView != null) dataView.Dispose();
                if (dataSet != null) dataSet.Dispose();
                datos.Desconectar();
            }
        }
        public Boolean adicionarOrdenesExamenes(List<examenesEmpleado> examenesLab,
            Decimal ID_SOLICITUD,
            Decimal ID_ENTIDAD,
            String NUM_CUENTA,
            String FORMA_PAGO,
            String TIPO_CUENTA,
            Decimal ID_REQUERIMIENTO,
            String ID_CIUDAD,
            Decimal ID_CENTRO_C,
            Decimal ID_SUB_C,
            Decimal ID_SERVICIO,
            Decimal ID_EMPRESA,
            Boolean TIENE_CUENTA)
        {
            Boolean correcto = true;

            ordenExamenes orden = new ordenExamenes(Empresa, Usuario);
            decimal idOrden = 0;
            int idLab = 0;

            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            try
            {
                foreach (examenesEmpleado item in examenesLab)
                {
                    if (item.valida == false)
                    {
                        idLab = item.idLab;
                        idOrden = orden.AdicionarConRegOrdenExamen(item.idSolIngreso, item.idRequerimientos, conexion);
                        if (idOrden <= 0)
                        {
                            correcto = false;
                            conexion.DeshacerTransaccion();
                            MensajeError = orden.MensajeError;
                            break;
                        }
                        else
                        {
                            Decimal ID_EXAMEN_EMPLEADO = AdicionarConRegExamenesEmpleado(Convert.ToInt32(idOrden), item.registroAlmacen, 0, "N", item.fecha, conexion);

                            if (ID_EXAMEN_EMPLEADO <= 0)
                            {
                                correcto = false;
                                conexion.DeshacerTransaccion();
                                break;
                            }
                            else
                            {
                                item.valida = true;
                            }
                        }
                    }
                }

                if (correcto == true)
                {
                    radicacionHojasDeVida _radicacionHojasDeVida = new radicacionHojasDeVida(Empresa, Usuario);
                    if (_radicacionHojasDeVida.ActualizarEntidadNumCuenta(Convert.ToInt32(ID_SOLICITUD), Convert.ToInt32(ID_ENTIDAD), NUM_CUENTA, FORMA_PAGO, TIPO_CUENTA, conexion) == false)
                    {
                        correcto = false;
                        MensajeError = _radicacionHojasDeVida.MensajeError;
                        conexion.DeshacerTransaccion();
                    }
                }

                if (correcto == true)
                {
                    ConRegContratoTemporal _contratoTemporal = new ConRegContratoTemporal(Empresa, Usuario);

                    Decimal ID_TEMPORAL = _contratoTemporal.AdicionarConRegContratoTemporal(ID_REQUERIMIENTO, ID_SOLICITUD, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C, ID_SERVICIO, ID_EMPRESA, TIENE_CUENTA, conexion);

                    if (ID_TEMPORAL <= 0)
                    {
                        correcto = false;
                        MensajeError = _contratoTemporal.MensajeError;
                        conexion.DeshacerTransaccion();
                    }
                }

                if (correcto == true)
                {
                    conexion.AceptarTransaccion();
                }
            }
            catch (ExecutionEngineException ex)
            {
                correcto = false;
                MensajeError = ex.Message;
                conexion.DeshacerTransaccion();
            }
            finally
            {
                conexion.Desconectar();
            }

            return correcto;
        }
示例#26
0
        public DataTable ObtenerTodosLosProcesos()
        {
            Conexion datos = new Conexion(Empresa);
            DataSet dataSet = new DataSet();
            String sql = null;

            sql = "usp_oper_permisos_obtenerTodosLosProcesos ";

            try
            {
                dataSet = datos.ExecuteReader(sql);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                datos.Desconectar();
            }
            return dataSet.Tables[0].DefaultView.Table;
        }
        public DataTable ObtenerAlmRegProductosProveedorPorProductoCiudad(int ID_PRODUCTO, String ID_CIUDAD)
        {
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;

            sql = "USP_ALM_REG_PRODUCTOS_PROVEEDOR_OBTENER_PROVEEDORES_POR_EXAMEN ";

            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(ID_CIUDAD)))
            {
                sql += "'" + ID_CIUDAD + "' ";
                informacion += "ID_CIUDAD = '" + ID_CIUDAD.ToString() + "'";
            }
            else
            {
                MensajeError += "El campo ID_CIUDAD no puede ser nulo\n";
                ejecutar = false;
            }

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;

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

            return _dataTable;
        }
        public DataTable ObtenerInformacionContratosParaProximasEntregasFiltroPorEmpresa(Decimal ID_EMPRESA)
        {
            DataSet _dataSet = new DataSet();
            DataView _dataView = new DataView();
            DataTable _dataTable = new DataTable();
            String sql = null;
            Boolean ejecutar = true;

            sql = "usp_nom_empleados_obtenerInformacionContratoParaProximasEntregas_por_id_empresa ";

            if (ID_EMPRESA != 0)
            {
                sql += ID_EMPRESA;
            }
            else
            {
                ejecutar = false;
                MensajeError = "El campo ID_EMPRESA no puede ser vacio.";
            }

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                try
                {
                    _dataSet = conexion.ExecuteReader(sql);
                    _dataView = _dataSet.Tables[0].DefaultView;
                    _dataTable = _dataView.Table;
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            return _dataTable;
        }
        public Boolean Actualizar(Decimal ID_AFP, String NIT, String DIG_VER, String COD_ENTIDAD, String NOM_ENTIDAD, String DIR_ENTIDAD,
            String TEL_ENTIDAD, String CONTACTO, String CARGO, bool ESTADO)
        {
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            sql = "usp_con_ent_afp_actualizar ";

            #region validaciones

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

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

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

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

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

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

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

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

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

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

            if (ESTADO) sql += "'S'";
            else sql += "'N'";
            #endregion validaciones

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                conexion.IniciarTransaccion();
                try
                {
                    #region adicionar entidad
                    if (conexion.ExecuteNonQuery(sql) == 0) ejecutadoCorrectamente = false;
                    #endregion adicionar entidad

                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    if (!(_auditoria.Adicionar(Usuario, tabla.CON_ENT_F_PENSIONES, tabla.ACCION_ACTUALIZAR, sql, informacion, conexion))) ejecutadoCorrectamente = false;
                    #endregion auditoria

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

            if (ejecutadoCorrectamente) return true;
            else return false;
        }
示例#30
0
        public Boolean Adicionar(List<Permiso> permisos)
        {
            String sql = null;
            Boolean ejecutado = true;

            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            foreach (Permiso permiso in permisos)
            {
                sql = "usp_oper_permisos_adicionar ";
                sql += "'" + permiso.Proceso.ToString() + "', ";
                sql += "'" + permiso.ProcesoPermitido.ToString() + "', ";
                sql += "'" + permiso.Seccion.ToString() + "'";

                try
                {
                    conexion.ExecuteNonQuery(sql);
                }
                catch (ApplicationException e)
                {
                    ejecutado = false;
                    throw new Exception(e.Message);
                }
            }

            if (ejecutado)
            {
                conexion.AceptarTransaccion();
            }
            else
            {
                conexion.DeshacerTransaccion();
                conexion.Desconectar();
            }
            return ejecutado;
        }