Guest User

Untitled

a guest
Jan 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. private void buttonSave_Click(object sender, EventArgs e)
  2. {
  3. SqlConnection con = new SqlConnection("Data Source=DESKTOP-R6KE2IE\SQLEXPRESS;Initial Catalog=passmaker;Integrated Security=True");
  4. SqlDataAdapter ASDF = new SqlDataAdapter("SELECT COUNT(*) FROM tbl_Login WHERE Password='" + textBoxPassword.Text + "'AND Email ='" + textBoxEmail.Text + "'", con);
  5. DataTable DS = new DataTable();
  6. ASDF.Fill(DS);
  7. ErrorProvider errorProvider = new ErrorProvider();
  8. errorProvider.Clear();
  9. if (DS.Rows[0][0].ToString() == "1")
  10. {
  11. if (textBoxNew.Text == textBoxOld.Text)
  12. {
  13. SqlCommand cmd = new SqlCommand("SELECT * FROM tbl_Login WHERE Password = '" + int.Parse(textBoxPassword.Text) + "'", con);
  14. con.Open();
  15. SqlDataReader dr = cmd.ExecuteReader();
  16. if (dr.Read())
  17. {
  18. con.Open();
  19. SqlCommand smd = new SqlCommand("Insert into tbl_Login(AsusPassword) Values ='" + textBoxNew.Text + "'", con); //SqlCommand smd = new SqlCommand("Insert into tbl_Login(Facebook) Values('" + textBoxNew.Text + "')", con);
  20. smd.ExecuteNonQuery();
  21. int i = smd.ExecuteNonQuery();
  22. con.Close();
  23. if (i > 0)
  24. {
  25. MessageBox.Show("You set your password successfully!!");
  26. }
  27. else
  28. {
  29. MessageBox.Show("something went wrong");
  30. }
  31. con.Close();
  32. }
  33. else
  34. {
  35. MessageBox.Show("OO my ");
  36. con.Close();
  37. }
  38. }
  39. else
  40. {
  41. MessageBox.Show("Are You Suere You Want To Change Your Password");
  42. SqlDataAdapter cc = new SqlDataAdapter("update tbl_Login set Facebook = '" + textBoxNew.Text + "' where Password = '" + textBoxPassword.Text + "' and Email ='" + textBoxEmail.Text + "'", con);
  43. MessageBox.Show("Password changed!!!");
  44. }
  45. }
  46. else
  47. {
  48. errorProvider.SetError(textBoxPassword, "Incorrect Password!");
  49. errorProvider.SetError(textBoxEmail, "Incorrect Email");
  50.  
  51. }
  52. }
Add Comment
Please, Sign In to add comment