public string AddRisk(WeekReportRisk risk) { try { dbContext.WeekReportRisks.Add(risk); dbContext.SaveChanges(); return Constants.AJAX_CREATE_SUCCESS_RETURN; } catch (Exception e1) { return "<p class='alert alert-danger'>出错了: " + e1.Message + "</p>"; } }
public string EditRisk(WeekReportRisk risk) { try { dbContext.Entry(risk).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); return Constants.AJAX_EDIT_SUCCESS_RETURN; } catch (Exception e1) { return "<p class='alert alert-danger'>出错了: " + e1.Message + "</p>"; } }
// 填报:风险与待协调问题 public ActionResult AddRisk() { // 默认加上当前的用户UID和姓名 User user = this.GetSessionCurrentUser(); // RptDate备选(取最近的5个) List<string> ls = this.GetRptDateList(); ls.Insert(0, DateTime.Now.Year + "年"); SelectList sl2 = MyTools.GetSelectList(ls); ViewBag.RptDateList = sl2; WeekReportRisk risk = new WeekReportRisk() { RptDate = DateTime.Now.Year + "年", RptPersonID = user.UID }; return View(risk); }