protected void DropDownList_CONT_NOMBRE_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList_CONT_NOMBRE.SelectedValue == "")
        {
            TextBox_CONT_MAIL.Text = "";
        }
        else
        {
            Decimal REGISTRO = Convert.ToDecimal(DropDownList_CONT_NOMBRE.SelectedValue);
            contactos _contactos = new contactos(Session["idEmpresa"].ToString());
            DataTable tablaContacto = _contactos.ObtenerContactosPorRegistro(REGISTRO);

            if (tablaContacto.Rows.Count > 0)
            {
                DataRow filaTablaContacto = tablaContacto.Rows[0];
                if (!(String.IsNullOrEmpty(filaTablaContacto["CONT_MAIL"].ToString().Trim())))
                {
                    TextBox_CONT_MAIL.Text = filaTablaContacto["CONT_MAIL"].ToString().Trim();
                }
            }
            else
            {
                TextBox_CONT_MAIL.Text = String.Empty;
            }
        }
    }
    protected void DropDownList_CONTACTOS_EXISTENTES_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList_CONTACTOS_EXISTENTES.SelectedValue != "")
        {
            Decimal REGISTRO = Convert.ToDecimal(DropDownList_CONTACTOS_EXISTENTES.SelectedValue);

            contactos _contactos = new contactos(Session["idEmpresa"].ToString());
            DataTable tablainfoContacto = _contactos.ObtenerContactosPorRegistro(REGISTRO);

            if (_contactos.MensajeError == null)
            {
                if (tablainfoContacto.Rows.Count <= 0)
                {
                    configurarMensajes(true, System.Drawing.Color.Red);
                    Label_MENSAJE.Text = "ADVERTENCIA: No se encontró información del Contácto identificado con el número: " + REGISTRO.ToString();

                    configurarBotonesDeAccion(true, false, false, false, true);

                    Panel_RESULTADOS_GRID.Visible = false;

                    Panel_FORMULARIO.Visible = false;
                }
                else
                {
                    DataRow filaInfoContacto = tablainfoContacto.Rows[0];

                    cargar_DropDownList_ESTADO();
                    DropDownList_ESTADO.SelectedValue = filaInfoContacto["CONT_ESTADO"].ToString().ToUpper().Trim();

                    TextBox_CONT_NOM.Text = filaInfoContacto["CONT_NOM"].ToString().Trim();
                    TextBox_CONT_CARGO.Text = filaInfoContacto["CONT_CARGO"].ToString().Trim();
                    TextBox_CONT_MAIL.Text = filaInfoContacto["CONT_MAIL"].ToString().Trim();

                    TextBox_CONT_TEL.Text = filaInfoContacto["CONT_TEL"].ToString().Trim();
                    TextBox_CONT_TEL1.Text = filaInfoContacto["CONT_TEL1"].ToString().Trim();
                    TextBox_CONT_CELULAR.Text = filaInfoContacto["CONT_CELULAR"].ToString().Trim();

                    _contactos.MensajeError = null;
                    DataRow filaInfoCiudadDepartamentoYRegional = obtenerDatosCiudadDepartamentoRegionalDelContacto(filaInfoContacto["CONT_CIUDAD"].ToString().Trim());
                    if (filaInfoCiudadDepartamentoYRegional != null)
                    {
                        cargar_DropDownList_REGIONAL();
                        DropDownList_REGIONAL.SelectedValue = filaInfoCiudadDepartamentoYRegional["ID_REGIONAL"].ToString().Trim();

                        cargar_DropDownList_CONT_DEPARTAMENTO(filaInfoCiudadDepartamentoYRegional["ID_REGIONAL"].ToString().Trim());
                        DropDownList_CONT_DEPARTAMENTO.SelectedValue = filaInfoCiudadDepartamentoYRegional["ID_DEPARTAMENTO"].ToString().Trim();
                        DropDownList_CONT_DEPARTAMENTO.Enabled = true;

                        cargar_DropDownList_CONT_CIUDAD(filaInfoCiudadDepartamentoYRegional["ID_DEPARTAMENTO"].ToString().Trim(), filaInfoCiudadDepartamentoYRegional["ID_REGIONAL"].ToString().Trim());
                        DropDownList_CONT_CIUDAD.SelectedValue = filaInfoCiudadDepartamentoYRegional["ID_CIUDAD"].ToString().Trim();
                        DropDownList_CONT_CIUDAD.Enabled = true;
                    }
                    else
                    {
                        cargar_DropDownList_REGIONAL();
                        inhabilitar_DropDownList_CONT_DEPARTAMENTO();
                        inhabilitar_DropDownList_CONT_CIUDAD();
                    }
                }
            }
            else
            {
                configurarMensajes(true, System.Drawing.Color.Red);
                Label_MENSAJE.Text = _contactos.MensajeError;

                configurarBotonesDeAccion(true, false, false, false, true);

                Panel_RESULTADOS_GRID.Visible = false;

                Panel_FORMULARIO.Visible = false;
            }

        }
    }
    private void iniciarControlesModificar()
    {
        tools _tools = new tools();
        SecureQueryString QueryStringSeguro;
        QueryStringSeguro = new SecureQueryString(_tools.byteParaQueryStringSeguro(), Request["data"]);

        contactos _contactos = new contactos(Session["idEmpresa"].ToString());

        Decimal REGISTRO = Convert.ToDecimal(QueryStringSeguro["contacto"]);
        DataTable tablainfoContacto = _contactos.ObtenerContactosPorRegistro(REGISTRO);

        if (_contactos.MensajeError == null)
        {
            if (tablainfoContacto.Rows.Count <= 0)
            {
                configurarMensajes(true, System.Drawing.Color.Red);
                Label_MENSAJE.Text = "ADVERTENCIA: No se encontró información del Contcato # " + REGISTRO.ToString();

                configurarBotonesDeAccion(true, false, false, false, true);

                Panel_RESULTADOS_GRID.Visible = false;

                Panel_FORMULARIO.Visible = false;
            }
            else
            {
                configurarBotonesDeAccion(false, false, true, true, true);

                Panel_RESULTADOS_GRID.Visible = false;

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

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

                Panel_CONTROL_REGISTRO.Visible = false;

                DataRow filaInfoContacto = tablainfoContacto.Rows[0];

                Page.Header.Title += ": " + filaInfoContacto["CONT_NOM"].ToString();

                TextBox_REGISTRO.Text = filaInfoContacto["REGISTRO"].ToString().Trim();
                Panel_IDENTIFICADOR.Visible = true;
                Panel_IDENTIFICADOR.Enabled = true;
                TextBox_REGISTRO.Enabled = false;

                Panel_CONTACTOS_ACTUALES.Visible = false;

                cargar_DropDownList_ESTADO();
                DropDownList_ESTADO.SelectedValue = filaInfoContacto["CONT_ESTADO"].ToString().ToUpper().Trim();

                TextBox_CONT_NOM.Text = filaInfoContacto["CONT_NOM"].ToString().Trim();
                TextBox_CONT_CARGO.Text = filaInfoContacto["CONT_CARGO"].ToString().Trim();
                TextBox_CONT_MAIL.Text = filaInfoContacto["CONT_MAIL"].ToString().Trim();

                TextBox_CONT_TEL.Text = filaInfoContacto["CONT_TEL"].ToString().Trim();
                TextBox_CONT_TEL1.Text = filaInfoContacto["CONT_TEL1"].ToString().Trim();
                TextBox_CONT_CELULAR.Text = filaInfoContacto["CONT_CELULAR"].ToString().Trim();

                _contactos.MensajeError = null;
                DataRow filaInfoCiudadDepartamentoYRegional = obtenerDatosCiudadDepartamentoRegionalDelContacto(filaInfoContacto["CONT_CIUDAD"].ToString().Trim());
                if (filaInfoCiudadDepartamentoYRegional != null)
                {
                    cargar_DropDownList_REGIONAL();
                    DropDownList_REGIONAL.SelectedValue = filaInfoCiudadDepartamentoYRegional["ID_REGIONAL"].ToString().Trim();

                    cargar_DropDownList_CONT_DEPARTAMENTO(filaInfoCiudadDepartamentoYRegional["ID_REGIONAL"].ToString().Trim());
                    DropDownList_CONT_DEPARTAMENTO.SelectedValue = filaInfoCiudadDepartamentoYRegional["ID_DEPARTAMENTO"].ToString().Trim();

                    cargar_DropDownList_CONT_CIUDAD(filaInfoCiudadDepartamentoYRegional["ID_DEPARTAMENTO"].ToString().Trim(), filaInfoCiudadDepartamentoYRegional["ID_REGIONAL"].ToString().Trim());
                    DropDownList_CONT_CIUDAD.SelectedValue = filaInfoCiudadDepartamentoYRegional["ID_CIUDAD"].ToString().Trim();
                }
                else
                {
                    cargar_DropDownList_REGIONAL();
                    inhabilitar_DropDownList_CONT_DEPARTAMENTO();
                    inhabilitar_DropDownList_CONT_CIUDAD();
                }

                if (_proceso == Convert.ToInt32(QueryStringSeguro["proceso"]))
                {
                    this.Panel_CARTERA.Visible = true;
                    this.TextBox_DIAS_PAGO.Text = filaInfoContacto["DIAS"].ToString().Trim();
                    if (!String.IsNullOrEmpty(filaInfoContacto["FORMA_PAGO"].ToString()))
                    {
                        this.DropDownList_FORMA_PAGO.SelectedIndex = DropDownList_FORMA_PAGO.Items.IndexOf(DropDownList_FORMA_PAGO.Items.FindByValue(filaInfoContacto["FORMA_PAGO"].ToString().Trim()));
                        if (DropDownList_FORMA_PAGO.SelectedItem.Value == "Consignacion" || DropDownList_FORMA_PAGO.SelectedItem.Value == "Transferencia")
                        {
                            cargar_DropDownList_BANCOS();
                            if (!String.IsNullOrEmpty(filaInfoContacto["BANCO"].ToString()))
                            {
                                this.DropDownList_BANCOS.SelectedIndex = DropDownList_BANCOS.Items.IndexOf(DropDownList_BANCOS.Items.FindByValue(filaInfoContacto["BANCO"].ToString().Trim()));
                                cargar_DropDownList_CUENTAS(Convert.ToInt32(DropDownList_BANCOS.SelectedItem.Value.ToString()));
                                if (!String.IsNullOrEmpty(filaInfoContacto["CUENTA"].ToString()))
                                {
                                    this.DropDownList_CUENTAS.SelectedIndex = DropDownList_CUENTAS.Items.IndexOf(DropDownList_CUENTAS.Items.FindByValue(filaInfoContacto["CUENTA"].ToString().Trim()));
                                }
                            }
                        }
                        else this.DropDownList_BANCOS.Items.Clear();
                    }
                }
                else this.Panel_CARTERA.Visible = false;

                Panel_INMEDIATO.Visible = false;
            }
        }
        else
        {
            configurarMensajes(true, System.Drawing.Color.Red);
            Label_MENSAJE.Text = _contactos.MensajeError;

            configurarBotonesDeAccion(true, false, false, false, true);

            Panel_RESULTADOS_GRID.Visible = false;

            Panel_FORMULARIO.Visible = false;
        }
    }
    protected void DropDownList_CONTACTO_SELECCION_SelectedIndexChanged(object sender, EventArgs e)
    {
        if(DropDownList_CONTACTO_SELECCION.SelectedIndex <= 0)
        {
            TextBox_EMAIL_SELECCION.Text = "";
        }
        else
        {
            Decimal ID_CONTACTO = Convert.ToDecimal(DropDownList_CONTACTO_SELECCION.SelectedValue);
            contactos _contactos = new contactos(Session["idEmpresa"].ToString());
            DataTable tablaContacto = _contactos.ObtenerContactosPorRegistro(ID_CONTACTO);
            DataRow filaContacto = tablaContacto.Rows[0];

            TextBox_EMAIL_SELECCION.Text = filaContacto["CONT_MAIL"].ToString().Trim() + "sasasa";
        }
    }
    private void SeleccionarEmailSeleccion(DataRow fila)
    {
        Decimal ID_CONTACTO = Convert.ToDecimal(fila["ID_CONTACTO_SELECCION"]);
        contactos _contactos = new contactos(Session["idEmpresa"].ToString());
        DataTable tablaContacto = _contactos.ObtenerContactosPorRegistro(ID_CONTACTO);
        DataRow filaContacto = tablaContacto.Rows[0];

        cargar_DropDownList_CONTACTO_SELECCION();
        DropDownList_CONTACTO_SELECCION.SelectedValue = fila["ID_CONTACTO_SELECCION"].ToString().Trim();
        TextBox_EMAIL_SELECCION.Text = filaContacto["CONT_MAIL"].ToString().Trim();
    }
 private void SeleccionarEmailSeleccion(DataRow fila)
 {
     Decimal ID_CONTACTO = !DBNull.Value.Equals(fila["ID_CONTACTO_SELECCION"]) ? Convert.ToDecimal(fila["ID_CONTACTO_SELECCION"]) : 0;
     contactos _contactos = new contactos(Session["idEmpresa"].ToString());
     DataTable tablaContacto = _contactos.ObtenerContactosPorRegistro(ID_CONTACTO);
     if (!tablaContacto.Rows.Count.Equals(0))
     {
         DataRow filaContacto = tablaContacto.Rows[0];
         Label_NOMBRE_CONTACTO_SELECCION.Text = filaContacto["CONT_NOM"].ToString().Trim();
         TextBox_EMAIL_SELECCION.Text = filaContacto["CONT_MAIL"].ToString().Trim();
     }
 }