Ejemplo n.º 1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = this.ParentPageURL;
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    GroupId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = this.ParentPageURL;
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                lblBack.Text = "<input type=button value=\" Back \" onclick=\"document.location='admin_groups.aspx'\">";

                if(!IsPostBack)
                {
                    user = new clsUsers();
                    user.cAction = "S";
                    user.iGroupId = GroupId;
                    user.iOrgId = OrgId;
                    if(user.GroupDetails() == -1)
                    {
                        Session["lastpage"] = ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(117);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblGroupName.Text = user.sGroupName.Value;

                    dsUsers = user.GetUsersListFromGroup();
                    dgUsers.DataSource = new DataView(dsUsers.Tables["Table"]);
                    dgUsers.DataBind();
                    if(dsUsers.Tables["Table1"].Rows.Count > 0)
                    {
                        ddlUsers.DataSource = new DataView(dsUsers.Tables["Table1"]);
                        ddlUsers.DataBind();
                    }
                    else
                    {
                        ddlUsers.Items.Add(new ListItem("<none>", "0"));
                        btnAddUser.Enabled = false;
                    }
                }
            }

            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = this.ParentPageURL;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
            }
        }