示例#1
0
        public ActionResult ShowPhoto(Int32 id)
        {
            //This is my method for getting the image information
            // including the image byte array from the image column in
            // a database.
            byte[] fileData = null;
            try
            {
                using (var c = new ArtWorkDBEntities1())
                {
                    fileData = (from p in c.Artworks
                                where p.ArtworkID == id
                                select p.Image).FirstOrDefault();
                    //var fileExtension = (from p in c.Artworks
                    //                     where p.ArtworkID == id
                    //                     select p.FileExtension).FirstOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }
            //As you can see the use is stupid simple.  Just get the image bytes and the
            //  saved content type.  See this is where the contentType comes in real handy.
            ImageResult result = new ImageResult(fileData, "jpg");

            return(result);
        }
示例#2
0
 public FileContentResult GetImg(int id)
 {
     try
     {
         byte[] fileData = null;
         using (ArtworkViewModel vm = new ArtworkViewModel())
         {
             using (var c = new ArtWorkDBEntities1())
             {
                 fileData = (from p in c.Artworks
                             where p.ArtworkID == id
                             select p.Image).FirstOrDefault();
                 var fileExtension = (from p in c.Artworks
                                      where p.ArtworkID == id
                                      select p.FileExtension).FirstOrDefault();
             }
             FileContentResult varFile = new FileContentResult(fileData, "image/octet-stream");
             return(varFile);
             //   return new FileContentResult(fileData, "application/octet-stream", 1);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // var context = new ArtWorkDBEntities1();
     if (!IsPostBack)
     {
         List <ViewModels.ArtworkViewModel> ArtworkVM = new List <ViewModels.ArtworkViewModel>();
         //using (ViewModels.ArtworkViewModel ViewModle= new ViewModels.ArtworkViewModel ())
         //{
         //    ArtworkVM = ViewModle.GetData();
         //    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/RPTReports/Report1.rdlc");
         //    ReportViewer1.LocalReport.DataSources.Clear();
         //    ReportDataSource rdc = new ReportDataSource("MyDataset", ArtworkVM);
         //    ReportViewer1.LocalReport.DataSources.Add(rdc);
         //    ReportViewer1.LocalReport.Refresh();
         //}
         using (var context = new ArtWorkDBEntities1())
         {
         }
     }
 }
示例#4
0
        public FileResult  GetImageFromDataBase(int id)
        {
            byte[] fileData = null;
            try
            {
                using (var c = new ArtWorkDBEntities1())
                {
                    fileData = (from p in c.Artworks
                                where p.ArtworkID == id
                                select p.Image).FirstOrDefault();
                    //var fileExtension = (from p in c.Artworks
                    //                     where p.ArtworkID == id
                    //                     select p.FileExtension).FirstOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }


            return(File(fileData, "image/jpg"));;
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List <ViewModels.ArtworkViewModel> ArtworkVM = new List <ViewModels.ArtworkViewModel>();

                using (var context = new ArtWorkDBEntities1())
                {
                    var collection = (from p in context.Artworks
                                      join q in context.ArtTypes
                                      on p.ArtTypeID equals q.ArtTypeID
                                      select new {
                        PurchasePrce = p.PurchasePrice
                        , ArtType = q.ArtType1
                    }
                                      ).Sum(o => o.PurchasePrce);
                    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/RPTReports/Report1.rdlc");
                    ReportViewer1.LocalReport.DataSources.Clear();
                    ReportDataSource rdc = new ReportDataSource("SQlDataSource1", collection);
                    ReportViewer1.LocalReport.DataSources.Add(rdc);
                    ReportViewer1.LocalReport.Refresh();
                }
            }
        }
示例#6
0
        public PhotoViewImage  GetByID(int id)
        {
            var q = new  PhotoViewImage();

            byte[] fileData = null;
            try
            {
                using (var c = new ArtWorkDBEntities1())
                {
                    fileData = (from p in c.Artworks
                                where p.ArtworkID == id
                                select p.Image).FirstOrDefault();
                    //var fileExtension = (from p in c.Artworks
                    //                     where p.ArtworkID == id
                    //                     select p.FileExtension).FirstOrDefault();
                    q.actualimage = fileData;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(q);
        }