Esempio n. 1
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtUsername.Text) && string.IsNullOrEmpty(txtPassword.Text))
     {
         MessageBox.Show(
             "Field can't be empty",
             "Error",
             MessageBoxButtons.OK,
             MessageBoxIcon.Error
             );
     }
     else
     {
         var logi = Login(txtUsername.Text.Trim(), txtPassword.Text.Trim());
         if (logi == true)
         {
             Form f = new FrmParent();
             f.Show();
             this.Hide();
         }
         else
         {
             MessageBox.Show
             (
                 "Account is not exists !",
                 "Error",
                 MessageBoxButtons.OK,
                 MessageBoxIcon.Error
             );
             txtUsername.Clear();
             txtPassword.Clear();
         }
     }
 }
Esempio n. 2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtPassword.Text != txtConfirmPassword.Text)
                {
                    MessageBox.Show(
                        "Please confirm your password",
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
                else if (txtPassword.Text == txtConfirmPassword.Text)
                {
                    do
                    {
                        userBindingSource.EndEdit();
                        this.userTableAdapter.Insert(txtUsername.Text, txtPassword.Text, txtConfirmPassword.Text);
                    }while (txtPassword.Text == txtConfirmPassword.Text);

                    MessageBox.Show(
                        "Your account has been created successfully",
                        "Confirmation",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );
                    Form f = new FrmParent();
                    f.Show();
                    this.Hide();
                }
            }
            catch
            {
                MessageBox.Show(
                    "Account already exist",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }



            /* User user = new User
             * (
             *   txtUsername.Text,
             *   txtPassword.Text,
             *   txtConfirmPassword.Text
             * );
             * foreach(User u in users)
             * {
             *   if(user.Username.Equals(u.Username))
             *   {
             *       MessageBox.Show
             *       (
             *           "Username already exists !",
             *           "Error",
             *           MessageBoxButtons.OK,
             *           MessageBoxIcon.Error
             *       );
             *       return;
             *   }
             * }
             * users.Add(user);*/

            txtUsername.Clear();
            txtPassword.Clear();
            txtConfirmPassword.Clear();
            txtUsername.Focus();
        }