private void ObtenerDatos()
        {
            string PartidosSeleccionados = string.Empty;

            foreach (ListItem listItem in cmbPartidosPoliticos.Items)
            {
                if (listItem.Selected)
                {
                    var val = listItem.Value;
                    var txt = listItem.Text;
                    PartidosSeleccionados += listItem.Value + ",";
                }
            }
            this.FG.Nombre            = txtNombre.Text;
            this.FG.Siglas            = txtSigla.Text;
            this.FG.PartidosPoliticos = PartidosSeleccionados;
            this.FG.Usuario           = User.Identity.Name;
            this.FG.Conexion          = Comun.Conexion;

            if (imgLogo.HasFile) //Hay imagen
            {
                int    size           = imgLogo.PostedFile.ContentLength;
                byte[] ImagenOriginal = new byte[size];
                imgLogo.PostedFile.InputStream.Read(ImagenOriginal, 0, size);
                Bitmap      ImagenOriginalBinaria = new Bitmap(imgLogo.PostedFile.InputStream);
                string      extension             = Path.GetExtension(imgLogo.FileName);
                ImageFormat imageFormateExtension = FG_Auxiliar.ObtenerExtensionImageFormat(extension);
                if (imageFormateExtension != null)
                {
                    this.FG.Logo = ZM_ConversionBS.ToBase64String(ImagenOriginalBinaria, imageFormateExtension);
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.cmbAfiliado.Enabled = false;
         CargarComboSeccion();
     }
     if (Request.Form.Count == 10)
     {
         if (this.cmbAfiliado.SelectedValue != "0" && this.cmbSeccion.SelectedValue != "0")
         {
             //Recuperar la Imagen
             int    size           = imgLogo.PostedFile.ContentLength;
             byte[] ImagenOriginal = new byte[size];
             imgLogo.PostedFile.InputStream.Read(ImagenOriginal, 0, size);
             Bitmap ImagenOriginalBinaria = new Bitmap(imgLogo.PostedFile.InputStream);
             //Imsertar Imagen en la Base de Datos
             string       imagenString = ZM_ConversionBS.ToBase64String(ImagenOriginalBinaria, ImageFormat.Jpeg);
             RR_Afiliados afiliados    = new RR_Afiliados()
             {
                 IDAfiliado = this.cmbAfiliado.SelectedValue.ToString(),
                 Conexion   = Comun.Conexion,
                 ImagenVoto = imagenString,
                 IDUsuario  = Comun.IDUsuario
             };
             JL_AfiliadosNegocio AN = new JL_AfiliadosNegocio();
             AN.ConfirmarVoto(afiliados);
             if (afiliados.Completado)
             {
                 Response.Redirect("frmConfirmarVoto.aspx", false);
             }
             else
             {
                 string ScriptError = DialogMessage.Show(TipoMensaje.Error, "Error al guardar los datos.", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true);
                 ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true);
                 CargarComboSeccion();
             }
         }
     }
 }
        private FG_CatPartidoPoliticoAlianza ObtenerFormulario()
        {
            FG_CatPartidoPoliticoAlianza DatosFormulario = new FG_CatPartidoPoliticoAlianza();

            DatosFormulario.IDPartidoPoliticoAlianza = int.Parse(txtIDAlianza.Value);
            DatosFormulario.Nombre   = txtNombre.Text;
            DatosFormulario.Siglas   = txtSigla.Text;
            DatosFormulario.Usuario  = User.Identity.Name;
            DatosFormulario.Conexion = Comun.Conexion;

            foreach (ListItem item in cmbPartidosPoliticos.Items)
            {
                if (item.Selected)
                {
                    DatosFormulario.PartidosPoliticos += item.Value + ",";
                }
            }
            if (imgLogo.HasFile)
            {
                int    size           = imgLogo.PostedFile.ContentLength;
                byte[] ImagenOriginal = new byte[size];
                imgLogo.PostedFile.InputStream.Read(ImagenOriginal, 0, size);
                Bitmap      ImagenOriginalBinaria = new Bitmap(imgLogo.PostedFile.InputStream);
                string      extension             = Path.GetExtension(imgLogo.FileName);
                ImageFormat imageFormateExtension = FG_Auxiliar.ObtenerExtensionImageFormat(extension);
                if (imageFormateExtension != null)
                {
                    DatosFormulario.Logo = ZM_ConversionBS.ToBase64String(ImagenOriginalBinaria, imageFormateExtension);
                }
            }
            else
            {
                DatosFormulario.Logo = Logo.Attributes["data-src"];
            }


            return(DatosFormulario);
        }
        protected void btnSubir_Click(object sender, EventArgs e)
        {
            if (!fuploadImagen.HasFile)
            {
            }
            else
            {
                #region Obtener datos de la imagen
                int    size           = fuploadImagen.PostedFile.ContentLength;
                byte[] ImagenOriginal = new byte[size];

                fuploadImagen.PostedFile.InputStream.Read(ImagenOriginal, 0, size);

                Bitmap ImagenOriginalBinaria = new Bitmap(fuploadImagen.PostedFile.InputStream);
                #endregion

                #region Insertar imagen en la base de datos
                string imagenString = ZM_ConversionBS.ToBase64String(ImagenOriginalBinaria, ImageFormat.Jpeg);

                string titulo = txtTituloImagenViewA.Text;
                if (titulo == string.Empty)
                {
                    titulo = "Sin titulo";
                }
                if (Request.QueryString["id"] != null)
                {
                    string IDusuario = Request.QueryString["id"];
                    Guardar(IDusuario, imagenString, titulo);
                }

                #endregion

                //string ImagenDataURL64 = "data:image/jpg;base64," + Convert.ToBase64String(ImagenOriginal);
                //imagPreview.ImageUrl = ImagenDataURL64;
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Para el boton de regresar
            op = Request.QueryString["op"];

            if (!IsPostBack)
            {
                ListItem itemDefault = new ListItem("--Selecione--", "");

                if (op != null)
                {
                    #region Valores Predeterminados
                    //padre
                    divAsiganado.Visible   = false;
                    cmbAsignado.DataSource = null;
                    //municipio
                    divMunicipio.Visible    = false;
                    cmbMunicipio.DataSource = null;
                    //suplente
                    divSuplente.Visible    = false;
                    cmbSuplente.DataSource = null;
                    //seccion
                    divSeccion.Visible    = false;
                    cmbSeccion.DataSource = null;
                    //casilla
                    divCasilla.Visible    = false;
                    cmbCasilla.DataSource = null;
                    //tipo de usuario (solo en admin, monitor y capturista)
                    cmbTipoUsuario.Visible    = false;
                    cmbTipoUsuario.DataSource = null;
                    #endregion
                    #region 100 Representante general
                    if (op == "100")
                    {
                        //Si es general, no tiene padre. no tiene suplente. no tiene seccion ni casilla
                        txtTipoUsuario.Visible = true;

                        txtTipoUsuario.Text   = "REPRESENTANTE GENERAL";
                        Session["idtipouser"] = 100;
                    }
                    #endregion
                    #region 101 Suplente de representante general
                    else if (op == "101")
                    {
                        //es suplente
                        divSuplente.Visible = true;
                        //LlenarCombo
                        llenarComboRepresentanteSinCasilla(100, op);

                        //padre
                        divAsiganado.Visible   = false;
                        cmbAsignado.DataSource = null;

                        txtTipoUsuario.Text   = "SUPLENTE DE REPRESENTANTE GENERAL";
                        Session["idtipouser"] = 101;
                    }
                    #endregion
                    #region 200 representante de seccion
                    else if (op == "200")
                    {
                        txtTipoUsuario.Text   = "REPRESENTANTE DE SECCIÓN";
                        Session["idtipouser"] = 200;

                        //seccion
                        txtTipoUsuario.Visible = true;

                        //padre
                        divAsiganado.Visible   = true;
                        cmbAsignado.DataSource = null;
                        llenarComboRepresentanteSinCasilla(100, op);

                        //municipio
                        divMunicipio.Visible = true;
                        llenarComboMunicipios();
                        cmbMunicipio.AutoPostBack = true;

                        //seccion
                        divSeccion.Visible = true;
                        cmbSeccion.Items.Insert(0, itemDefault);
                    }
                    #endregion
                    #region 201 suplente de representante de seccion
                    else if (op == "201")
                    {
                        //es suplente
                        divSuplente.Visible = true;
                        llenarComboRepresentanteSinCasilla(200, op);
                        cmbSuplente.AutoPostBack = true;

                        divSeccion.Visible    = true;
                        cmbSeccion.DataSource = null;
                        cmbSeccion.Items.Insert(0, itemDefault);

                        txtTipoUsuario.Text   = "SUPLENTE DE REPRESENTANTE DE SECCIÓN";
                        Session["idtipouser"] = 201;
                    }
                    #endregion
                    #region 300 representante de casilla
                    else if (op == "300")
                    {
                        txtTipoUsuario.Visible = true;

                        //padre
                        divAsiganado.Visible = true;
                        llenarComboRepresentanteSinCasilla(200, op);
                        cmbAsignado.AutoPostBack = true;

                        //se llena segun el asignado
                        divSeccion.Visible    = true;
                        cmbSeccion.DataSource = null;
                        cmbSeccion.Items.Insert(0, itemDefault);

                        //OBTENER LAS CASILLAS DE ACUERDO AL REPRESENTANTE DE SECCION
                        divCasilla.Visible    = true;
                        cmbCasilla.DataSource = null;
                        cmbCasilla.Items.Insert(0, itemDefault);

                        txtTipoUsuario.Text   = "REPRESENTANTE DE CASILLA";
                        Session["idtipouser"] = 300;
                    }
                    #endregion
                    #region 301 suplente de representante de casilla
                    else if (op == "301")
                    {
                        //es suplente
                        divSuplente.Visible = true;
                        llenarComboSuplente(300);
                        cmbSuplente.AutoPostBack = true;

                        //seccion y casilla se toma del padre
                        divSeccion.Visible    = true;
                        cmbSeccion.DataSource = null;
                        cmbSeccion.Items.Insert(0, itemDefault);

                        divCasilla.Visible    = true;
                        cmbCasilla.DataSource = null;
                        cmbCasilla.Items.Insert(0, itemDefault);

                        txtTipoUsuario.Text   = "SUPLENTE DE REPRESENTANTE DE CASILLA";
                        Session["idtipouser"] = 301;
                    }
                    #endregion
                    #region 400 operador politico
                    else if (op == "400")
                    {
                        //operador
                        txtTipoUsuario.Visible = true;
                        divAsiganado.Visible   = true;

                        //llenar combo a partir de casilla al parecer
                        llenarComboPadre(300, op);
                        cmbAsignado.AutoPostBack = true;

                        //seccion y casilla se toma del padre, seria del jefe de casilla, solo para efecto de muestra
                        divSeccion.Visible    = true;
                        cmbSeccion.DataSource = null;
                        cmbSeccion.Items.Insert(0, itemDefault);

                        //Para efecto de muestra
                        divCasilla.Visible    = true;
                        cmbCasilla.DataSource = null;
                        cmbCasilla.Items.Insert(0, itemDefault);

                        txtTipoUsuario.Text   = "OPERADOR POLÍTICO";
                        Session["idtipouser"] = 400;
                    }
                    #endregion
                    #region 1-10-11 administrador, secretaria y monitor
                    //administrador, secretaria y monitor
                    else if (op == "1" || op == "10" || op == "11")
                    {
                        //escondemos el input tipo de usuario
                        txtTipoUsuario.Visible = false;
                        txtTipoUsuario.Text    = "";
                        divTipoUsuario.Visible = false;
                        //cambiamos a dropdown
                        cmbTipoUsuario.Visible = true;
                        //llenarCombo
                        this.CargarComboTipoUsuario();

                        Session["idtipouser"] = null;
                    }
                    #endregion
                }
            }


            if (!IsPostBack)
            {
                this.CargarComboGenero();
                if (Request.QueryString["opW"] != null)
                {//MODIFICAR
                    if (Request.QueryString["opW"] == "2")
                    {
                        if (Request.QueryString["id"] != null)
                        {
                            string ID = Request.QueryString["id"].ToString();
                            if (Request.QueryString["id"].ToString() == ID)
                            {
                                //Obtener los datos y dibujarlos.
                                EM_CatColaborador DatosAux = new EM_CatColaborador {
                                    Conexion = Comun.Conexion, IDColaborador = ID
                                };
                                EM_CatalagosNegocio CN = new EM_CatalagosNegocio();
                                CN.ObtenerDetalleColaboradoresXID(DatosAux);
                                if (DatosAux.Completado)
                                {
                                    this.CargarDatos(DatosAux);
                                    #region 101 Asignar valores Suplente Representante General
                                    if (DatosAux.IDTipoUsu == 101)
                                    {
                                        ListItem listItemSuplente = cmbSuplente.Items.FindByValue(DatosAux.Sumplente);
                                        if (listItemSuplente != null)
                                        {
                                            cmbSuplente.SelectedValue = listItemSuplente.Value;
                                        }
                                        else
                                        {
                                            cmbSuplente.SelectedIndex = -1;
                                        }
                                    }
                                    #endregion
                                    #region 200 Asignar valores Representante de seccion
                                    if (DatosAux.IDTipoUsu == 200)
                                    {
                                        cmbAsignado.SelectedIndex  = -1;
                                        cmbMunicipio.SelectedIndex = -1;
                                        cmbSeccion.SelectedIndex   = -1;

                                        ListItem listItemPadre = cmbAsignado.Items.FindByValue(DatosAux.Padre);
                                        if (listItemPadre != null)
                                        {
                                            cmbAsignado.SelectedValue = listItemPadre.Value;
                                        }
                                        else
                                        {
                                            cmbAsignado.SelectedIndex = -1;
                                        }

                                        ListItem listItemMunicipio = cmbMunicipio.Items.FindByValue(DatosAux.Municipio.ToString());
                                        if (listItemMunicipio != null)
                                        {
                                            cmbMunicipio.SelectedValue = listItemMunicipio.Value;
                                        }
                                        else
                                        {
                                            cmbMunicipio.SelectedIndex = -1;
                                        }

                                        llenarComboSeccionesXMunicipio(DatosAux.Municipio);
                                        cmbSeccion.SelectedIndex = -1;

                                        ListItem listItemSeccion = cmbSeccion.Items.FindByValue(DatosAux.Seccion.ToString());
                                        if (listItemMunicipio != null)
                                        {
                                            cmbSeccion.SelectedValue = listItemSeccion.Value;
                                        }
                                        else
                                        {
                                            cmbSeccion.SelectedIndex = -1;
                                        }
                                    }
                                    #endregion
                                    #region 201 Asignar valores Suplente de Representante de seccion
                                    else if (DatosAux.IDTipoUsu == 201)
                                    {
                                        ListItem listItemSuplente = cmbSuplente.Items.FindByValue(DatosAux.Sumplente);
                                        if (listItemSuplente != null)
                                        {
                                            cmbSuplente.SelectedValue = listItemSuplente.Value;
                                        }
                                        else
                                        {
                                            cmbSuplente.SelectedIndex = -1;
                                        }
                                        llenarComboSeccionesXMunicipio(DatosAux.Municipio);
                                        cmbSeccion.SelectedIndex = -1;
                                        cmbSeccion.Items.Insert(0, new ListItem(DatosAux.Seccion.ToString(), DatosAux.Seccion.ToString()));
                                    }
                                    #endregion
                                    #region 300 Asignar valores Representante de casilla
                                    else if (DatosAux.IDTipoUsu == 300)
                                    {
                                        cmbAsignado.SelectedIndex = -1;
                                        cmbSeccion.SelectedIndex  = -1;
                                        cmbCasilla.SelectedIndex  = -1;

                                        ListItem listItemAsignado = cmbAsignado.Items.FindByValue(DatosAux.Padre);
                                        if (listItemAsignado != null)
                                        {
                                            cmbAsignado.SelectedValue = listItemAsignado.Value;
                                        }
                                        else
                                        {
                                            cmbAsignado.SelectedIndex = -1;
                                        }

                                        //la seccion se llena directo ya que es el mismo id y nombre, es único
                                        cmbSeccion.Items.Insert(0, new ListItem(DatosAux.Seccion.ToString(), DatosAux.Seccion.ToString()));

                                        llenarComboCasillas(DatosAux.Seccion.ToString());
                                        cmbCasilla.SelectedIndex = -1;

                                        ListItem listItemCasilla = cmbCasilla.Items.FindByValue(DatosAux.Casilla.ToString());
                                        if (listItemCasilla != null)
                                        {
                                            cmbCasilla.SelectedValue = listItemCasilla.Value;
                                        }
                                        else
                                        {
                                            cmbCasilla.SelectedIndex = -1;
                                        }
                                    }
                                    #endregion
                                    #region 301 Asignar Valores Suplente de casilla
                                    else if (DatosAux.IDTipoUsu == 301)
                                    {
                                        cmbSuplente.SelectedIndex = -1;
                                        cmbSeccion.SelectedIndex  = -1;
                                        cmbCasilla.SelectedIndex  = -1;

                                        ListItem listItemSuplente = cmbSuplente.Items.FindByValue(DatosAux.Sumplente);
                                        if (listItemSuplente != null)
                                        {
                                            cmbSuplente.SelectedValue = listItemSuplente.Value;
                                        }
                                        else
                                        {
                                            cmbSuplente.SelectedIndex = -1;
                                        }

                                        //la seccion se llena directo ya que es el mismo id y nombre, es único
                                        cmbSeccion.Items.Insert(0, new ListItem(DatosAux.Seccion.ToString(), DatosAux.Seccion.ToString()));
                                        cmbCasilla.Items.Insert(0, new ListItem(DatosAux.NomCasilla, DatosAux.Casilla.ToString()));
                                    }
                                    #endregion
                                    #region 400 Operador político
                                    else if (DatosAux.IDTipoUsu == 400)
                                    {
                                        cmbAsignado.SelectedIndex = -1;
                                        cmbSeccion.SelectedIndex  = -1;
                                        cmbCasilla.SelectedIndex  = -1;

                                        ListItem listItemAsignado = cmbAsignado.Items.FindByValue(DatosAux.Padre);
                                        if (listItemAsignado != null)
                                        {
                                            cmbAsignado.SelectedValue = listItemAsignado.Value;
                                        }
                                        else
                                        {
                                            cmbAsignado.SelectedIndex = -1;
                                        }

                                        //la seccion se llena directo ya que es el mismo id y nombre
                                        cmbSeccion.Items.Insert(0, new ListItem(DatosAux.Seccion.ToString(), DatosAux.Seccion.ToString()));
                                        cmbCasilla.Items.Insert(0, new ListItem(DatosAux.NomCasilla, DatosAux.Casilla.ToString()));
                                    }
                                    #endregion
                                    else if (DatosAux.IDTipoUsu == 1 || DatosAux.IDTipoUsu == 10 || DatosAux.IDTipoUsu == 11)
                                    {
                                        cmbTipoUsuario.SelectedIndex = -1;
                                        ListItem listItemTipoUsuario = cmbTipoUsuario.Items.FindByValue(DatosAux.IDTipoUsu.ToString());
                                        if (listItemTipoUsuario != null)
                                        {
                                            cmbTipoUsuario.SelectedValue = listItemTipoUsuario.Value;
                                        }
                                        else
                                        {
                                            cmbTipoUsuario.SelectedIndex = -1;
                                        }
                                    }
                                }
                                else
                                {
                                    //Ocurrió un error
                                    Response.Redirect("frmColaboradores.aspx?error=" + "Error al cargar los datos&nError=1", false);
                                }
                            }
                            else
                            {
                                Response.Redirect("frmColaboradores.aspx", false);
                            }
                        }
                        else
                        {
                            Response.Redirect("frmColaboradores.aspx", false);
                        }
                    }
                    else
                    {
                        Response.Redirect("frmColaboradores.aspx", false);
                    }
                }
                else
                {//NUEVO
                    this.IniciarDatos();
                }
            }
            else
            {
                //al parecer c sera null si es evento del boton submit
                Control c = GetPostBackControl(this.Page);
                if (c == null)
                {
                    try
                    {
                        string imagen         = string.Empty;
                        string sBandImgServer = Request.Form["ctl00$cph_MasterBody$inputImgServer"].ToString();
                        bool   bandImgServer  = (sBandImgServer == "False") ? false : true;

                        CultureInfo esMX = new CultureInfo("es-MX");
                        int         IDGenero, IDTipoUsuario = -1;
                        DateTime    txtFechaNac;

                        if (imgImagen.HasFile) //Hay cambio de imagen
                        {
                            #region Obtener datos de la imagen
                            int    size           = imgImagen.PostedFile.ContentLength;
                            byte[] ImagenOriginal = new byte[size];
                            imgImagen.PostedFile.InputStream.Read(ImagenOriginal, 0, size);
                            Bitmap ImagenOriginalBinaria = new Bitmap(imgImagen.PostedFile.InputStream);
                            #endregion
                            #region Insertar imagen en la base de datos
                            imagen = ZM_ConversionBS.ToBase64String(ImagenOriginalBinaria, ImageFormat.Jpeg);
                            #endregion
                            bandImgServer = true;
                        }

                        //obtener tipo de usuario
                        if (Session["idtipouser"] != null)
                        {
                            IDTipoUsuario = Convert.ToInt32(Session["idtipouser"].ToString());
                        }
                        else
                        {
                            IDTipoUsuario = Convert.ToInt32(cmbTipoUsuario.SelectedValue.ToString());
                        }

                        //Valores predeterminados, tanto para el representante general como el administrador
                        string padre = "X", suplente = "X", id_poligono = "X";
                        int    seccion = 0, municipio = 0, casilla = 0;

                        //regla de los nuevos campos
                        //checamos el suplente del representante general
                        if (IDTipoUsuario == 101)
                        {
                            suplente = cmbSuplente.SelectedValue.ToString();
                        }
                        //representante de seccion
                        else if (IDTipoUsuario == 200)
                        {
                            padre     = cmbAsignado.SelectedValue.ToString();
                            municipio = Int32.Parse(cmbMunicipio.SelectedValue.ToString());
                            seccion   = Int32.Parse(cmbSeccion.SelectedValue.ToString());
                        }
                        //suplente de representante de seccion
                        else if (IDTipoUsuario == 201)
                        {
                            suplente = cmbSuplente.SelectedValue.ToString();
                            seccion  = Convert.ToInt32(cmbSeccion.SelectedValue.ToString());
                        }
                        //representate de casilla
                        else if (IDTipoUsuario == 300)
                        {
                            padre   = cmbAsignado.SelectedValue.ToString();
                            seccion = Convert.ToInt32(cmbSeccion.SelectedValue.ToString());
                            int.TryParse(cmbCasilla.SelectedValue.ToString(), out casilla);
                        }
                        //suplente representante de casilla
                        else if (IDTipoUsuario == 301)
                        {
                            suplente = cmbSuplente.SelectedValue.ToString();
                            seccion  = Convert.ToInt32(cmbSeccion.SelectedValue.ToString());
                            int.TryParse(cmbCasilla.SelectedValue.ToString(), out casilla);
                        }
                        //operador politico
                        else if (IDTipoUsuario == 400)
                        {
                            padre   = cmbAsignado.SelectedValue.ToString();
                            seccion = Int32.Parse(cmbSeccion.SelectedValue.ToString());
                            int.TryParse(cmbCasilla.SelectedValue.ToString(), out casilla);
                        }
                        //Administrador | capturista | monitor
                        else if (IDTipoUsuario == 1 || IDTipoUsuario == 10 || IDTipoUsuario == 11)
                        {
                        }

                        int estado = 0;

                        string txtNomb          = Request.Form["ctl00$cph_MasterBody$txtNombre"].ToString();
                        string txtApPaterno     = Request.Form["ctl00$cph_MasterBody$txtApPaterno"].ToString();
                        string txtApMaterno     = Request.Form["ctl00$cph_MasterBody$txtApMaterno"].ToString();
                        string txtCorreo        = Request.Form["ctl00$cph_MasterBody$txtCorreo"].ToString();
                        string txtTelefono      = Request.Form["ctl00$cph_MasterBody$txtTelefono"].ToString();
                        string txtPassword      = Request.Form["ctl00$cph_MasterBody$id_password"].ToString();
                        string txtPasswordConfi = Request.Form["ctl00$cph_MasterBody$id_password_again"].ToString();
                        string FechaNacimi      = string.IsNullOrEmpty(Request.Form["ctl00$cph_MasterBody$txtFechaNac"]) ? string.Empty : Request.Form["ctl00$cph_MasterBody$txtFechaNac"];
                        DateTime.TryParseExact(FechaNacimi, "dd-MM-yyyy", esMX, System.Globalization.DateTimeStyles.None, out txtFechaNac);
                        string txtCP      = Request.Form["ctl00$cph_MasterBody$txtCodigoPostal"].ToString();
                        string direccion  = Request.Form["ctl00$cph_MasterBody$txtDireccion"].ToString();
                        string numExt     = Request.Form["ctl00$cph_MasterBody$txtNumeroExt"].ToString();
                        string numInt     = Request.Form["ctl00$cph_MasterBody$txtNumeroInt"].ToString();
                        string colonia    = Request.Form["ctl00$cph_MasterBody$txtColonia"].ToString();
                        string clvElector = Request.Form["ctl00$cph_MasterBody$txtClavElector"].ToString();
                        IDGenero = Int32.Parse(cmbGenero.SelectedValue.ToString());
                        string IDColaborador  = Request.Form["ctl00$cph_MasterBody$hf"].ToString();
                        bool   bandPassServer = bool.Parse(Request.Form["ctl00$cph_MasterBody$inputPassServer"].ToString());

                        this.Guardar(
                            IDColaborador, IDTipoUsuario, txtNomb, txtApPaterno, txtApMaterno, estado,
                            municipio, id_poligono, direccion, numExt, numInt, colonia,
                            txtCP, clvElector, txtCorreo, txtTelefono, txtPassword, IDGenero,
                            txtFechaNac, imagen, bandPassServer, padre, suplente, casilla,
                            bandImgServer, seccion
                            );
                    }
                    catch (Exception ex)
                    {
                        Response.Redirect("ErrorPage.aspx?msjError=" + ex.Message, false);
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CH_Poligono Datos = new CH_Poligono();

            Datos.Conexion    = Comun.Conexion;
            Datos.IDEstado    = 1;
            Datos.IDMunicipio = 1;

            ER_Secciones DatosSecciones = new ER_Secciones();

            DatosSecciones.Conexion = Comun.Conexion;

            CH_PoligonoNegocio CPN = new CH_PoligonoNegocio();

            poligonos             = CPN.ObtenerComboPoligonos(Datos);
            DatosSecciones.opcion = 15;
            ER_SeccionesNegocio ESN = new ER_SeccionesNegocio();

            municipios = ESN.ObtenerComboMunicipios(DatosSecciones);

            CH_PartidoPolitico datos = new CH_PartidoPolitico {
                Conexion = Comun.Conexion
            };
            CH_CatalogosNegocio CPPN = new CH_CatalogosNegocio();

            partidos = CPPN.ObtenerCatalogoPartidos(datos);
            CPPN.ObtenerComboColaboradoresTipo(datos);
            DatosGlobales = datos;

            if (!IsPostBack)
            {
            }
            else
            {
                CH_Conteo conteo = new CH_Conteo();

                string    idseccion   = Request.Form["CmbSecciones"].ToString();
                string    idcasilla   = Request.Form["CmbCasilla"].ToString();
                string    colaborador = Request.Form["cmbColaboradores"].ToString();
                DataTable dt          = new DataTable();
                dt.Columns.AddRange(new DataColumn[3] {
                    new DataColumn("IDPartido", typeof(int)), new DataColumn("Votos", typeof(int)), new DataColumn("alianza", typeof(bool))
                });

                for (int i = 0; i < partidos.Count; i++)
                {
                    int      id        = Convert.ToInt32(partidos[i].IDPartido);
                    int      voto      = Convert.ToInt32(Request.Form[partidos[i].Siglas].ToString());
                    bool     alianza   = Convert.ToBoolean(partidos[i].alianza);
                    object[] FilaDatos = { id, voto, alianza };
                    dt.Rows.Add(id, voto, alianza);
                }

                #region Obtener datos de la imagen
                int    size           = fuploadImagen.PostedFile.ContentLength;
                byte[] ImagenOriginal = new byte[size];

                fuploadImagen.PostedFile.InputStream.Read(ImagenOriginal, 0, size);

                Bitmap ImagenOriginalBinaria = new Bitmap(fuploadImagen.PostedFile.InputStream);
                #endregion

                #region recuperar datos de la vista


                #endregion

                #region Insertar imagen en la base de datos
                string imagenString = ZM_ConversionBS.ToBase64String(ImagenOriginalBinaria, ImageFormat.Jpeg);


                #endregion

                this.Guardar("", dt, idseccion, idcasilla, colaborador, imagenString);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["op"] != null)
                {
                    if (Request.QueryString["op"] == "2")
                    {
                        if (Request.QueryString["id"] != null)
                        {
                            int ID = 0;
                            if (int.TryParse(Request.QueryString["id"].ToString(), out ID))
                            {
                                //Obtener los datos y dibujarlos.
                                CH_PartidoPolitico DatosAux = new CH_PartidoPolitico {
                                    Conexion = Comun.Conexion, IDPartido = ID
                                };
                                CH_CatalogosNegocio CN = new CH_CatalogosNegocio();
                                CN.ObtenerDetallePartidoXID(DatosAux);
                                if (DatosAux.Completado)
                                {
                                    this.CargarDatos(DatosAux);
                                }
                                else
                                {
                                    //Ocurrió un error
                                    Response.Redirect("frmPartidosGrid.aspx?error=" + "Error al cargar los datos&nError=1");
                                }
                            }
                            else
                            {
                                Response.Redirect("frmPartidosGrid.aspx");
                            }
                        }
                        else
                        {
                            Response.Redirect("frmPartidosGrid.aspx");
                        }
                    }
                    else
                    {
                        Response.Redirect("frmPartidosGrid.aspx");
                    }
                }
                else
                {
                    this.IniciarDatos();
                }
            }
            else
            {
                if (Request.Form.Count == 8 || Request.Form.Count == 9)
                {
                    bool Band = false;
                    if (imgLogo.HasFile)    //Hay cambio de imagen
                    {
                        Band = true;
                    }
                    string         txtNomb     = Request.Form["ctl00$cph_MasterBody$txtNombre"].ToString();
                    string         txtSigl     = Request.Form["ctl00$cph_MasterBody$txtSigla"].ToString();
                    string         txtColo     = Request.Form["ctl00$cph_MasterBody$txtColor"].ToString();
                    int            IDPartido   = -1;
                    string         logoPartido = string.Empty;
                    HttpPostedFile bannerImage = imgLogo.PostedFile as HttpPostedFile;
                    try
                    {
                        string AuxID = Request.Form["ctl00$cph_MasterBody$hf"].ToString();
                        int.TryParse(AuxID, out IDPartido);
                        bool NuevoRegistro = !(IDPartido > 0);
                        if (imgLogo.HasFile)
                        {
                            int    size           = imgLogo.PostedFile.ContentLength;
                            byte[] ImagenOriginal = new byte[size];
                            imgLogo.PostedFile.InputStream.Read(ImagenOriginal, 0, size);
                            Bitmap      ImagenOriginalBinaria = new Bitmap(imgLogo.PostedFile.InputStream);
                            string      extension             = Path.GetExtension(imgLogo.FileName);
                            ImageFormat imageFormateExtension = FG_Auxiliar.ObtenerExtensionImageFormat(extension);
                            if (imageFormateExtension != null)
                            {
                                logoPartido = ZM_ConversionBS.ToBase64String(ImagenOriginalBinaria, imageFormateExtension);
                            }
                        }
                        else
                        {
                            logoPartido = Logo.Attributes["data-src"];
                        }

                        this.Guardar(NuevoRegistro, IDPartido, txtNomb, txtSigl, txtColo, logoPartido, Band);
                    }
                    catch (Exception ex)
                    {
                        Response.Redirect("ErrorPage.aspx?msjError=" + ex.Message);
                    }
                }
            }
        }