Beispiel #1
0
        public ActionResult AlterPicEdit(string id, string AlterType = "0")
        {
            SWfsAppAlterPic entity;

            if (string.IsNullOrEmpty(id))
            {
                entity = new SWfsAppAlterPic();
            }
            else
            {
                entity = appIndexService.GetAppAlterPicById(id);
            }
            if (entity == null)
            {
                entity = new SWfsAppAlterPic();
            }
            else
            {
                if (entity.RefType == 2)//查询品牌
                {
                    ViewBag.BrandName = appIndexService.GetBrandName(entity.RefContent);
                }
                if (entity.RefType == 0)//查询活动
                {
                    ViewBag.SubjectObj = appIndexService.GetSubjectByNo(entity.RefContent);
                }
            }

            return(View(entity));
        }
Beispiel #2
0
 public bool UpdateAppAlterPic(SWfsAppAlterPic entity)
 {
     return(DapperUtil.UpdatePartialColumns <SWfsAppAlterPic>(new
     {
         AppSlterPicId = entity.AppSlterPicId,
         Name = entity.Name,
         PicNo = entity.PicNo,
         RefContent = entity.RefContent,
         AlterType = entity.AlterType,
         RefType = entity.RefType,
         Sort = entity.Sort,
         StartTime = entity.StartTime
     }));
 }
Beispiel #3
0
        public ActionResult AlterPicEdit(FormCollection f)
        {
            int                id     = Convert.ToInt32(f["AppSlterPicId"]);
            SWfsAppAlterPic    entity = new SWfsAppAlterPic();
            HttpPostedFileBase file   = Request.Files["picFile"];

            entity.Name = f["Name"];

            entity.AlterType  = Convert.ToInt16(f["AlterType"]);
            entity.Sort       = Convert.ToInt32(f["Sort"]);
            entity.StartTime  = DateTime.Parse(f["StartTime"]);
            entity.RefType    = Convert.ToInt16(f["RefType"]);
            entity.RefContent = f["RefContent"];
            entity.CreateDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
            int           sameTimeID    = appIndexService.IsExistSameTimeAlter(entity.StartTime.ToString("yyyy-MM-dd HH:mm"), entity.Sort);
            CommonService commonService = new CommonService();

            rsPic.Clear();
            if (file != null && file.ContentLength > 0)
            {
                rsPic = commonService.PostImg(file, "width:0 ,Height:0,Length:100");
                if (rsPic.Keys.Contains("error"))
                {
                    ViewData["tip"] = "<script>alert('" + rsPic["error"] + "')</script>";
                    entity.PicNo    = Request.Form["PicNo"];
                    return(View(entity));
                }
                entity.PicNo = rsPic["success"];
            }
            else
            {
                if (!string.IsNullOrEmpty(Request.Form["PicNo"]))
                {
                    entity.PicNo = Request.Form["PicNo"];
                }
            }
            if (id > 0)
            {
                entity.AppSlterPicId = id;
                //验证是否重复时间的轮播图
                if (sameTimeID > 0 && sameTimeID != entity.AppSlterPicId)
                {
                    ViewData["tip"] = "<script>alert('已经存在开始时间相同的轮播图')</script>";
                    return(View(entity));
                }
            }
            else
            {
                if (sameTimeID > 0)
                {
                    ViewData["tip"] = "<script>alert('已经存在开始时间相同的轮播图')</script>";
                    return(View(entity));
                }
            }



            if (string.IsNullOrEmpty(entity.PicNo))
            {
                entity.PicNo = "";
            }

            int result = id > 0 ? (appIndexService.UpdateAppAlterPic(entity) ? 1 : 0) : appIndexService.InsertAppAlterPic(entity);

            return(Redirect("/shangpin/AppIndexMamager/AlterPicList?AlterType=" + Request.Form["AlterType"]));
        }
Beispiel #4
0
 public int InsertAppAlterPic(SWfsAppAlterPic entity)
 {
     return(DapperUtil.Insert <SWfsAppAlterPic>(entity, false));
 }