Exemplo n.º 1
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(@"\Uploads\" + Image.ImageName));
			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");
		}
Exemplo n.º 2
0
		private void Page_Load(object sender, EventArgs e)
		{
			this.AuthenticatePage(new string[] {PermissionLevels.EditImages, PermissionLevels.AddImages, PermissionLevels.ViewImages});
			if (ImageID > 0)
			{
				if (this.CarrielUser.RolePermission(PermissionLevels.EditImages) != 2)
				{
					btnSubmit.Visible = false;
					btnDelete.Visible = false;
				}
				else
				{
					btnSubmit.Visible = true;
					btnDelete.Visible = true;
				}
			}
			else
			{
				if (this.CarrielUser.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.º 3
0
		private bool UpdateRecordWithExistingFile()
		{
			try 
			{
				BPImages bp = new BPImages();
				BEImages ds = bp.SelectByID(ImageID);

				BEImages.tbl_ImagesRow ImageRow = ds.tbl_Images.FindByImageID(ImageID);

				//ImageRow.SubCategoryID = Convert.ToInt32(ddlSubCategories.SelectedValue);
				ImageRow.ImageAlias = txtAlias.Text;
				ImageRow.ImageActive = chkSingle.Checked;
				ImageRow.ImageDescription = txtDesc.Text;
				//ImageRow.ClientID = Convert.ToInt32(ddlExtranetClients.SelectedValue);
				
				ImageRow.ImageCategoryID = Convert.ToInt32(ddlImageCategory.SelectedValue);
				
				bp.Update(ds);
				return true;
			}
			catch (Exception)
			{
				pnlError.Visible = true;
				lblError.Text = "Some of the data you have entered maybe invalid, please check all fields and try again.";
				return false;
			}
		}