private void btn_newRound_Click(object sender, EventArgs e) { if (checkCanDone() == false) { MessageBoxEx.Show("您尚有未填写的指标测试结果,无法开始下一轮测试。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (maxRound != currentRound) { MessageBoxEx.Show("请先切换到最新的轮次,并确保其测试结果填写完整", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } maxTaskStep = (int)(trp.dgv.Rows[0].Cells["taskStep"].Value); TaskNewRoundDefine tnrd = new TaskNewRoundDefine(taskInfoId, maxRound, maxTaskStep); tnrd.init(); tnrd.getTemplateIndicators(); DialogResult result = tnrd.ShowDialog(this); if (result == DialogResult.Yes) { currentRound++; maxRound++; ModiRoundText(currentRound); trp.init(taskInfoId, false, currentRound); if (trp.dgv.Rows.Count > 0) { maxTaskStep = (int)(trp.dgv.Rows[0].Cells["taskStep"].Value);//轮次切换后,会进行页面刷新,获取当前轮次页面的最大步骤 } //新增轮次后,task的最新轮次更新,且进度重置为0 Tb_taskInfo task = TaskCache.getCacheById(taskInfoId); if (task != null) { task.taskRound = maxRound; task.percent = 0; TaskCache.addCache(task); } } else { } } }
private void btn_save_Click(object sender, EventArgs e) { List <Tb_taskResult> resultList = new List <Db.Entity.Tb_taskResult>(); //int oldRound = -1; if (currentRound != maxRound) { MessageBoxEx.Show("当前轮次不是最大轮次,无法保存", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //foreach (DataGridViewRow dr in trp.dgv.Rows) //{ // if (dr.Cells["taskRecord"].Value == null) // { // dr.Cells["taskRecord"].Value = ""; // } // if (dr.Cells["taskRemark"].Value == null) // { // dr.Cells["taskRemark"].Value = ""; // } // if (dr.Cells["attachment"].Value == null) // { // dr.Cells["attachment"].Value = ""; // } // //如果修改过测试结果,或是测试结果内有内容(无论是否本次输入),都保存 // if (dr.Cells["taskResult"].Style.BackColor == Color.LightSeaGreen // || dr.Cells["taskRecord"].Style.BackColor == Color.LightSeaGreen // || dr.Cells["taskRemark"].Style.BackColor == Color.LightSeaGreen // || dr.Cells["attachmentCount"].Style.BackColor == Color.LightSeaGreen // || dr.Cells["taskResult"].Value.ToString() != "0" // || dr.Cells["taskRecord"].Value.ToString() != string.Empty // || dr.Cells["taskRemark"].Value.ToString() != string.Empty // || dr.Cells["attachment"].Value.ToString() != string.Empty) // { // Tb_taskResult result = new Tb_taskResult(); // result.indicatorId = (int)dr.Cells["indicatorId"].Value; // result.modelId = (int)dr.Cells["modelId"].Value; // result.taskDateTime = DateTime.Now; // result.taskExecutor = User.currentUser.name; // result.taskId = taskInfoId; // result.taskRecord = dr.Cells["taskRecord"].Value == null ? "" : dr.Cells["taskRecord"].Value.ToString(); // result.taskRemark = dr.Cells["taskRemark"].Value.ToString(); // result.taskResult = (int)dr.Cells["taskResult"].Value; // result.attachment = dr.Cells["attachment"].Value.ToString(); // result.supplement = dr.Cells["supplement"].Value == null ? "" : dr.Cells["supplement"].Value.ToString(); // result.taskStep = maxTaskStep + 1; // result.taskRound = currentRound; // //result.taskRound = int.Parse(labelItem2.Text); // resultList.Add(result); // //保存任务之时,判断当前项是否填写完整,如果填写完整,则修改该控件下的isFillFinish值 // if (result.taskResult != 0 && result.taskRecord != "") // { // dr.Cells["isFill"].Value = 1; // } // } //} foreach (var item in trp.allResultModelList) { if (item.isHaveModi == 1) { Tb_taskResult result = new Tb_taskResult(); result.indicatorId = item.indicatorId; result.modelId = item.modelId; DateTime taskDateTime; result.taskDateTime = DateTime.TryParse(item.taskDateTime, out taskDateTime) ? taskDateTime : DateTime.Now; //result.taskDateTime = DateTime.TryParse(dr.Cells["taskDateTime"].Value.ToString(), out taskDateTime) ? taskDateTime : DateTime.Now;//DateTime.Now; result.taskExecutor = User.currentUser.name; result.taskId = taskInfoId; result.taskRecord = item.taskRecord; result.taskRemark = item.taskRemark; result.taskResult = item.taskResult; result.attachment = item.attachment; result.supplement = item.supplement; result.taskStep = maxTaskStep + 1; result.taskRound = currentRound; //result.taskRound = int.Parse(labelItem2.Text); resultList.Add(result); if (result.taskResult != 0 && result.taskRecord != "") { item.isFillFinish = 1; } } } if (resultList.Count > 0) { TaskResultCache.addCache(resultList); //添加测试记录 var taskInfo = TaskCache.getCacheById(taskInfoId); //更新任务进度字段 var taskResultMainCount = trp.getAllResultModelCount(); taskInfo.percent = resultList.Count * 100 / taskResultMainCount; TaskCache.addCache(taskInfo); //刷新单元格背景色为白色 foreach (DataGridViewRow dr in trp.dgv.Rows) { dr.Cells["taskResult"].Style.BackColor = Color.White; dr.Cells["taskRecord"].Style.BackColor = Color.White; dr.Cells["taskRemark"].Style.BackColor = Color.White; dr.Cells["attachmentCount"].Style.BackColor = Color.White; dr.Cells["taskStep"].Value = int.Parse(dr.Cells["taskStep"].Value.ToString()) + 1; } MainFormAdapter.reloadTaskMainPanel(); maxTaskStep++;//最大步骤编号,每次保存,都加1,如果切换轮次,需重新获取该轮次的最大步骤编号 trp.maxResultStep = maxTaskStep; trp.currentResultStep = maxTaskStep; } }