private void btnPasswordReset_Click(object sender, RoutedEventArgs e) { try { string str = Interaction.InputBox("Enter user id to reset", "", "", -1, -1); if (str == "") { return; } int tmp; if (!int.TryParse(str, out tmp)) { MessageBox.Show("Invalid ID"); return; } user = queries.GetUser(tmp); if (user == null) { MessageBox.Show("Unable To Find User"); return; } queries.ResetUserLogin(user); MessageBox.Show("Password has been reset"); Close(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void Login() { try { string[] text = new string[] { "SELECT * FROM login WHERE user_id='", txtEmployeeId.Text, "' AND password='******'" }; MySqlCommand mySqlCommand = new MySqlCommand(string.Concat(text), myConnection.MySqlConnection); myConnection.Open(); MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(); int num = 0; while (mySqlDataReader.Read()) { num++; } if (num == 1) { myConnection.Close(); Session.CreateSession(txtEmployeeId.Text, txtPassword.Password); MainWindow mainWindow = new MainWindow(queries.GetUser(int.Parse(txtEmployeeId.Text))); mainWindow.Show(); Close(); } else if (num <= 1) { MessageBox.Show("Incorrect Username and/or Password"); myConnection.Close(); } else { MessageBox.Show("Duplicate Username and password.... Access Denied"); myConnection.Close(); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }