private void btnMenu_Click(object sender, EventArgs e) { this.Close(); menu screen = new menu(); screen.Show(); }
private void btnMenu_Click(object sender, EventArgs e) { menu menu = new menu(); this.Close(); menu.Show(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "Admin" && textBox2.Text.ToString() == "123") { menu page2 = new menu(); page2.Show(); Hide(); } else { lblErrorText.Text = "Invalid username or password"; lblErrorText.ForeColor = Color.Red; } }
public void UserNamePasswordValidation(Action ac) { string path = @"Data\Login\"; path += usrnmTextBox.Text; if (ac == Action.CREATE) { if (usrnmTextBox.Text == "User Name" || usrnmTextBox.Text == "") { MessageBox.Show("Error! Enter valid username!"); usrnmTextBox.Focus(); } else if (passwordTextBox.Text == "Password" || passwordTextBox.Text == "") { MessageBox.Show("Error! Enter valid password!"); passwordTextBox.Focus(); } else // UserName and Password are non-empty. We can create account. { try { if (File.Exists(path)) { MessageBox.Show("Sorry! User already exists."); return; } // Create a file to write to. using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(Encrypt(passwordTextBox.Text)); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } else if (ac == Action.LOGIN) { try { using (StreamReader sr = new StreamReader(path)) { string password; password = sr.ReadLine(); if (Decrypt(password) == passwordTextBox.Text) { mainMenu.Tag = this; mainMenu.Show(this); Hide(); } else { MessageBox.Show("Sorry! Incorrect password! Try again."); } } } catch (Exception e) { // Let the user know what went wrong. MessageBox.Show("Sorry! User doesn't exists!"); } } else if (ac == Action.CHANGEPASSWORD) { try { using (StreamReader sr = new StreamReader(path)) { string password; password = sr.ReadLine(); sr.Close(); changePasswordForm chPassForm = new changePasswordForm(); chPassForm.savedPassword = Decrypt(password); chPassForm.savedUser = usrnmTextBox.Text; chPassForm.Tag = this; chPassForm.ShowDialog(this); } } catch (Exception e) { // Let the user know what went wrong. MessageBox.Show("Sorry! User doesn't exists!"); } } }