public ActionResult KpiList(int year = 0, int month = 0, List <int> rid = null) { CheckDate(ref year, ref month); //读取/创建进程 var process = Bll.BllKpi_Process.GetModel(MyInfo.Id, year, month); if (process == null) { process = new Kpi_Process() { IsCreated = false, IsApprove = false, Month = month, Year = year, Score = 0, UserId = MyInfo.Id, Remark = "" }; int id = Bll.BllKpi_Process.Insert(process); if (id > 0) { process.Id = id; } else { return(MessageBoxAndReturn("当前进程创建失败,请联系管理员!")); } } //目标项 List <Kpi_Records> recordlist = Bll.BllKpi_Records.GetList(process.Id); ViewBag.year = year; ViewBag.month = month; ViewBag.startyear = StartYear; ViewBag.recordlist = recordlist; return(View(process)); }
//导入模版 public ActionResult KpiModelCreate(List <int> rid, int year = 0, int month = 0) { if (rid == null || rid.Count == 0) { return(MessageBoxAndReturn("请选择指标!")); } CheckDate(ref year, ref month); //生成进程 var process = Bll.BllKpi_Process.GetModel(MyInfo.Id, year, month); if (process == null) { process = new Kpi_Process() { IsCreated = false, IsApprove = false, Month = month, Year = year, Score = 0, UserId = MyInfo.Id, Remark = "" }; int pid = Bll.BllKpi_Process.Insert(process); if (pid > 0) { process.Id = pid; } else { return(MessageBoxAndReturn("当前进程创建失败,请联系管理员!")); } } if (process.IsCreated ?? false) { return(MessageBoxAndReturn("该进程已生成,请勿重新生成!")); } var recordlist = Bll.BllKpi_Records.GetListByIds(rid); if (recordlist == null) { return(MessageBoxAndReturn("该进程模版不存在!")); } foreach (var item in recordlist) { item.DeAttach();//实体恢复默认状态 item.Id = 0; item.Pid = process.Id; item.Year = year; item.Month = month; item.IsApprove = false; item.IsCreated = false; item.CreateTime = DateTime.Now; //清空评分记录 item.Remark = ""; item.ParScore = 0; item.FinishScore = 0; item.ApproveTime = null; item.SelfScore = 0; item.IsSelfApprove = false; item.SelfRemark = ""; item.SelfApproveTime = null; } int id = Bll.BllKpi_Records.Insert(recordlist); if (id > 0) { return(Redirect($"/kpi/kpi/kpilist?year={process.Year}&month={process.Month}")); } else { return(MessageBoxAndReturn("导入失败!")); } }