Beispiel #1
0
 private void btnAddGroup_Click(object sender, System.EventArgs e)
 {
     try
     {
         user2 = new clsUsers();
         user2.cAction = "U";
         user2.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
         user2.iGroupId = 0;
         user2.sGroupName = tbGroupName.Text;
         tbGroupName.Text = "";
         if(user2.GroupDetails() == -1)
         {
             Session["lastpage"] = "admin_groups.aspx";
             Session["error"] = _functions.ErrorMessage(117);
             Response.Redirect("error.aspx", false);
             return;
         }
         ShowGroups();
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_groups.aspx";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(user2 != null)
             user2.Dispose();
     }
 }
Beispiel #2
0
        private void dgGroups_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            try
            {
                switch(e.CommandName)
                {
                    case "Delete":
                        user2 = new clsUsers();
                        user2.cAction = "D";
                        user2.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                        user2.iGroupId = Convert.ToInt32(e.Item.Cells[0].Text);
                        switch(user2.GroupDetails())
                        {
                            case -1:
                                Session["lastpage"] = "admin_groups.aspx";
                                Session["error"] = _functions.ErrorMessage(117);
                                Response.Redirect("error.aspx", false);
                                return;
                            case 1:
                                Session["lastpage"] = "admin_groups.aspx";
                                Session["error"] = _functions.ErrorMessage(118);
                                Response.Redirect("error.aspx", false);
                                return;
                            case 0:
                                dgGroups.EditItemIndex = -1;
                                ShowGroups();
                                break;
                            default:
                                break;
                        }
                        break;
                    case "Cancel":
                        dgGroups.EditItemIndex = -1;
                        ShowGroups();
                        break;
                    case "Edit":
                        dgGroups.EditItemIndex = e.Item.ItemIndex;
                        ShowGroups();
                        break;
                    case "Update":
                        user2 = new clsUsers();
                        user2.cAction = "U";
                        user2.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                        user2.iGroupId = Convert.ToInt32(((Label)e.Item.FindControl("lblEditId")).Text);
                        user2.sGroupName = ((TextBox)e.Item.FindControl("tbNameEdit")).Text;
                        if(user2.GroupDetails() == -1)
                        {
                            Session["lastpage"] = "admin_groups.aspx";
                            Session["error"] = _functions.ErrorMessage(117);
                            Response.Redirect("error.aspx", false);
                            return;
                        }

                        dgGroups.EditItemIndex = -1;
                        ShowGroups();
                        break;
                    default:
                        break;
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "admin_groups.aspx";
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user2 != null)
                    user2.Dispose();
            }
        }
        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)
                {
                    ViewState["GroupId"] = GroupId;

                    perm = new clsPermissions();
                    user = new clsUsers();
                    perm.iGroupId = GroupId;
                    perm.iOrgId = OrgId;
                    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;

                    dsPerm = perm.GetPermissionListFromGroup();
                    dgPermissions.DataSource = new DataView(dsPerm.Tables["Table"]);
                    dgPermissions.DataBind();
                    if(dsPerm.Tables["Table1"].Rows.Count > 0)
                    {
                        ddlNewPerm.DataTextField = "vchName";
                        ddlNewPerm.DataValueField = "Id";
                        ddlNewPerm.DataSource = new DataView(dsPerm.Tables["Table1"]);
                        ddlNewPerm.DataBind();
                    }
                    else
                    {
                        ddlNewPerm.Items.Add( new ListItem("<none>", "0"));
                        btnAddPerm.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();
                if(perm != null)
                    perm.Dispose();
            }
        }