Ejemplo n.º 1
0
 public ActionResult Edit(int id)
 {
     ViewData["SysImageID"] = id;
     string feID = Request.QueryString["feID"] == null ? "" : Request.QueryString["feID"].ToString();
     ViewData["feID"] = feID;
     bizSysImages s = new bizSysImages();
     SysImages model = s.Get(id);
     return View(model);
 }
Ejemplo n.º 2
0
        public ActionResult Edit(FormCollection f, HttpPostedFileBase fileImage)
        {
            string feID = Request.Form["feID"] == null ? "" : Request.Form["feID"].ToString();
            ViewData["feID"] = feID;
            bizSysImages s = new bizSysImages();
            SysImages model = s.Get(int.Parse(f["SysImageID"]));
            byte isShuiyin = Request.Form["isShuiyin"]==null?byte.Parse("0"):byte.Parse("1");
            string basePath = ConfigurationManager.AppSettings["ImagePath"];
            int size = model.ImageSize;
            int width = model.Width;
            int height = model.Height;

            if (f["btn"] == "2")
            {
                s.Delete(model.SysImageID);
                System.IO.File.Delete(Images.GetPhysicsPath(model.ImagePath, basePath));
                return Redirect("/AdminImages/Index.html?feID=" + feID);
            }

            if (fileImage != null)
            {
                if (MyText.GetFileExtName(model.ImagePath).ToLower() != MyText.GetFileExtName(fileImage.FileName).ToLower())
                {
                    TempData["Msg"] = "�ϴ����ļ����ͱ���Ҫ�͵�ǰͼƬ������һ��";
                    return Redirect("/AdminImages/Edit?feID=" + feID.ToString());
                }
                else
                {
                    Public.ImageHelper.UpImageAttr upImageAttr1;
                    string result;
                    result = Public.ImageHelper.ImageUp(fileImage, Enumerations.ImageUpPathType.sysimg, "", 100, 0, 0, out upImageAttr1);
                    if (result != "")
                    {
                        TempData["Msg"] = result;
                        return Redirect("/AdminImages/Edit?feID=" + feID.ToString());
                    }
                    else
                    {
                        size=upImageAttr1.imageSize;
                        width=upImageAttr1.width;
                        height=upImageAttr1.height;
                    }

                    //System.Drawing.Image image = System.Drawing.Image.FromStream(fileImage.InputStream);

                    //try
                    //{
                    //    string filePath = model.ImagePath ;
                    //    filePath = basePath + filePath;

                    //    if (isShuiyin == 1)
                    //    {
                    //        if (MyText.GetFileExtName(fileImage.FileName).ToLower() != "gif")
                    //            image = PublicHelper.AddWatermarkImage(image, basePath + "/images/shuiyin.gif", "WM_BOTTOM_RIGHT");
                    //    }
                    //    size = fileImage.ContentLength / 1024;
                    //    width = image.Width;
                    //    height = image.Height;
                    //    image.Save(filePath);
                    //    image.Dispose();
                    //}
                    //catch (Exception e)
                    //{
                    //    TempData["Msg"] = e.Message;
                    //    return Redirect("/AdminImages/Edit?feID=" + feID.ToString());
                    //}
                }
            }
            model.Attach();
            model.IsShuiying = fileImage == null ? model.IsShuiying : isShuiyin;
            model.ImageSize = size;
            model.Width = width;
            model.Height = height;
            model.Title = f["title"].Trim();
            model.Keyword = Request.Form["Keyword"] == null ? "" : Request.Form["Keyword"].ToString() + ",";
            model.Detach();
            s.Update(model);
            return Redirect("/AdminImages/Index.html?feID=" + feID.ToString());
        }