Example #1
0
        //修改图片信息
        protected void UpdatePic_Click(object sender, EventArgs e)
        {
            Picture pic = new Picture();

            pic.Pic_ID1   = Convert.ToInt32(Request.QueryString["picid"].ToString());
            pic.Pic_Name1 = Name.Text.Trim();
            //pic.Pic_ImgUrl1 = @"Img_Pic\" + FileUpload_img.PostedFile.FileName;
            pic.Pic_Class1 = DropDownList_Class.SelectedIndex == 0 ? "壁纸" : "原画";
            if (DropDownList_Class.SelectedIndex == 1)
            {
                pic.Pic_ImgUrl1 = @"~/Img_Pic/yh/" + FileUpload_img.PostedFile.FileName;
            }
            else
            {
                pic.Pic_ImgUrl1 = @"~/Img_Pic/bz/" + FileUpload_img.PostedFile.FileName;
            }
            try
            {
                if (PictureBll.updatepic(pic) == 1)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('修改成功!');</script>");
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('修改失败!');</script>");
                }
            }
            catch (Exception ex)
            {
                Response.Write("错误原因:" + ex.Message);
            }
        }
Example #2
0
        protected void addPic_Click(object sender, EventArgs e)
        {
            Picture pic = new Picture();

            pic.Pic_Name1  = txtName1.Text.Trim();
            pic.Pic_Class1 = DropDownList_Class.SelectedIndex == 0 ? "壁纸" : "原画";
            if (DropDownList_Class.SelectedIndex == 1)
            {
                pic.Pic_ImgUrl1 = @"~/Img_Pic/yh/" + FileUpload_img.PostedFile.FileName;
            }
            else
            {
                pic.Pic_ImgUrl1 = @"~/Img_Pic/bz/" + FileUpload_img.PostedFile.FileName;
            }
            try
            {
                if (PictureBll.addpic(pic) == 1)
                {
                    txtName1.Text = "";
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('添加成功!');</script>");
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('添加失败!');</script>");
                }
            }
            catch (Exception ex)
            {
                Response.Write("错误原因:" + ex.Message);
            }
        }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DataTable yh = PictureBll.yhAll();
         Pic_YH.DataSource = yh;
         Pic_YH.DataBind();
     }
 }
Example #4
0
        //绑定壁纸数据源
        protected void bingbz()
        {
            DataTable bz = PictureBll.bzAll();

            if (bz != null)
            {
                Pic_bz.DataSource = bz;
                Pic_bz.DataBind();
            }
        }
Example #5
0
        public void CreatePicture(PictureBll picture)
        {
            if (picture == null)
            {
                throw new ArgumentNullException("picture");
            }

            var pictureDal = picture.ToDal();

            repository.Create(pictureDal);
            uow.Commit();
        }
Example #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     BindView();
     int id;
     if (!IsPostBack)
     {
         if (Request.QueryString["picid"] != null)
         {
             id = Convert.ToInt32(Request.QueryString["picid"].ToString());
             PictureBll.deleteid(id);
             BindView();
         }
     }
 }
Example #7
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (DropDownList_Class.SelectedIndex == 0)
     {
         BindView();
     }
     else if (DropDownList_Class.SelectedIndex == 1)
     {
         ListView1.DataSource = PictureBll.bzAll();
         ListView1.DataBind();
     }
     else
     {
         ListView1.DataSource = PictureBll.yhAll();
         ListView1.DataBind();
     }
 }
        private int CreatePicture(AddPictureModel picture)
        {
            var imageBytes = picture.ImageFile.GetBytes();
            var newPicture = new PictureBll()
            {
                Name  = picture.Name,
                Image = imageBytes,
                Hash  = GetImageHash(imageBytes),
            };

            pictureService.CreatePicture(newPicture);

            PictureBll addedPic = pictureService
                                  .GetPicturesByHash(newPicture.Hash)
                                  .First(pic => pic.Name == picture.Name);

            return(addedPic.Id);
        }
Example #9
0
        //绑定最新原画数据源
        protected void bingyh()
        {
            DataTable yh = PictureBll.yhTop5();

            if (yh != null)
            {
                string img1 = yh.Rows[0][2].ToString();
                string img2 = yh.Rows[1][2].ToString();
                string img3 = yh.Rows[2][2].ToString();
                string img4 = yh.Rows[3][2].ToString();
                string img5 = yh.Rows[4][2].ToString();
                Image1.ImageUrl = img1;

                Image2.ImageUrl = img2;
                Image3.ImageUrl = img3;
                Image4.ImageUrl = img4;
                Image5.ImageUrl = img5;
            }
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id;

            if (!IsPostBack)
            {
                if (Request.QueryString["picid"] != null)
                {
                    id = Convert.ToInt32(Request.QueryString["picid"].ToString());
                    SqlDataReader dt = PictureBll.IDselcet(id);
                    dt.Read();
                    if (dt != null)
                    {
                        string img1 = dt[2].ToString().Trim();
                        Image1.ImageUrl = img1;
                    }
                }
            }
        }
Example #11
0
        public void UpdatePicture(PictureBll picture)
        {
            if (picture == null)
            {
                throw new ArgumentNullException("picture");
            }

            PictureDal currentPicture = picture.ToDal();
            PictureDal existedPicture = repository.GetById(picture.Id);

            if (existedPicture == null)
            {
                throw new EntityNotFoundException("picture", picture.Id);
            }

            existedPicture.Image = currentPicture.Image;
            existedPicture.Hash  = currentPicture.Hash;
            existedPicture.Name  = currentPicture.Name;

            repository.Update(existedPicture);
            uow.Commit();
        }
Example #12
0
        public void DeletePicture(PictureBll picture)
        {
            if (picture == null)
            {
                throw new ArgumentNullException("picture");
            }
            if (picture.Id <= 0)
            {
                throw new InvalidIdException();
            }

            var removedPicture = repository.GetById(picture.Id);

            if (removedPicture == null)
            {
                throw
                    new EntityNotFoundException("picture", picture.Id);
            }

            repository.Delete(removedPicture);
            uow.Commit();
        }
        private PictureProfileModel Map(PictureProfileBll profile, int index)
        {
            var modelProfile = new PictureProfileModel()
            {
                Description = profile.Description,
                LoadingDate = profile.LoadingDate,
                PictureId   = profile.PictureId,
                Index       = index,
                UserId      = profile.UserId,
            };

            PictureBll picture = pictureService.GetPictureById(profile.PictureId);

            if (picture == null)
            {
                return(null);
            }

            modelProfile.Name  = picture.Name;
            modelProfile.Image = Convert.ToBase64String(picture.Image);

            return(modelProfile);
        }
Example #14
0
 //绑定图片数据
 private void BindView()
 {
     ListView1.DataSource = PictureBll.all();
     ListView1.DataBind();
 }
Example #15
0
 public PictureService()
 {
     db    = Bll.NewBllNoRelation();
     dbSet = db.Pictures;
 }
Example #16
0
 public static PictureDal ToDal(this PictureBll pictureBll)
 {
     return(Mapper.Map <PictureBll, PictureDal>(pictureBll));
 }