private void Btn_login_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(tb_userName.Text)) // Check empty box { MessageBox.Show("Please input 'Email' "); } else if (String.IsNullOrEmpty(pb_password.Password.ToString())) { MessageBox.Show("Please input 'Password' "); } else { int keyCheck = 1; foreach (string listEmail in DataAccessUser.CheckEmail()) //check email and password { if (listEmail == tb_userName.Text) { foreach (string listPassword in DataAccessUser.CheckPassword()) { if (listPassword == pb_password.Password.ToString()) { WindowMenu windowMenu = new WindowMenu(); this.Close(); windowMenu.Show(); keyCheck = 2; break; } } } if (keyCheck == 2) { break; } } if (keyCheck == 1) { MessageBox.Show("Email or Password is not correct"); } pb_password.Clear(); } //tb_userName.Foreground = Brushes.Red; //เปลี่ยนสี text }
private void Btn_add_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(tb_email.Text)) { MessageBox.Show("Please input your 'EAMIL'"); } else if (String.IsNullOrEmpty(tb_password.Text)) { MessageBox.Show("Please input your 'PASSWORD'"); } else if (String.IsNullOrEmpty(tb_firstname.Text)) { MessageBox.Show("Please input your 'FIRSTNAME'"); } else if (String.IsNullOrEmpty(tb_lastname.Text)) { MessageBox.Show("Please input your 'LASTNAME'"); } else { int keyCheck = 1; foreach (string list in DataAccessUser.CheckEmail()) { if (list == tb_email.Text) { keyCheck = 2; MessageBox.Show("This Eamil is already exist"); ClearDataInTextbox(); break; } } if (keyCheck == 1) { DataAccessUser.AddData(tb_email.Text, tb_password.Text, tb_firstname.Text, tb_lastname.Text); MessageBox.Show("Add user complete"); ClearDataInTextbox(); } } }