Example #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Event handler. Called by btnValidar for click events. </summary>
        ///
        /// <remarks>   Vmolero, 13/04/2010. </remarks>
        ///
        /// <param name="sender">   Source of the event. </param>
        /// <param name="e">        Event information. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void btnValidar_Click(object sender, EventArgs e)
        {
            if (TVO_Utiles.Validacion.NifValido(this.eNIF.Text))
            {
                administrador = new ENPersona(this.eNIF.Text, this.eClave.Text);
                EventArgsAcceso args = null;
                try
                {
                    // p = (ENAdministrador) ControladorAcceso.valida(this.eNIF.Text, this.eClave.Text);
                    administrador.obtenerAcceso();

                    //if (administrador.Perfil == kPerfil.pNinguno)
                    //    throw new Exception();

                    Hashtable datos = new Hashtable();
                    datos["nif"]       = administrador.Dni;
                    datos["nombre"]    = administrador.Nombre;
                    datos["apellidos"] = administrador.Apellidos;
                    datos["perfil"]    = (int)administrador.Perfil;
                    if (administrador.ImgData != null)
                    {
                        datos["foto"] = (byte[])administrador.ImgData;
                    }
                    args = new EventArgsAcceso(datos);
                    EventoValidar(this, args);
                }
                catch (ENException enex)
                {
                    // MessageBox.Show(enex.Mensaje);
                    etMensaje.Text = "Error de validaciĆ³n: " + enex.Mensaje;
                    eClave.Clear();
                    eClave.Focus();
                }
            }
            else
            {
                etMensaje.Text = "Formato de NIF incorrecto.";
                Init();
            }
        }
Example #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Event handler. Called by RespuestaFormAcceso for validar events. </summary>
        ///
        /// <remarks>   . </remarks>
        ///
        /// <param name="sender">   Source of the event. </param>
        /// <param name="e">        The. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void RespuestaFormAcceso_Validar(object sender, EventArgsAcceso e)
        {
            FVistaPortadaBase Portada = new FVistaPortadaBase();

            try
            {
                administrador           = new ENPersona();
                administrador.Dni       = Convert.ToString(e.persona["nif"]);
                administrador.Nombre    = Convert.ToString(e.persona["nombre"]);
                administrador.Apellidos = Convert.ToString(e.persona["apellidos"]);
                administrador.Perfil    = (kPerfil)Convert.ToInt32(e.persona["perfil"]);
                if (e.persona["foto"] != null)
                {
                    administrador.ImgData = (byte[])e.persona["foto"];
                }

                if (administrador.Perfil == kPerfil.pTecnico)
                {
                    TVO_Mostar_FormPortadaTecnico();
                }
                else if (administrador.Perfil == kPerfil.pModerador)
                {
                    TVO_Mostar_FormPortadaModerador();
                }
                else
                {
                    throw new System.Exception("Error de validaciĆ³n");
                }

                ((FVistaAcceso)sender).EventoValidar -= new FVistaAcceso.EventoAccesoHandler(RespuestaFormAcceso_Validar);
            }
            catch (Exception ex)
            {
                ((FVistaAcceso)TVO_FormActivo).Init();
            }
        }