protected void btnNext_Click(object sender, ImageClickEventArgs e)
        {
            List <int>  list = (List <int>)Session["search"];
            HiddenField ID   = FormView1.FindControl("ID") as HiddenField;
            int         id   = 0;

            if (int.TryParse(ID.Value, out id))
            {
                int index = list.FindIndex(x => x == id);
                if (index == list.Count - 1)
                {
                    index = 0;
                }
                else
                {
                    index = index + 1;
                }

                id = list[index];
                ArtGalleryDS.PictureDataTable table = PictureDL.GetById(id);
                FormView1.DataSource = table.Rows;
                FormView1.DataBind();

                ArtGalleryDS.Picture_GetWithWaterMarkDataTable table1 = PictureDL.GetWithWaterMark(id);
                FormView2.DataSource = table1.Rows;
                FormView2.DataBind();
                up1.Update();
                up2.Update();
            }
        }
        protected bool GenerateInvoice(int id, SpiceLogic.PayPalCtrlForWPS.Controls.BuyNowButton btnBuy, bool unframe)
        {
            ArtGalleryDS.PictureDataTable table = PictureDL.GetById(id);
            if (table == null || table.Rows.Count != 1)
            {
                return(false);
            }
            ArtGalleryDS.PictureRow row = table[0];
            btnBuy.ItemName   = row.Title + (unframe ? " (unframed)" : "");
            btnBuy.ItemNumber = id.ToString();
            if (!unframe)
            {
                Calculate(btnBuy, row.Width, row.Height, row.Frame, row.weight);
            }
            else
            {
                btnBuy.Height   = (int)Math.Ceiling(Math.Min(row.Width, row.Height));
                btnBuy.Width    = 3;
                btnBuy.Handling = 10;
                btnBuy.Weight   = (decimal)2.0;
                btnBuy.AdditionalDataItems["strongbox"] = "none needed";
            }
            btnBuy.ItemNumber = id.ToString();
            btnBuy.AdditionalDataItems["unframed"] = unframe.ToString().ToLower();
            btnBuy.AdditionalDataItems["width"]    = "0";
            btnBuy.AdditionalDataItems["height"]   = "0";
            btnBuy.Amount = (decimal)row.price;

            return(true);
        }
 /// <summary>
 /// This event is fired when user selects the next button. It takes the user
 /// to next record (alphabetically) in the current gallery.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnNext_Click( object sender, EventArgs e )
 {
     int id = (int)FormView1.DataKey.Value;
     int galleryid = int.Parse( Request.QueryString["id"] );
     int newId = PictureDL.Next( id );
     if (newId > 0)
     {
         Response.Redirect( "EditPicture.aspx?id=" + newId.ToString() );
     }
 }
        private void ProcessPicture(int id)
        {
            ArtGalleryDS.PictureDataTable table = PictureDL.GetById(id);
            FormView1.DataSource = table.Rows;
            FormView1.DataBind();

            ArtGalleryDS.Picture_GetWithWaterMarkDataTable table1 = PictureDL.GetWithWaterMark(id);
            FormView2.DataSource = table1.Rows;
            FormView2.DataBind();
        }
        protected void btnPrevious_Click(object sender, ImageClickEventArgs e)
        {
            int id    = (int)FormView1.DataKey.Values["id"];
            int newId = PictureDL.PreviousPublic(id);

            if (newId > 0)
            {
                ProcessPicture(newId);
            }
        }
 /// <summary>
 /// Event when user select upload picture button. It uploads the picture file to the
 /// App_Data directory and writes the file name inr the File Name text box and updates
 /// that column in the database.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void UploadButton_Click( object sender, EventArgs e )
 {
     if (FileUpload1.HasFile)
     {
         try
         {
             string filename = Path.GetFileName( FileUpload1.FileName );
             FileUpload1.SaveAs( Server.MapPath( "~/App_Data/" ) + filename );
             ErrorLabel.Text = "Upload status: File uploaded!";
             PictureDL.UpdatePicturePath((int) FormView1.DataKey.Value, filename );
             FormView1.DataBind();
         }
         catch (Exception ex)
         {
             ErrorLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
         }
         up2.Update();
     }
     else
         ErrorLabel.Text = "Could not find file";
 }
Beispiel #7
0
 public static ArtGalleryDS.OrphanPictureDataTable GetOrphanPicture()
 {
     ArtGalleryDS.PictureDataTable       table   = PictureDL.Get();
     ArtGalleryDS.OrphanPictureDataTable missing = new ArtGalleryDS.OrphanPictureDataTable();
     string[] files = Directory.GetFiles(HttpContext.Current.Server.MapPath("~/App_Data"));
     foreach (string file in files)
     {
         FileInfo fi       = new FileInfo(file);
         string   filename = fi.Name;
         if (filename == "Missing.jpg" || filename == "artgallery.p12" || filename == "paypal_cert_pem.txt")
         {
             continue;
         }
         var query = from p in table where filename.ToUpper() == p.PicturePath.ToUpper() select p.PicturePath;
         if (query.Count() == 0)
         {
             object[] missingfile = new object[1];
             missingfile[0] = filename;
             missing.Rows.Add(missingfile);
         }
     }
     return(missing);
 }
 /// <summary>
 /// This event occurs when the timer fires. A random picture is displayed
 /// in the right side of page
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Timer1_Tick(object sender, EventArgs e)
 {
     frmTop.DataSource = PictureDL.GetWithWaterMark(PictureDL.Random());
     frmTop.DataBind();
     up1.Update();
 }