Exemplo n.º 1
0
		private void Page_Load(object sender, EventArgs e)
		{
			this.AuthenticatePage(new string[] {PermissionLevels.EditImages, PermissionLevels.AddImages, PermissionLevels.ViewImages});
			if (ImageID > 0)
			{
				if (this.OryxUser.RolePermission(PermissionLevels.EditImages) != 2)
				{
					btnSubmit.Visible = false;
					btnDelete.Visible = false;
				}
				else
				{
					btnSubmit.Visible = true;
					btnDelete.Visible = true;
				}
			}
			else
			{
				if (this.OryxUser.RolePermission(PermissionLevels.AddImages) != 2)
				{
					btnSubmit.Visible = false;
				}
			}

			if (IsNewSession)
			{
				AddToListIfAdmin();
				IsNewSession = false;
			}
			
			if (!Page.IsPostBack)
			{
				BindImageCategories();

				BPImages bp = new BPImages();
		
				if (ImageID != 0)
				{
					DSImages = bp.SelectByID(ImageID);
					Image = DSImages.tbl_Images.FindByImageID(ImageID);

					//ddlExtranetClients.SelectedValue = Image.ClientID.ToString();

					lblImageName.Text = Image.ImageName.ToString();
					txtAlias.Text = Image.ImageAlias;
					chkSingle.Checked = Image.ImageActive;
					txtDesc.Text = (Image.IsImageDescriptionNull())? string.Empty : Image.ImageDescription;
					if (ddlImageCategory.Items.FindByValue(Image.ImageCategoryID.ToString()) != null)
					{
						ddlImageCategory.SelectedValue = Image.ImageCategoryID.ToString();
					}
					
					lblTitle.Text = "Edit Image - " + Image.ImageAlias;
				}
				else 
				{
					btnDelete.Visible = false;
					lblTitle.Text = "Upload Image";
				}
			}
		}
Exemplo n.º 2
0
		//		private void ddlCategories_SelectedIndexChanged(object sender, System.EventArgs e)
		//		{
		//			BindSubCategories();
		//		}

		private void btnDelete_Click(object sender, EventArgs e)
		{
			BPImages bp = new BPImages();
			BEImages.tbl_ImagesRow Image;
			
			DSImages = bp.SelectByID(ImageID);
			Image = DSImages.tbl_Images.FindByImageID(ImageID);

			File.Delete(Server.MapPath(@System.Configuration.ConfigurationSettings.AppSettings["UploadsPath"] + Image.ImageName));

			Image.Delete();
			bp.Update(DSImages);

			//remove all instances of this image in Products
//			BPProducts bpProducts = new BPProducts();
//			bpProducts.RemoveImagesByImageID(ImageID);

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