Ejemplo n.º 1
0
 private void buttonLogin_Click(object sender, EventArgs e)
 {
     if (textBoxUsername.Text.Length < 1 || textBoxPassword.Text.Length < 1)
     {
         labelError.Visible = true;
         labelError.Text    = "You need to enter username and/or password!";
     }
     else
     {
         if (db.Login(textBoxUsername.Text, textBoxPassword.Text))
         {
             username = textBoxUsername.Text;
             FormApp form = new FormApp();
             form.Show();
             form.Activate();
             this.Hide();
             labelError.Visible = false;
             ClearBoxes();
         }
         else
         {
             labelError.Visible = true;
             labelError.Text    = "This user does not exist! Consider creating a new one by pressing Register button!";
         }
     }
 }
Ejemplo n.º 2
0
 private void Register()
 {
     if (textBoxPassword.Text == textBoxPasswordConfirm.Text)
     {
         if (db.CheckUsernameDuplicate(textBoxUsername.Text))
         {
             labelError.Visible = true;
             labelError.Text    = "That username already exists! Please choose a different one.";
         }
         else
         {
             db.RegisterUser(textBoxUsername.Text, textBoxPassword.Text, textBoxName.Text, textBoxSurname.Text, textBoxAge.Text, comboBoxSex.Text, textBoxCountry.Text);
             this.Hide();
             loginForm.username = textBoxUsername.Text;
             FormApp fApp = new FormApp();
             fApp.Show();
             labelError.Visible = false;
             fApp.Activate();
             lForm.ClearBoxes();
             lForm.Hide();
         }
     }
     else
     {
         labelError.Visible = true;
         labelError.Text    = "Passwords must match!";
         textBoxPassword.Clear();
         textBoxPasswordConfirm.Clear();
     }
 }