Exemplo n.º 1
0
        private void btn_entrar_Click(object sender, RoutedEventArgs e)
        {
            string username = txt_rut.Text;
            string pass     = txt_pass.Password;

            Biblioteca.Usuario usuario = new Biblioteca.Usuario()
            {
                Username = username,
                Password = pass
            };

            if (usuario.login())
            {
                string rol = "";
                usuario.rolUsuario();
                switch (usuario.Rol)
                {
                case 1: rol = "Alumno"; break;

                case 2: Mantenedores mantenedor = new Mantenedores(); mantenedor.Show(); this.Close(); break;

                case 3: rol = "Cem"; break;

                case 4: rol = "Cel"; break;

                case 5: rol = "Anfitrion"; break;
                }
                lblMsj.Content = rol;
            }
            else
            {
                lblMsj.Content = "Datos Incorrectos";
            }
        }
Exemplo n.º 2
0
        private void btn_entrar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string username = txt_rut.Text;
                string pass     = txt_pass.Password;
                string hash     = string.Empty;

                using (MD5 md5Hash = MD5.Create())
                {
                    hash = GetMd5Hash(md5Hash, txt_pass.Password);
                }
                Biblioteca.Usuario usuario = new Biblioteca.Usuario()
                {
                    Username = username,
                    Password = hash
                };

                if (usuario.login())
                {
                    string rol = "";
                    usuario.rolUsuario();
                    switch (usuario.Rol)
                    {
                    case 1: rol = "Alumno"; break;

                    case 2: Admin.Admin admin = new Admin.Admin(); admin.Show(); this.Close(); break;

                    case 3: Cem.Cem cem = new Cem.Cem(); cem.Show(); this.Close(); break;

                    case 4: Cel.Cel cel = new Cel.Cel(); cel.Show(); this.Close(); break;

                    case 5: rol = "Anfitrion"; break;
                    }
                    lblMsj.Content = rol;
                }
                else
                {
                    lblMsj.Content = "Datos Incorrectos";
                }
            }
            catch (Exception ex)
            {
                lblMsj.Content = ex.Message;
            }
        }