private void button1_Click(object sender, EventArgs e) { // ------------------ CLICKING THE BACK BUTTON WILL TAKE YOU ON PREVIOUS PAGE -------------------- // it will hide the previous page and show the page you wanted to open that is inputData page this.Hide(); inputData ss1 = new inputData(); ss1.Show(); }
private void button1_Click(object sender, EventArgs e) { // ------------------ CLICKING THE BACK BUTTON WILL TAKE YOU YOU TO PREVIOUS PAGE -------------------- // previous page hides when new page is requested this.Hide(); inputData ss1 = new inputData(); ss1.Show(); }
private void button1_Click(object sender, EventArgs e) { // ------------------ CLICKING THE SIGNUP BUTTON WILL LET YOU MAKE AN ACCOUNT -------------------- // Storing data values entered by the user in variables string Username = UserID.Text; string FirstName = F_Name.Text; string LastName = L_Name.Text; string email = Email.Text; string password = pas.Text; string C_password = cpass.Text; // Openong the connection con.Open(); // Storing data entered by the user in the database tables SqlCommand cmd = new SqlCommand("insert into UserTable(UserID,FirstName,LastName,Email,Password)values(@username,@fname,@lname,@email,@password)", con); cmd.Parameters.AddWithValue("@username", Username); cmd.Parameters.AddWithValue("@fname", FirstName); cmd.Parameters.AddWithValue("@lname", LastName); cmd.Parameters.AddWithValue("@email", email); cmd.Parameters.AddWithValue("@password", password); if (password == C_password) { // If both the password and confirm password text matches, the success message is displayed warning.ForeColor = Color.Green; warning.Text = "Matched"; cmd.ExecuteNonQuery(); MessageBox.Show("You are Successfully Registered"); // After signing in, the inputData page will be displayed where user will make a choice /// either to create a time table or see the previously generated timetable using code this.Hide(); inputData ss1 = new inputData(); ss1.Show(); } else { // If both the password and confirm password text does not matches, the warrning message // is displayed in red color with message that the password did not match. warning.ForeColor = Color.Red; warning.Text = "Password did not match! "; } // Closing the connection con.Close(); }
private void loginbut_Click(object sender, EventArgs e) { // ------------------ LOGIN BUTTON WILL LET YOU LOGIN THE ACCOUNT USING // INFORMATION YOU SIGNED UP WITH -------------------- SqlConnection con = new SqlConnection("Data Source=DESKTOP-6FG9FQD;Initial Catalog=AutoTimeTable;Integrated Security=True"); // Storing data in a string from textbox string username = UserID_textBox.Text; string password = Password_textBox.Text; // Opening the conection con.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM UserTable WHERE UserID=@username AND Password=@password ", con); cmd.Parameters.AddWithValue("@username", username); cmd.Parameters.AddWithValue("@password", password); cmd.ExecuteNonQuery(); SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adapter.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { // If the data entered is valid; user will shown a success message and will be // logged in to the system. MessageBox.Show("You are Logged in Successfully"); // After login, next page of inputData is displayed and the previous one is hidden this.Hide(); inputData ss1 = new inputData(); ss1.Show(); } else { // Incase the username and password are not valid, a error message will be displayed. MessageBox.Show("Login Credential are incorrect"); } // Connection is closed con.Close(); }