Ejemplo n.º 1
0
        public void AddLinks()
        {
            ClassLibrary.BLL.ScrollImages   linksBLL   = new ClassLibrary.BLL.ScrollImages();
            ClassLibrary.Model.ScrollImages linksModel = new ClassLibrary.Model.ScrollImages();

            if (string.IsNullOrEmpty(Request.Form["Title"]))
            {
                Response.Write("<script>alert('请输入标题!');history.back(-1);</script>");
                return;
            }
            else
            {
                linksModel.Title = Request.Form["Title"];
            }
            linksModel.LinkURL = Request.Form["LinkURL"];
            linksModel.Img     = string.Empty;

            HttpPostedFile file = Request.Files["Img"];

            if (file.ContentLength > 0)
            {
                string ext          = Path.GetExtension(file.FileName);
                string fileName     = Function.GetRandomTime() + ext;
                string fileFullPath = Server.MapPath(SysConfig.UploadFilePathScrollImg);
                Function.CreatedDirectory(fileFullPath);
                file.SaveAs(fileFullPath + fileName);

                //缩图
                //Bitmap tmp = new Bitmap(fileFullPath + fileName);
                //Bitmap bmp0 = Function.MakeThumNail(tmp, 735, 352);
                //tmp.Dispose();
                ////bmp0.Save(fileFullPath + fileName);
                //Function.SaveBitmapImg(bmp0, fileFullPath + fileName, ((long)100));
                //bmp0.Dispose();

                linksModel.Img = fileName;
            }

            if (linksBLL.Add(linksModel) > 0)
            {
                Function.goMessagePage("添加首页图片", "操作成功", "Advertise/ScrollImageList.aspx");
            }
            else
            {
                Function.goMessagePage("添加首页图片", "操作失败,请稍后再试", "Advertise/ScrollImageList.aspx");
            }
        }
Ejemplo n.º 2
0
        private void ScrollImageDelete(HttpContext context)
        {
            ClassLibrary.BLL.ScrollImages bll = new ClassLibrary.BLL.ScrollImages();

            string strid = context.Request.QueryString["id"];
            string img   = context.Request.QueryString["img"];

            if (bll.Delete(Convert.ToInt32(strid)) > 0)
            {
                ClassLibrary.Common.Function.DeleteFile(context.Server.MapPath(ClassLibrary.Common.SysConfig.UploadFilePathScrollImg + img));

                Print(context, "success");
            }
            else
            {
                Print(context, "error");
            }
        }