// 修改:每周工作 public ActionResult EditDetail(int id) { WeekReportDetail detail = dbContext.WeekReportDetails.ToList().Find(a => a.WRDetailID == id); if (detail == null) { return(View()); } // 工作类型下拉列表 SelectList sl = MyTools.GetSelectList(Constants.WorkTypeList, false, true, detail.WorkType); ViewBag.WorkTypeList = sl; // RptDate备选(取最近的5个) List <string> ls = this.GetRptDateList(); ls.Insert(0, DateTime.Now.Year + "年"); SelectList sl2 = MyTools.GetSelectList(ls, false, true, detail.RptDate); ViewBag.RptDateList = sl2; // 重点项目下拉 var mainList = dbContext.WeekReportMains.Where(a => a.DoNotTrack != true); SelectList sl3 = new SelectList(mainList, "WRMainID", "WorkName"); ViewBag.WorkNameList = sl3; return(View(detail)); }
// 添加每周工作 public ActionResult AddDetail(int id = 0, bool isCopy = false) { // 当前用户 User user = this.GetSessionCurrentUser(); if (user == null) { user = new User(); } // RptDate备选(取最近的5个) List <string> ls = this.GetRptDateList(); ls.Insert(0, DateTime.Now.Year + "年"); SelectList sl = MyTools.GetSelectList(ls); ViewBag.RptDateList = sl; // 工作类型下拉列表 SelectList sl2 = MyTools.GetSelectList(Constants.WorkTypeList); ViewBag.WorkTypeList = sl2; WeekReportDetail detail = null; // 若是复制则直接读取现有的 if (isCopy) { detail = dbContext.WeekReportDetails.ToList().Find(a => a.WRDetailID == id); } else { detail = new WeekReportDetail() { RptDate = DateTime.Now.Year + "年", Person = user.Realname, RptPersonID = user.UID, Progress = 100, IsWithMain = false }; } // 重点项目下拉 var mainList = dbContext.WeekReportMains.Where(a => a.DoNotTrack != true); SelectList sl3 = new SelectList(mainList, "WRMainID", "WorkName"); ViewBag.WorkNameList = sl3; return(View(detail)); }
public string EditDetail(WeekReportDetail detail) { try { dbContext.Entry(detail).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); // 自动计算工时 if (detail.IsWithMain) { this.UpdateWorkTime(detail.WorkName); } } catch (Exception e1) { return("<p class='alert alert-danger'>出错了: " + e1.Message + "</p>"); } return(Constants.AJAX_EDIT_SUCCESS_RETURN); }
public string AddDetail(WeekReportDetail detail) { try { dbContext.WeekReportDetails.Add(detail); dbContext.SaveChanges(); // 自动计算工时 if (detail.IsWithMain) { this.UpdateWorkTime(detail.WorkName); } return(Constants.AJAX_CREATE_SUCCESS_RETURN); } catch (Exception e1) { return("<p class='alert alert-danger'>出错了: " + e1.Message + "</p>"); } }
public string DeleteDetail(int id) { try { WeekReportDetail detail = dbContext.WeekReportDetails.ToList().Find(a => a.WRDetailID == id); dbContext.Entry(detail).State = System.Data.Entity.EntityState.Deleted; dbContext.SaveChanges(); // 自动计算工时 if (detail.IsWithMain) { this.UpdateWorkTime(detail.WorkName); } return("删除成功"); } catch (Exception e1) { return("出错了: " + e1.Message); } }