/manageaccount.aspx.cs
C# | 61 lines | 59 code | 1 blank | 1 comment | 13 complexity | f4f390899a42e2a80b9f4f49d59ca4dd MD5 | raw file
- using System;
- using System.Collections;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Xml.Linq;
-
- public partial class manageaccount : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- DataTable dt = SqlHelper.ExecuteDatatable(GlobalVariable.con,CommandType.Text,"select UserName,Password from tbl_user");
- txtUserName.Text = dt.Rows[0]["UserName"].ToString();
- //TxtBoxOldPwd.Text = dt.Rows[0]["Password"].ToString();
- }
- }
- protected void BtnSubmit_Click(object sender, EventArgs e)
- {
- if (TxtBoxOldPwd.Text != "")
- {
- object pwd = SqlHelper.ExecuteScalar(GlobalVariable.con,CommandType.Text,"select Password from tbl_user");
- if (pwd != null && TxtBoxOldPwd.Text == pwd.ToString())
- {
- if (TxtBoxNewPwd.Text == "" || TxtBoxConfirmPwd.Text == "")
- {
- SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "update tbl_user set UserName='" + txtUserName.Text + "'");
- LblMsg.Text = "Account updated. Username changed";
- }
- else
- {
- if (TxtBoxNewPwd.Text == TxtBoxConfirmPwd.Text)
- {
- SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "update tbl_user set UserName='" + txtUserName.Text + "', Password='"+TxtBoxNewPwd.Text+"'");
- LblMsg.Text = "Account updated. Username and password changed.";
- }
- else
- {
- LblMsg.Text = "Account not updated. Password did not matched.";
- }
- }
- }
- else
- {
- LblMsg.Text = "Account not updated. Old password did not matched.";
- }
- }
- else
- {
- SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "update tbl_user set UserName='" + txtUserName.Text + "'");
- LblMsg.Text = "Account updated. Username changed";
- }
- }
- }