private void Page_Load(object sender, System.EventArgs e)
 {
     try
     {
         if (Request.QueryString["id"] == null)
         {
             Session["lastpage"] = "admin_permissions.aspx";
             Session["error"]    = _functions.ErrorMessage(104);
             Response.Redirect("error.aspx", false);
             return;
         }
         try
         {
             PermId = Convert.ToInt32(Request.QueryString["id"]);
         }
         catch (FormatException fex)
         {
             Session["lastpage"] = "admin_permissions.aspx";
             Session["error"]    = _functions.ErrorMessage(105);
             Response.Redirect("error.aspx", false);
             return;
         }
         lblBack.Text = "<input type=button value=\" Back \" onclick=\"document.location='admin_permissions.aspx'\">";
         if (!IsPostBack)
         {
             perm         = new clsPermissions();
             perm.iId     = PermId;
             perm.cAction = "S";
             if (perm.PermissionDetail() == -1)
             {
                 Session["lastpage"] = "admin_permission_detail.aspx?id=" + PermId.ToString();
                 Session["error"]    = _functions.ErrorMessage(116);
                 Response.Redirect("error.aspx", false);
                 return;
             }
             lblPermCode.Text   = perm.sCode.Value;
             lblPermName.Text   = perm.sName.Value;
             dsPages            = perm.GetPagesListFromPermission();
             dgPages.DataSource = new DataView(dsPages.Tables["Table"]);
             dgPages.DataBind();
             if (dsPages.Tables["Table1"].Rows.Count > 0)
             {
                 ddlNewPages.DataTextField  = "vchPageName";
                 ddlNewPages.DataValueField = "Id";
                 ddlNewPages.DataSource     = new DataView(dsPages.Tables["Table1"]);
                 ddlNewPages.DataBind();
             }
             else
             {
                 ddlNewPages.Items.Add(new ListItem("<none>", "0"));
                 btnAddPage.Enabled = false;
             }
         }
     }
     catch (Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"]     = ParentPageURL;
         Session["error"]        = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if (perm != null)
         {
             perm.Dispose();
         }
     }
 }
Esempio n. 2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "admin_permissions.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    PermId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "admin_permissions.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                string [,] arrBrdCrumbs = new string [3, 2];
                arrBrdCrumbs[0, 0]      = "main.aspx";
                arrBrdCrumbs[0, 1]      = "Home";
                arrBrdCrumbs[1, 0]      = "admin.aspx";
                arrBrdCrumbs[1, 1]      = "Administration";
                arrBrdCrumbs[2, 0]      = "admin_permissions.aspx";
                arrBrdCrumbs[2, 1]      = "Permissions Manager";
                PageTitle        = "Pages Manager for Permission";
                Header.BrdCrumbs = ParseBreadCrumbs(arrBrdCrumbs, PageTitle);
                Header.PageTitle = PageTitle;
                SourcePageName   = "admin_permission_detail.aspx.cs";
                lblBack.Text     = "<input type=button value=\" Back \" onclick=\"document.location='admin_permissions.aspx'\">";
                if (!IsPostBack)
                {
                    perm               = new clsPermissions();
                    perm.iId           = PermId;
                    dsPages            = perm.GetPagesListFromPermission();
                    dgPages.DataSource = new DataView(dsPages.Tables["Table"]);
                    dgPages.DataBind();
                    if (dsPages.Tables["Table1"].Rows.Count > 0)
                    {
                        ddlNewPages.DataTextField  = "vchPageName";
                        ddlNewPages.DataValueField = "Id";
                        ddlNewPages.DataSource     = new DataView(dsPages.Tables["Table1"]);
                        ddlNewPages.DataBind();
                    }
                    else
                    {
                        ddlNewPages.Items.Add(new ListItem("<none>", "0"));
                        btnAddPage.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = ParentPageURL;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (perm != null)
                {
                    perm.Dispose();
                }
            }
        }