private void cargar_DropDownList_SUB_CENTRO(Decimal ID_EMPRESA, Decimal ID_CENTRO_C)
    {
        DropDownList_sub_cc.Items.Clear();

        subCentroCosto _subCentroCosto = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaSUB_C = _subCentroCosto.ObtenerSubCentrosDeCostoPorIdEmpresaIdCentroCosto(ID_EMPRESA, ID_CENTRO_C);

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

        foreach (DataRow fila in tablaSUB_C.Rows)
        {
            item = new System.Web.UI.WebControls.ListItem(fila["NOM_SUB_C"].ToString(), fila["ID_SUB_C"].ToString());
            DropDownList_sub_cc.Items.Add(item);
        }

        DropDownList_sub_cc.DataBind();
    }
    private void cargar_GridView_SUB_CENTROS_DE_COSTO(Decimal ID_EMPRESA, Decimal ID_CENTRO_C)
    {
        subCentroCosto _subCentroCosto = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

        DataTable tablaSUBCCDeCC = _subCentroCosto.ObtenerSubCentrosDeCostoPorIdEmpresaIdCentroCosto(ID_EMPRESA, ID_CENTRO_C);

        if (tablaSUBCCDeCC.Rows.Count <= 0)
        {
            configurarMensajesSUBCC(true, System.Drawing.Color.Red);
            Label_MENSAJE_COBERTURA.Text = "El Centro de costos seleccionado no tiene sub centros.";
        }
        else
        {
            configurarMensajesSUBCC(false, System.Drawing.Color.Red);

            GridView_SUB_CENTROS_DE_COSTO.DataSource = tablaSUBCCDeCC;
            GridView_SUB_CENTROS_DE_COSTO.DataBind();

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

            for (int i = 0; i < tablaSUBCCDeCC.Rows.Count; i++)
            {
                filaEnTablaSUBCC = tablaSUBCCDeCC.Rows[i];

                tablaCondicionesComercialesDeSUBCC = _condicionComercial.ObtenerCondicionesEconomicasPorId(ID_EMPRESA, null,0, Convert.ToDecimal(filaEnTablaSUBCC["ID_SUB_C"]));
                if (tablaCondicionesComercialesDeSUBCC.Rows.Count <= 0)
                {
                    GridView_SUB_CENTROS_DE_COSTO.Rows[i].BackColor = colorNo;
                }
                else
                {
                    GridView_SUB_CENTROS_DE_COSTO.Rows[i].BackColor = colorSi;
                }

                GridView_SUB_CENTROS_DE_COSTO.Rows[i].Cells[2].Enabled = false;
            }
        }
    }
    private void cargar_GridView_CENTROS_DE_COSTO(Decimal ID_EMPRESA, String ID_CIUDAD)
    {
        centroCosto _centroCosto = new centroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

        DataTable tablaCCDeCiudad = _centroCosto.ObtenerCentrosDeCostoPorIdEmpresaIdCiudad(ID_EMPRESA, ID_CIUDAD);

        if (tablaCCDeCiudad.Rows.Count <= 0)
        {
            configurarMensajesCC(true, System.Drawing.Color.Red);
            Label_MENSAJE_COBERTURA.Text = "La Ciudad no tiene centros de costo actualmente.";
        }
        else
        {
            configurarMensajesCC(false, System.Drawing.Color.Red);

            GridView_CENTROS_DE_COSTO.DataSource = tablaCCDeCiudad;
            GridView_CENTROS_DE_COSTO.DataBind();

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

            subCentroCosto _subCentroCosto = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
            DataTable tablaSUBCCDeCC;
            for (int i = 0; i < tablaCCDeCiudad.Rows.Count; i++)
            {
                filaEnTablaCC = tablaCCDeCiudad.Rows[i];

                tablaCondicionesComercialesDeCC = _condicionComercial.ObtenerCondicionesEconomicasPorId(ID_EMPRESA, null, Convert.ToDecimal(filaEnTablaCC["ID_CENTRO_C"]), 0);
                if (tablaCondicionesComercialesDeCC.Rows.Count <= 0)
                {
                    GridView_CENTROS_DE_COSTO.Rows[i].BackColor = colorNo;
                }
                else
                {
                    GridView_CENTROS_DE_COSTO.Rows[i].BackColor = colorSi;
                }

                tablaSUBCCDeCC = _subCentroCosto.ObtenerSubCentrosDeCostoPorIdEmpresaIdCentroCosto(ID_EMPRESA, Convert.ToDecimal(filaEnTablaCC["ID_CENTRO_C"]));
                if (tablaSUBCCDeCC.Rows.Count <= 0)
                {
                    GridView_CENTROS_DE_COSTO.Rows[i].Cells[2].Enabled = false;
                }
                else
                {
                    GridView_CENTROS_DE_COSTO.Rows[i].Cells[2].Enabled = true;
                }
            }
        }

        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.";
        GridView_SUB_CENTROS_DE_COSTO.DataSource = null;
        GridView_SUB_CENTROS_DE_COSTO.DataBind();
    }
    private void Cargar(GridView gridView, decimal IdEmpresa, decimal idCentroCosto)
    {
        subCentroCosto subCentroCosto = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable dataTable = subCentroCosto.ObtenerSubCentrosDeCostoPorIdEmpresaIdCentroCosto(IdEmpresa, idCentroCosto);

        if (dataTable.Rows.Count > 0)
        {
            gridView.DataSource = dataTable;
            gridView.DataBind();
        }
        if (dataTable != null) dataTable.Dispose();
    }
    protected void GridView_CENTROS_DE_COSTO_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        tools _tools = new tools();
        SecureQueryString QueryStringSeguro;
        QueryStringSeguro = new SecureQueryString(_tools.byteParaQueryStringSeguro(), Request["data"].ToString());
        this.Label_CC.Text = String.Empty;

        if (e.CommandName == "centrocosto")
        {
            int fila = Convert.ToInt32(e.CommandArgument);

            Decimal ID_EMPRESA = Convert.ToDecimal(QueryStringSeguro["reg"]);
            Decimal ID_CENTRO_C = Convert.ToDecimal(GridView_CENTROS_DE_COSTO.DataKeys[fila].Value);
            subCentroCosto _subCentroCosto = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

            DataTable tablaSubCC = _subCentroCosto.ObtenerSubCentrosDeCostoPorIdEmpresaIdCentroCosto(ID_EMPRESA, ID_CENTRO_C);
            this.HiddenField_cc.Value = ID_CENTRO_C.ToString();

            Cargar(ID_EMPRESA, ID_CENTRO_C);

            if (tablaSubCC.Rows.Count == 0) Informar(Label_MENSAJE_CC, "ADVERTENCIA: El Centro de costos seleccionado no tiene sub centros.", Proceso.Error);

            GridView_SUB_CENTROS_DE_COSTO.DataSource = tablaSubCC;
            GridView_SUB_CENTROS_DE_COSTO.DataBind();
            if (GridView_SUB_CENTROS_DE_COSTO.Rows.Count > 0) this.Panel_MENSAJE_SUB_CC.Visible = false;
            else this.Panel_MENSAJE_SUB_CC.Visible = true;
            tablaSubCC.Dispose();
            Label_INFO_ADICIONAL_MODULO.Text = "Centro de costo - " + GridView_CENTROS_DE_COSTO.DataKeys[fila].Values["NOM_CC"].ToString();
        }
    }
    private void cargar_GridView_SUB_C()
    {
        tools _tools = new tools();
        SecureQueryString QueryStringSeguro;
        QueryStringSeguro = new SecureQueryString(_tools.byteParaQueryStringSeguro(), Request["data"]);

        Decimal ID_EMPRESA = Convert.ToDecimal(QueryStringSeguro["reg"].ToString());
        Decimal ID_CENTRO_C = Convert.ToDecimal(QueryStringSeguro["cc"].ToString());

        subCentroCosto _subCentroCosto = new subCentroCosto(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaInfoSubC = _subCentroCosto.ObtenerSubCentrosDeCostoPorIdEmpresaIdCentroCosto(ID_EMPRESA, ID_CENTRO_C);

        if (tablaInfoSubC.Rows.Count > 0)
        {
            Panel_SUB_CENTROS.Visible = true;

            GridView_SUB_C.DataSource = tablaInfoSubC;
            GridView_SUB_C.DataBind();
        }
        else
        {
            Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "El CENTRO DE COSTO no posee sub centros.", Proceso.Advertencia);
        }
    }