PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/manageaccount.aspx.cs

https://bitbucket.org/xpertech/paycell
C# | 61 lines | 59 code | 1 blank | 1 comment | 13 complexity | f4f390899a42e2a80b9f4f49d59ca4dd MD5 | raw file
  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.HtmlControls;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Xml.Linq;
  13. public partial class manageaccount : System.Web.UI.Page
  14. {
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. if (!IsPostBack)
  18. {
  19. DataTable dt = SqlHelper.ExecuteDatatable(GlobalVariable.con,CommandType.Text,"select UserName,Password from tbl_user");
  20. txtUserName.Text = dt.Rows[0]["UserName"].ToString();
  21. //TxtBoxOldPwd.Text = dt.Rows[0]["Password"].ToString();
  22. }
  23. }
  24. protected void BtnSubmit_Click(object sender, EventArgs e)
  25. {
  26. if (TxtBoxOldPwd.Text != "")
  27. {
  28. object pwd = SqlHelper.ExecuteScalar(GlobalVariable.con,CommandType.Text,"select Password from tbl_user");
  29. if (pwd != null && TxtBoxOldPwd.Text == pwd.ToString())
  30. {
  31. if (TxtBoxNewPwd.Text == "" || TxtBoxConfirmPwd.Text == "")
  32. {
  33. SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "update tbl_user set UserName='" + txtUserName.Text + "'");
  34. LblMsg.Text = "Account updated. Username changed";
  35. }
  36. else
  37. {
  38. if (TxtBoxNewPwd.Text == TxtBoxConfirmPwd.Text)
  39. {
  40. SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "update tbl_user set UserName='" + txtUserName.Text + "', Password='"+TxtBoxNewPwd.Text+"'");
  41. LblMsg.Text = "Account updated. Username and password changed.";
  42. }
  43. else
  44. {
  45. LblMsg.Text = "Account not updated. Password did not matched.";
  46. }
  47. }
  48. }
  49. else
  50. {
  51. LblMsg.Text = "Account not updated. Old password did not matched.";
  52. }
  53. }
  54. else
  55. {
  56. SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "update tbl_user set UserName='" + txtUserName.Text + "'");
  57. LblMsg.Text = "Account updated. Username changed";
  58. }
  59. }
  60. }