// 添加每周工作
        public ActionResult AddDetail(int id = 0, bool isCopy = false)
        {
            // 当前用户
            User user = this.GetSessionCurrentUser();

            // 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 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 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;
        }