private void submit_Click(object sender, EventArgs e) { MySqlConnection connection = DatabaseConnection.GetConnection(); try { /*if (Regex.IsMatch(usernameText.Text, @"^[a-zA-Z0-9_]+$")){ * if (Regex.IsMatch(passwordText.Text, @"^[a-zA-Z0-9!@#$%^&*]+$")) * { * Employee employee = new Employee(); * if(employee.login(usernameText.Text, passwordText.Text)) * { * this.Hide(); * Main main = new Main(); * main.Show(); * } * else * { * MessageBox.Show("Username or Password is incorrect.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); * } * } * }*/ this.Hide(); Main main = new Main(); main.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message + " Program will terminate.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Miscellaneous.Shutdown(); } }
public static MySqlConnection GetConnection() { if (connection == null) { try { connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["databaseconnection"].ConnectionString); }catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Miscellaneous.Shutdown(); } } return(connection); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { Miscellaneous.Shutdown(); }