public JsonResult CheckSave(T_PhotoApprove model) { using (TransactionScope sc = new TransactionScope()) { try { string name = Server.UrlDecode(Request.Cookies["NickName"].Value); T_PhotoApprove editModel = db.T_PhotoApprove.Find(model.ID); editModel.Status = model.Status; editModel.ApproveTime = DateTime.Now; editModel.ApproveName = name; editModel.Memo = model.Memo; db.Entry <T_PhotoApprove>(editModel).State = System.Data.Entity.EntityState.Modified; T_Photograph PhotoModel = db.T_Photograph.Find(editModel.PID); if (model.Status == 1)//同意 { int nextStep = editModel.Step + 1; List <T_PhotoConfig> ConfigList = db.T_PhotoConfig.Where(a => a.Step == nextStep).ToList(); if (ConfigList.Count > 0)//下一步 { PhotoModel.Status = 0; PhotoModel.Step = nextStep; PhotoModel.CurrentApprove = ConfigList.First().Name; T_PhotoApprove newApprove = new T_PhotoApprove(); newApprove.ApproveName = ConfigList.First().Name; newApprove.PID = editModel.PID; newApprove.Status = -1; newApprove.Step = nextStep; db.T_PhotoApprove.Add(newApprove); } else//结束 { PhotoModel.Status = 1; PhotoModel.Step = 99; } } else//不同意结束 { PhotoModel.Status = 2; PhotoModel.Step = 99; } db.Entry <T_Photograph>(PhotoModel).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { State = "Faile", Message = e.Message }, JsonRequestBehavior.AllowGet)); } } }
public JsonResult EditSave(T_Photograph model, string jsonStr) { using (TransactionScope sc = new TransactionScope()) { try { T_Photograph editModel = db.T_Photograph.Find(model.ID); editModel.CurrentApprove = model.CurrentApprove; db.Entry <T_Photograph>(editModel).State = System.Data.Entity.EntityState.Modified; List <T_PhotoDetail> details = Com.Deserialize <T_PhotoDetail>(jsonStr); // editModel.CurrentApprove = model.CurrentApprove; foreach (T_PhotoDetail item in details) { T_PhotoDetail editDetail = db.T_PhotoDetail.Find(item.ID); editDetail.BasicRequire = item.BasicRequire; editDetail.GoodsCode = item.GoodsCode; editDetail.GoodsName = item.GoodsName; editDetail.ShopName = item.ShopName; editDetail.Spec = item.Spec; editDetail.SpecialRequire = item.SpecialRequire; db.Entry <T_PhotoDetail>(editDetail).State = System.Data.Entity.EntityState.Modified; } if (editModel.Status == 2) { editModel.Status = -1; editModel.Step = 1; T_PhotoApprove Approvemodel = new T_PhotoApprove(); Approvemodel.Status = -1; Approvemodel.ApproveName = editModel.CurrentApprove; Approvemodel.Memo = ""; Approvemodel.PID = model.ID; Approvemodel.Step = 1; db.T_PhotoApprove.Add(Approvemodel); } db.SaveChanges(); sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { State = "Faile", Message = e.Message }, JsonRequestBehavior.AllowGet)); } } }
public JsonResult Delete(int ID) { try { T_Photograph delModel = db.T_Photograph.Find(ID); delModel.IsDelete = 1; db.Entry <T_Photograph>(delModel).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { State = "Faile", Message = e.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ViewEdit(int ID) { ViewData["ID"] = ID; T_Photograph model = db.T_Photograph.Find(ID); ViewData["ApproveList"] = getApproveName(1); if (model != null) { return(View(model)); } else { return(HttpNotFound()); } }
public JsonResult ApplySave(T_Photograph model, string jsonStr) { using (TransactionScope sc = new TransactionScope()) { try { string nickName = Server.UrlDecode(Request.Cookies["NickName"].Value); List <T_PhotoDetail> details = Com.Deserialize <T_PhotoDetail>(jsonStr); //主表保存 model.PostTime = DateTime.Now; model.Status = -1; model.Step = 1; model.IsDelete = 0; // model.CurrentApprove = "游神"; model.PostName = nickName; db.T_Photograph.Add(model); int i = db.SaveChanges(); if (i > 0) { T_PhotoApprove Approvemodel = new T_PhotoApprove(); Approvemodel.Status = -1; Approvemodel.ApproveName = model.CurrentApprove; Approvemodel.Memo = ""; Approvemodel.PID = model.ID; Approvemodel.Step = 1; db.T_PhotoApprove.Add(Approvemodel); foreach (T_PhotoDetail item in details) { item.PID = model.ID; db.T_PhotoDetail.Add(item); } db.SaveChanges(); sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } return(Json(new { State = "Faile", Message = "保存失败" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet)); } } }