private void logInButton_Click(object sender, EventArgs e) { MatchUserAndPassword matchUser=new MatchUserAndPassword(); bool status = matchUser.PasswordAndUserNameVerification(userNameTextBox.Text, passwordTextBox.Text); if (status) { MainMenuUI mainMenu = new MainMenuUI(userNameTextBox.Text, passwordTextBox.Text); this.Hide(); mainMenu.ShowDialog(); } else { MessageBox.Show("Please enter the currect username and password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void SubmitButton_Click(object sender, EventArgs e) { try { if (CurrentUserNameTextBox.Text.Equals("")) { MessageBox.Show("Please enter the current User Name.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (currentPasswordtExtBox.Text.Equals("")) { MessageBox.Show("Please enter the current Password.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (newUserNameTextBxo.Text.Equals("")) { MessageBox.Show("Please enter the new User Name.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (newPasswordTextBox.Text.Equals("")) { MessageBox.Show("Please enter the new Password.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (confirmPasswordTextBox.Text.Equals("")) { MessageBox.Show("Please re -enter the new password.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (!newPasswordTextBox.Text.Equals(confirmPasswordTextBox.Text)) { MessageBox.Show("Password conflit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MatchUserAndPassword matchUser=new MatchUserAndPassword(); bool b = matchUser.PasswordAndUserNameVerification(CurrentUserNameTextBox.Text, currentPasswordtExtBox.Text); if (b) { DBManager manager=new DBManager(); SqlConnection connection = manager.Connection(); string query = "UPDATE Security_12 set User_Name='"+newUserNameTextBxo.Text+"',Password='******' where User_Name='" + userNmae + "'and Password='******'"; SqlCommand command=new SqlCommand(query,connection); connection.Open(); int i = command.ExecuteNonQuery(); MessageBox.Show("You have sucessfully change user name and password", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("User name and Password are not currect.Please enter Currect user and Password and then try.","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } } } catch (Exception exception) { MessageBox.Show(exception.Message); } }