コード例 #1
0
		private void btnSubmit_ServerClick(object sender, EventArgs e)
		{
			BPImageCategories bp = new BPImageCategories();
			BEImageCategories.tbl_ImageCategoriesRow category;
			DSImageCategories = new BEImageCategories();

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

				if ((wasActive) && (! chkImageCategoryActive.Checked))
				{
					bp.UpdateByImageCategoryID(ImageCategoryID);
				}
			}

			if (ImageCategoryID == 0)
			{
				// Add a Image Category
				category = DSImageCategories.tbl_ImageCategories.Newtbl_ImageCategoriesRow();
			}
			else
			{
				// Edit a Image Category
				DSImageCategories = bp.SelectImageCategoryByID(ImageCategoryID);
				category = DSImageCategories.tbl_ImageCategories.FindByImageCategoryID(ImageCategoryID);				
			}
			//all content to be updated/inserted between here
			category.ImageCategoryName = txtImageCategoryName.Text;
			category.ImageCategoryDescription = txtImageCategoryDescription.Text;
			category.ImageCategoryActive = chkImageCategoryActive.Checked;

			category.DateModified = DateTime.Now;
			category.ModifiedByAdminID = Convert.ToInt32(OryxUser.OryxIdentity.MemberID);
			//all content to be updated/inserted between here			
			if (ImageCategoryID == 0)
			{
				//Add new Image Category
				category.ImageCategoryOrder = bp.GetImageCategoryMaxOrder();
				category.DateCreated = DateTime.Now;

				DSImageCategories.tbl_ImageCategories.Addtbl_ImageCategoriesRow(category);
			}

			bp.Update(DSImageCategories);

			Response.Redirect("BrowseImageCategories.aspx");
		}