예제 #1
0
		protected void BindProductCategoriesList()
		{
			BPProductCategories bpAppCats = new BPProductCategories();
			if (ProductCategoryID > 0)
			{
				DSProductCategories = bpAppCats.SelectProductCategoryByID(ProductCategoryID);

				BindProductsList();
			}
			else
			{
				DSProductCategories = bpAppCats.SelectAllActive();
			}

			rptProductCategories.DataBind();
		}
예제 #2
0
		private string GetProductCategoryTitle(int ProjectCategoryID)
		{
			BPProductCategories bp = new BPProductCategories();
			DSProductCategories = bp.SelectProductCategoryByID(ProjectCategoryID);
			BEProductCategories.tbl_ProductCategoriesRow title;
			title = DSProductCategories.tbl_ProductCategories.FindByProductCategoryID(ProjectCategoryID);
			if (DSProductCategories.tbl_ProductCategories.Count > 0)
			{
				return title.ProductCategoryName;
			}
			else
			{
				return "";
			}
		}
		private void Page_Load(object sender, EventArgs e)
		{
			this.AuthenticatePage(new string[] {PermissionLevels.EditProductCategories, PermissionLevels.AddProductCategories, PermissionLevels.ViewProductCategories});
			if (ProductCategoryID > 0)
			{
				if (this.CarrielUser.RolePermission(PermissionLevels.EditProductCategories) != 2)
				{
					btnSubmit.Visible = false;
					btnDelete.Visible = false;
				}
				else
				{
					btnSubmit.Visible = true;
					btnDelete.Visible = true;
				}
			}
			else
			{
				if (this.CarrielUser.RolePermission(PermissionLevels.AddProductCategories) != 2)
				{
					btnSubmit.Visible = false;
				}
			}

			if(!IsPostBack)
			{
				if (ProductCategoryID == 0)
				{
					lblTitle.Text = "Add Product Category";
					btnDelete.Visible = false;
					lblActiveWarning.Visible = false;
				}
				else
				{
					BPProductCategories bpCat = new BPProductCategories();
					BEProductCategories ds = bpCat.SelectProductCategoryByID(ProductCategoryID);
					BEProductCategories.tbl_ProductCategoriesRow category = ds.tbl_ProductCategories.FindByProductCategoryID(ProductCategoryID);

					txtProductCategoryName.Text = category.ProductCategoryName;
					lblTitle.Text = "Edit Product Category - " + category.ProductCategoryName;

					edtProductCategoryDescription.TextBoxText = category.ProductCategoryDescription;
					chkProductCategoryActive.Checked = category.ProductCategoryActive;

					lblActiveWarning.Visible = true;
				}
			}
		}
		private void btnDelete_Click(object sender, EventArgs e)
		{
//			BPProducts bpProducts = new BPProducts();
//			DSProducts = bpProducts.SelectLockedProductsByProductCategoryID(ProductCategoryID);
//			if (DSProducts.tbl_Products.Count > 0)
//			{
//				pnlLockedError.Visible = true;
//			}
//			else
//			{
				BPProductCategories bp = new BPProductCategories();
				BEProductCategories.tbl_ProductCategoriesRow ProductCategory;
			
				DSProductCategories = bp.SelectProductCategoryByID(ProductCategoryID);
				ProductCategory = DSProductCategories.tbl_ProductCategories.FindByProductCategoryID(ProductCategoryID);

				ProductCategory.Delete();
				bp.Update(DSProductCategories);

				bp.UpdateByProductCategoryID(ProductCategoryID);

				Response.Redirect("BrowseProductCategories.aspx");
//			}
		}
		private void btnSubmit_ServerClick(object sender, EventArgs e)
		{
			BPProductCategories bp = new BPProductCategories();
			BEProductCategories.tbl_ProductCategoriesRow category;
			DSProductCategories = new BEProductCategories();

			//if they are making this category inactive make all items below this category unassigned and inactive
			if (ProductCategoryID > 0)
			{
				bool wasActive = GetProductCategoryActiveStatus(ProductCategoryID);

				if ((wasActive) && (! chkProductCategoryActive.Checked))
				{
					bp.UpdateByProductCategoryID(ProductCategoryID);
				}
			}

			if (ProductCategoryID == 0)
			{
				// Add a Product Category
				category = DSProductCategories.tbl_ProductCategories.Newtbl_ProductCategoriesRow();
			}
			else
			{
				// Edit a Product Category
				DSProductCategories = bp.SelectProductCategoryByID(ProductCategoryID);
				category = DSProductCategories.tbl_ProductCategories.FindByProductCategoryID(ProductCategoryID);				
			}
			//all content to be updated/inserted between here
			Editor ApplicationContent = edtProductCategoryDescription;
			string strCategoryDescription = Request.Form[ApplicationContent.Editor_HiddenField].ToString();

			category.ProductCategoryName = txtProductCategoryName.Text;
			category.ProductCategoryDescription = strCategoryDescription;
			category.ProductCategoryActive = chkProductCategoryActive.Checked;

			category.DateModified = DateTime.Now;
			category.ModifiedByAdminID = Convert.ToInt32(CarrielUser.CarrielIdentity.MemberID);
			//all content to be updated/inserted between here			
			if (ProductCategoryID == 0)
			{
				//Add new Product Category
				category.ProductCategoryOrder = bp.GetProductCategoryMaxOrder();
				category.DateCreated = DateTime.Now;

				DSProductCategories.tbl_ProductCategories.Addtbl_ProductCategoriesRow(category);
			}

			bp.Update(DSProductCategories);

			Response.Redirect("BrowseProductCategories.aspx");
		}
		protected bool GetProductCategoryActiveStatus(int ProductCategoryID)
		{
			BPProductCategories bp = new BPProductCategories();
			DSProductCategories = bp.SelectProductCategoryByID(ProductCategoryID);
			BEProductCategories.tbl_ProductCategoriesRow category = DSProductCategories.tbl_ProductCategories[0];
			category = DSProductCategories.tbl_ProductCategories[0];
			return category.ProductCategoryActive;
		}