protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Adminitrators's Dashboard - eCMR";
            if (HttpContext.Current.Session["RoAccessLevel"] != null
                && HttpContext.Current.Session["RoAccessLevel"].ToString() == "1")
            {
                userID = Request.QueryString["UserID"];
                this.dbm = new DatabaseMgmt();
                if (!IsPostBack)
                {
                    this.currentUser = dbm.FindUserByUserID(userID);
                    if (currentUser != null)
                    {
                        userAccount.Value = currentUser.usAccount;
                        userPassword.Value = currentUser.usPassword;
                        userFullName.Value = currentUser.usFullName;
                        bool usSex = currentUser.usSex;
                        if(usSex == true)
                        {
                            sexMale.Checked = true;
                            sexFemale.Checked = false;
                        }
                        else
                        {
                            sexMale.Checked = false;
                            sexFemale.Checked = true;
                        }
                        userAddress.Value = currentUser.usAddress;
                        userPhone.Value = currentUser.usPhone;
                        txtDate.Text = String.Format("{0:yyyy-MM-dd}", currentUser.usDateOfBirth);

                    }
                    else
                    {
                        Response.Redirect("ADM-CourseMgmt.aspx");
                    }
                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
 public List<User> ListCourseModerator()
 {
     DataTable dt;
     List<User> userList = new List<User>();
     User u = null;
     try
     {
         dt = new DataTable();
         this.conn.Open();
         string cmdString = "SELECT Users.*,Roles.RoAccessLevel FROM Users ";
         cmdString += "INNER JOIN Roles ON Users.RoID = Roles.RoID ";
         cmdString += "WHERE Roles.RoAccessLevel='4'";
         this.command = new SqlCommand(cmdString, conn);
         dt.Load(this.command.ExecuteReader());
         if (dt.Rows.Count > 0)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 int? UsID = Convert.ToInt32(dt.Rows[i]["UsID"]);
                 string UsAccount = dt.Rows[i]["UsAccount"].ToString();
                 string UsPassword = dt.Rows[i]["UsPassword"].ToString();
                 string UsFullName = dt.Rows[i]["UsFullName"].ToString();
                 bool UsSex = Convert.ToBoolean(dt.Rows[i]["UsSex"]);
                 string UsAddress = dt.Rows[i]["UsAddress"].ToString();
                 string UsPhone = dt.Rows[i]["UsPhone"].ToString();
                 DateTime? UsDateOfBirth = (DateTime?)dt.Rows[i]["UsDateOfBirth"];
                 int? RoID = Convert.ToInt32(dt.Rows[i]["RoID"]);
                 int? RoAccessLevel = Convert.ToInt32(dt.Rows[i]["RoAccessLevel"]);
                 u = new User(UsID, UsAccount, UsPassword, UsFullName, UsSex,
                     UsAddress, UsPhone, UsDateOfBirth, RoID, RoAccessLevel);
                 userList.Add(u);
             }
         }
         return userList;
     }
     catch (Exception)
     {
         return null;
         throw;
     }
     finally
     {
         this.conn.Close();
     }
 }
 public User FindUserByUserID(string userID)
 {
     DataTable dt;
     User u = null;
     try
     {
         dt = new DataTable();
         this.conn.Open();
         string cmdString = "SELECT Users.*,Roles.RoAccessLevel FROM Users";
         cmdString += " INNER JOIN Roles ON Users.RoID = Roles.RoID ";
         cmdString += " WHERE Users.UsID = '" + userID + "'";
         this.command = new SqlCommand(cmdString, conn);
         dt.Load(this.command.ExecuteReader());
         if (dt.Rows.Count > 0)
         {
             int? UsID = Convert.ToInt32(dt.Rows[0]["UsID"]);
             string UsAccount = dt.Rows[0]["UsAccount"].ToString();
             string UsPassword = dt.Rows[0]["UsPassword"].ToString();
             string UsFullName = dt.Rows[0]["UsFullName"].ToString();
             bool UsSex = Convert.ToBoolean(dt.Rows[0]["UsSex"]);
             string UsAddress = dt.Rows[0]["UsAddress"].ToString();
             string UsPhone = dt.Rows[0]["UsPhone"].ToString();
             DateTime? UsDateOfBirth = (DateTime?)dt.Rows[0]["UsDateOfBirth"];
             int? RoID = Convert.ToInt32(dt.Rows[0]["RoID"]);
             int? RoAccessLevel = Convert.ToInt32(dt.Rows[0]["RoAccessLevel"]);
             u = new User(UsID, UsAccount, UsPassword, UsFullName, UsSex, UsAddress, UsPhone, UsDateOfBirth, RoID, RoAccessLevel);
         }
         return u;
     }
     catch (Exception)
     {
         return null;
         throw;
     }
     finally
     {
         this.conn.Close();
     }
 }
 private void SaveSessionLogin(User u)
 {
     ChangeSession("UsID", u.usID.ToString());
     ChangeSession("UsAccount", u.usAccount);
     ChangeSession("RoAccessLevel", u.roAccessLevel.ToString());
     ChangeSession("UsFullName", u.usFullName);
     // Add more...
 }