public static void SetItem(ArticlePosterModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("ArticlePoster"); tableObj.GetDataFromObject(item); string sql = "Select 1 From ArticlePoster Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["Creator"] = MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("MenuID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj["Modifier"] = MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; tableObj.Update(item.ID); } }
public string PosterQuickAdd(long siteId, long menuId, string name) { if (string.IsNullOrWhiteSpace(name)) { return(null); } ArticlePosterModels poster = new ArticlePosterModels { ID = WorkLib.GetItem.NewSN(), MenuID = menuId, Name = name, Photo = string.Empty, Intro = string.Empty, Resume = string.Empty, IsIssue = true, Sort = int.MaxValue }; ArticlePosterDAO.SetItem(poster); return(poster.ID.ToString()); }
public ActionResult PosterEdit(long siteId, long menuId, long?id) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId); ArticlePosterModels type = null; if (id != null) { type = ArticlePosterDAO.GetItem((long)id); } if (type == null) { type = new ArticlePosterModels { ID = WorkLib.GetItem.NewSN(), IsIssue = true, Sort = int.MaxValue } } ; return(View(type)); }
public ActionResult PosterEdit(long siteId, long menuId, ArticlePosterModels item) { if (!Utility.CheckIsLogin()) { Response.Redirect(Url.Action("Login", "Home")); } ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId); ViewBag.Exit = true; if (!string.IsNullOrWhiteSpace(item.Photo)) { ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.Photo); if (imgModel.ID == 0) // 新上傳的圖片 { HttpPostedFileBase postedFile = Request.Files["fPhoto"]; string fPhotoBase64 = Request.Form["fPhotoBase64"]; string fPhotoBase64_Resize = Request.Form["fPhotoBase64_Resize"]; if (postedFile == null || postedFile.ContentLength == 0) { item.Photo = string.Empty; } else { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, fPhotoBase64, fPhotoBase64_Resize); imgModel.ID = 1; imgModel.Img = saveName; item.Photo = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel); } } } ArticlePosterDAO.SetItem(item); return(View(item)); }