Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                CampingEntities1 db = new CampingEntities1();

                var     d = db.Usuario.ToList();
                Usuario u = new Usuario();

                //Dim x = From n in Table1 _
                var x = from n in d select new { Nombre = n.nombre, Apellido = n.apellido };
                //Select n.FirstName, n.LastName, N.Department
                //DataGridView1.DataSource = x
                var employee = db.Usuario.Where(em => true).Select(em => new { em.nombre, em.correo }).ToList();
                //where(x => x.EMAIL == givenInfo || x.USER_NAME == givenInfo)
                //.Select(x => new { x.EMAIL, x.ID });

                dataGridView1.DataSource = employee;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
Esempio n. 2
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            TimeSpan ts    = System.DateTime.Today - dpFecNac.Value;
            int      years = ts.Days / 365;

            if (tbNombres.TextLength < 1 || tbApellidos.TextLength < 1 || tbUsername.TextLength < 1 ||
                tbPass.TextLength < 6 || !tbPass.Text.Equals(tbPassConf.Text) ||
                tbEmail.TextLength < 1 || years < 18)
            {   // EN REALIDAD ESTE HICE A LAS APURADAS, TENDRÍAMMOS QUE SEPARAR CADA CASO E INFORMAR PORQUEÉ NO SE PUEDE
                MessageBox.Show("Error putito");
            }
            else  /// ésto es en el caso de que todo esté bien
            {   /// unhandled acveptioon,  excepción no atenddia (el delay me está reventando jajaç)
                CampingEntities1 db = new CampingEntities1();

                try         ///  falta hacer que se cierre la ventana. cargá esto así trabajo desde acá porque hice modificaciónes hoy pero las meto en este
                {
                    var q = db.Usuario.Where(p => p.username.Equals(tbUsername.Text));
                    if (q.Count() > 0)
                    {
                        MessageBox.Show("El nombre de usuario ya existe");
                    }
                    else
                    {
                        Usuario u = new Usuario
                        {
                            apellido   = tbApellidos.Text,
                            nombre     = tbNombres.Text,
                            username   = tbUsername.Text,
                            clave      = tbPass.Text,
                            correo     = tbEmail.Text,
                            hombre     = rbMasculino.Checked,
                            nacimiento = dpFecNac.Value,
                            direccion  = tbDireccion.Text,
                            id_rol     = Rol.USUARIO
                        };
                        db.Usuario.Add(u);
                        db.SaveChanges();
                        MessageBox.Show("Listo");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 3
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     pictureBox1.BackgroundImage = Properties.Resources.ingresar2;
     if (txtuser.Text.Trim() == "")
     {
         MessageBox.Show("Asegúrese de ingresar el Usuario");
         txtuser.Focus();
     }
     else if (txtpass.Text.Trim() == "")
     {
         MessageBox.Show("Asegúrese de ingresar la Contraseña");
         txtpass.Focus();
     }
     else
     {
         CampingEntities1 db = new CampingEntities1();
         Usuario          u  = null;
         try
         {
             u = db.Usuario.Single(p => p.username.Equals(txtuser.Text.ToString()));
             if (u == null)
             {
                 MessageBox.Show("Usuario incorrecto");
             }
             else if (u.clave.Equals(txtpass.Text))
             {
                 MessageBox.Show("Bienvenid" + (u.hombre?"o ":"a ") + u.nombre);
                 Program.usuario = u.nombre;
                 this.Hide();
                 MenuPrincipalEmpAdmin fr = new MenuPrincipalEmpAdmin();
                 fr.Show();
             }
             else
             {
                 MessageBox.Show("Clave incorrecta");
                 txtpass.Text = "";
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }