private void Page_Load(object sender, EventArgs e) { this.AuthenticatePage(new string[] {PermissionLevels.EditDocumentCategories, PermissionLevels.AddDocumentCategories, PermissionLevels.ViewDocumentCategories}); if (DocumentCategoryID > 0) { if (this.OryxUser.RolePermission(PermissionLevels.EditDocumentCategories) != 2) { btnSubmit.Visible = false; btnDelete.Visible = false; } else { btnSubmit.Visible = true; btnDelete.Visible = true; } } else { if (this.OryxUser.RolePermission(PermissionLevels.AddDocumentCategories) != 2) { btnSubmit.Visible = false; } } // if (IsNewSession) // { // AddToListIfAdmin(); // IsNewSession = false; // } if(!IsPostBack) { if (DocumentCategoryID == 0) { lblTitle.Text = "Add Document Category"; btnDelete.Visible = false; lblActiveWarning.Visible = false; } else { BPDocumentCategories bpCat = new BPDocumentCategories(); BEDocumentCategories ds = bpCat.SelectDocumentCategoryByID(DocumentCategoryID); BEDocumentCategories.tbl_DocumentCategoriesRow category = ds.tbl_DocumentCategories.FindByDocumentCategoryID(DocumentCategoryID); txtDocumentCategoryName.Text = category.DocumentCategoryName; lblTitle.Text = "Edit Document Category - " + category.DocumentCategoryName; txtDocumentCategoryDescription.Text = category.DocumentCategoryDescription; chkDocumentCategoryActive.Checked = category.DocumentCategoryActive; lblActiveWarning.Visible = true; } } }
private void btnSubmit_ServerClick(object sender, EventArgs e) { BPDocumentCategories bp = new BPDocumentCategories(); BEDocumentCategories.tbl_DocumentCategoriesRow category; DSDocumentCategories = new BEDocumentCategories(); //if they are making this category inactive make all items below this category unassigned and inactive if (DocumentCategoryID > 0) { bool wasActive = GetDocumentCategoryActiveStatus(DocumentCategoryID); if ((wasActive) && (! chkDocumentCategoryActive.Checked)) { bp.UpdateByDocumentCategoryID(DocumentCategoryID); } } if (DocumentCategoryID == 0) { // Add a Document Category category = DSDocumentCategories.tbl_DocumentCategories.Newtbl_DocumentCategoriesRow(); } else { // Edit a Document Category DSDocumentCategories = bp.SelectDocumentCategoryByID(DocumentCategoryID); category = DSDocumentCategories.tbl_DocumentCategories.FindByDocumentCategoryID(DocumentCategoryID); } //all content to be updated/inserted between here category.DocumentCategoryName = txtDocumentCategoryName.Text; category.DocumentCategoryDescription = txtDocumentCategoryDescription.Text; category.DocumentCategoryActive = chkDocumentCategoryActive.Checked; category.DateModified = DateTime.Now; category.ModifiedByAdminID = Convert.ToInt32(OryxUser.OryxIdentity.MemberID); //all content to be updated/inserted between here if (DocumentCategoryID == 0) { //Add new Document Category category.DocumentCategoryOrder = bp.GetDocumentCategoryMaxOrder(); category.DateCreated = DateTime.Now; DSDocumentCategories.tbl_DocumentCategories.Addtbl_DocumentCategoriesRow(category); } bp.Update(DSDocumentCategories); Response.Redirect("BrowseDocumentCategories.aspx"); }
private void btnDelete_Click(object sender, EventArgs e) { BPDocumentCategories bp = new BPDocumentCategories(); BEDocumentCategories.tbl_DocumentCategoriesRow DocumentCategory; DSDocumentCategories = bp.SelectDocumentCategoryByID(DocumentCategoryID); DocumentCategory = DSDocumentCategories.tbl_DocumentCategories.FindByDocumentCategoryID(DocumentCategoryID); DocumentCategory.Delete(); bp.Update(DSDocumentCategories); bp.UpdateByDocumentCategoryID(DocumentCategoryID); Response.Redirect("BrowseDocumentCategories.aspx"); }
protected bool GetDocumentCategoryActiveStatus(int DocumentCategoryID) { BPDocumentCategories bp = new BPDocumentCategories(); DSDocumentCategories = bp.SelectDocumentCategoryByID(DocumentCategoryID); BEDocumentCategories.tbl_DocumentCategoriesRow category = DSDocumentCategories.tbl_DocumentCategories[0]; category = DSDocumentCategories.tbl_DocumentCategories[0]; return category.DocumentCategoryActive; }