Guest User

Untitled

a guest
Nov 17th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. string UserName;
  4. if (Session["User"] == null)
  5. {
  6. Response.Redirect("Home.aspx");
  7. }
  8. if ((Session["AdminMode"] == "1") || (Session["AdminMode"] == "2"))
  9. UserName = Session["AdminEditUser"].ToString();
  10. else
  11. UserName = Session["User"].ToString();
  12. if (!IsPostBack)
  13. {
  14. int i, j;
  15. string birthDate;
  16. string connectionStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:WebSitesMyWebsiteApp_DataDataBase.mdb;Persist Security Info=True";
  17. OleDbConnection connectObj = new OleDbConnection(connectionStr);
  18. string mySql = "SELECT * from Users WHERE UserName= '" + UserName + "'";
  19. OleDbDataAdapter dataAdapt = new OleDbDataAdapter(mySql, connectObj);
  20. DataSet ds = new DataSet();
  21. dataAdapt.Fill(ds, "Users");
  22. DataRow row = ds.Tables["Users"].Rows[0];
  23. AccountText.Text = UserName.ToString();
  24. pass.Text = row[2].ToString();
  25. passchecker.Text = row[2].ToString();
  26. firstname.Text = row[3].ToString();
  27. lastname.Text = row[4].ToString();
  28. MyEmail.Text = row[5].ToString();
  29. PlaceList.Text = row[6].ToString();
  30. }
  31.  
  32. protected void EditClick_Click(object sender, EventArgs e)
  33. {
  34. string eMailAvailable = MyEmail.Text;
  35. string usercheck = users.IsEmailBelong(eMailAvailable);
  36. bool eMailCheck = users.IsEmailExist(eMailAvailable);
  37. if (eMailCheck == true)
  38. {
  39. if (usercheck == UserName)
  40. {
  41. IsEmail.Text = "";
  42. MyEmail.BackColor = System.Drawing.Color.White;
  43. }
  44. else
  45. {
  46. IsEmail.Text = "";
  47. MyEmail.BackColor = System.Drawing.Color.IndianRed;
  48. }
  49. }
  50. else
  51. {
  52. MyEmail.BackColor = System.Drawing.Color.White;
  53. }
  54.  
  55.  
  56. if (MyEmail.Text == "")
  57. {
  58. int i;
  59. string userName = UserName;
  60. string Password = pass.Text;
  61. string firstName = firstname.Text;
  62. string lastName = lastname.Text;
  63. string eMail = MyEmail.Text;
  64. string cityID = PlaceList.Text;
  65. bool result = users.EditUser(userName, Password, firstName, lastName, eMail, cityID);
  66. if (result == true)
  67. {
  68. Response.Redirect("Home.aspx");
  69. }
  70. }
  71. }
Add Comment
Please, Sign In to add comment