/// <summary> /// Adding the permission /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddPerm_Click(object sender, System.EventArgs e) { try { perm2 = new clsPermissions(); perm2.cAction = "U"; perm2.iId = 0; perm2.sName = tbAddPermName.Text; perm2.sCode = tbAddPermCode.Text; tbAddPermName.Text = ""; tbAddPermCode.Text = ""; if(perm2.PermissionDetail() == -1) { Session["lastpage"] = "admin_permissions.aspx"; Session["error"] = _functions.ErrorMessage(116); Response.Redirect("error.aspx", false); return; } ShowPermissions(); } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "admin_permissions.aspx"; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(perm2 != null) perm2.Dispose(); } }
/// <summary> /// Adding the page to the permission /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddPage_Click(object sender, System.EventArgs e) { try { perm = new clsPermissions(); perm.cAction = "I"; perm.iId = PermId; perm.iPageId = Convert.ToInt32(ddlNewPages.SelectedValue); if(perm.PagesPermissionDetail() == -1) { Session["lastpage"] = "admin_permission_detail.aspx?id=" + PermId.ToString(); Session["error"] = _functions.ErrorMessage(116); Response.Redirect("error.aspx", false); return; } else Response.Redirect("admin_permission_detail.aspx?id=" + PermId.ToString(), false); } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "admin_permissions_detail.aspx?id=" + PermId.ToString(); Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(perm != null) perm.Dispose(); } }
private void btnAddPerm_Click(object sender, System.EventArgs e) { try { GroupId = (int)ViewState["GroupId"]; perm = new clsPermissions(); perm.cAction = "I"; perm.iId = Convert.ToInt32(ddlNewPerm.SelectedValue); perm.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); perm.iGroupId = GroupId; if(perm.GroupsPermissionsDetail() == -1) { Session["lastpage"] = "admin_groups_permissions.aspx?id=" + GroupId.ToString(); Session["error"] = _functions.ErrorMessage(116); Response.Redirect("error.aspx", false); return; } else Response.Redirect("admin_groups_permissions.aspx?id=" + GroupId.ToString(), false); } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "admin_groups_permissions.aspx?id=" + GroupId.ToString(); Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(perm != null) perm.Dispose(); } }
/// <summary> /// Showing all permission on screen /// </summary> private void ShowPermissions() { try { perm = new clsPermissions(); dgPermissions.DataSource = new DataView(perm.GetPermissionsList()); dgPermissions.DataBind(); } catch(Exception ex) { throw new Exception(ex.Message, ex); } finally { if(perm != null) perm.Dispose(); } }
/// <summary> /// Processing the permissions for the select, the edit and the removing /// </summary> /// <param name="source"></param> /// <param name="e"></param> private void dgPermissions_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { switch(e.CommandName) { case "Select": Response.Redirect("admin_permission_detail.aspx?id=" + e.Item.Cells[1].Text, false); break; case "Delete": perm2 = new clsPermissions(); perm2.cAction = "D"; perm2.iId = Convert.ToInt32(e.Item.Cells[1].Text); if(perm2.PermissionDetail() == -1) { Session["lastpage"] = "admin_permissions.aspx"; Session["error"] = _functions.ErrorMessage(116); Response.Redirect("error.aspx", false); return; } dgPermissions.EditItemIndex = -1; ShowPermissions(); break; case "Cancel": rfvAddNewPermCode.Enabled = true; rfvAddNewPermName.Enabled = true; btnAddPerm.Enabled = true; dgPermissions.EditItemIndex = -1; ShowPermissions(); break; case "Edit": rfvAddNewPermCode.Enabled = false; rfvAddNewPermName.Enabled = false; btnAddPerm.Enabled = false; dgPermissions.EditItemIndex = e.Item.ItemIndex; ShowPermissions(); break; case "Update": rfvAddNewPermCode.Enabled = true; rfvAddNewPermName.Enabled = true; btnAddPerm.Enabled = true; perm2 = new clsPermissions(); perm2.cAction = "U"; perm2.iId = Convert.ToInt32(((Label)e.Item.FindControl("lblEditId")).Text); perm2.sName = ((TextBox)e.Item.FindControl("tbNameEdit")).Text; if(perm2.PermissionDetail() == -1) { Session["lastpage"] = "admin_permissions.aspx"; Session["error"] = _functions.ErrorMessage(116); Response.Redirect("error.aspx", false); return; } dgPermissions.EditItemIndex = -1; ShowPermissions(); break; default: break; } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "admin_permissions.aspx"; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(perm2 != null) perm2.Dispose(); } }
private void dgPermissions_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { if(Request.QueryString["id"] == null) { Session["lastpage"] = "admin_groups.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { GroupId = Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "admin_groups.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } perm = new clsPermissions(); perm.cAction = "D"; perm.iId = Convert.ToInt32(e.Item.Cells[0].Text); perm.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); perm.iGroupId = GroupId; if(perm.GroupsPermissionsDetail() == -1) { Session["lastpage"] = "admin_groups_permissions.aspx?id=" + GroupId.ToString(); Session["error"] = _functions.ErrorMessage(116); Response.Redirect("error.aspx", false); return; } else Response.Redirect("admin_groups_permissions.aspx?id=" + GroupId.ToString(), false); } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "admin_groups_permissions.aspx?id=" + GroupId.ToString(); Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(perm != null) perm.Dispose(); } }
private void Page_Load(object sender, System.EventArgs e) { try { if(Request.QueryString["id"] == null) { Session["lastpage"] = "admin_groups.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { GroupId = Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "admin_groups.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_groups.aspx"; arrBrdCrumbs[2,1]="Groups Manager"; PageTitle = "Permissions Manager for Group"; Header.BrdCrumbs=ParseBreadCrumbs(arrBrdCrumbs,PageTitle); Header.PageTitle=PageTitle; SourcePageName = "admin_groups_permissions.aspx.cs"; lblBack.Text = "<input type=button value=\" Back \" onclick=\"document.location='admin_groups.aspx'\">"; if(!IsPostBack) { perm = new clsPermissions(); perm.iGroupId = GroupId; perm.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); 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"] = ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(perm != null) perm.Dispose(); } }
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(); } }
/// <summary> /// Delete page from the permission /// </summary> /// <param name="source"></param> /// <param name="e"></param> private void dgPages_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { perm = new clsPermissions(); perm.cAction = "D"; perm.iId = PermId; perm.iPageId = Convert.ToInt32(e.Item.Cells[0].Text); if(perm.PagesPermissionDetail() == -1) { Session["lastpage"] = "admin_permission_detail.aspx?id=" + PermId.ToString(); Session["error"] = _functions.ErrorMessage(116); Response.Redirect("error.aspx", false); return; } else Response.Redirect("admin_permission_detail.aspx?id=" + PermId.ToString(), false); } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "admin_permissions_detail.aspx?id=" + PermId.ToString(); Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(perm != null) perm.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(); } }