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;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Header.Title = "ACTIVAR CONTRATO";

        tools _tools = new tools();
        SecureQueryString QueryStringSeguro;
        QueryStringSeguro = new SecureQueryString(_tools.byteParaQueryStringSeguro(), Request["data"]);

        Panel_MENSAJES.Visible = false;

        CargarQueryString();

        if (IsPostBack == false)
        {
            Configurar();

            String accion = QueryStringSeguro["accion"].ToString();
            if (accion == "inicial")
            {
                iniciar_interfaz_inicial();

                Panel_BOTONES_INTERNOS.Visible = true;
                cargar_menu_botones_modulos_internos(false);
            }
            else if (accion == "cargar")
            {
                Panel_Cargos_Por_Fuente.Visible = true;
                Panel_Informacion_Contrato.Visible = true;
                Panel_MENSAJES.Visible = false;

                registroContrato _contrato = new registroContrato(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                DataTable tablaContratos = _contrato.ObtenerContratoPorNumeroIdentificacion(HiddenField_NUM_DOC_IDENTIDAD.Value);
                if (tablaContratos.Rows.Count == 0)
                {
                    Ocultar(Acciones.Contratar);
                    Decimal ID_REQUERIMIENTO = Convert.ToDecimal(HiddenField_ID_REQUISICION.Value);
                    Decimal ID_SOLICITUD = Convert.ToDecimal(HiddenField_ID_SOLICITUD.Value);

                    radicacionHojasDeVida _solIngreso = new radicacionHojasDeVida(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                    _solIngreso.ActualizarEstadoProcesoRegSolicitudesIngreso(Convert.ToInt32(ID_REQUERIMIENTO), Convert.ToInt32(ID_SOLICITUD), "ELABORAR CONTRATO", Session["USU_LOG"].ToString());

                    tablaContratos = _contrato.ObtenerDatosNuevoContrato(Convert.ToInt32(ID_REQUERIMIENTO), Convert.ToInt32(ID_SOLICITUD));
                    DataRow filaContrato = tablaContratos.Rows[0];
                    String nombre = filaContrato["NOMBRES"].ToString() + " " + filaContrato["APELLIDOS"].ToString();
                    String NUM_DOC_IDENTIDAD = filaContrato["TIP_DOC_IDENTIDAD"].ToString() + " " + filaContrato["NUM_DOC_IDENTIDAD"].ToString();

                    String Datos_persona = "Nombre: " + nombre + "<br> Numero Identificación: " + NUM_DOC_IDENTIDAD + "<br> Empresa: " + filaContrato["RAZ_SOCIAL"].ToString() + "<br>Cargo: " + filaContrato["NOM_OCUPACION"].ToString();
                    configurarInfoAdicionalModulo(true, Datos_persona);

                    cargar_menu_botones_modulos_internos(false);

                    requisicion _req = new requisicion(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                    DataTable tablaReq = _req.ObtenerComRequerimientoPorIdRequerimiento(ID_REQUERIMIENTO);
                    DataRow filaReq = tablaReq.Rows[0];

                    HiddenField_ID_PERFIL.Value = filaReq["REGISTRO_PERFIL"].ToString().Trim();

                    TextBox_Apellidos.Text = filaContrato["APELLIDOS"].ToString();
                    TextBox_Nombres.Text = filaContrato["NOMBRES"].ToString();
                    TextBox_doc_identidad.Text = filaContrato["TIP_DOC_IDENTIDAD"].ToString() + " " + filaContrato["NUM_DOC_IDENTIDAD"].ToString();

                    DateTime fechaInicio;

                    try
                    {
                        fechaInicio = Convert.ToDateTime(filaContrato["F_ING_C"]);
                    }
                    catch
                    {
                        fechaInicio = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    }

                    TextBox_fecha_inicio.Text = fechaInicio.ToShortDateString();
                    RangeValidator_TextBox_fecha_inicio.MinimumValue = DateTime.Now.ToShortDateString();
                    RangeValidator_TextBox_fecha_inicio.MaximumValue = DateTime.Now.AddDays(30).ToShortDateString();

                    TextBox_fecha_inicio.Enabled = true;

                    TextBox_Salario.Text = Convert.ToDecimal(filaContrato["SUELDO_C"]).ToString();
                    HiddenField_SUELDO.Value = filaContrato["SUELDO_C"].ToString();
                    TextBox_empresa.Text = filaContrato["RAZ_SOCIAL"].ToString();
                    TextBox_Cargo.Text = filaContrato["ID_Y_NOMBRE_CARGO"].ToString().Trim();

                    cargar_DropDownList_Clase_contrato();
                    cargar_DropDownList_tipo_Contrato();

                    cargar_DropDownList_FORMA_IMPRESION_CONTRATO(String.Empty);
                    DropDownList_FORMA_IMPRESION_CONTRATO.Enabled = false;
                    CheckBox_CON_CARNET_APARTE.Enabled = false;
                    CheckBox_CON_CARNET_APARTE.Checked = false;

                    cargar_DropDownList_Salario_integral();
                    cargar_DropDownList_SALARIO();

                    cargar_DropDownList_PERIODO_PAGO();

                    IniciarSeleccionDeUbicacion();

                    configurarBotonesDeAccion(false, true, true, false);
                }
                else
                {
                    DataRow filaContrato = tablaContratos.Rows[0];
                    HiddenField_ID_CONTRATO.Value += filaContrato["REGISTRO"].ToString();
                    HiddenField_persona.Value += "," + filaContrato["REGISTRO"].ToString() + ", " + filaContrato["ID_EMPLEADO"].ToString();
                    cargar_menu_botones_modulos_internos(false);

                    Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "El empleado ya tiene contrato activo. Para realizar modificaciones por favor utlice el modulo de auditoría de contratos.", Proceso.Advertencia);

                    Panel_Informacion_Contrato.Visible = false;
                }
            }
        }
    }
    private void Cargar(Decimal ID_REQUERIMIENTO, Decimal ID_SOLICITUD, Decimal ID_EMPRESA, Decimal ID_OCUPACION)
    {
        HiddenField_ID_REQUERIMIENTO.Value = ID_REQUERIMIENTO.ToString();
        HiddenField_ID_SOLICITUD.Value = ID_SOLICITUD.ToString();
        HiddenField_ID_EMPRESA.Value = ID_EMPRESA.ToString();
        HiddenField_ID_OCUPACION.Value = ID_OCUPACION.ToString();

        Ocultar(Acciones.Inicio);

        radicacionHojasDeVida _solIngreso = new radicacionHojasDeVida(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        _solIngreso.ActualizarEstadoProcesoRegSolicitudesIngreso(Convert.ToInt32(ID_REQUERIMIENTO), Convert.ToInt32(ID_SOLICITUD), "EN EXAMENES", Session["USU_LOG"].ToString());

        condicionesContratacion CondicionesContratacion = new condicionesContratacion(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable _tablaReq = CondicionesContratacion.ObtenerComRequerimientoPorIdRequerimiento(ID_REQUERIMIENTO);
        DataRow _filaReq = _tablaReq.Rows[0];
        String CIUDAD_REQ = _filaReq["CIUDAD_REQ"].ToString().Trim();
        HiddenField_CIUDAD_REQ.Value = CIUDAD_REQ;

        perfil _PERFIL = new perfil(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaPerfil = _PERFIL.ObtenerPorRegistro(Convert.ToInt32(_filaReq["REGISTRO_PERFIL"]));
        DataRow filaPerfil = tablaPerfil.Rows[0];
        Decimal ID_PERFIL = Convert.ToDecimal(_filaReq["REGISTRO_PERFIL"]);
        ID_OCUPACION = Convert.ToDecimal(filaPerfil["ID_OCUPACION"]);
        if (!string.IsNullOrEmpty(filaPerfil["CODIGO"].ToString())) Label_RIESGO.Text =  filaPerfil["CODIGO"].ToString();
        HiddenField_ID_PERFIL.Value = ID_PERFIL.ToString();
        HiddenField_ID_OCUPACION.Value = ID_OCUPACION.ToString();

        DataTable tablasol = _solIngreso.ObtenerRegSolicitudesingresoPorIdSolicitud(Convert.ToInt32(ID_SOLICITUD));
        DataRow filaSolIngreso = tablasol.Rows[0];
        String NOMBRE_TRABAJADOR = filaSolIngreso["NOMBRES"].ToString().Trim() + " " + filaSolIngreso["APELLIDOS"].ToString().Trim();
        String NUM_DOC_IDENTIDAD_COMPLETO = filaSolIngreso["TIP_DOC_IDENTIDAD"].ToString().Trim() + " " + filaSolIngreso["NUM_DOC_IDENTIDAD"].ToString().Trim();
        String NUM_DOC_IDENTIDAD = filaSolIngreso["NUM_DOC_IDENTIDAD"].ToString().Trim();
        HiddenField_NUM_DOC_IDENTIDAD.Value = NUM_DOC_IDENTIDAD;

        cliente _empresa = new cliente(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaEmpresa = _empresa.ObtenerEmpresaConIdEmpresa(ID_EMPRESA);
        DataRow filaEmpresa = tablaEmpresa.Rows[0];
        String RAZ_SOCIAL = filaEmpresa["RAZ_SOCIAL"].ToString().Trim();
        HiddenField_ID_EMPRESA.Value = filaEmpresa["ID_EMPRESA"].ToString().Trim();

        cargo _cargo = new cargo(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaOcupacion = _cargo.ObtenerOcupacionPorIdOcupacion(ID_OCUPACION);
        DataRow filaOcupacion = tablaOcupacion.Rows[0];
        String CARGO = filaOcupacion["NOM_OCUPACION"].ToString().Trim();

        HiddenField_persona.Value = ID_SOLICITUD.ToString() + "," + ID_REQUERIMIENTO.ToString() + "," + ID_OCUPACION.ToString() + "," + ID_EMPRESA.ToString() + "," + NUM_DOC_IDENTIDAD.Trim();

        cargar_menu_botones_modulos_internos();

        if (!String.IsNullOrEmpty(filaSolIngreso["NUM_CUENTA"].ToString())) CheckBox_TIENE_CUENTA.Checked = true;

        cargarDatosTrabajador(NOMBRE_TRABAJADOR, NUM_DOC_IDENTIDAD_COMPLETO, RAZ_SOCIAL, CARGO, ID_OCUPACION.ToString());

        ordenExamenes _ordenes = new ordenExamenes(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaOrdenes = _ordenes.ObtenerConRegOrdenExamenPorSolicitud(Convert.ToInt32(ID_REQUERIMIENTO), Convert.ToInt32(ID_SOLICITUD));

        if (tablaOrdenes.Rows.Count <= 0)
        {
            if (_ordenes.MensajeError != null)
            {
                Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, _ordenes.MensajeError, Proceso.Error);
            }
            else
            {

                Mostrar(Acciones.SeleccionUbicacion);

                HiddenField_ESTADO_PROCESO.Value = AccionesProceso.Paso1ConfigurarExamenes.ToString();

                CargarSeccionUbicacionTrabajador();

                Panel_INFO_ADICIONAL_MODULO.Visible = true;
                Label_INFO_ADICIONAL_MODULO.Text = "SELECCIONE LA UBICACIÓN DONDE TRABAJARÁ LA PERSONA SELECICONADA";
            }
        }
        else
        {
            HiddenField_ESTADO_PROCESO.Value = AccionesProceso.Paso2RegistrarResultadosExamenes.ToString();

            Boolean TIENE_CUENTA = CargarUbicacionTrabajadorTemporal(ID_REQUERIMIENTO, ID_SOLICITUD);

            Cargar_GridView_EXAMENES_REALIZADOS_desde_tabla(tablaOrdenes);

            Cargar_forma_Pago(filaSolIngreso, TIENE_CUENTA);

            Mostrar(Acciones.ResultadosExamenes);

            if (filaSolIngreso["PAR_FORMA_PAGO_VARIABLE"].ToString().Trim() == "1")
            {
                if (TIENE_CUENTA == false)
                {
                    Button_Imprimir_Carta.Visible = true;
                }
                else
                {
                    Button_Imprimir_Carta.Visible = false;
                }
            }
            else
            {
                Button_Imprimir_Carta.Visible = false;
            }

            Panel_INFO_ADICIONAL_MODULO.Visible = false;
            Label_INFO_ADICIONAL_MODULO.Text = "";

            Button_DescartarPorExamenes.Visible = true;
        }
    }
    private void Cargar(Decimal ID_REQUERIMIENTO, Decimal ID_SOLICITUD, Decimal ID_EMPRESA, Decimal ID_OCUPACION)
    {
        HiddenField_ID_REQUERIMIENTO.Value = ID_REQUERIMIENTO.ToString();
        HiddenField_ID_SOLICITUD.Value = ID_SOLICITUD.ToString();
        HiddenField_ID_EMPRESA.Value = ID_EMPRESA.ToString();
        HiddenField_ID_OCUPACION.Value = ID_OCUPACION.ToString();

        radicacionHojasDeVida _solIngreso = new radicacionHojasDeVida(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        _solIngreso.ActualizarEstadoProcesoRegSolicitudesIngreso(Convert.ToInt32(ID_REQUERIMIENTO), Convert.ToInt32(ID_SOLICITUD), "EN AFILIACIONES", Session["USU_LOG"].ToString());

        requisicion _requisicion = new requisicion(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable _tablaReq = _requisicion.ObtenerComRequerimientoPorIdRequerimiento(ID_REQUERIMIENTO);
        DataRow _filaReq = _tablaReq.Rows[0];
        String CIUDAD_REQ = _filaReq["CIUDAD_REQ"].ToString().Trim();
        HiddenField_CIUDAD_REQ.Value = CIUDAD_REQ;

        perfil _PERFIL = new perfil(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaPerfil = _PERFIL.ObtenerPorRegistro(Convert.ToInt32(_filaReq["REGISTRO_PERFIL"]));
        DataRow filaPerfil = tablaPerfil.Rows[0];
        Decimal ID_PERFIL = Convert.ToDecimal(_filaReq["REGISTRO_PERFIL"]);
        ID_OCUPACION = Convert.ToDecimal(filaPerfil["ID_OCUPACION"]);
        if (!string.IsNullOrEmpty(filaPerfil["CODIGO"].ToString())) Label_RIESGO.Text = filaPerfil["CODIGO"].ToString();
        HiddenField_ID_PERFIL.Value = ID_PERFIL.ToString();
        HiddenField_ID_OCUPACION.Value = ID_OCUPACION.ToString();

        DataTable tablasol = _solIngreso.ObtenerRegSolicitudesingresoPorIdSolicitud(Convert.ToInt32(ID_SOLICITUD));
        DataRow filaSolIngreso = tablasol.Rows[0];
        String NOMBRE_TRABAJADOR = filaSolIngreso["NOMBRES"].ToString().Trim() + " " + filaSolIngreso["APELLIDOS"].ToString().Trim();
        String NUM_DOC_IDENTIDAD_COMPLETO = filaSolIngreso["TIP_DOC_IDENTIDAD"].ToString().Trim() + " " + filaSolIngreso["NUM_DOC_IDENTIDAD"].ToString().Trim();
        String NUM_DOC_IDENTIDAD = filaSolIngreso["NUM_DOC_IDENTIDAD"].ToString().Trim();
        HiddenField_NUM_DOC_IDENTIDAD.Value = NUM_DOC_IDENTIDAD;

        cliente _empresa = new cliente(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaEmpresa = _empresa.ObtenerEmpresaConIdEmpresa(ID_EMPRESA);
        DataRow filaEmpresa = tablaEmpresa.Rows[0];
        String RAZ_SOCIAL = filaEmpresa["RAZ_SOCIAL"].ToString().Trim();
        HiddenField_ID_EMPRESA.Value = filaEmpresa["ID_EMPRESA"].ToString().Trim();

        cargo _cargo = new cargo(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaOcupacion = _cargo.ObtenerOcupacionPorIdOcupacion(ID_OCUPACION);
        DataRow filaOcupacion = tablaOcupacion.Rows[0];
        String CARGO = filaOcupacion["NOM_OCUPACION"].ToString().Trim();

        HiddenField_persona.Value = ID_SOLICITUD.ToString() + "," + ID_REQUERIMIENTO.ToString() + "," + ID_OCUPACION.ToString() + "," + ID_EMPRESA.ToString() + "," + NUM_DOC_IDENTIDAD.Trim();

        cargarDatosTrabajador(NOMBRE_TRABAJADOR, NUM_DOC_IDENTIDAD_COMPLETO, RAZ_SOCIAL, CARGO, ID_OCUPACION.ToString());

        ConRegContratoTemporal _contratoTemporal = new ConRegContratoTemporal(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaCOntratoTemporal = _contratoTemporal.ObtenerConRegContratosTemporalPorIdRequerimientoIdSolicitud(ID_REQUERIMIENTO, ID_SOLICITUD);

        Panel_UbicacionTrabajador.Visible = true;

        if (tablaCOntratoTemporal.Rows.Count <= 0)
        {
            if (_contratoTemporal.MensajeError != null)
            {
                Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, _contratoTemporal.MensajeError, Proceso.Error);
            }

            CargarSeccionUbicacionTrabajador();

            Panel_INFO_ADICIONAL_MODULO.Visible = true;
            Label_INFO_ADICIONAL_MODULO.Text = "SELECCIONE LA UBICACIÓN DONDE LABORARÁ EL TRABAJADOR, PARA PODER CONTINUAR CON LAS AFILIACIONES";
        }
        else
        {
            DataRow filaContratoTemporal = tablaCOntratoTemporal.Rows[0];
            CargarUbicacionTrabajadorSegunTemporal(filaContratoTemporal);
            Panel_INFO_ADICIONAL_MODULO.Visible = true;
            Label_INFO_ADICIONAL_MODULO.Text = "DILIGENCIAR AFILIACIONES DEL TRABAJADOR";
        }

        limpiar_DropDownList_ENTIDAD_ARP();
        limpiar_DropDownList_ENTIDAD_EPS();
        limpiar_DropDownList_ENTIDAD_Caja();
        limpiar_DropDownList(DropDownList_DepartamentoCajaC);
        limpiar_DropDownList(DropDownList_CiudadCajaC);
        limpiar_DropDownList_AFP();

        cargar_DropDownList_pensionado();

        if (HiddenField_SELECCION_ITEM_CON_CONDICIONES_CONTRATACION.Value == "S")
        {
            Panel_ARP.Visible = true;
            Panel_EPS.Visible = true;
            Panel_CCF.Visible = true;
            Panel_AFP.Visible = true;

            cargar_DropDownList_ENTIDAD_AFP();
            cargar_DropDownList_ENTIDAD_ARP();
            cargar_DropDownList_ENTIDAD_CAJA();
            cargar_DropDownList_ENTIDAD_EPS();
        }

        cargar_GridView_AFP(ID_SOLICITUD.ToString(), ID_REQUERIMIENTO.ToString());
        cargar_GridView_ARP(ID_SOLICITUD.ToString(), ID_REQUERIMIENTO.ToString());
        cargar_GridView_CCF(ID_SOLICITUD.ToString(), ID_REQUERIMIENTO.ToString());
        cargar_GridView_EPS(ID_SOLICITUD.ToString(), ID_REQUERIMIENTO.ToString());

        TextBox_ARP_OBSERVACIONES.Text = "";
        TextBox_COMENTARIOS_AFP.Text = "";
        TextBox_COMENTARIOS_EPS.Text = "";
        TextBox_observaciones_Caja.Text = "";

        Panel_Registro_CCF.Visible = true;
        Panel_registro_EPS.Visible = true;
        Panel_registros_afp.Visible = true;
        Panel_registros_ARP.Visible = true;

        if (GridView_ARP.Rows.Count > 0)
        {
            Panel_registros_ARP.Visible = false;
        }
        if (GridView_AFP.Rows.Count > 0)
        {
            Panel_registros_afp.Visible = false;
        }
        if (GridView_CAJA.Rows.Count > 0)
        {
            Panel_Registro_CCF.Visible = false;
        }
        if (GridView_EPS.Rows.Count > 0)
        {
            Panel_registro_EPS.Visible = false;
        }
    }
    protected void Button_Guardar_Click(object sender, EventArgs e)
    {
        EntregaServicioComplementario _entregas = new EntregaServicioComplementario(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        String idEntrega = null;
        String talla = null;
        DropDownList dropTalla;
        TextBox CantidadaEntregar;
        DataTable tablaConfigurados = new DataTable();
        tablaConfigurados.Columns.Add("ID_PRODUCTO");
        tablaConfigurados.Columns.Add("CANTIDAD_A_ENTREGAR");
        tablaConfigurados.Columns.Add("TALLA");

        DataTable tablaLotes = new DataTable();
        tablaLotes.Columns.Add("ID_PRODUCTO");
        tablaLotes.Columns.Add("ID_LOTE");
        tablaLotes.Columns.Add("TALLA");
        tablaLotes.Columns.Add("CONTENIDO_LOTE");
        tablaLotes.Columns.Add("CANTIDAD_CONFIGURADA");

        String[] datos = HiddenField_persona.Value.Split(',');
        int empleado = Convert.ToInt32(datos[6].ToString());
        int id_producto;
        int id_lote;
        int ContenidoLote;
        int cantidadConf;
        DateTime fecha = System.DateTime.Today;

        for (int i = 0; i < GridView_Entregas_Configurados.Rows.Count; i++)
        {
            id_producto = Convert.ToInt32(GridView_Entregas_Configurados.DataKeys[i].Values["ID_PRODUCTO"].ToString());
            dropTalla = GridView_Entregas_Configurados.Rows[i].FindControl("DropDownList_Talla") as DropDownList;
            CantidadaEntregar = GridView_Entregas_Configurados.Rows[i].FindControl("TextBox_Cantidad") as TextBox;

            DataRow productosConfigurados = tablaConfigurados.NewRow();

            productosConfigurados[0] = id_producto;
            productosConfigurados[1] = CantidadaEntregar.Text;
            productosConfigurados[2] = dropTalla.SelectedValue;

            tablaConfigurados.Rows.Add(productosConfigurados);

        }
        for (int i = 0; i < GridView_lotes.Rows.Count; i++)
        {
            id_producto = Convert.ToInt32(GridView_lotes.DataKeys[i].Values["ID_PRODUCTO"].ToString());
            id_lote = Convert.ToInt32(GridView_lotes.DataKeys[i].Values["ID_LOTE"].ToString());
            talla = GridView_lotes.Rows[i].Cells[3].Text;
            ContenidoLote = Convert.ToInt32(GridView_lotes.Rows[i].Cells[2].Text);
            cantidadConf = Convert.ToInt32(GridView_lotes.Rows[i].Cells[4].Text);

            DataRow lotesDisponibles = tablaLotes.NewRow();

            lotesDisponibles[0] = id_producto;
            lotesDisponibles[1] = id_lote;
            lotesDisponibles[2] = talla;
            lotesDisponibles[3] = ContenidoLote;
            lotesDisponibles[4] = cantidadConf;

            tablaLotes.Rows.Add(lotesDisponibles);
        }
        if (HiddenField_idBodega.Value.Equals(""))
        {
            Label_MENSAJE_Entregas.Text = "ADVERTENCIA: No se tiene bodega. Verifique con el administrador";
            configurarMensajes(true, System.Drawing.Color.Red, Label_MENSAJE_Entregas, Panel_MENSAJE_Entregas);
        }
        else
        {

            int idbodega = Convert.ToInt32(HiddenField_idBodega.Value);
            String faltantes = HiddenField_Faltantes.Value;
            idEntrega = _entregas.adicionarEntregas(empleado, fecha, idbodega, tablaConfigurados, tablaLotes, datos, faltantes);

            HiddenField_idEntrega.Value = idEntrega;

            if (idEntrega.Equals(""))
            {
                Label_MENSAJE_Entregas.Text = "ADVERTENCIA: No se almaceno correctamente la entrega. Verifique por favor" + _entregas.MensajeError;
                configurarMensajes(true, System.Drawing.Color.Red, Label_MENSAJE_Entregas, Panel_MENSAJE_Entregas);
            }
            else
            {
                Panel_Entregas_configurados.Enabled = false;
                registroContrato _contrato = new registroContrato(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                SecureQueryString QueryStringSeguro;
                tools _tools = new tools();
                QueryStringSeguro = new SecureQueryString(_tools.byteParaQueryStringSeguro(), Request["data"]);
                String persona = QueryStringSeguro["persona"].ToString();
                String[] datosEmpleado = persona.Split(',');
                radicacionHojasDeVida _solIngreso = new radicacionHojasDeVida(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

                _solIngreso.ActualizarEstadoProcesoRegSolicitudesIngreso(Convert.ToInt32(datosEmpleado[1]), Convert.ToInt32(datosEmpleado[0]), "CONTRATADO", Session["USU_LOG"].ToString());

                Label_MENSAJE_Entregas.Text = "La entrega se almacenó correctamente. Número entrega: " + idEntrega;
                configurarMensajes(true, System.Drawing.Color.Green, Label_MENSAJE_Entregas, Panel_MENSAJE_Entregas);
                activarEmpleado();
            }
        }
    }
        public Boolean DescartarConRegContratosTemporal(Decimal ID_REQUERIMIENTO,
            Decimal ID_SOLICITUD,
            String OBSERVACIONES)
        {
            Boolean correcto = true;

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

            try
            {
                if (ActualizarDescarte(ID_REQUERIMIENTO, ID_SOLICITUD, OBSERVACIONES, conexion) == false)
                {
                    correcto = false;
                    conexion.DeshacerTransaccion();
                }
                else
                {
                    radicacionHojasDeVida _rad = new radicacionHojasDeVida(Empresa, Usuario);

                    if (_rad.ActualizarEstadoProcesoRegSolicitudesIngreso(Convert.ToInt32(ID_REQUERIMIENTO), Convert.ToInt32(ID_SOLICITUD), "EN DESCARTE", Usuario, conexion) == false)
                    {
                        correcto = false;
                        conexion.DeshacerTransaccion();
                    }
                }

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

            return correcto;
        }
    protected void Button_AUDITADO_Click(object sender, EventArgs e)
    {
        int ID_SOLICITUD = Convert.ToInt32(TextBox_ID_SOLICITUD.Text);
        int ID_REQUERIMIENTO = Convert.ToInt32(HiddenField_ID_REQUERIMIENTO.Value);
        Decimal ID_CONTRATO = Convert.ToDecimal(HiddenField_ID_CONTRATO.Value);

        radicacionHojasDeVida _radicacionHojasDeVida = new radicacionHojasDeVida(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        if (_radicacionHojasDeVida.ActualizarEstadoProcesoRegSolicitudesIngreso(ID_REQUERIMIENTO, ID_SOLICITUD, "AUDITADO", Session["USU_LOG"].ToString()) == false)
        {
            Informar(Panel_MENSAJES, Label_MENSAJE, _radicacionHojasDeVida.MensajeError, Proceso.Error);
        }
        else
        {
            Ocultar(Acciones.Inicio);
            Mostrar(Acciones.Inicio);
            Cargar(Acciones.Inicio);

            Informar(Panel_MENSAJES, Label_MENSAJE, "El contrato número: " + ID_CONTRATO.ToString() + " fue auditado correctamente. ", Proceso.Correcto);
        }
    }