Beispiel #1
0
        public ActionResult Edit(int id, int newsType, string title, string subHead, HttpPostedFileBase img, string content, int isshow, int priority)
        {
            ViewBag.Error = "none";
            MldNews model = dal.Query(id);

            if (img != null && img.ContentLength > 0)
            {
                UploadFileResult result = img.FileUpLoad("img", 1024 * 1024 * 4, "images");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    model.Img = result.Data;
                }
            }
            model.NewsType = newsType;
            model.SubHead  = subHead;
            model.Content  = content;
            model.IsShow   = isshow;
            model.Priority = priority;
            model.Title    = title;
            if (dal.Update(model))
            {
                ViewBag.Success = "ok";
            }
            else
            {
                ViewBag.Error = "添加失败";
            }
            return(View(model));
        }
        public ActionResult Index(int pid, HttpPostedFileBase img)
        {
            ViewBag.Error = "none";
            string imgUrl = "";

            if (img != null && img.ContentLength > 0)
            {
                UploadFileResult result = img.FileUpLoad("img", 1024 * 1024 * 4, "images");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    imgUrl = result.Data;
                    MldProductImg model = new MldProductImg();
                    model.Img = imgUrl;
                    model.Pid = pid;
                    if (advDal.Add(model) > 0)
                    {
                        ViewBag.Success = "ok";
                    }
                    else
                    {
                        ViewBag.Error = "Error";
                    }
                }
            }
            else
            {
                ViewBag.Error = "Please select the picture to upload";
            }
            return(View());
        }
        public ActionResult Edit(int id, string name, HttpPostedFileBase homebg, HttpPostedFileBase icon, string subhead, string content, int homeshowflag)
        {
            ViewBag.Error = "none";
            MldApplicationArea model   = dal.Query(id);
            string             imgUrl1 = model.HomeBg;

            if (homebg != null && homebg.ContentLength > 0)
            {
                UploadFileResult result = homebg.FileUpLoad("img", 1024 * 1024 * 4, "applicationarea");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    imgUrl1 = result.Data;
                }
            }
            string imgUrl2 = model.Icon;

            if (icon != null && icon.ContentLength > 0)
            {
                UploadFileResult result = icon.FileUpLoad("img", 1024 * 1024 * 4, "applicationarea");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    imgUrl2 = result.Data;
                }
            }

            model.Content      = content;
            model.HomeBg       = imgUrl1;
            model.Icon         = imgUrl2;
            model.Name         = name;
            model.SubHead      = subhead;
            model.HomeShowFlag = homeshowflag;

            if (dal.Update(model))
            {
                ViewBag.Success = "ok";
            }
            else
            {
                ViewBag.Error = "Error";
            }

            model = dal.Query(id);
            return(View(model));
        }
Beispiel #4
0
        public ActionResult Edit(int id, string title, string subhead, int advType, string link, HttpPostedFileBase img, int isshow, int priority)
        {
            ViewBag.Error = "none";
            string imgUrl = "";

            if (img != null && img.ContentLength > 0)
            {
                UploadFileResult result = img.FileUpLoad("img", 1024 * 1024 * 4, "images");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    imgUrl = result.Data;
                }
            }

            MldAdv model = advDal.Query(id);

            model.AdvType  = advType;
            model.Link     = link;
            model.IsShow   = isshow;
            model.Priority = priority;
            model.ID       = id;
            model.SubHead  = subhead;
            model.Title    = title;
            if (!string.IsNullOrEmpty(imgUrl))
            {
                model.Img = imgUrl;
            }

            if (advDal.Update(model))
            {
                ViewBag.Success = "ok";
            }
            else
            {
                ViewBag.Error = "Error";
            }
            return(View(model));
        }
Beispiel #5
0
        public ActionResult Upload(HttpPostedFileBase file)
        {
            UploadFileResult result = file.FileUpLoad("img", 1024 * 1024 * 4, "images");

            if (result.Ok)
            {
                return(Json(new
                {
                    ok = true,
                    url = result.Data
                }));
            }
            else
            {
                return(Json(new
                {
                    ok = false,
                    error = result.Data
                }));
            }
        }
        public ActionResult Index(string name, HttpPostedFileBase homebg, HttpPostedFileBase icon, string subhead, string content, int homeshowflag)
        {
            ViewBag.Error = "none";

            if (homebg != null && homebg.ContentLength > 0 && icon != null && icon.ContentLength > 0)
            {
                UploadFileResult result1 = homebg.FileUpLoad("img", 1024 * 1024 * 4, "applicationarea");
                UploadFileResult result2 = icon.FileUpLoad("img", 1024 * 1024 * 4, "applicationarea");
                if (!result1.Ok || !result2.Ok)
                {
                    ViewBag.Error = "图片上传错误";
                }
                else
                {
                    MldApplicationArea model = new MldApplicationArea();
                    model.AddTime      = DateTime.Now;
                    model.Content      = content;
                    model.HomeBg       = result1.Data;
                    model.Icon         = result2.Data;
                    model.Name         = name;
                    model.SubHead      = subhead;
                    model.HomeShowFlag = homeshowflag;

                    int id = dal.Add(model);
                    if (id > 0)
                    {
                        ViewBag.Success = "ok";
                    }
                    else
                    {
                        ViewBag.Error = "Error";
                    }
                }
            }
            else
            {
                ViewBag.Error = "请选择要上传的背景图和图标";
            }
            return(View());
        }
Beispiel #7
0
        public ActionResult Index(string title, string subhead, int advType, string link, HttpPostedFileBase img, int isshow, int priority)
        {
            ViewBag.Error = "none";
            string imgUrl = "";

            if (img != null && img.ContentLength > 0)
            {
                UploadFileResult result = img.FileUpLoad("img", 1024 * 1024 * 4, "images");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    imgUrl = result.Data;
                    MldAdv model = new MldAdv();
                    model.AdvType  = advType;
                    model.Link     = link;
                    model.Img      = imgUrl;
                    model.IsShow   = isshow;
                    model.Priority = priority;
                    model.Title    = title;
                    model.SubHead  = subhead;
                    if (advDal.Add(model) > 0)
                    {
                        ViewBag.Success = "ok";
                    }
                    else
                    {
                        ViewBag.Error = "Error";
                    }
                }
            }
            else
            {
                ViewBag.Error = "Please select the picture to upload";
            }
            return(View());
        }
Beispiel #8
0
        public ActionResult Index(string title, HttpPostedFileBase logo, string keyword, string description, string pagedown)
        {
            ViewBag.Error = "none";
            MldWebSite model = Helper.ApplicationHelper.CurWebsite;

            if (logo != null && logo.ContentLength > 0)
            {
                UploadFileResult result = logo.FileUpLoad("img", 1024 * 1024 * 4, "images");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    model.Logo = result.Data;
                }
            }

            model.Title       = title;
            model.KeyWord     = keyword;
            model.Description = description;
            model.Content     = pagedown;

            using (BasicDB db = new BasicDB(false))
            {
                if (websiteDal.Update(model))
                {
                    ViewBag.Success = "ok";
                    Helper.ApplicationHelper.CurWebsite = model;
                }
                else
                {
                    ViewBag.Error = "Error";
                }
            }
            return(View(Helper.ApplicationHelper.CurWebsite));
        }
        public ActionResult Edit(int id, HttpPostedFileBase img)
        {
            ViewBag.Error = "none";
            string imgUrl = "";

            if (img != null && img.ContentLength > 0)
            {
                UploadFileResult result = img.FileUpLoad("img", 1024 * 1024 * 4, "images");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    imgUrl = result.Data;
                }
            }

            MldProductImg model = advDal.Query(id);

            model.ID = id;
            if (!string.IsNullOrEmpty(imgUrl))
            {
                model.Img = imgUrl;
            }

            if (advDal.Update(model))
            {
                ViewBag.Success = "ok";
            }
            else
            {
                ViewBag.Error = "Error";
            }
            return(View(model));
        }
Beispiel #10
0
        public ActionResult Index(int cid, string name, string subhead, string profile, string application, string material, string weight, string length, string massOfInertia, string sectionModulus, HttpPostedFileBase profileimg, HttpPostedFileBase img, string content, string datacontent, int allshowflag, int homeshowflag, int iselite, HttpPostedFileBase img1, HttpPostedFileBase img2, HttpPostedFileBase img3, HttpPostedFileBase img4)
        {
            ViewBag.Error     = "none";
            ViewBag.Category1 = new MldProductCategoryDal().QueryList("id asc", "tid=@1", 0);
            if (img != null && img.ContentLength > 0)
            {
                UploadFileResult result = img.FileUpLoad("img", 1024 * 1024 * 4, "product");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    MldProduct model = new MldProduct();
                    model.Img = result.Data;
                    List <string> imgList = new List <string>();
                    if (img1 != null && img1.ContentLength > 0)
                    {
                        UploadFileResult result1 = img1.FileUpLoad("img", 1024 * 1024 * 4, "product");
                        if (result1.Ok)
                        {
                            imgList.Add(result1.Data);
                        }
                    }
                    if (img2 != null && img2.ContentLength > 0)
                    {
                        UploadFileResult result2 = img2.FileUpLoad("img", 1024 * 1024 * 4, "product");
                        if (result2.Ok)
                        {
                            imgList.Add(result2.Data);
                        }
                    }
                    if (img3 != null && img3.ContentLength > 0)
                    {
                        UploadFileResult result3 = img3.FileUpLoad("img", 1024 * 1024 * 4, "product");
                        if (result3.Ok)
                        {
                            imgList.Add(result3.Data);
                        }
                    }
                    if (img4 != null && img4.ContentLength > 0)
                    {
                        UploadFileResult result4 = img4.FileUpLoad("img", 1024 * 1024 * 4, "product");
                        if (result4.Ok)
                        {
                            imgList.Add(result4.Data);
                        }
                    }
                    model.Cid          = cid;
                    model.Name         = name;
                    model.SubHead      = subhead;
                    model.Content      = content;
                    model.AllShowFlag  = allshowflag;
                    model.HomeShowFlag = homeshowflag;
                    model.IsElite      = iselite;
                    model.AddTime      = DateTime.Now;

                    model.Profile        = profile;
                    model.Application    = application;
                    model.Material       = material;
                    model.Weight         = weight;
                    model.Length         = length;
                    model.MassOfInertia  = massOfInertia;
                    model.SectionModulus = sectionModulus;


                    if (profileimg != null && profileimg.ContentLength > 0)
                    {
                        UploadFileResult result5 = profileimg.FileUpLoad("img", 1024 * 1024 * 4, "product");
                        if (result5.Ok)
                        {
                            model.ProfileImg = result5.Data;
                        }
                    }


                    int id = dal.Add(model);
                    if (id > 0)
                    {
                        MldProductImgDal imgDal = new MldProductImgDal();
                        foreach (var item in imgList)
                        {
                            MldProductImg itemImg = new MldProductImg();
                            itemImg.Img = item;
                            itemImg.Pid = id;
                            imgDal.Add(itemImg);
                        }
                        ViewBag.Success = "ok";
                    }
                    else
                    {
                        ViewBag.Error = "Error";
                    }
                }
            }
            else
            {
                ViewBag.Error = "Please select the picture to upload";
            }
            return(View());
        }
Beispiel #11
0
        public ActionResult Edit(int id, int cid, string name, string subhead, string profile, string application, string material, string weight, string length, string massOfInertia, string sectionModulus, HttpPostedFileBase profileimg, HttpPostedFileBase img, string content, string datacontent, int allshowflag, int homeshowflag, int iselite)
        {
            ViewBag.Error     = "none";
            ViewBag.Category1 = new MldProductCategoryDal().QueryList("id asc", "tid=@1", 0);
            MldProduct model  = dal.Query(id);
            string     imgUrl = model.Img;

            if (img != null && img.ContentLength > 0)
            {
                UploadFileResult result = img.FileUpLoad("img", 1024 * 1024 * 4, "product");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    imgUrl = result.Data;
                }
            }



            model.Img          = imgUrl;
            model.Cid          = cid;
            model.Name         = name;
            model.SubHead      = subhead;
            model.Content      = content;
            model.AllShowFlag  = allshowflag;
            model.HomeShowFlag = homeshowflag;
            model.IsElite      = iselite;

            model.Profile        = profile;
            model.Application    = application;
            model.Material       = material;
            model.Weight         = weight;
            model.Length         = length;
            model.MassOfInertia  = massOfInertia;
            model.SectionModulus = sectionModulus;

            if (profileimg != null && profileimg.ContentLength > 0)
            {
                UploadFileResult result = profileimg.FileUpLoad("img", 1024 * 1024 * 4, "product");
                if (result.Ok)
                {
                    model.ProfileImg = result.Data;
                }
            }

            if (dal.Update(model))
            {
                ViewBag.Success = "ok";
            }
            else
            {
                ViewBag.Error = "Error";
            }

            MldProductCategoryDal categoryDal = new MldProductCategoryDal();

            model = dal.Query(id);
            MldProductCategory category = categoryDal.Query(model.Cid);

            ViewBag.TopCategoryID = categoryDal.Query(category.Tid).ID;
            ViewBag.Category1     = categoryDal.QueryList("id asc", "tid=@1", 0);
            ViewBag.Category2     = categoryDal.QueryList("id asc", "tid=@1", category.Tid);
            return(View(model));
        }