// Jump to login page private void picLogo_Click(object sender, EventArgs e) { Login_Page frmLogin = new Login_Page(); frmLogin.Show(); Hide(); }
/// <summary> /// Return to Login Form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void picLogo_Click(object sender, EventArgs e) { this.Hide(); Login_Page login = new Login_Page(); login.Show(); }
/// <summary> /// Register a new administrator account /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRegister_Click(object sender, EventArgs e) { // Name can't be null if (txtName.Text == "") { picNameError.Visible = true; } // Telephone can't be null if (txtTelephone.Text == "") { picTelError.Visible = true; } // E-mail can't be null if (txtEmail.Text == "") { picemailError.Visible = true; } // Password can't be null if (txtPassword.Text == "") { picPassword.Visible = true; } // Confirm Password can not be null if (txtEnsurePsw.Text == "") { picConfirmPasw.Visible = true; } // The warning icons are showing the Mysql command can not be executed if ((picNameError.Visible == true) || (picTelError.Visible == true) || (picemailError.Visible == true) || (picPassword.Visible == true) || (picConfirmPasw.Visible == true)) { MessageBox.Show("Please confirm that the personal information \n is complete and accurate !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if ((txtName.Text == "") || (txtTelephone.Text == "") || (txtEmail.Text == "") || (txtPassword.Text == "") || (txtEnsurePsw.Text == "")) // The text box can not be empty ! { MessageBox.Show("Personal information cannot be empty !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { ConnDB(); // Connect the Database // Mysql query command...........And the password is enciphered ! string strsql = string.Format("Insert into Administrator(Name, TelNum, Email, Password) values ('{0}', '{1}', '{2}', md5('{3}'))", txtName.Text, txtTelephone.Text, txtEmail.Text, txtPassword.Text); // Represents a transact-sql statement or stored procedure to execute against the SQL Server database MySqlCommand cmd = new MySqlCommand(strsql, conn); try { // Execute the SQL command cmd.ExecuteNonQuery(); MessageBox.Show("Registered Successfully !", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); lblTip.Text = "Waiting to jump to the login page !"; // The current page is hide this.Hide(); // Open the log in page Login_Page frmLogin = new Login_Page(); frmLogin.Show(); } catch { MessageBox.Show("The Administrator Already Exists !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtName.Focus();// Set the cursor here } conn.Close(); } }