Example #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);
 }
Example #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());
        }
Example #3
0
        public ActionResult Index(FormCollection f,HttpPostedFileBase fileImage)
        {
            string feID = Request.Form["feID"] == null ? "" : Request.Form["feID"].ToString();
            string keyword = Request.Form["Keyword"] == null ? "" : Request.Form["Keyword"].ToString() + ",";
            byte isShuiyin = Request.Form["isShuiyin"]==null?byte.Parse("0"):byte.Parse("1");
            //string imagePath = "";
            //string basePath = Server.MapPath("/");
            //int size = 0;
            //int width = 0;
            //int height = 0;

            Public.ImageHelper.UpImageAttr upImageAttr1;
            string result;
            result = Public.ImageHelper.ImageUp(fileImage, Enumerations.ImageUpPathType.sysimg, "", 100, 0, 0, out upImageAttr1);
            if(result!="")
            {
                TempData["Msg"]=result;
            }
            else
            {
                bizSysImages s = new bizSysImages();
                SysImages model = new SysImages();
                model.Title = f["Title"].Trim()==""?fileImage.FileName.Split('.')[0].ToString():f["Title"].Trim();
                model.Keyword = keyword;
                model.IsShuiying = isShuiyin;
                model.ImageSize = upImageAttr1.imageSize;
                model.Height = upImageAttr1.height;
                model.Width = upImageAttr1.width;
                model.ImagePath = upImageAttr1.imagePath;
                model.UserName = UserName;
                model.AddTime = DateTime.Now;
                s.Add(model);
            }

            return Redirect("/AdminImages/Index.html?feID=" + feID);

            //if (fileImage == null)
            //{
            //    TempData["Msg"] = "û��ѡ��ͼƬ�ļ�";
            //    return Redirect("/AdminImages/Index.html?feID=" + feID);
            //}

            //string extName = MyText.GetFileExtName(fileImage.FileName);
            //if (MyText.IsImage(extName) == false)
            //{
            //    TempData["Msg"] = "���Ƿ��Ϲ涨��ͼƬ�ļ�";
            //    return Redirect("/AdminImages/Index.html?feID="+feID);
            //}

            //DateTime nowDate = DateTime.Now;

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

            //try
            //{
            //    string filePath = "/userfiles/sysimg/" + nowDate.Year + "/" + nowDate.Month + "/" + nowDate.Day;
            //    string fileName = nowDate.Hour.ToString() + nowDate.Minute.ToString() + nowDate.Second.ToString() + nowDate.Millisecond.ToString() + "." + extName;
            //    imagePath = filePath + "/" + fileName;
            //    filePath = basePath + filePath;
            //    System.IO.Directory.CreateDirectory(filePath);

            //    if (isShuiyin==1)
            //    {
            //        if (extName.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 + "/" + fileName);
            //    image.Dispose();

            //}
            //catch (Exception e)
            //{
            //    TempData["Msg"] =e.Message;
            //    return Redirect("/AdminImages/Index.html?feID=" + feID);
            //}

            //return Redirect("/AdminImages/Index.html?feID=" + feID);
        }
Example #4
0
        //
        // GET: /AdminImages/
        public ActionResult Index()
        {
            string feID = Request.QueryString["feID"] == null ? "" : Request.QueryString["feID"].ToString();
            string title = Request.QueryString["title"] == null ? "" : Request.QueryString["title"].ToString();
            string keyword = Request.QueryString["keyword"] == null ? "" : Request.QueryString["keyword"].ToString();
            int count;
            int pageSize=40;
            int page = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"].ToString());
            bizSysImages si = new bizSysImages();
            List<SysImages> list = si.List(title, keyword, pageSize, page-1, out count);
            string url = "/AdminImages/Index.html?feID=" + feID + "&title=" + title + "&keyword" + keyword;
            ViewData["PageList"] = Common.Untilies.Page.GetPageList(url, count, pageSize, page, true);
            ViewData["feID"] = feID;
            ViewData["title"] = title;
            ViewData["keyword"] = keyword;

            return View(list);
        }