Beispiel #1
0
        private void clLogin_Click(object sender, EventArgs e)
        {
            if (textUsername.Text.Trim().Length == 0) return;
            if (textPassword.Text.Trim().Length == 0) return;

            var user = db.Users.Where(o => o.Username == textUsername.Text).FirstOrDefault();
            if (user == null)
            {
                user = new User { Username = textUsername.Text, Password = textPassword.Text };

                db.AddToUsers(user);
                db.SaveChanges();

                _args = new TextEventArgs("Success") { Data = user };
                this.Hide();
            }
            else if (user.Password != textPassword.Text)
            {
                _args = new TextEventArgs("Fail") { Data = null };
                MessageBox.Show(this, @"Username/Password does not match!");

            }
            else
            {
                _args = new TextEventArgs("Success") { Data = user };
                this.Hide();
            }
        }
Beispiel #2
0
 private void LoginForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (_args == null)
         _args = new TextEventArgs("Fail") { Data = null };
     InvokeLoggedIn(_args);
 }
Beispiel #3
0
 private void commandLink1_Click(object sender, EventArgs e)
 {
     _args = new TextEventArgs("Fail") { Title = "", Data = null };
     this.Hide();
 }