示例#1
0
        private void PopulateUserRoleGrid()
        {
            try
            {
                lblMessage.Content = "";
                var userRoles = myUserRoleManager.GetUserRoleList();
                grdUserRoleList.ItemsSource = userRoles;

                var count = myUserRoleManager.GetUserRoleCount();
                lblUserRoleCount.Content = "Count: " + count.ToString();
            }
            catch (Exception)
            {
                grdUserRoleList.ItemsSource = null;
                lblUserRoleCount.Content    = "Count: 0";
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["AppLocation"] == null || Session.Count == 0 || Session["AppUserID"].ToString() == "")
        {
            IQCareMsgBox.Show("SessionExpired", this);
            Response.Redirect("~/frmlogin.aspx", true);
        }
        Session["PatientId"] = 0;
        //(Master.FindControl("lblheader") as Label).Text = "User Group Administration";
        //(Master.FindControl("lblMark") as Label).Visible = false;
        (Master.FindControl("levelOneNavigationUserControl1").FindControl("lblRoot") as Label).Visible = false;
        (Master.FindControl("levelOneNavigationUserControl1").FindControl("lblheader") as Label).Text  = "User Group Administration";

        IUserRole UserRoleManager;

        try
        {
            if (!IsPostBack)
            {
                UserRoleManager = (IUserRole)ObjectFactory.CreateInstance("BusinessProcess.Administration.BUserRole, BusinessProcess.Administration");
                DataSet theDS = (DataSet)UserRoleManager.GetUserRoleList();
                this.grdUsergroup.DataSource   = theDS.Tables[0];
                ViewState["gridSortDirection"] = theDS.Tables[0];
                if (ViewState["gridSource"] == null)
                {
                    ViewState["gridSource"]        = theDS.Tables[0];
                    ViewState["gridSortDirection"] = "Desc";
                }
                this.grdUsergroup.DataBind();

                BindGrid();
            }
        }
        catch (Exception err)
        {
            MsgBuilder theMsgBuilder = new MsgBuilder();
            theMsgBuilder.DataElements["MessageText"] = err.Message.ToString();
            IQCareMsgBox.Show("#C1", theMsgBuilder, this);
            return;
        }
        finally
        {
            UserRoleManager = null;
        }
    }