private void cargar_DropDownList_SERVICIO_centro_c(Decimal ID_CENTRO_C)
    {
        DropDownList_servicio.Items.Clear();

        condicionComercial _condicionComercial = new condicionComercial(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaServicios = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCentroC(ID_CENTRO_C);

        System.Web.UI.WebControls.ListItem item = new System.Web.UI.WebControls.ListItem("Seleccione...", "");
        DropDownList_servicio.Items.Add(item);

        foreach (DataRow fila in tablaServicios.Rows)
        {
            item = new System.Web.UI.WebControls.ListItem(fila["NOMBRE_SERVICIO"].ToString(), fila["ID_SERVICIO"].ToString());
            DropDownList_servicio.Items.Add(item);
        }

        DropDownList_servicio.DataBind();
    }
    private void controlesParaNuevaCondicionEconomica()
    {
        capturarVariablesGlogales();

        if ((String.IsNullOrEmpty(ID_CIUDAD) == true) && (ID_CENTRO_C == 0) && (ID_SUB_C == 0))
        {
            configurarBotonesDeAccion(false, true, true, false);

            configurarMensajes(true, System.Drawing.Color.Red);
            Label_MENSAJE.Text = "ADVERTENCIA: No se encontraron registros de condiciones económicas para mostrar, por favor digitelas y guarde.";

            Panel_CONTROL_REGISTRO.Visible = false;

            Panel_COD_CONDICIONES.Visible = false;

            CheckBox_FACTURA_NOMINA.Checked = false;

            cargar_DropDownList_MOD_SOPORTE();
            cargar_DropDownList_MOD_FACTURA();

            TextBox_AD_NOM.Text = "0";
            CheckBox_SOLO_DEV.Checked = false;
            CheckBox_APL_MTZ.Checked = false;

            TextBox_AD_PENSION.Text = "0";
            TextBox_AD_SALUD.Text = "0";
            TextBox_AD_RIESGOS.Text = "0";
            TextBox_AD_APO_SENA.Text = "0";
            TextBox_AD_APO_ICBF.Text = "0";
            TextBox_AD_APO_CAJA.Text = "0";
            TextBox_AD_VACACIONES.Text = "0";
            TextBox_AD_CESANTIA.Text = "0";
            TextBox_AD_INT_CES.Text = "0";
            TextBox_AD_PRIMA.Text = "0";
            TextBox_AD_SEG_VID.Text = "0";

            CheckBox_SUB_PENSION.Checked = false;
            CheckBox_SUB_SALUD.Checked = false;
            CheckBox_SUB_RIESGO.Checked = false;
            CheckBox_SUB_SENA.Checked = false;
            CheckBox_SUB_ICBF.Checked = false;
            CheckBox_SUB_CAJA.Checked = false;
            CheckBox_SUB_VACACIONES.Checked = false;
            CheckBox_SUB_CESANTIAS.Checked = false;
            CheckBox_SUB_INT_CES.Checked = false;
            CheckBox_SUB_PRIMA.Checked = false;
            CheckBox_SUB_SEG_VID.Checked = false;

            CheckBox_RET_VAC.Checked = false;
            CheckBox_RET_CES.Checked = false;
            CheckBox_RET_INT_CES.Checked = false;
            CheckBox_RET_PRIM.Checked = false;

            TextBox_DIAS_VNC.Text = "";

            cargar_DropDownList_REGIMEN();

            TextBox_OBS_FACT.Text = "";

            habilitarSeccionServiciosParaDatosNuevos(true);

            mostrar_modulo_copia_condiciones_grupoempresarial();
        }
        else
        {
            Decimal ID_EMPRESA_1 = ID_EMPRESA;
            String ID_CIUDAD_1 = null;
            Decimal ID_CENTRO_C_1 = 0;
            Decimal ID_SUB_C_1 = 0;

            Panel_FORMULARIO.Visible = true;
            Panel_FORMULARIO.Enabled = true;

            Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = false;

            configurarMensajes(false, System.Drawing.Color.Green);

            condicionComercial _condicionComercial = new condicionComercial(Session["idEmpresa"].ToString(),Session["USU_LOG"].ToString());

            if (ID_SUB_C != 0)
            {
                subCentroCosto _subCentroCosto = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                DataTable tablainfoSubCentro = _subCentroCosto.ObtenerSubCentrosDeCostoPorIdSubCosto(ID_SUB_C);
                DataRow infoSubCentro = tablainfoSubCentro.Rows[0];

                ID_EMPRESA_1 = ID_EMPRESA;
                ID_CIUDAD_1 = null;
                ID_CENTRO_C_1 = Convert.ToDecimal(infoSubCentro["ID_CENTRO_C"]);
                ID_SUB_C_1 = 0;
            }
            else
            {
                if (ID_CENTRO_C != 0)
                {
                    centroCosto _centroCosto = new centroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                    DataTable tablaCentroCosto = _centroCosto.ObtenerCentrosDeCostoPorIdCentroCosto(ID_CENTRO_C);
                    DataRow infoCentroCosto = tablaCentroCosto.Rows[0];

                    ID_EMPRESA_1 = ID_EMPRESA;
                    ID_CIUDAD_1 = infoCentroCosto["ID_CIUDAD"].ToString().Trim();
                    ID_CENTRO_C_1 = 0;
                    ID_SUB_C_1 = 0;
                }
            }

            DataTable tablaCondicionesHeredadas = _condicionComercial.ObtenerCondicionesEconomicasPorId(ID_EMPRESA_1, ID_CIUDAD_1, ID_CENTRO_C_1, ID_SUB_C_1);

            if (tablaCondicionesHeredadas.Rows.Count <= 0)
            {
                configurarBotonesDeAccion(false, true, true, true);

                configurarMensajes(true, System.Drawing.Color.Red);
                Label_MENSAJE.Text = "ADVERTENCIA: No se encontraron registros de condiciones económicas para mostrar y no se pudieron heredar condiciones económicas de la entidad anterior a la seleccionada,  por favor digite las nuevas condiciones y guarde.";

                Panel_CONTROL_REGISTRO.Visible = false;

                Panel_COD_CONDICIONES.Visible = false;

                CheckBox_FACTURA_NOMINA.Checked = false;

                cargar_DropDownList_MOD_SOPORTE();
                cargar_DropDownList_MOD_FACTURA();

                TextBox_AD_NOM.Text = "0,00";
                CheckBox_SOLO_DEV.Checked = false;
                CheckBox_APL_MTZ.Checked = false;

                TextBox_AD_PENSION.Text = "0,00";
                TextBox_AD_SALUD.Text = "0,00";
                TextBox_AD_RIESGOS.Text = "0,00";
                TextBox_AD_APO_SENA.Text = "0,00";
                TextBox_AD_APO_ICBF.Text = "0,00";
                TextBox_AD_APO_CAJA.Text = "0,00";
                TextBox_AD_VACACIONES.Text = "0,00";
                TextBox_AD_CESANTIA.Text = "0,00";
                TextBox_AD_INT_CES.Text = "0,00";
                TextBox_AD_PRIMA.Text = "0,00";
                TextBox_AD_SEG_VID.Text = "0,00";

                CheckBox_SUB_PENSION.Checked = false;
                CheckBox_SUB_SALUD.Checked = false;
                CheckBox_SUB_RIESGO.Checked = false;
                CheckBox_SUB_SENA.Checked = false;
                CheckBox_SUB_ICBF.Checked = false;
                CheckBox_SUB_CAJA.Checked = false;
                CheckBox_SUB_VACACIONES.Checked = false;
                CheckBox_SUB_CESANTIAS.Checked = false;
                CheckBox_SUB_INT_CES.Checked = false;
                CheckBox_SUB_PRIMA.Checked = false;
                CheckBox_SUB_SEG_VID.Checked = false;

                CheckBox_RET_VAC.Checked = false;
                CheckBox_RET_CES.Checked = false;
                CheckBox_RET_INT_CES.Checked = false;
                CheckBox_RET_PRIM.Checked = false;

                TextBox_DIAS_VNC.Text = "";

                cargar_DropDownList_REGIMEN();

                TextBox_OBS_FACT.Text = "";

                habilitarSeccionServiciosParaDatosNuevos(true);
            }
            else
            {
                DataRow infoCondicionesComerciales = tablaCondicionesHeredadas.Rows[0];

                configurarMensajes(true, System.Drawing.Color.Red);
                Label_MENSAJE.Text = "ADVERTENCIA: No se encontraron registros de condiciones económicas para mostrar, se heredaron las condiciones económicas de la entidad anterior a la seleccionada, por favor realice los cambios necesarios y guarde la información.";

                configurarBotonesDeAccion(false, true, true, true);

                Panel_CONTROL_REGISTRO.Visible = false;

                Panel_COD_CONDICIONES.Visible = false;

                cargar_campos_condiciones_comerciales(infoCondicionesComerciales);

                TextBox_USU_CRE.Text = "";
                TextBox_FCH_CRE.Text = "";
                TextBox_HOR_CRE.Text = "";
                TextBox_USU_MOD.Text = "";
                TextBox_FCH_MOD.Text = "";
                TextBox_HOR_MOD.Text = "";

                TextBox_COD_CONDICION.Text = "";

                DataTable tablaServiciosHeredados;

                if (ID_SUB_C != 0)
                {
                    tablaServiciosHeredados = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCentroC(ID_CENTRO_C_1);
                }
                else
                {
                    if (ID_CENTRO_C != 0)
                    {
                        tablaServiciosHeredados = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCiudad(ID_CIUDAD_1, ID_EMPRESA_1);
                    }
                    else
                    {
                        tablaServiciosHeredados = _condicionComercial.ObtenerServiciosPorEmpresaPorIdEmpresa(ID_EMPRESA_1);
                    }
                }

                if (tablaServiciosHeredados.Rows.Count <= 0)
                {
                    habilitarSeccionServiciosParaDatosNuevos(true);
                }
                else
                {

                    List<servicio> listaServicios = new List<servicio>();
                    Session.Remove("listaServicios_" + ID_EMPRESA.ToString());
                    Session.Add("listaServicios_" + ID_EMPRESA.ToString(), listaServicios);
                    List<detalleServicio> listaDetallesServicio = new List<detalleServicio>();
                    Session.Remove("listaDetallesServicio_" + ID_EMPRESA.ToString());
                    Session.Add("listaDetallesServicio_" + ID_EMPRESA.ToString(), listaDetallesServicio);

                    cargarInformacionServiciosComplementariosDeUnaEntidad(tablaServiciosHeredados, true, true);
                }

                if ((String.IsNullOrEmpty(ID_CIUDAD) == true) && (ID_CENTRO_C == 0) && (ID_SUB_C == 0))
                {
                    Panel_ESTRUCTURA_CENTRO_COSTOS.Visible = true;
                    cargarEstructuraDeCC();

                    configurarMensajesCC(true, System.Drawing.Color.Red);
                    Label_MENSAJE_CC.Text = "Por favor seleccionar una ciudad de la lista de cobertura.";

                    configurarMensajesSUBCC(true, System.Drawing.Color.Red);
                    Label_MENSAJE_SUB_CC.Text = "Por favor seleccionar un centro de costo de la lista de centros de costo.";
                }
                else
                {
                    Panel_ESTRUCTURA_CENTRO_COSTOS.Visible = false;
                }
            }
        }
    }
    private void cargarInfoCondiciones(Boolean bModificar)
    {
        capturarVariablesGlogales();

        if (ID_SUB_C != 0)
        {
            subCentroCosto _subCentroCostoMODULO = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
            DataTable tablaInfoSubCentro = _subCentroCostoMODULO.ObtenerSubCentrosDeCostoPorIdSubCosto(ID_SUB_C);
            DataRow filaTablaInfoSubCentro = tablaInfoSubCentro.Rows[0];

            configurarInfoAdicionalModulo(true, filaTablaInfoSubCentro["NOM_SUB_C"].ToString());

            Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = false;
        }
        else
        {
            if (ID_CENTRO_C != 0)
            {
                centroCosto _centroCostoMODULO = new centroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                DataTable tablaInfoCC = _centroCostoMODULO.ObtenerCentrosDeCostoPorIdCentroCosto(ID_CENTRO_C);
                DataRow filaTablaInfoCC = tablaInfoCC.Rows[0];

                configurarInfoAdicionalModulo(true, filaTablaInfoCC["NOM_CC"].ToString());

                Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = false;
            }
            else
            {
                if ((String.IsNullOrEmpty(ID_CIUDAD) == false) && (ID_EMPRESA != 0))
                {
                    cobertura _coberturaMODULO = new cobertura(Session["idEmpresa"].ToString());
                    DataTable tablaInfoCiudad = _coberturaMODULO.obtenerNombreCiudadPorIdCiudad(ID_CIUDAD);
                    DataRow filaTablaInfoCiudad = tablaInfoCiudad.Rows[0];

                    configurarInfoAdicionalModulo(true, filaTablaInfoCiudad["NOMBRE"].ToString());

                    Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = false;
                }
                else
                {
                    cliente _clienteMODULO = new cliente(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                    DataTable tablaInfoCliente = _clienteMODULO.ObtenerEmpresaConIdEmpresa(ID_EMPRESA);
                    DataRow filaTablaInfoCliente = tablaInfoCliente.Rows[0];

                    configurarInfoAdicionalModulo(true, filaTablaInfoCliente["RAZ_SOCIAL"].ToString());
                    Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = true;
                }
            }
        }

        condicionComercial _condicionComercial = new condicionComercial(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

        DataTable tablaCondiciones = _condicionComercial.ObtenerCondicionesEconomicasPorId(ID_EMPRESA, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C);
        if (tablaCondiciones.Rows.Count <= 0)
        {
            if (_condicionComercial.MensajeError != null)
            {
                if ((String.IsNullOrEmpty(ID_CIUDAD) == true) && (ID_CENTRO_C == 0) && (ID_SUB_C == 0))
                {
                    configurarBotonesDeAccion(false, false, false, false);
                }
                else
                {
                    configurarBotonesDeAccion(false, false, false, true);
                }

                Panel_FORMULARIO.Visible = false;

                Panel_SECCION_SERVICIOS.Visible = false;

                Panel_ESTRUCTURA_CENTRO_COSTOS.Visible = false;

                configurarMensajes(true, System.Drawing.Color.Red);
                Label_MENSAJE.Text = _condicionComercial.MensajeError;

                Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = false;
            }
            else
            {
                if ((String.IsNullOrEmpty(ID_CIUDAD) == true) && (ID_CENTRO_C == 0) && (ID_SUB_C == 0))
                {
                    configurarBotonesDeAccion(false, true, true, false);
                }
                else
                {
                    configurarBotonesDeAccion(false, true, true, true);
                }

                Panel_FORMULARIO.Visible = true;

                Panel_SECCION_SERVICIOS.Visible = false;

                Panel_ESTRUCTURA_CENTRO_COSTOS.Visible = true;

                controlesParaNuevaCondicionEconomica();

                if ((String.IsNullOrEmpty(ID_CIUDAD) == true) && (ID_CENTRO_C == 0) && (ID_SUB_C == 0))
                {
                    Panel_ESTRUCTURA_CENTRO_COSTOS.Visible = true;
                    cargarEstructuraDeCC();

                    configurarMensajesCC(true, System.Drawing.Color.Red);
                    Label_MENSAJE_CC.Text = "Por favor seleccionar una ciudad de la lista de cobertura.";

                    configurarMensajesSUBCC(true, System.Drawing.Color.Red);
                    Label_MENSAJE_SUB_CC.Text = "Por favor seleccionar un centro de costo de la lista de centros de costo.";
                }
                else
                {
                    Panel_ESTRUCTURA_CENTRO_COSTOS.Visible = false;
                }
            }
        }
        else
        {

            if (bModificar == true)
            {
                if ((String.IsNullOrEmpty(ID_CIUDAD) == true) && (ID_CENTRO_C == 0) && (ID_SUB_C == 0))
                {
                    configurarBotonesDeAccion(false, true, true, false);
                }
                else
                {
                    configurarBotonesDeAccion(false, true, true, true);
                }

                Panel_FORMULARIO.Enabled = true;

                Panel_CONTROL_REGISTRO.Visible = false;

                Panel_COD_CONDICIONES.Visible = false;

                Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = true;
                mostrar_modulo_copia_condiciones_grupoempresarial();

            }
            else
            {
                if ((String.IsNullOrEmpty(ID_CIUDAD) == true) && (ID_CENTRO_C == 0) && (ID_SUB_C == 0))
                {
                    configurarBotonesDeAccion(true, false, false, false);
                }
                else
                {
                    configurarBotonesDeAccion(true, false, false, true);
                }

                Panel_FORMULARIO.Enabled = false;

                Panel_CONTROL_REGISTRO.Visible = true;
                Panel_CONTROL_REGISTRO.Enabled = false;

                Panel_COD_CONDICIONES.Visible = true;
                Panel_COD_CONDICIONES.Enabled = false;

                Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = false;
            }

            Panel_FORMULARIO.Visible = true;

            configurarMensajes(false, System.Drawing.Color.Green);

            DataRow infoCondicionesComerciales = tablaCondiciones.Rows[0];

            cargar_campos_condiciones_comerciales(infoCondicionesComerciales);

            DataTable tablaServiciosDeLaEntidad;
            if (ID_SUB_C != 0)
            {
                tablaServiciosDeLaEntidad = _condicionComercial.ObtenerServiciosPorEmpresaPorIdSubC(ID_SUB_C);

                Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = false;
            }
            else
            {
                if (ID_CENTRO_C != 0)
                {
                    tablaServiciosDeLaEntidad = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCentroC(ID_CENTRO_C);

                    Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = false;
                }
                else
                {
                    if ((ID_EMPRESA != 0) && (String.IsNullOrEmpty(ID_CIUDAD) == false))
                    {
                        tablaServiciosDeLaEntidad = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCiudad(ID_CIUDAD, ID_EMPRESA);

                        Panel_COPIA_CONDICIONES_ECONOMICAS_GRUPO_EMPRESARIAL.Visible = false;
                    }
                    else
                    {
                        tablaServiciosDeLaEntidad = _condicionComercial.ObtenerServiciosPorEmpresaPorIdEmpresa(ID_EMPRESA);

                    }
                }
            }

            if (tablaServiciosDeLaEntidad.Rows.Count <= 0)
            {
                habilitarSeccionServiciosParaDatosNuevos(bModificar);
            }
            else
            {

                List<servicio> listaServicios = new List<servicio>();
                Session.Remove("listaServicios_" + ID_EMPRESA.ToString());
                Session.Add("listaServicios_" + ID_EMPRESA.ToString(), listaServicios);
                List<detalleServicio> listaDetallesServicio = new List<detalleServicio>();
                Session.Remove("listaDetallesServicio_" + ID_EMPRESA.ToString());
                Session.Add("listaDetallesServicio_" + ID_EMPRESA.ToString(), listaDetallesServicio);

                cargarInformacionServiciosComplementariosDeUnaEntidad(tablaServiciosDeLaEntidad, bModificar, false);
            }

            if ((String.IsNullOrEmpty(ID_CIUDAD) == true) && (ID_CENTRO_C == 0) && (ID_SUB_C == 0))
            {
                Panel_ESTRUCTURA_CENTRO_COSTOS.Visible = true;
                cargarEstructuraDeCC();

                configurarMensajesCC(true, System.Drawing.Color.Red);
                Label_MENSAJE_CC.Text = "Por favor seleccionar una ciudad de la lista de cobertura.";

                configurarMensajesSUBCC(true, System.Drawing.Color.Red);
                Label_MENSAJE_SUB_CC.Text = "Por favor seleccionar un centro de costo de la lista de centros de costo.";
            }
            else
            {
                Panel_ESTRUCTURA_CENTRO_COSTOS.Visible = false;
            }
        }
    }
    protected void Button_ADICIONAR_SERVICIO_COMPLEMENTARIO_Click(object sender, EventArgs e)
    {
        tools _tools = new tools();
        SecureQueryString QueryStringSeguro;
        QueryStringSeguro = new SecureQueryString(_tools.byteParaQueryStringSeguro(), Request["data"]);

        Boolean verificador = true;

        if (DropDownList_CONFIGURACION.SelectedValue == "AIU")
        {
            if (Convert.ToDecimal(TextBox_SER_ADMON.Text) <= 0)
            {
                verificador = false;
                configurarMensajesServicioComplementario(true, System.Drawing.Color.Red);
                Label_MENSAJE_SERVICIO_COMPLEMENTARIO.Text = "(Configuración: AIU), Debe digitar el PORCENTAJE DE ADMINISTRACIÓN para poder continuar.";
            }
        }
        else
        {
            if (DropDownList_CONFIGURACION.SelectedValue == "AIU_PREFERENCIAL")
            {
                if (Convert.ToDecimal(TextBox_SER_ADMON.Text) <= 0)
                {
                    verificador = false;
                    configurarMensajesServicioComplementario(true, System.Drawing.Color.Red);
                    Label_MENSAJE_SERVICIO_COMPLEMENTARIO.Text = "(Configuración: AIU PREFERENCIAL), Debe digitar el PORCENTAJE DE ADMINISTRACIÓN para poder continuar.";
                }
            }
            else
            {
                if (DropDownList_CONFIGURACION.SelectedValue == "TARIFA")
                {
                    if (Convert.ToDecimal(TextBox_SER_VALOR.Text) <= 0)
                    {
                        verificador = false;
                        configurarMensajesServicioComplementario(true, System.Drawing.Color.Red);
                        Label_MENSAJE_SERVICIO_COMPLEMENTARIO.Text = "(Configuración: TARIFA), Debe digitar el valorde la TARIFA para poder continuar.";
                    }
                }
                else
                {
                    if (DropDownList_CONFIGURACION.SelectedValue == "IVA")
                    {
                        if (Convert.ToDecimal(TextBox_SER_IVA.Text) <= 0)
                        {
                            verificador = false;
                            configurarMensajesServicioComplementario(true, System.Drawing.Color.Red);
                            Label_MENSAJE_SERVICIO_COMPLEMENTARIO.Text = "(Configuración: IVA), Debe digitar el valorde del IVA para poder continuar.";
                        }
                    }
                }
            }
        }

        if (verificador == true)
        {
            Decimal ID_EMPRESA = Convert.ToDecimal(QueryStringSeguro["reg"]);
            String ID_CIUDAD = null;
            Decimal ID_CENTRO_C = 0;
            Decimal ID_SUB_C = 0;

            try
            {
                ID_CIUDAD = QueryStringSeguro["codCiudad"].ToString();
            }
            catch
            {
                ID_CIUDAD = null;
            }

            try
            {
                ID_CENTRO_C = Convert.ToDecimal(QueryStringSeguro["codCC"]);
            }
            catch
            {
                ID_CENTRO_C = 0;
            }

            try
            {
                ID_SUB_C = Convert.ToDecimal(QueryStringSeguro["codSUBCC"]);
            }
            catch
            {
                ID_SUB_C = 0;
            }

            configurarMensajesServicioComplementario(false, System.Drawing.Color.Green);

            DataTable tablaServiciosEnGrid = obtenerDataTableDeGridViewServiciosComplementarios();

            foreach (DataRow fila in tablaServiciosEnGrid.Rows)
            {
                if (fila["ID_SERVICIO_COMPLEMENTARIO"].ToString() == DropDownList_SERVICIOS_COMPLEMENTARIOS.SelectedValue)
                {
                    verificador = false;
                }
            }

            if (verificador == true)
            {
                List<servicio> listaServicio = capturarListaServiciosDesdeSession();
                List<detalleServicio> listaDetalles = capturarListaDetallesServicioDesdeSession();
                detalleServicio _detalleServicioParaLista;

                DataRow filaServicioAAdicionar = tablaServiciosEnGrid.NewRow();
                _detalleServicioParaLista = new detalleServicio(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

                condicionComercial _condicionComercial = new condicionComercial(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

                String ID_SERVICIO = listaServicio[0].ID_SERVICIO.ToString();
                String ID_SERVICIO_POR_EMPRESA = listaServicio[0].ID_SERVICIO_POR_EMPRESA.ToString();
                String NOMBRE_SERVICIO = listaServicio[0].NOMBRE_SERVICIO;

                DataTable tablaServiciosEspecificos;
                if (ID_SUB_C != 0)
                {
                    tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdSubC(ID_SUB_C);
                }
                else
                {
                    if (ID_CENTRO_C != 0)
                    {
                        tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCentroC(ID_CENTRO_C);
                    }
                    else
                    {
                        if ((ID_EMPRESA != 0) && (String.IsNullOrEmpty(ID_CIUDAD) == false))
                        {
                            tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCiudad(ID_CIUDAD, ID_EMPRESA);
                        }
                        else
                        {
                            tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdEmpresa(ID_EMPRESA);
                        }
                    }
                }

                filaServicioAAdicionar["ID_SERVICIO"] = ID_SERVICIO;
                filaServicioAAdicionar["ID_SERVICIO_COMPLEMENTARIO"] = DropDownList_SERVICIOS_COMPLEMENTARIOS.SelectedValue;
                filaServicioAAdicionar["NOMBRE_SERVICIO_COMPLEMENTARIO"] = DropDownList_SERVICIOS_COMPLEMENTARIOS.SelectedItem.Text;

                if (String.IsNullOrEmpty(TextBox_SER_ADMON.Text) == false)
                {
                    filaServicioAAdicionar["AIU"] = TextBox_SER_ADMON.Text;
                }
                else
                {
                    filaServicioAAdicionar["AIU"] = 0;
                }

                if (String.IsNullOrEmpty(TextBox_SER_IVA.Text) == false)
                {
                    filaServicioAAdicionar["IVA"] = TextBox_SER_IVA.Text;
                }
                else
                {
                    filaServicioAAdicionar["IVA"] = 0;
                }

                if (String.IsNullOrEmpty(TextBox_SER_VALOR.Text) == false)
                {
                    filaServicioAAdicionar["VALOR"] = TextBox_SER_VALOR.Text;
                }
                else
                {
                    filaServicioAAdicionar["VALOR"] = 0;
                }

                _detalleServicioParaLista.ACCION = "INSERTAR";
                _detalleServicioParaLista.AIU = Convert.ToDecimal(filaServicioAAdicionar["AIU"]);
                _detalleServicioParaLista.ID_DETALLE_SERVICIO = 0;
                _detalleServicioParaLista.ID_SERVICIO = Convert.ToDecimal(ID_SERVICIO);
                _detalleServicioParaLista.ID_SERVICIO_COMPLEMENTARIO = Convert.ToDecimal(filaServicioAAdicionar["ID_SERVICIO_COMPLEMENTARIO"]);
                _detalleServicioParaLista.ID_SERVICIO_POR_EMPRESA = Convert.ToDecimal(ID_SERVICIO_POR_EMPRESA);
                _detalleServicioParaLista.IVA = Convert.ToDecimal(filaServicioAAdicionar["IVA"]);
                _detalleServicioParaLista.NOMBRE_SERVICIO = NOMBRE_SERVICIO;
                _detalleServicioParaLista.VALOR = Convert.ToDecimal(filaServicioAAdicionar["VALOR"]);

                listaDetalles.Add(_detalleServicioParaLista);
                tablaServiciosEnGrid.Rows.Add(filaServicioAAdicionar);

                DataView DV = new DataView(tablaServiciosEnGrid, "", "NOMBRE_SERVICIO_COMPLEMENTARIO", DataViewRowState.CurrentRows);
                GridView_SERVICIOS_INCLUIDOS.DataSource = DV;
                GridView_SERVICIOS_INCLUIDOS.DataBind();

                cargar_DropDownList_SERVICIOS_COMPLEMENTARIOS();
                cargar_DropDownList_CONFIGURACION();
                limpiarTextBoxServicioAdicionar();

                Session["listaDetallesServicio_" + ID_EMPRESA.ToString()] = listaDetalles;
            }
            else
            {
                configurarMensajesServicioComplementario(true, System.Drawing.Color.Red);
                Label_MENSAJE_SERVICIO_COMPLEMENTARIO.Text = "ADVERTENCIA: Servicio complementario que desea agregar ya se encuentra en el lista.<br>Para actualizar la información de un servicio complementario debe primero eliminarlo del la lista.";
            }
        }
    }
    private void controlesParaNuevaCondicionEconomica()
    {
        tools _tools = new tools();
        SecureQueryString QueryStringSeguro;
        QueryStringSeguro = new SecureQueryString(_tools.byteParaQueryStringSeguro(), Request["data"]);

        Decimal ID_EMPRESA = Convert.ToDecimal(QueryStringSeguro["reg"]);
        String ID_CIUDAD = null;
        Decimal ID_CENTRO_C = 0;
        Decimal ID_SUB_C = 0;

        try
        {
            ID_CIUDAD = QueryStringSeguro["codCiudad"].ToString();
        }
        catch
        {
            ID_CIUDAD = null;
        }

        try
        {
            ID_CENTRO_C = Convert.ToDecimal(QueryStringSeguro["codCC"]);
        }
        catch
        {
            ID_CENTRO_C = 0;
        }

        try
        {
            ID_SUB_C = Convert.ToDecimal(QueryStringSeguro["codSUBCC"]);
        }
        catch
        {
            ID_SUB_C = 0;
        }

        Decimal ID_EMPRESA_1 = ID_EMPRESA;
        String ID_CIUDAD_1 = null;
        Decimal ID_CENTRO_C_1 = 0;
        Decimal ID_SUB_C_1 = 0;

        if (ID_SUB_C != 0)
        {
            subCentroCosto _subCentroCosto = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
            DataTable tablainfoSubCentro = _subCentroCosto.ObtenerSubCentrosDeCostoPorIdSubCosto(ID_SUB_C);
            DataRow infoSubCentro = tablainfoSubCentro.Rows[0];

            ID_EMPRESA_1 = ID_EMPRESA;
            ID_CIUDAD_1 = null;
            ID_CENTRO_C_1 = Convert.ToDecimal(infoSubCentro["ID_CENTRO_C"]);
            ID_SUB_C_1 = 0;
        }
        else
        {
            if (ID_CENTRO_C != 0)
            {
                centroCosto _centroCosto = new centroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                DataTable tablaCentroCosto = _centroCosto.ObtenerCentrosDeCostoPorIdCentroCosto(ID_CENTRO_C);
                DataRow infoCentroCosto = tablaCentroCosto.Rows[0];

                ID_EMPRESA_1 = ID_EMPRESA;
                ID_CIUDAD_1 = infoCentroCosto["ID_CIUDAD"].ToString().Trim();
                ID_CENTRO_C_1 = 0;
                ID_SUB_C_1 = 0;
            }
        }

        condicionComercial _condicionComercial = new condicionComercial(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

        DataTable tablaCondicionesHeredadas = _condicionComercial.ObtenerCondicionesEconomicasPorId(ID_EMPRESA_1, ID_CIUDAD_1, ID_CENTRO_C_1, ID_SUB_C_1);

        if (tablaCondicionesHeredadas.Rows.Count <= 0)
        {
            if (_condicionComercial.MensajeError != null)
            {
                configurarBotonesDeAccion(false, false, false, true);

                Panel_FORMULARIO.Visible = false;

                configurarMensajes(true, System.Drawing.Color.Red);
                Label_MENSAJE.Text = _condicionComercial.MensajeError;
            }
            else
            {
                configurarBotonesDeAccion(false, true, true, true);

                Panel_FORMULARIO.Visible = true;

                Panel_SERVICIOS_COMPLEMENTARIOS.Visible = false;

                configurarMensajes(true, System.Drawing.Color.Red);
                Label_MENSAJE.Text = "ADVERTENCIA: No se encontraron registros de condiciones económicas para mostrar y la entidad anterior no tiene condiciones económicas para heredar, por favor digitelas y guarde.";

                Panel_CONTROL_REGISTRO.Visible = false;

                Panel_COD_CONDICIONES.Visible = false;

                CheckBox_FACTURA_NOMINA.Checked = false;

                cargar_DropDownList_MOD_SOPORTE();
                cargar_DropDownList_MOD_FACTURA();

                TextBox_AD_NOM.Text = "0";
                CheckBox_SOLO_DEV.Checked = false;

                TextBox_AD_PENSION.Text = "0";
                TextBox_AD_SALUD.Text = "0";
                TextBox_AD_RIESGOS.Text = "0";
                TextBox_AD_APO_SENA.Text = "0";
                TextBox_AD_APO_ICBF.Text = "0";
                TextBox_AD_APO_CAJA.Text = "0";
                TextBox_AD_VACACIONES.Text = "0";
                TextBox_AD_CESANTIA.Text = "0";
                TextBox_AD_INT_CES.Text = "0";
                TextBox_AD_PRIMA.Text = "0";
                TextBox_AD_SEG_VID.Text = "0";

                CheckBox_SUB_PENSION.Checked = false;
                CheckBox_SUB_SALUD.Checked = false;
                CheckBox_SUB_RIESGO.Checked = false;
                CheckBox_SUB_SENA.Checked = false;
                CheckBox_SUB_ICBF.Checked = false;
                CheckBox_SUB_CAJA.Checked = false;
                CheckBox_SUB_VACACIONES.Checked = false;
                CheckBox_SUB_CESANTIAS.Checked = false;
                CheckBox_SUB_INT_CES.Checked = false;
                CheckBox_SUB_PRIMA.Checked = false;
                CheckBox_SUB_SEG_VID.Checked = false;

                CheckBox_RET_VAC.Checked = false;
                CheckBox_RET_CES.Checked = false;
                CheckBox_RET_INT_CES.Checked = false;
                CheckBox_RET_PRIM.Checked = false;

                TextBox_DIAS_VNC.Text = "";

                cargar_DropDownList_REGIMEN();

                TextBox_OBS_FACT.Text = "";

                List<servicio> listaServicios = new List<servicio>();
                Session.Remove("listaServicios_" + ID_EMPRESA.ToString());
                Session.Add("listaServicios_" + ID_EMPRESA.ToString(), listaServicios);
                List<detalleServicio> listaDetallesServicio = new List<detalleServicio>();
                Session.Remove("listaDetallesServicio_" + ID_EMPRESA.ToString());
                Session.Add("listaDetallesServicio_" + ID_EMPRESA.ToString(), listaDetallesServicio);

                CheckBox_ACTIVAR_SERVICIO_COMPLEMENTARIO.Checked = false;
                cargarTextCheckActivarServicios(ID_EMPRESA, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C, "sin");
                Panel_SERVICIOS_COMPLEMENTARIOS.Visible = false;
            }
        }
        else
        {
            configurarBotonesDeAccion(false, true, true, true);

            Panel_FORMULARIO.Visible = true;
            Panel_FORMULARIO.Enabled = true;

            configurarMensajes(true, System.Drawing.Color.Red);
            Label_MENSAJE.Text = "ADVERTENCIA: No se encontraron registros de condiciones económicas para mostrar, pero se heredaron las condiciones económicas desde la entidad anterior, REALICE LOS CAMBIOS NECESARIOS Y GUARDE LA INFORMACIÓN.";

            DataRow infoCondicionesComerciales = tablaCondicionesHeredadas.Rows[0];

            Panel_CONTROL_REGISTRO.Visible = false;

            Panel_COD_CONDICIONES.Visible = false;

            if (infoCondicionesComerciales["FACTURA"].ToString().Trim() == "N")
            {
                CheckBox_FACTURA_NOMINA.Checked = false;
            }
            else
            {
                if (infoCondicionesComerciales["FACTURA"].ToString().Trim() == "S")
                {
                    CheckBox_FACTURA_NOMINA.Checked = true;
                }
            }

            cargar_DropDownList_MOD_SOPORTE();
            DropDownList_MOD_SOPORTE.SelectedValue = infoCondicionesComerciales["MOD_SOPORTE"].ToString().Trim();
            cargar_DropDownList_MOD_FACTURA();
            DropDownList_MOD_FACTURA.SelectedValue = infoCondicionesComerciales["MOD_FACTURA"].ToString().Trim();

            TextBox_AD_NOM.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_NOM"]));

            if (infoCondicionesComerciales["SOLO_DEV"].ToString().Trim() == "N")
            {
                CheckBox_SOLO_DEV.Checked = false;
            }
            else
            {
                if (infoCondicionesComerciales["SOLO_DEV"].ToString().Trim() == "S")
                {
                    CheckBox_SOLO_DEV.Checked = true;
                }
            }

            TextBox_AD_PENSION.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_PENSION"]));
            TextBox_AD_SALUD.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_SALUD"]));
            TextBox_AD_RIESGOS.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_RIESGOS"]));
            TextBox_AD_APO_SENA.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_APO_SENA"]));
            TextBox_AD_APO_ICBF.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_APO_ICBF"]));
            TextBox_AD_APO_CAJA.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_APO_CAJA"]));
            TextBox_AD_VACACIONES.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_VACACIONES"]));
            TextBox_AD_CESANTIA.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_CESANTIA"]));
            TextBox_AD_INT_CES.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_INT_CES"]));
            TextBox_AD_PRIMA.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_PRIMA"]));
            TextBox_AD_SEG_VID.Text = String.Format("{0:N2}", Convert.ToDecimal(infoCondicionesComerciales["AD_SEG_VID"]));

            cargarCheckBox(CheckBox_SUB_PENSION, infoCondicionesComerciales["SUB_PENSION"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_SALUD, infoCondicionesComerciales["SUB_SALUD"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_RIESGO, infoCondicionesComerciales["SUB_RIESGOS"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_SENA, infoCondicionesComerciales["SUB_SENA"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_ICBF, infoCondicionesComerciales["SUB_ICBF"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_CAJA, infoCondicionesComerciales["SUB_CAJA"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_VACACIONES, infoCondicionesComerciales["SUB_VACACIONES"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_CESANTIAS, infoCondicionesComerciales["SUB_CESANTIAS"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_INT_CES, infoCondicionesComerciales["SUB_INT_CES"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_PRIMA, infoCondicionesComerciales["SUB_PRIMA"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_SEG_VID, infoCondicionesComerciales["SUB_SEG_VID"].ToString().Trim());

            cargarCheckBox(CheckBox_RET_VAC, infoCondicionesComerciales["RET_VAC"].ToString().Trim());
            cargarCheckBox(CheckBox_RET_CES, infoCondicionesComerciales["RET_CES"].ToString().Trim());
            cargarCheckBox(CheckBox_RET_INT_CES, infoCondicionesComerciales["RET_INT_CES"].ToString().Trim());
            cargarCheckBox(CheckBox_RET_PRIM, infoCondicionesComerciales["RET_PRIM"].ToString().Trim());

            TextBox_DIAS_VNC.Text = infoCondicionesComerciales["DIAS_VNC"].ToString().Trim();

            cargar_DropDownList_REGIMEN();
            DropDownList_REGIMEN.SelectedValue = infoCondicionesComerciales["REGIMEN"].ToString().Trim();

            TextBox_OBS_FACT.Text = infoCondicionesComerciales["OBS_FACT"].ToString().Trim();

            DataTable tablaServiciosEspecificos;

            if (ID_SUB_C != 0)
            {
                tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCentroC(ID_CENTRO_C_1);
            }
            else
            {
                if (ID_CENTRO_C != 0)
                {
                    tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCiudad(ID_CIUDAD_1, ID_EMPRESA_1);
                }
                else
                {
                    tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdEmpresa(ID_EMPRESA_1);
                }
            }

            if (tablaServiciosEspecificos.Rows.Count <= 0)
            {
                CheckBox_ACTIVAR_SERVICIO_COMPLEMENTARIO.Checked = false;
                cargarTextCheckActivarServicios(ID_EMPRESA, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C, "sin");
                Panel_SERVICIOS_COMPLEMENTARIOS.Visible = false;

                List<servicio> listaServicios = new List<servicio>();
                Session.Remove("listaServicios_" + ID_EMPRESA.ToString());
                Session.Add("listaServicios_" + ID_EMPRESA.ToString(), listaServicios);
                List<detalleServicio> listaDetallesServicio = new List<detalleServicio>();
                Session.Remove("listaDetallesServicio_" + ID_EMPRESA.ToString());
                Session.Add("listaDetallesServicio_" + ID_EMPRESA.ToString(), listaDetallesServicio);
            }
            else
            {
                CheckBox_ACTIVAR_SERVICIO_COMPLEMENTARIO.Checked = true;
                cargarTextCheckActivarServicios(ID_EMPRESA, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C, "con");
                Panel_SERVICIOS_COMPLEMENTARIOS.Visible = true;
                configurarMensajesServicioComplementario(false, System.Drawing.Color.Green);
                cargarInformacionServiciosComplementariosEspecificos(tablaServiciosEspecificos, true);

                Panel_SERVICIOS_COMPLEMENTARIOS_ADICIONAR.Visible = true;
            }
        }
    }
    private void cargarInfoCondiciones(Boolean bModificar)
    {
        tools _tools = new tools();
        SecureQueryString QueryStringSeguro;
        QueryStringSeguro = new SecureQueryString(_tools.byteParaQueryStringSeguro(), Request["data"]);

        Decimal ID_EMPRESA = Convert.ToDecimal(QueryStringSeguro["reg"]);
        String ID_CIUDAD = null;
        Decimal ID_CENTRO_C = 0;
        Decimal ID_SUB_C = 0;

        try
        {
            ID_CIUDAD = QueryStringSeguro["codCiudad"].ToString();
        }
        catch
        {
            ID_CIUDAD = null;
        }

        try
        {
            ID_CENTRO_C = Convert.ToDecimal(QueryStringSeguro["codCC"]);
        }
        catch
        {
            ID_CENTRO_C = 0;
        }

        try
        {
            ID_SUB_C = Convert.ToDecimal(QueryStringSeguro["codSUBCC"]);
        }
        catch
        {
            ID_SUB_C = 0;
        }

        if (ID_SUB_C != 0)
        {
            subCentroCosto _subCentroCostoMODULO = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
            DataTable tablaInfoSubCentro = _subCentroCostoMODULO.ObtenerSubCentrosDeCostoPorIdSubCosto(ID_SUB_C);
            DataRow filaTablaInfoSubCentro = tablaInfoSubCentro.Rows[0];

            configurarInfoAdicionalModulo(true, filaTablaInfoSubCentro["NOM_SUB_C"].ToString());
        }
        else
        {
            if (ID_CENTRO_C != 0)
            {
                centroCosto _centroCostoMODULO = new centroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                DataTable tablaInfoCC = _centroCostoMODULO.ObtenerCentrosDeCostoPorIdCentroCosto(ID_CENTRO_C);
                DataRow filaTablaInfoCC = tablaInfoCC.Rows[0];

                configurarInfoAdicionalModulo(true, filaTablaInfoCC["NOM_CC"].ToString());
            }
            else
            {
                if ((String.IsNullOrEmpty(ID_CIUDAD) == false) && (ID_EMPRESA != 0))
                {
                    cobertura _coberturaMODULO = new cobertura(Session["idEmpresa"].ToString());
                    DataTable tablaInfoCiudad = _coberturaMODULO.obtenerNombreCiudadPorIdCiudad(ID_CIUDAD);
                    DataRow filaTablaInfoCiudad = tablaInfoCiudad.Rows[0];

                    configurarInfoAdicionalModulo(true, filaTablaInfoCiudad["NOMBRE"].ToString());
                }
                else
                {
                    cliente _clienteMODULO = new cliente(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                    DataTable tablaInfoCliente = _clienteMODULO.ObtenerEmpresaConIdEmpresa(ID_EMPRESA);
                    DataRow filaTablaInfoCliente = tablaInfoCliente.Rows[0];

                    configurarInfoAdicionalModulo(true, filaTablaInfoCliente["RAZ_SOCIAL"].ToString());
                }
            }
        }

        condicionComercial _condicionComercial = new condicionComercial(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

        DataTable tablaCondiciones = _condicionComercial.ObtenerCondicionesEconomicasPorId(ID_EMPRESA, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C);
        if (tablaCondiciones.Rows.Count <= 0)
        {
            if (_condicionComercial.MensajeError != null)
            {
                configurarBotonesDeAccion(false, false, false, true);

                Panel_FORMULARIO.Visible = false;

                configurarMensajes(true, System.Drawing.Color.Red);
                Label_MENSAJE.Text = _condicionComercial.MensajeError;
            }
            else
            {
                configurarBotonesDeAccion(false, true, true, true);

                Panel_FORMULARIO.Visible = true;

                Panel_SERVICIOS_COMPLEMENTARIOS.Visible = false;

                controlesParaNuevaCondicionEconomica();
            }
        }
        else
        {
            if (bModificar == true)
            {
                configurarBotonesDeAccion(false, true, true, true);
            }
            else
            {
                configurarBotonesDeAccion(true, false, false, true);
            }

            Panel_FORMULARIO.Visible = true;
            if (bModificar == true)
            {
                Panel_FORMULARIO.Enabled = true;
            }
            else
            {
                Panel_FORMULARIO.Enabled = false;
            }

            configurarMensajes(false, System.Drawing.Color.Green);

            DataRow infoCondicionesComerciales = tablaCondiciones.Rows[0];

            if (bModificar == false)
            {
                Panel_CONTROL_REGISTRO.Visible = true;
                Panel_CONTROL_REGISTRO.Enabled = false;
                TextBox_USU_CRE.Text = infoCondicionesComerciales["USU_CRE"].ToString();
                try
                {
                    TextBox_FCH_CRE.Text = DateTime.Parse(infoCondicionesComerciales["FCH_CRE"].ToString()).ToShortDateString();
                    TextBox_HOR_CRE.Text = DateTime.Parse(infoCondicionesComerciales["FCH_CRE"].ToString()).ToShortTimeString();
                }
                catch
                {
                    TextBox_FCH_CRE.Text = "";
                    TextBox_HOR_CRE.Text = "";
                }
                TextBox_USU_MOD.Text = infoCondicionesComerciales["USU_MOD"].ToString();
                try
                {
                    TextBox_FCH_MOD.Text = DateTime.Parse(infoCondicionesComerciales["FCH_MOD"].ToString()).ToShortDateString();
                    TextBox_HOR_MOD.Text = DateTime.Parse(infoCondicionesComerciales["FCH_MOD"].ToString()).ToShortTimeString();
                }
                catch
                {
                    TextBox_FCH_MOD.Text = "";
                    TextBox_HOR_MOD.Text = "";
                }
            }
            else
            {
                Panel_CONTROL_REGISTRO.Visible = false;
            }

            if (bModificar == false)
            {
                Panel_COD_CONDICIONES.Visible = true;
                Panel_COD_CONDICIONES.Enabled = false;
                TextBox_COD_CONDICION.Text = infoCondicionesComerciales["REGISTRO"].ToString().Trim();
            }
            else
            {
                Panel_COD_CONDICIONES.Visible = false;
            }

            if (infoCondicionesComerciales["FACTURA"].ToString().Trim() == "N")
            {
                CheckBox_FACTURA_NOMINA.Checked = false;
            }
            else
            {
                if (infoCondicionesComerciales["FACTURA"].ToString().Trim() == "S")
                {
                    CheckBox_FACTURA_NOMINA.Checked = true;
                }
            }

            cargar_DropDownList_MOD_SOPORTE();
            DropDownList_MOD_SOPORTE.SelectedValue = infoCondicionesComerciales["MOD_SOPORTE"].ToString().Trim();
            cargar_DropDownList_MOD_FACTURA();
            DropDownList_MOD_FACTURA.SelectedValue = infoCondicionesComerciales["MOD_FACTURA"].ToString().Trim();

            TextBox_AD_NOM.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_NOM"]));

            if (infoCondicionesComerciales["SOLO_DEV"].ToString().Trim() == "N")
            {
                CheckBox_SOLO_DEV.Checked = false;
            }
            else
            {
                if (infoCondicionesComerciales["SOLO_DEV"].ToString().Trim() == "S")
                {
                    CheckBox_SOLO_DEV.Checked = true;
                }
            }

            TextBox_AD_PENSION.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_PENSION"]));
            TextBox_AD_SALUD.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_SALUD"]));
            TextBox_AD_RIESGOS.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_RIESGOS"]));
            TextBox_AD_APO_SENA.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_APO_SENA"]));
            TextBox_AD_APO_ICBF.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_APO_ICBF"]));
            TextBox_AD_APO_CAJA.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_APO_CAJA"]));
            TextBox_AD_VACACIONES.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_VACACIONES"]));
            TextBox_AD_CESANTIA.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_CESANTIA"]));
            TextBox_AD_INT_CES.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_INT_CES"]));
            TextBox_AD_PRIMA.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_PRIMA"]));
            TextBox_AD_SEG_VID.Text = String.Format("{0:N2}",Convert.ToDecimal(infoCondicionesComerciales["AD_SEG_VID"]));

            cargarCheckBox(CheckBox_SUB_PENSION,infoCondicionesComerciales["SUB_PENSION"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_SALUD, infoCondicionesComerciales["SUB_SALUD"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_RIESGO, infoCondicionesComerciales["SUB_RIESGOS"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_SENA, infoCondicionesComerciales["SUB_SENA"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_ICBF, infoCondicionesComerciales["SUB_ICBF"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_CAJA, infoCondicionesComerciales["SUB_CAJA"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_VACACIONES, infoCondicionesComerciales["SUB_VACACIONES"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_CESANTIAS, infoCondicionesComerciales["SUB_CESANTIAS"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_INT_CES, infoCondicionesComerciales["SUB_INT_CES"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_PRIMA, infoCondicionesComerciales["SUB_PRIMA"].ToString().Trim());
            cargarCheckBox(CheckBox_SUB_SEG_VID, infoCondicionesComerciales["SUB_SEG_VID"].ToString().Trim());

            cargarCheckBox(CheckBox_RET_VAC, infoCondicionesComerciales["RET_VAC"].ToString().Trim());
            cargarCheckBox(CheckBox_RET_CES, infoCondicionesComerciales["RET_CES"].ToString().Trim());
            cargarCheckBox(CheckBox_RET_INT_CES, infoCondicionesComerciales["RET_INT_CES"].ToString().Trim());
            cargarCheckBox(CheckBox_RET_PRIM, infoCondicionesComerciales["RET_PRIM"].ToString().Trim());

            TextBox_DIAS_VNC.Text = infoCondicionesComerciales["DIAS_VNC"].ToString().Trim();

            cargar_DropDownList_REGIMEN();
            DropDownList_REGIMEN.SelectedValue = infoCondicionesComerciales["REGIMEN"].ToString().Trim();

            TextBox_OBS_FACT.Text = infoCondicionesComerciales["OBS_FACT"].ToString().Trim();

            DataTable tablaServiciosEspecificos;

            if (ID_SUB_C != 0)
            {
                tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdSubC(ID_SUB_C);
            }
            else
            {
                if (ID_CENTRO_C != 0)
                {
                    tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCentroC(ID_CENTRO_C);
                }
                else
                {
                    if ((ID_EMPRESA != 0) && (String.IsNullOrEmpty(ID_CIUDAD) == false))
                    {
                        tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdCiudad(ID_CIUDAD, ID_EMPRESA);
                    }
                    else
                    {
                        tablaServiciosEspecificos = _condicionComercial.ObtenerServiciosPorEmpresaPorIdEmpresa(ID_EMPRESA);
                    }
                }
            }

            if (tablaServiciosEspecificos.Rows.Count <= 0)
            {
                CheckBox_ACTIVAR_SERVICIO_COMPLEMENTARIO.Checked = false;
                cargarTextCheckActivarServicios(ID_EMPRESA, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C, "sin");
                Panel_SERVICIOS_COMPLEMENTARIOS.Visible = false;

                List<servicio> listaServicios = new List<servicio>();
                Session.Remove("listaServicios_" + ID_EMPRESA.ToString());
                Session.Add("listaServicios_" + ID_EMPRESA.ToString(), listaServicios);
                List<detalleServicio> listaDetallesServicio = new List<detalleServicio>();
                Session.Remove("listaDetallesServicio_" + ID_EMPRESA.ToString());
                Session.Add("listaDetallesServicio_" + ID_EMPRESA.ToString(), listaDetallesServicio);
            }
            else
            {
                CheckBox_ACTIVAR_SERVICIO_COMPLEMENTARIO.Checked = true;
                cargarTextCheckActivarServicios(ID_EMPRESA, ID_CIUDAD, ID_CENTRO_C, ID_SUB_C, "con");
                Panel_SERVICIOS_COMPLEMENTARIOS.Visible = true;
                configurarMensajesServicioComplementario(false, System.Drawing.Color.Green);
                cargarInformacionServiciosComplementariosEspecificos(tablaServiciosEspecificos, false);

                if (bModificar == true)
                {
                    Panel_SERVICIOS_COMPLEMENTARIOS_ADICIONAR.Visible = true;
                }
                else
                {
                    Panel_SERVICIOS_COMPLEMENTARIOS_ADICIONAR.Visible = false;
                }
            }
        }
    }