Ejemplo n.º 1
0
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            using (var db = new QLBHDataContext())
            {
                var user = db.Users.SingleOrDefault(u => u.f_Username.Equals(textBoxUsername.Text));

                if (user != null)
                {
                    EncryptPassword encryptPw = new EncryptPassword();

                    if (encryptPw.IsPasswordValid(textBoxPassword.Text, user.f_Password))
                    {
                        MessageBox.Show("Logged in successfully!");
                    }
                    else
                    {
                        MessageBox.Show("Login failed!");
                    }
                }
                else
                {
                    MessageBox.Show("Login failed!");
                }
            }
        }
Ejemplo n.º 2
0
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            using (var db = new QLBHDataContext())
            {
                var newUser = GetUser();

                if (db.Users.FirstOrDefault(u => u.f_Username.Equals(newUser.f_Username)) == null)
                {
                    db.Users.InsertOnSubmit(newUser);
                    db.SubmitChanges();
                    MessageBox.Show("Signed up successfully!");
                }
                else
                {
                    MessageBox.Show("Username already exists! Please try other username!");
                }
            }
        }