private void button4_Click(object sender, EventArgs e) { this.Hide(); frm_Dashboard DashboardOpen = new frm_Dashboard(); DashboardOpen.ShowDialog(); }
private void button2_Click(object sender, EventArgs e) { if (txt_createFname.Text == "") { MessageBox.Show("Can't leave anything blank, Please enter your Firstname.", "Creating Account Error"); } else if (txt_createLname.Text == "") { MessageBox.Show("Can't leave anything blank, Please enter your Lastname.", "Creating Account Error"); } else if (txt_createEmail.Text == "") { MessageBox.Show("Can't leave anything blank, Please enter your Email.", "Creating Account Error"); } else if (txt_createUsername.Text == "") { MessageBox.Show("Can't leave anything blank, Please create a Username.", "Creating Account Error"); } else if (txt_createPassword.Text == "") { MessageBox.Show("Can't leave anything blank, Please create a Password.", "Creating Account Error"); } else if (txt_createConfirmPassword.Text == "") { MessageBox.Show("Can't leave anything blank, Please re-enter your password to verify.", "Creating Account Error"); } else { try { if (txt_createPassword.Text == txt_createConfirmPassword.Text) { connection.Open(); OleDbCommand command = new OleDbCommand(); command.Connection = connection; command.CommandText = "insert into UserData (FirstName,Username,LastName,Pw,Email) values ('" + txt_createFname.Text + "','" + txt_createUsername.Text + "','" + txt_createLname.Text + "','" + txt_createPassword.Text + "','" + txt_createEmail.Text + "')"; command.ExecuteNonQuery(); MessageBox.Show("Creating new account success", "Message"); connection.Close(); MessageBox.Show("Welcome " + txt_createUsername.Text + "!", "New User Logging In"); this.Hide(); frm_Dashboard dashboardOpen = new frm_Dashboard(); dashboardOpen.ShowDialog(); } else { MessageBox.Show("Your password does not match, please try again.", "Creating Account Error"); } } catch (Exception ex) { MessageBox.Show("Error " + ex); } } }
private void btn_Login_Click(object sender, EventArgs e) { if (txt_Username.Text == "") { MessageBox.Show("Please enter your Username", "Login Error"); } else if (txt_Password.Text == "") { MessageBox.Show("Please enter your Password", "Login Error"); } else { connection.Open(); OleDbCommand command = new OleDbCommand(); command.Connection = connection; command.CommandText = "select * from UserData where Username='******' and Pw='" + txt_Password.Text + "'"; OleDbDataReader reader = command.ExecuteReader(); int count = 0; while (reader.Read()) { count = count + 1; } if (count == 1) { MessageBox.Show("Welcome " + txt_Username.Text + "!", "Login Successful"); connection.Close(); connection.Dispose(); this.Hide(); frm_Dashboard dashboardOpen = new frm_Dashboard(); dashboardOpen.ShowDialog(); } else if (count > 1) { MessageBox.Show("Duplicate Username and Password"); connection.Close(); } else { MessageBox.Show("Username or Password is Incorrect", "Login Failed"); connection.Close(); } } }