Example #1
0
 private void btnlogin_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(txtuser.Text) == true || string.IsNullOrWhiteSpace(txtpass.Text) == true)
     {
         MessageBox.Show("No se permiten campos vacios.");
     }
     else
     {
         if (txtuser.Text == txtpass.Text)
         {
             string passEncrypt = Mantenimiento.Encrypt(txtpass.Text);
             using (SSSMEntities db = new SSSMEntities())
             {
                 Usuario otabla = db.Usuario.Find(Properties.Settings.Default.UserID);;
                 otabla.Clave           = passEncrypt;
                 otabla.Estado          = "Activo";
                 db.Entry(otabla).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 MessageBox.Show("Se actualizo la contraseña correctamente.");
                 Login log = new Login();
                 log.Show();
                 this.Close();
             }
         }
         else
         {
             MessageBox.Show("Contraseñas no coinciden.");
         }
     }
 }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(nombre.Text) == false && string.IsNullOrWhiteSpace(user.Text) == false && string.IsNullOrWhiteSpace(pass.Text) == false)
            {
                string clave = Mantenimiento.Encrypt(pass.Text);
                string puesto;

                if (radUser.Checked)
                {
                    puesto = "Usuario";
                }
                else
                {
                    puesto = "Administrador";
                }

                using (SSSMEntities db = new SSSMEntities())
                {
                    oTabla.Nombre      = nombre.Text;
                    oTabla.Clave       = clave;
                    oTabla.Estado      = estadoCmb.Text;
                    oTabla.TipoUsuario = puesto;

                    db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("No se permiten espacios en blanco");
            }
        }
Example #3
0
        private void btnlogin_Click(object sender, EventArgs e)
        {
            using (SSSMEntities db = new SSSMEntities())
            {
                string passEncrypt = Mantenimiento.Encrypt(txtpass.Text);
                var    lst         = from d in db.Usuario
                                     where d.Usuario1 == txtuser.Text &&
                                     d.Clave == passEncrypt
                                     select d;
                if (lst.Count() > 0)
                {
                    Usuario otabla = lst.FirstOrDefault <Usuario>();
                    Properties.Settings.Default.UserID = otabla.ID;
                    switch (otabla.Estado)
                    {
                    case "Activo":
                        Properties.Settings.Default.UserAdmin = otabla.TipoUsuario;
                        Properties.Settings.Default.UserName  = otabla.Nombre;
                        this.Hide();
                        PantallaPrincipal frm = new PantallaPrincipal();
                        frm.FormClosed += (s, args) => this.Close();
                        frm.Show();
                        break;

                    case "Inactivo":
                        MessageBox.Show("Usuario Inactivo");
                        break;

                    case "CambiarClave":
                        CambiarClave clave = new CambiarClave();
                        clave.Show();
                        this.Hide();
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Usuario o contraseña incorrecto");
                }
            }
        }
Example #4
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(nombre.Text) == false && string.IsNullOrWhiteSpace(usuario.Text) == false && string.IsNullOrWhiteSpace(pass.Text) == false)
            {
                string tipo;
                if (radUser.Checked)
                {
                    tipo = "Usuario";
                }
                else
                {
                    tipo = "Administrador";
                }

                string passEncrypt = Mantenimiento.Encrypt(pass.Text);

                using (SSSMEntities db = new SSSMEntities())
                {
                    Usuario oTabla = new Usuario();

                    oTabla.Nombre      = nombre.Text;
                    oTabla.Clave       = passEncrypt;
                    oTabla.Usuario1    = usuario.Text;
                    oTabla.TipoUsuario = tipo;
                    oTabla.Estado      = "CambiarClave";

                    db.Usuario.Add(oTabla);
                    db.SaveChanges();

                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("No se permiten espacios en blanco");
            }
        }