public String ActualizarFechaPeriodo(Decimal ID_EMPRESA, String PERIODOSPROCESO, DateTime FECHA)
        {
            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();
            Boolean ejecutar = true;
            String sql = null;
            String informacion = null;
            String actualizado = "N";
            tools fecha = new tools();

            sql = "usp_actualizar_fecha_memorando ";

            #region validaciones
            if (ID_EMPRESA > 0)
            {
                sql += ID_EMPRESA.ToString() + ", ";
                informacion += "ID_EMPRESA= '" + ID_EMPRESA.ToString() + ", ";
            }
            else
            {
                MensajeError = "El campo ID_EMPRESA es requerido para la consulta.";
                ejecutar = false;
            }

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

            sql += "'" + fecha.obtenerStringConFormatoFechaSQLServer(FECHA) + "', ";
            informacion += "FECHA = '" + FECHA.ToString() + "', ";

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

            if (ejecutar)
            {
                try
                {
                    conexion.ExecuteNonQuery(sql);
                    actualizado = "S";
                    #region auditoria
                    auditoria _auditoria = new auditoria(Empresa);
                    _auditoria.Adicionar(Usuario, tabla.NOM_PERIODO, tabla.ACCION_LIQUIDAR, sql, informacion, conexion);
                    #endregion auditoria
                    conexion.AceptarTransaccion();
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                    conexion.DeshacerTransaccion();
                }
                finally
                {
                    conexion.Desconectar();
                }
            }
            return actualizado;
        }
        public Decimal ActualizarAuditoriaContratosPorSeccionYEstadoProceso(Decimal ID_EMPLEADO, String TABLA_AUDITADA, Decimal ID_AUDITADO, Boolean ACTUALIZAR_ESTADO_PROCESO, Decimal ID_SOLICITUD, String ESTADO_PROCESO)
        {
            Decimal ID_AUDITORIA = 0;

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

            try
            {
                ID_AUDITORIA = AdicionarAuditoriaContratos(ID_EMPLEADO, TABLA_AUDITADA, ID_AUDITADO, DateTime.Now, conexion);

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

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

            return ID_AUDITORIA;
        }
        public Boolean ActualizarDocumentos(List<DocumentoValidacion> listaDocs)
        {
            Boolean correcto = true;

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

            try
            {
                foreach (DocumentoValidacion documento in listaDocs)
                {
                    if (documento.id_sel_reg_documentos == 0)
                    {
                        if (AdicionarDocumentoConTransaccion(documento.nombre, documento.vigente, conexion) <= 0)
                        {
                            conexion.DeshacerTransaccion();
                            correcto = false;
                            break;
                        }
                    }
                    else
                    {
                        if (ActualizarRegistroConTransaccion(documento.id_sel_reg_documentos, documento.nombre, documento.vigente, conexion) == false)
                        {
                            conexion.DeshacerTransaccion();
                            correcto = false;
                            break;
                        }
                    }
                }

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

            return correcto;
        }
        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;
        }
        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;
        }
        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 Boolean Actualizar(int ID_UNIDAD_REPORTE, String DESCRIPCION, String DESC_ABREV, Boolean ACTIVO)
        {
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            sql = "usp_par_unidad_reporte_actualizar ";

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

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

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

            informacion += "ACTIVO = '" + ACTIVO + "' ";

            if (ACTIVO) sql += "1,";
            else sql += "0,";

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

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

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

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

            if (ejecutadoCorrectamente) return true;
            else return false;
        }
Esempio n. 8
0
        public Boolean ActualizarPresupuestoGeneral(Decimal ID_PRES_GEN,
            Decimal MONTO,
            String DESCRIPCION)
        {
            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            int numRegistrosAfectados = 0;

            tools _tools = new tools();

            sql = "usp_prog_presupuestos_generales_actualizar ";

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

            if (MONTO != 0)
            {
                sql += MONTO.ToString().Replace(",", ".") + ", ";
                informacion += "MONTO = '" + MONTO.ToString() + "', ";
            }
            else
            {
                MensajeError = "El campo MONTO no puede ser vacio.";
                ejecutar = false;
            }

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

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

            #endregion validaciones

            if (ejecutar)
            {
                try
                {
                    numRegistrosAfectados = conexion.ExecuteNonQuery(sql);

                    if (numRegistrosAfectados <= 0)
                    {
                        conexion.DeshacerTransaccion();
                        numRegistrosAfectados = 0;
                        ejecutadoCorrectamente = false;
                    }
                    else
                    {
                        auditoria _auditoria = new auditoria(Empresa);

                        if (_auditoria.Adicionar(Usuario, tabla.PROG_PRESUPUESTOS_GENERALES, tabla.ACCION_ACTUALIZAR, sql, informacion, conexion) == false)
                        {
                            conexion.DeshacerTransaccion();
                            numRegistrosAfectados = 0;
                            ejecutadoCorrectamente = false;
                        }
                    }

                    if (ejecutadoCorrectamente == true)
                    {
                        conexion.AceptarTransaccion();
                    }
                }
                catch (Exception e)
                {
                    conexion.DeshacerTransaccion();
                    MensajeError = e.Message;
                    ejecutadoCorrectamente = false;
                    numRegistrosAfectados = 0;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }
            else
            {
                ejecutadoCorrectamente = false;
                numRegistrosAfectados = 0;
            }

            if (ejecutadoCorrectamente)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    public Boolean CargarEnBdElManualServicioActual(Decimal ID_EMPRESA)
    {
        Boolean resultado = true;
        Boolean correcto = true;

        Conexion _datos = new Conexion(Session["idEmpresa"].ToString().Trim());
        _datos.IniciarTransaccion();

        try
        {
            //capturamos el historial de versionamineto de la empresa
            ManualServicio _manualServicio = new ManualServicio(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
            DataTable tablaManual = _manualServicio.ObtenerVersionamientoManualPorEmpresa(ID_EMPRESA, _datos);

            if (tablaManual.Rows.Count <= 0)
            {
                //si no se ha creado manual se deveulve true
                resultado = true;
                correcto = true;
            }
            else
            {
                DataRow filaVersionamientoManual = tablaManual.Rows[tablaManual.Rows.Count - 1];
                Decimal ID_VERSIONAMIENTO = Convert.ToDecimal(filaVersionamientoManual["ID_VERSIONAMIENTO"].ToString());
                DateTime fechaEmisionManual = Convert.ToDateTime(filaVersionamientoManual["FECHA_EMISION"]);
                String version = filaVersionamientoManual["VERSION_MAYOR"].ToString().Trim() + "." + filaVersionamientoManual["VERSION_MENOR"].ToString().Trim();
                DateTime fechaApartirDe = Convert.ToDateTime(filaVersionamientoManual["APLICAR_A_PARTIR"]);

                //revisamos si esa version ya tiene manual en pdf generado o sino lo generamos y lo guardamos en bd
                DataTable tablaArchivoVersion = _manualServicio.ObtenerArchivoManualServicioPorVersion(ID_VERSIONAMIENTO, _datos);

                if (tablaArchivoVersion.Rows.Count > 0)
                {
                    //el archivo ya esta guardado
                    resultado = true;
                    correcto = true;
                }
                else
                {
                    //toca generar el archivo y guardarlo
                    maestrasInterfaz _maestrasInterfaz = new maestrasInterfaz();
                    byte[] archivoManual = _maestrasInterfaz.GenerarPDFManualServicio(ID_VERSIONAMIENTO, version, fechaEmisionManual, fechaApartirDe, ID_EMPRESA, _datos);

                    Decimal ID_DOCUMENTO = Convert.ToDecimal(_datos.ExecuteEscalarParaAdicionarDocsManualServixo(ID_VERSIONAMIENTO, archivoManual,".pdf",archivoManual.Length, "application/pdf", Session["USU_LOG"].ToString()));

                    if (ID_DOCUMENTO <= 0)
                    {
                        resultado = false;
                        correcto = false;
                        _datos.DeshacerTransaccion();
                    }
                    else
                    {
                        resultado = true;
                        correcto = true;
                    }
                }
            }

            if (correcto == true)
            {
                _datos.AceptarTransaccion();
            }

        }
        catch(Exception ex)
        {
            _datos.DeshacerTransaccion();
            resultado = false;
            MensajeError = ex.Message;
        }
        finally
        {
            _datos.Desconectar();
        }

        return resultado;
    }
        public Boolean ActualizarCategoriaYSusMotivos(Decimal ID_MAESTRA_ROTACION,
            String TITULO_CATEGORIA,
            Boolean ACTIVO_CATEGORIA,
            List<MotivoRotacionRetiro> listaMotivos)
        {
            Boolean correcto = true;

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

            try
            {
                if (ActualizarCategoria(ID_MAESTRA_ROTACION, TITULO_CATEGORIA, ACTIVO_CATEGORIA, conexion) == false)
                {
                    conexion.DeshacerTransaccion();
                    correcto = false;
                }
                else
                {
                    DataTable tablaMotivosActuales = ObtenerMotivosActivosDeCategoria(ID_MAESTRA_ROTACION, conexion);
                    Boolean motivoEncontrado = false;
                    foreach (DataRow filaMotivosActuales in tablaMotivosActuales.Rows)
                    {
                        motivoEncontrado = false;
                        Decimal ID_DETALLE_ROTACION_ACTUAL = Convert.ToDecimal(filaMotivosActuales["ID_DETALLE_ROTACION"]);

                        foreach (MotivoRotacionRetiro m in listaMotivos)
                        {
                            if (ID_DETALLE_ROTACION_ACTUAL == m.ID_DETALLE_ROTACION)
                            {
                                motivoEncontrado = true;
                                break;
                            }
                        }

                        if (motivoEncontrado == false)
                        {
                            if (InhabilitarMoivo(ID_DETALLE_ROTACION_ACTUAL, conexion) == false)
                            {
                                correcto = false;
                                conexion.DeshacerTransaccion();
                                break;
                            }
                        }
                    }

                    if (correcto == true)
                    {
                        foreach (MotivoRotacionRetiro m in listaMotivos)
                        {
                            if (m.ID_DETALLE_ROTACION == 0)
                            {
                                Decimal ID_DETALLE_ROTACION = AdicionarMotivo(ID_MAESTRA_ROTACION, m.TITULO, conexion);

                                if (ID_DETALLE_ROTACION <= 0)
                                {
                                    conexion.DeshacerTransaccion();
                                    correcto = false;
                                    break;
                                }
                            }
                            else
                            {
                                if (ActualizarMotivo(m.ID_DETALLE_ROTACION, m.TITULO, m.ACTIVO, conexion) == false)
                                {
                                    correcto = false;
                                    conexion.DeshacerTransaccion();
                                    break;
                                }
                            }
                        }

                    }
                }

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

            return correcto;
        }
Esempio n. 11
0
        public Decimal Adicionar(String NIT, String DIG_VER, String COD_ENTIDAD, String NOM_ENTIDAD, String DIR_ENTIDAD,
            String TEL_ENTIDAD, String CONTACTO, String CARGO)
        {
            String sql = null;
            String ID = null;
            String informacion = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            sql = "usp_con_ent_eps_adicionar ";

            #region validaciones

            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() + "' ";
            #endregion validaciones

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

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

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

            if (ejecutadoCorrectamente) return Convert.ToDecimal(ID);
            else return 0;
        }
        private void Cargar(StreamReader streamReader, string idEmpresa)
        {
            System.Collections.ArrayList arrayList = new System.Collections.ArrayList();
            DataTable dataTable = new DataTable();
            int _int;
            Int32 registro = 0;
            Decimal _decimal;
            String linea = "";
            char[] delimitadores = { ';' };
            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            try
            {

                while (linea != null)
                {
                    linea = streamReader.ReadLine();
                    registro++;
                    if (linea != null)
                    {
                        arrayList.Add(linea);
                        string[] datos = linea.Split(delimitadores);
                        if (datos.Length == 5)
                        {

                            if (Decimal.TryParse(datos[1].ToString(), out _decimal))
                            {
                                if (Int32.TryParse(datos[2].ToString(), out _int))
                                {
                                    if (!string.IsNullOrEmpty(datos[3].ToString()))
                                    {
                                        if (!string.IsNullOrEmpty(datos[4].ToString()))
                                        {
                                            int ValideRegistro = 0;
                                            ValideRegistro = Adicionar(idEmpresa, Usuario, datos[0].ToString(), datos[1].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), conexion);
                                            if (ValideRegistro > 0)
                                            {
                                                if (ValideRegistro == 1) Adicionar(datos[1].ToString(), datos[0].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), "La cedula reportada no esta registrada en las solicitudes de ingreso.");
                                                if (ValideRegistro == 2) Adicionar(datos[1].ToString(), datos[0].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), "Este trabajador no tiene contratos activos.");
                                                if (ValideRegistro == 3) Adicionar(datos[1].ToString(), datos[0].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), "Este trabajador tiene mas de un contrato activo.");
                                                if (ValideRegistro == 9) Adicionar(datos[1].ToString(), datos[0].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), "Error desconocido, consulte con el administrador.");
                                            }
                                        }
                                        else Adicionar(datos[1].ToString(), datos[0].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), "Inconsistencia: El valor no puede estar vacio, sino existe debe estar en cero(0)");
                                    }
                                    else Adicionar(datos[1].ToString(), datos[0].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), "Inconsistencia: La cantidad no puede estar vacia, sino existe debe estar en cero(0)");
                                }
                                else Adicionar(datos[1].ToString(), datos[0].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), "Inconsistencia: El concepto no es númerico");
                            }
                            else Adicionar(datos[1].ToString(), datos[0].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), "Inconsistencia: El número de documento no es númerico");
                        }
                        else Adicionar(datos[1].ToString(), datos[0].ToString(), datos[2].ToString(), datos[3].ToString(), datos[4].ToString(), "Inconsistencia: El registro " + registro.ToString() + ", no tienen la cantidad de columnas requerida");
                    }
                }
                dataTable = Procesar(idEmpresa, Usuario, conexion);
                if (!dataTable.Rows.Count.Equals(0)) Cargar(dataTable);
                conexion.AceptarTransaccion();
            }
            catch (Exception e)
            {
                conexion.DeshacerTransaccion();
                throw new Exception(e.Message);
            }
            finally
            {
                conexion.Desconectar();
            }
        }
Esempio n. 13
0
        public Boolean Actualizar(Decimal ID_EMPRESA, String ACTIVO, System.DateTime FCH_INGRESO, String NIT_EMPRESA, String ACT_ECO,
            String RAZ_SOCIAL, String DIR_EMP, String CIU_EMP, String TEL_EMP, String CUB_CIUDADES, String NOM_REP_LEGAL, String CC_REP_LEGAL,
            String TIPO_EMPRESA, String CIU_ORG_NEG, Int32 NUM_EMPLEADOS, String USU_MOD, String FAC_NAL,
            Decimal ID_ALIANZA, Int32 DIG_VER, String EMP_ESTADO, String EMP_EXC_IVA,
            String TEL_EMP1, String NUM_CELULAR, String ID_ACTIVIDAD, Decimal ID_GRUPO_EMPRESARIAL,
            List<cobertura> coberturas, String ID_CIUDAD_CC_REP_LEGAL, String ID_SERVICIO, String TIP_DOC_REG_LEGAL, List<empresasRiesgos> listaRiesgos, String RAZ_SOCIAL_ANTERIOR)
        {
            Decimal ID_VERSIONAMIENTO = 0;
            Boolean realizarVersionamientoManual = true;
            Boolean continuarNormalmente = true;
            ManualServicio _manual = new ManualServicio(Empresa, Usuario);

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

            Boolean verificador = true;
            try
            {
                realizarVersionamientoManual = _manual.EmpresaConManualDeServicioCreado(ID_EMPRESA, conexion);

                DataTable tablaDatosAnteriores = _manual.ObtenerInfoRegistroTabla(diccionarioCamposVenEmpresas, "VEN_EMPRESAS", "ID_EMPRESA", ID_EMPRESA.ToString(), conexion);

                if (ActualizarRegistroVEN_EMPRESAS(ID_EMPRESA, ACTIVO, FCH_INGRESO, NIT_EMPRESA, ACT_ECO, RAZ_SOCIAL, DIR_EMP, CIU_EMP, TEL_EMP, CUB_CIUDADES, NOM_REP_LEGAL, CC_REP_LEGAL, TIPO_EMPRESA, CIU_ORG_NEG, NUM_EMPLEADOS, USU_MOD, FAC_NAL, ID_ALIANZA, DIG_VER, EMP_ESTADO, EMP_EXC_IVA, TEL_EMP1, NUM_CELULAR, ID_ACTIVIDAD, ID_GRUPO_EMPRESARIAL, ID_CIUDAD_CC_REP_LEGAL, ID_SERVICIO, TIP_DOC_REG_LEGAL, conexion) == false)
                {
                    conexion.DeshacerTransaccion();
                    verificador = false;
                }
                else
                {
                    DataTable tablaDatosNuevos = _manual.ObtenerInfoRegistroTabla(diccionarioCamposVenEmpresas, "VEN_EMPRESAS", "ID_EMPRESA", ID_EMPRESA.ToString(), conexion);

                    if (realizarVersionamientoManual == true)
                    {
                        ID_VERSIONAMIENTO = _manual.DeterminarYRegistrarModificacionesEnCampos(diccionarioCamposVenEmpresas, tablaDatosAnteriores, tablaDatosNuevos, ID_VERSIONAMIENTO, ID_EMPRESA, ManualServicio.ListaSecciones.Comercial, ManualServicio.AccionesManual.Actualizar, conexion);
                        if (ID_VERSIONAMIENTO == -1)
                        {
                            conexion.DeshacerTransaccion();
                            verificador = false;
                            continuarNormalmente = false;
                            ID_VERSIONAMIENTO = 0;
                        }
                    }

                    if (continuarNormalmente == true)
                    {
                        cobertura _cobertura = new cobertura(Empresa);
                        Boolean eliminarCobertura = true;
                        Boolean insertarCobertura = true;

                        DataTable tablaCoberturaActual = _cobertura.obtenerCoberturaDeUnCliente(ID_EMPRESA, conexion);

                        for (int i = 0; i < tablaCoberturaActual.Rows.Count; i++)
                        {
                            DataRow filaCoberturaActual = tablaCoberturaActual.Rows[i];
                            String ID_CIUDAD_COBERTURA_ACTUAL = filaCoberturaActual["Código Ciudad"].ToString().Trim();

                            eliminarCobertura = true;

                            foreach (cobertura c in coberturas)
                            {
                                if (c.IDCIUDAD == ID_CIUDAD_COBERTURA_ACTUAL)
                                {
                                    eliminarCobertura = false;
                                    break;
                                }
                            }

                            if (eliminarCobertura == true)
                            {
                                if (realizarVersionamientoManual == true)
                                {
                                    ID_VERSIONAMIENTO = _manual.RegistrarDesactivacionRegistroTabla(ID_EMPRESA, ManualServicio.ListaSecciones.Comercial, ManualServicio.AccionesManual.Eliminar, "COBERTURA", "Cobertura", ID_CIUDAD_COBERTURA_ACTUAL, ID_VERSIONAMIENTO, conexion);
                                    if (ID_VERSIONAMIENTO == -1)
                                    {
                                        conexion.DeshacerTransaccion();
                                        verificador = false;
                                        continuarNormalmente = false;
                                        ID_VERSIONAMIENTO = 0;
                                        break;
                                    }
                                }

                                if (continuarNormalmente == true)
                                {
                                    if (_cobertura.EliminarUnaCiudadDeLaCoberturaDeCliente(ID_EMPRESA, ID_CIUDAD_COBERTURA_ACTUAL, Usuario, conexion) == false)
                                    {
                                        MensajeError = _cobertura.MensajeError;
                                        conexion.DeshacerTransaccion();
                                        verificador = false;
                                        break;
                                    }
                                }
                            }
                        }

                        foreach (cobertura c in coberturas)
                        {
                            insertarCobertura = true;

                            for (int i = 0; i < tablaCoberturaActual.Rows.Count; i++)
                            {
                                DataRow filaCoberturaActual = tablaCoberturaActual.Rows[i];
                                String ID_CIUDAD_COBERTURA_ACTUAL = filaCoberturaActual["Código Ciudad"].ToString().Trim();

                                if (c.IDCIUDAD == ID_CIUDAD_COBERTURA_ACTUAL)
                                {
                                    insertarCobertura = false;
                                    break;
                                }
                            }

                            if (insertarCobertura == true)
                            {
                                if (realizarVersionamientoManual == true)
                                {
                                    ID_VERSIONAMIENTO = _manual.RegistrarInsersionRegistroTabla(ID_VERSIONAMIENTO, ManualServicio.ListaSecciones.Comercial, "COBERTURA", "Cobertura", c.IDCIUDAD, ManualServicio.AccionesManual.Insertar, ID_EMPRESA, conexion);
                                    if (ID_VERSIONAMIENTO == -1)
                                    {
                                        conexion.DeshacerTransaccion();
                                        verificador = false;
                                        continuarNormalmente = false;
                                        ID_VERSIONAMIENTO = 0;
                                        break;
                                    }
                                }

                                if (continuarNormalmente == true)
                                {
                                    if (_cobertura.Adicionar(ID_EMPRESA, c.IDCIUDAD, Usuario, conexion) == false)
                                    {
                                        verificador = false;
                                        conexion.DeshacerTransaccion();
                                        MensajeError = _cobertura.MensajeError;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                if (_cobertura.ActualizarPermisosParaCiudaYEmpresaEnGeneral(ID_EMPRESA, c.IDCIUDAD, Usuario, conexion) == false)
                                {
                                    verificador = false;
                                    conexion.DeshacerTransaccion();
                                    MensajeError = _cobertura.MensajeError;
                                    break;
                                }
                            }
                        }

                        if (verificador == true)
                        {
                            empresasRiesgos _empresasRiesgos = new empresasRiesgos(Empresa, Usuario);
                            DataTable tablaRiesgosActuales = _empresasRiesgos.ObtenerRoesgosPorEmpresa(ID_EMPRESA, conexion);

                            Boolean riesgoEncontrado = false;

                            foreach (DataRow filaRiegosActuales in tablaRiesgosActuales.Rows)
                            {
                                riesgoEncontrado = false;
                                foreach (empresasRiesgos filaRiesgosNuevos in listaRiesgos)
                                {
                                    if (filaRiesgosNuevos.DESCRIPCION_RIESGO == filaRiegosActuales["DESCRIPCION_RIESGO"].ToString())
                                    {
                                        riesgoEncontrado = true;
                                        break;
                                    }
                                }

                                if (riesgoEncontrado == false)
                                {
                                    if (_empresasRiesgos.desactivarRiesgoParaEmpresa(ID_EMPRESA, filaRiegosActuales["DESCRIPCION_RIESGO"].ToString(), conexion) == false)
                                    {
                                        conexion.DeshacerTransaccion();
                                        verificador = false;
                                        break;
                                    }
                                }
                            }

                            if (verificador == true)
                            {
                                foreach (empresasRiesgos filaRiesgosNuevos in listaRiesgos)
                                {
                                    if (_empresasRiesgos.Adicionar(ID_EMPRESA, filaRiesgosNuevos.DESCRIPCION_RIESGO, conexion) == 0)
                                    {
                                        verificador = false;
                                        MensajeError = _empresasRiesgos.MensajeError;
                                        conexion.DeshacerTransaccion();
                                        break;
                                    }
                                }

                                if (verificador == true)
                                {
                                    if (RAZ_SOCIAL != RAZ_SOCIAL_ANTERIOR)
                                    {
                                        if (AdicionarCambiorazonSocial(ID_EMPRESA, RAZ_SOCIAL_ANTERIOR, RAZ_SOCIAL, Usuario, conexion) <= 0)
                                        {
                                            conexion.DeshacerTransaccion();
                                            verificador = false;
                                        }
                                    }
                                    else
                                    {
                                        verificador = true;
                                    }

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

            return verificador;
        }
Esempio n. 14
0
        public Decimal Adicionar(String ACTIVO, System.DateTime FCH_INGRESO, String NIT_EMPRESA, String ACT_ECO,
            String RAZ_SOCIAL, String DIR_EMP, String CIU_EMP, String TEL_EMP, String CUB_CIUDADES, String NOM_REP_LEGAL, String CC_REP_LEGAL,
            String TIPO_EMPRESA, String CIU_ORG_NEG, Int32 NUM_EMPLEADOS, String USU_CRE, String FAC_NAL,
            Decimal ID_ALIANZA, Int32 DIG_VER, String EMP_ESTADO, String EMP_EXC_IVA,
            String TEL_EMP1, String NUM_CELULAR, String ID_ACTIVIDAD, Decimal ID_GRUPO_EMPRESARIAL,
            List<cobertura> coberturas, String ID_CIUDAD_CC_REP_LEGAL, String ID_SERVICIO, String TIP_DOC_REP_LEGAL, List<empresasRiesgos> listaRiesgos)
        {
            Decimal ID_EMPRESA = 0;

            Boolean verificador = true;

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

            try
            {
                ID_EMPRESA = AdicinarRegistroVEN_EMPRESAS(ACTIVO, FCH_INGRESO, NIT_EMPRESA, ACT_ECO, RAZ_SOCIAL, DIR_EMP, CIU_EMP, TEL_EMP, CUB_CIUDADES, NOM_REP_LEGAL, CC_REP_LEGAL, TIPO_EMPRESA, CIU_ORG_NEG, NUM_EMPLEADOS, USU_CRE, FAC_NAL, ID_ALIANZA, DIG_VER, EMP_ESTADO, EMP_EXC_IVA, TEL_EMP1, NUM_CELULAR, ID_ACTIVIDAD, ID_GRUPO_EMPRESARIAL, ID_CIUDAD_CC_REP_LEGAL, ID_SERVICIO, TIP_DOC_REP_LEGAL, conexion);

                if (ID_EMPRESA == 0)
                {
                    conexion.DeshacerTransaccion();
                    verificador = false;
                }
                else
                {
                    cobertura _cobertura = new cobertura(Empresa);
                    foreach (cobertura c in coberturas)
                    {
                        if (_cobertura.Adicionar(ID_EMPRESA, c.IDCIUDAD, USU_CRE, conexion) == false)
                        {
                            conexion.DeshacerTransaccion();
                            ID_EMPRESA = 0;
                            verificador = false;
                            break;
                        }
                    }

                    if (verificador == true)
                    {
                        empresasRiesgos _empresasRiesgos = new empresasRiesgos(Empresa, Usuario);
                        foreach (empresasRiesgos r in listaRiesgos)
                        {
                            if (_empresasRiesgos.Adicionar(ID_EMPRESA, r.DESCRIPCION_RIESGO, conexion) <= 0)
                            {
                                conexion.DeshacerTransaccion();
                                ID_EMPRESA = 0;
                                verificador = false;
                                break;
                            }
                        }

                        if (verificador == true)
                        {
                            conexion.AceptarTransaccion();
                        }
                    }
                }
            }
            catch
            {
                conexion.DeshacerTransaccion();
                ID_EMPRESA = 0;
                verificador = false;
            }
            finally
            {
                conexion.Desconectar();
            }

            return ID_EMPRESA;
        }
Esempio n. 15
0
        private Boolean Actualizar(DataTable _dataTable)
        {
            Int32 cantidadRegistrosActualizados = 0;
            String sql = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            if (_dataTable.Rows.Count == 0)
            {
                MensajeError += "No existen filas para ser actualizadas\n";
                ejecutar = false;
            }

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                conexion.IniciarTransaccion();
                try
                {
                    foreach (DataRow dataRow in _dataTable.Rows)
                    {
                        sql = "usp_sel_control_requisitos_actualizar ";

                        sql += String.IsNullOrEmpty(dataRow["ID_CONTROL_REQUISITOS"].ToString()) ? "Null, " : dataRow["ID_CONTROL_REQUISITOS"].ToString() + ",";
                        sql += String.IsNullOrEmpty(dataRow["ID_PRUEBA"].ToString()) ? "Null, " : dataRow["ID_PRUEBA"] + ",";
                        sql += String.IsNullOrEmpty(dataRow["ID_DOCUMENTO"].ToString()) ? "Null, " : dataRow["ID_DOCUMENTO"] + ",";
                        sql += String.IsNullOrEmpty(dataRow["CUMPLIDO"].ToString()) ? "Null, " : dataRow["CUMPLIDO"] + ",";
                        sql += String.IsNullOrEmpty(dataRow["DEROGADO"].ToString()) ? "Null, " : dataRow["DEROGADO"] + ",";
                        sql += String.IsNullOrEmpty(dataRow["OBSERVACIONES"].ToString()) ? "Null " : "'" + dataRow["OBSERVACIONES"] + "' ";
                        cantidadRegistrosActualizados = conexion.ExecuteNonQuery(sql);

                        #region auditoria
                        #endregion auditoria
                    }
                    conexion.AceptarTransaccion();
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                    ejecutadoCorrectamente = false;
                    conexion.DeshacerTransaccion();
                }
                finally
                {
                    conexion.Desconectar();
                }
            }
            return ejecutadoCorrectamente;
        }
        public String ObtenerEmpresaCesantias(Decimal ID_EMPRESA)
        {
            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();
            Boolean ejecutar = true;
            String sql = null;
            String _empresa = "";

            sql = "usp_traer_empresa ";

            #region validaciones
            if (ID_EMPRESA > 0)
            {
                sql += ID_EMPRESA.ToString() + "";
            }
            else
            {
                MensajeError = "El campo ID_EMPRESA es requerido para la consulta.";
                ejecutar = false;
            }

            #endregion

            if (ejecutar)
            {
                try
                {
                    _empresa = conexion.ExecuteScalar(sql);
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                    conexion.DeshacerTransaccion();
                }
                finally
                {
                    conexion.Desconectar();
                }
            }
            return _empresa;
        }
        public Boolean GrabarRegistrosDefCesantias(Decimal ID_EMPRESA, Int32 PERIODO, String FECHA, String TIPO_PAGO, Int32 ID_CONCEPTO_CESANTIAS, Int32 ID_CONCEPTO_INTERESES, Int32 CONTROL)
        {
            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();
            Boolean ejecutar = true;
            String sql = null;
            String informacion = null;
            Boolean grabado = false;

            sql = "usp_grabar_cesantias_definitiva ";

            #region validaciones
            if (ID_EMPRESA > 0)
            {
                sql += ID_EMPRESA.ToString() + ", ";
                informacion += "ID_EMPRESA= '" + ID_EMPRESA.ToString() + ", ";
            }
            else
            {
                MensajeError = "El campo ID_EMPRESA es requerido para la consulta.";
                ejecutar = false;
            }

            sql += PERIODO.ToString() + ", ";

            sql += "'" + FECHA.ToString() + "', ";

            sql += "'" + TIPO_PAGO.ToString() + "', ";

            sql += ID_CONCEPTO_CESANTIAS.ToString() + ", ";

            sql += ID_CONCEPTO_INTERESES.ToString() + ", ";

            sql += CONTROL.ToString() + ", ";

            if (!(String.IsNullOrEmpty(Usuario)))
            {
                sql += "'" + Usuario.ToString() + "'";
                informacion += "USU_CRE = '" + Usuario.ToString() + "'";
            }
            else
            {
                MensajeError = "El campo Usuario es requerido para la consulta.";
                ejecutar = false;
            }

            #endregion

            if (ejecutar)
            {
                try
                {
                    grabado = Convert.ToBoolean(conexion.ExecuteScalar(sql));
                    if (grabado == true)
                    {
                        #region auditoria
                        #endregion auditoria
                        conexion.AceptarTransaccion();
                    }
                    else
                        conexion.DeshacerTransaccion();
                }
                catch (Exception e)
                {
                    MensajeError = e.Message;
                    conexion.DeshacerTransaccion();
                }
                finally
                {
                    conexion.Desconectar();
                }
            }
            return grabado;
        }
        public Boolean ActualizarMotivosRotacionEmpresa(Decimal ID_EMPRESA, List<MotivoRotacionEmpresa> listaMotivosAsociados)
        {
            Boolean correcto = true;

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

            try
            {
                DataTable tablaMotivoAsociadosActuales = ObtenerMotivosActivosEmpresa(ID_EMPRESA, conexion);

                Boolean motivoExiste = false;
                foreach (DataRow filaMotivosActuales in tablaMotivoAsociadosActuales.Rows)
                {
                    Decimal ID_ROTACION_EMPRESA_ACTUAL = Convert.ToDecimal(filaMotivosActuales["ID_ROTACION_EMPRESA"]);

                    motivoExiste = false;

                    foreach (MotivoRotacionEmpresa m in listaMotivosAsociados)
                    {
                        if (ID_ROTACION_EMPRESA_ACTUAL == m.ID_ROTACION_EMPRESA)
                        {
                            motivoExiste = true;
                            break;
                        }
                    }

                    if (motivoExiste == false)
                    {
                        if (InhabilitarMotivoAsociadoAEmpresa(ID_ROTACION_EMPRESA_ACTUAL, conexion) == false)
                        {
                            conexion.DeshacerTransaccion();
                            correcto = false;
                            break;
                        }
                    }
                }

                if (correcto == true)
                {
                    foreach (MotivoRotacionEmpresa m in listaMotivosAsociados)
                    {
                        if (m.ID_ROTACION_EMPRESA == 0)
                        {
                            Decimal ID_ROTACION_EMPRESA = AdicionarMotivoAsociadoAEmpresa(ID_EMPRESA, m.ID_DETALLE_ROTACION, conexion);

                            if (ID_ROTACION_EMPRESA <= 0)
                            {
                                conexion.DeshacerTransaccion();
                                correcto = false;
                                break;
                            }
                        }
                    }
                }

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

            return correcto;
        }
        public Decimal AdicionarNuevaActaComite(DateTime FECHA_R,
            DateTime FECHA_ACTA,
            String TITULO,
            String TIPO_DOCUMENTO,
            Byte[] ARCHIVO,
            String ARCHIVO_EXTENSION,
            Decimal ARCHIVO_TAMANO,
            String ARCHIVO_TYPE,
            String ACTIVO)
        {
            Decimal ID_ACTA_COMITE = 0;
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            tools _tools = new tools();

            sql = "usp_reg_comite_convivencia_adicionar_acta_comite ";

            #region validaciones

            sql += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_R) + "', ";
            informacion += "FECHA_R = '" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_R) + "', ";

            sql += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_ACTA) + "', ";
            informacion += "FECHA_ACTA = '" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_ACTA) + "', ";

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

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

            sql += "'[DATOS_BINARIOS]', ";
            informacion += "ARCHIVO = '[DATOS_BINARIOS]', ";

            sql += "'" + ARCHIVO_EXTENSION + "', ";
            informacion += "ARCHIVO_EXTENSION = '" + ARCHIVO_EXTENSION + "', ";

            sql += ARCHIVO_TAMANO + ", ";
            informacion += "ARCHIVO_TAMANO = '" + ARCHIVO_TAMANO + "', ";

            sql += "'" + ARCHIVO_TYPE + "', ";
            informacion += "ARCHIVO_TYPE = '" + ARCHIVO_TYPE + "', ";

            sql += "'" + ACTIVO + "', ";
            informacion += "ACTIVO = '" + ACTIVO + "', ";

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

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                conexion.IniciarTransaccion();
                try
                {
                    ID_ACTA_COMITE = Convert.ToDecimal(conexion.ExecuteEscalarParaAdicionaNuevaActaComite(FECHA_R, FECHA_ACTA, TITULO, TIPO_DOCUMENTO, ARCHIVO, ARCHIVO_EXTENSION, ARCHIVO_TAMANO, ARCHIVO_TYPE, ACTIVO, Usuario));

                    if (ID_ACTA_COMITE <= 0)
                    {
                        conexion.DeshacerTransaccion();
                        MensajeError = "ERROR: Al intentar ingresar la nueva acta de comite.";
                        ejecutadoCorrectamente = false;
                    }
                    else
                    {
                        auditoria _auditoria = new auditoria(Empresa);
                        if (!(_auditoria.Adicionar(Usuario, tabla.REG_COMITE_CONVIVENCIA, tabla.ACCION_ADICIONAR, sql, informacion, conexion)))
                        {
                            conexion.DeshacerTransaccion();
                            MensajeError = "ERROR: Al intentar ingresar la auditoría para el registro de fallecidos.";
                            ejecutadoCorrectamente = false;
                        }
                        else
                        {
                            conexion.AceptarTransaccion();
                        }
                    }
                }
                catch (Exception e)
                {
                    conexion.DeshacerTransaccion();
                    MensajeError = e.Message;
                    ejecutadoCorrectamente = false;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }
            else
            {
                ejecutadoCorrectamente = false;
            }

            if (ejecutadoCorrectamente)
            {
                return ID_ACTA_COMITE;
            }
            else
            {
                return 0;
            }
        }
        public Decimal ActualizarResultadosEntrevistaRetiroDeEmpleado(Decimal ID_MAESTRA_ROTACION_EMPLEADO,
            Decimal ID_EMPLEADO,
            String OBSERVACIONES,
            List<EntrevistaRotacionEmpleado> listaResultadosEntrevista)
        {
            Boolean correcto = true;

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

            try
            {
                if (ID_MAESTRA_ROTACION_EMPLEADO <= 0)
                {
                    ID_MAESTRA_ROTACION_EMPLEADO = AdicionarMaestraEntrevistaRetiro(ID_EMPLEADO, OBSERVACIONES, conexion);

                    if (ID_MAESTRA_ROTACION_EMPLEADO <= 0)
                    {
                        conexion.DeshacerTransaccion();
                        correcto = false;
                        ID_MAESTRA_ROTACION_EMPLEADO = 0;
                    }
                }

                if (correcto == true)
                {
                    DataTable tablaResultadosActuales = ObtenerResultadosEntrevistaDeRetiroParaEmpleado(ID_EMPLEADO, conexion);

                    Boolean resultadoEncontrado = false;
                    foreach (DataRow filaAtual in tablaResultadosActuales.Rows)
                    {
                        resultadoEncontrado = false;

                        Decimal ID_DETALLE_ROTACION_EMPLEADO_ACTUAL = Convert.ToDecimal(filaAtual["ID_DETALLE_ROTACION_EMPLEADO"]);

                        foreach (EntrevistaRotacionEmpleado e in listaResultadosEntrevista)
                        {
                            if (ID_DETALLE_ROTACION_EMPLEADO_ACTUAL == e.ID_DETALLE_ROTACION_EMPLEADO)
                            {
                                resultadoEncontrado = true;
                                break;
                            }
                        }

                        if (resultadoEncontrado == false)
                        {
                            if (InhabilitarResultadoEntrevistaRetiro(ID_DETALLE_ROTACION_EMPLEADO_ACTUAL, conexion) == false)
                            {
                                conexion.DeshacerTransaccion();
                                ID_MAESTRA_ROTACION_EMPLEADO = 0;
                                correcto = false;
                                break;
                            }
                        }
                    }

                    if (correcto == true)
                    {
                        foreach (EntrevistaRotacionEmpleado e in listaResultadosEntrevista)
                        {
                            if (e.ID_DETALLE_ROTACION_EMPLEADO == 0)
                            {
                                Decimal ID_DETALLE_ROTACION_EMPLEADO = AdicionarResultadoEntrevistaRetiro(ID_MAESTRA_ROTACION_EMPLEADO, e.ID_ROTACION_EMPRESA, conexion);

                                if (ID_DETALLE_ROTACION_EMPLEADO <= 0)
                                {
                                    conexion.DeshacerTransaccion();
                                    correcto = false;
                                    ID_MAESTRA_ROTACION_EMPLEADO = 0;
                                    break;
                                }
                            }
                        }
                    }
                }

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

            return ID_MAESTRA_ROTACION_EMPLEADO;
        }
        public Decimal Adicionar(String DESCRIPCION, String DESC_ABREV, Boolean ACTIVO)
        {
            String sql = null;
            String ID = null;
            String informacion = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            sql = "usp_par_unidad_reporte_adicionar ";

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

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

            informacion += "ACTIVO = '" + ACTIVO + "' ";

            if (ACTIVO) sql += "1,";
            else sql += "0,";

            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_UNIDAD_REPORTE, 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 GuardarCategoriaYSusMotivos(String TITULO_CATEGORIA,
            List<MotivoRotacionRetiro> listaMotivos)
        {
            Boolean correcto = true;

            Decimal ID_MAESTRA_ROTACION = 0;

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

            try
            {
                ID_MAESTRA_ROTACION = AdicionarCategoria(TITULO_CATEGORIA, conexion);

                if (ID_MAESTRA_ROTACION <= 0)
                {
                    correcto = false;
                    conexion.DeshacerTransaccion();
                    ID_MAESTRA_ROTACION = 0;
                }
                else
                {
                    foreach (MotivoRotacionRetiro m in listaMotivos)
                    {
                        Decimal ID_DETALLE_ROTACION = AdicionarMotivo(ID_MAESTRA_ROTACION, m.TITULO, conexion);

                        if (ID_DETALLE_ROTACION <= 0)
                        {
                            correcto = false;
                            conexion.DeshacerTransaccion();
                            ID_MAESTRA_ROTACION = 0;
                            break;
                        }
                    }
                }

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

            return ID_MAESTRA_ROTACION;
        }
        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 Boolean ActualizarConfiguracionDeEnvioDeOrdenesDeCompra(Decimal ID_USUARIO_PRINCIPAL_ANTERIOR,
            Decimal ID_USUARIO_PRINCIPAL_NUEVO,
            String TIPO_CONFIGURACION_PRINCIPAL,
            List<ConfiguracionEnvioOrden> listaConfiguraciones)
        {
            Boolean correcto = true;

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

            try
            {
                if (ID_USUARIO_PRINCIPAL_ANTERIOR != ID_USUARIO_PRINCIPAL_NUEVO)
                {
                    if (AdicionarNuevoRegistroEnvioOrdenPrincipal(ID_USUARIO_PRINCIPAL_NUEVO, TIPO_CONFIGURACION_PRINCIPAL, conexion) <= 0)
                    {
                        conexion.DeshacerTransaccion();
                        correcto = false;
                    }
                }

                if (correcto == true)
                {
                    if (ActualizarListaConfiguracionesCopia(listaConfiguraciones, conexion) == false)
                    {
                        conexion.DeshacerTransaccion();
                        correcto = false;
                    }
                }

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

            return correcto;
        }
Esempio n. 25
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;
        }
        public Boolean ActualizarMotivos(Programa.Areas area,
            String tipo,
            List<MotivoProgComp> listaMotivos)
        {
            Boolean correcto = true;

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

            try
            {
                foreach (MotivoProgComp motivo in listaMotivos)
                {
                    if (motivo.ID_MOTIVO == 0)
                    {
                        if (AdicionarMotivo(area, motivo.MOTIVO, tipo, motivo.ACTIVO, conexion) <= 0)
                        {
                            conexion.DeshacerTransaccion();
                            correcto = false;
                            break;
                        }
                    }
                    else
                    {
                        if (ActualizarMotivo(motivo.ID_MOTIVO, motivo.MOTIVO, motivo.ACTIVO, conexion) == false)
                        {
                            conexion.DeshacerTransaccion();
                            correcto = false;
                            break;
                        }
                    }
                }

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

            return correcto;
        }
        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 Decimal Adicionar(String DESCRIPCION, Decimal PORCENTAJE, String COD_CONTABLE)
        {
            String sql = null;
            String ID = null;
            String informacion = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            sql = "usp_par_seguridad_social_adicionar ";

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

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

            if (!(String.IsNullOrEmpty(COD_CONTABLE)))
            {
                sql += "'" + COD_CONTABLE + "', ";
                informacion += "COD_CONTABLE = '" + COD_CONTABLE + "', ";
            }
            else
            {
                MensajeError += "El campo COD_CONTABLE no puede ser nulo\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_SEGURIDAD_SOCIAL, 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;
        }
Esempio n. 29
0
        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;
        }
        public Boolean Actualizar(int ID_SEGURIDAD_SOCIAL, String DESCRIPCION, Decimal PORCENTAJE, String COD_CONTABLE)
        {
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            sql = "usp_par_prestacionales_actualizar ";

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

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

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

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

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

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

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

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

            if (ejecutadoCorrectamente) return true;
            else return false;
        }