示例#1
0
 private async void button1_Click(object sender, EventArgs e)
 {
     //log in
     //check if user exists
     if ((!(username.Text.Equals("")) && (!password.Text.Equals(""))))
     {
         if (await ListDB.checkUserExists(username.Text))
         {
             if (await ListDB.logIn(username.Text, ListDB.hashIt(password.Text)))
             {
                 //username and password match
                 MainForm.label1.Text = "Logged in as ' " + username.Text + " '";
                 MainForm.button7.Hide();
                 MainForm.button8.Show();
                 MainForm.LoggedIn = true;
                 Close();
             }
             else
             {
                 MessageBox.Show("Wrong password!");
             }
             //password does not match
         }
         else
         {
             MessageBox.Show("That username does not exist.");
         }
     }
     else
     {
         MessageBox.Show("The username or password field is empty.");
     }
 }
示例#2
0
 private async void button1_Click(object sender, EventArgs e)
 {
     if ((!(username.Text.Equals("")) && (!password.Text.Equals(""))))
     {
         //if user does not exist already
         if (await ListDB.checkUserExists(username.Text) == false)
         {
             //hash password
             var pwdHash = ListDB.hashIt(password.Text);
             //create user
             ListDB.newUser(username.Text, pwdHash);
             //return to login form
             Close();
         }
         else
         {
             MessageBox.Show("That username has already been taken. Please try another.");
         }
     }
     else
     {
         MessageBox.Show("The username or password field is empty.");
     }
 }
示例#3
0
 private void Form3_Load(object sender, EventArgs e)
 {
     ListDB DB = new ListDB();
 }