private void Logo2_Click(object sender, EventArgs e) { Logged_HomeScreen lh = new Logged_HomeScreen(); lh.Show(); this.Hide(); }
private void btnBuyNow_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='F:\C# FINAL ASSIGNMENT (GROUP 06)\DATABASE (Accounts).mdf';Integrated Security=True;Connect Timeout=30"); String delete = "DELETE FROM Items"; SqlCommand cmd = new SqlCommand(delete, con); try { con.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Your order is successfull!", "CONGRATULATIONS!", MessageBoxButtons.OK, MessageBoxIcon.Information); Logged_HomeScreen lh = new Logged_HomeScreen(); lh.Show(); this.Hide(); } catch (Exception ex) { MessageBox.Show("Error detected :" + ex, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { con.Close(); } }
private void Button1_Click_1(object sender, EventArgs e) { if (txtFname.Text == "" || txtLname.Text == "" || txtEmail.Text == "" || txtPassword.Text == "") { MessageBox.Show("Please fill the all fields!", "WARNING!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string FirstName = txtFname.Text; string LastName = txtLname.Text; string Email = txtEmail.Text; string Password = txtPassword.Text; SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='F:\C# FINAL ASSIGNMENT (GROUP 06)\DATABASE (Accounts).mdf';Integrated Security=True;Connect Timeout=30"); String query = "Insert into SignUp Values ('" + FirstName + "' , '" + LastName + "' , '" + Email + "' , '" + Password + "')"; SqlCommand cmd = new SqlCommand(query, con); try { con.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Registration succesfull! " + txtFname.Text + ", Welcome to our online shopping store!", "WELCOME!", MessageBoxButtons.OK, MessageBoxIcon.Information); Logged_HomeScreen lh = new Logged_HomeScreen(); lh.Show(); this.Hide(); } catch (Exception ex) { MessageBox.Show($"Something wrong in registration {ex}", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void Button1_Click_1(object sender, EventArgs e) { if (txtEmail.Text == "" || txtPassword.Text == "") { MessageBox.Show("Please fill the all fields!", "WARNING!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='F:\C# FINAL ASSIGNMENT (GROUP 06)\DATABASE (Accounts).mdf';Integrated Security=True;Connect Timeout=30"); con.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM SignUp WHERE Email = '" + txtEmail.Text + "' AND Password = '******' ", con); SqlDataReader dr; dr = cmd.ExecuteReader(); int count = 0; while (dr.Read()) { count += 1; } if (count == 1) { MessageBox.Show("Hello " + txtEmail.Text + ", Welcome back to our online shopping store!", "WELCOME!", MessageBoxButtons.OK, MessageBoxIcon.Information); Logged_HomeScreen lg = new Logged_HomeScreen(); lg.Show(); this.Hide(); } else if (count > 0) { MessageBox.Show("Duplicate email & password.", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Clear(); txtPassword.Clear(); } else { MessageBox.Show("Email or password is not correct.", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Clear(); txtPassword.Clear(); } } }