// Login Button CLick private void loginLoginButton_Click(object sender, EventArgs e) { // Obtain login information string userName = loginUsernameTextBox.Text; string password = loginPasswordTextBox.Text; int userID; // Check if username or password are empty if (String.IsNullOrWhiteSpace(loginUsernameTextBox.Text) || String.IsNullOrWhiteSpace(loginPasswordTextBox.Text)) { // Display appropriate message based on language if (currentCulture == "fr-FR") { MessageBox.Show("Le nom d'utilisateur et le mot de passe ne peuvent pas être vides"); } else { MessageBox.Show("Username and password cannot be empty"); } return; } // Open database connection DataInterface.DBOpen(); // Build Query MySqlCommand cmd = new MySqlCommand($"SELECT userId FROM user WHERE userName = '******' AND password = '******'", DataInterface.conn); MySqlDataReader reader = cmd.ExecuteReader(); // If matching data is present, set current user information and open MainForm if (reader.HasRows) { // Read rows returned reader.Read(); // Set userID based on row returned userID = Convert.ToInt32(reader[0]); // set current user information DataInterface.setCurrentUserID(userID); DataInterface.setCurrentUserName(userName); // close database connection reader.Close(); DataInterface.DBClose(); // Hide Login form and open MainForm MainForm mainForm = new MainForm(); MainForm.loginForm = this; this.Hide(); mainForm.Show(); loginUsernameTextBox.Text = ""; loginPasswordTextBox.Text = ""; recordLogin(DataInterface.getCurrentUserName()); } // Username/Password do not match information in database else { // Dipslay language appropriate error message MessageBox.Show(errorMessage); loginPasswordTextBox.Text = ""; } }