private void UpdateStepList() { StepList = ConnectionManager.Context.table("Step").where ("ProjectID='" + MainForm.Instance.ProjectObj.ID + "'").select("*").getList <Step>(new Step()); if (StepList != null) { int indexx = 0; dgvDetail.Rows.Clear(); foreach (Step step in StepList) { string stepContent = string.Empty; ProjectAndStep projectAndStep = ConnectionManager.Context.table("ProjectAndStep").where ("StepID='" + step.ID + "'").select("*").getItem <ProjectAndStep>(new ProjectAndStep()); if (projectAndStep != null) { stepContent = projectAndStep.StepContent; } indexx++; List <object> cells = new List <object>(); cells.Add(indexx + ""); cells.Add(step.StepIndex); cells.Add(stepContent); cells.Add(step.StepDest); cells.Add(step.StepMoney); int rowIndex = dgvDetail.Rows.Add(cells.ToArray()); dgvDetail.Rows[rowIndex].Tag = step; } } }
public override void OnSaveEvent() { base.OnSaveEvent(); foreach (DataGridViewRow dgvRow in dgvDetail.Rows) { if (dgvRow.Tag != null) { Step step = (Step)dgvRow.Tag; if (dgvRow.Cells[3].Value == null || string.IsNullOrEmpty(dgvRow.Cells[3].Value.ToString())) { MessageBox.Show("对不起,请输入完成内容及阶段目标"); return; } dgvRow.Cells[4].Value = "暂时不用"; if (dgvRow.Cells[4].Value == null || string.IsNullOrEmpty(dgvRow.Cells[4].Value.ToString())) { MessageBox.Show("对不起,请输入完成内容"); return; } if (dgvRow.Cells[5].Value == null || string.IsNullOrEmpty(dgvRow.Cells[5].Value.ToString())) { MessageBox.Show("对不起,请输入阶段成果、考核指标及考核方式"); return; } dgvRow.Cells[6].Value = "暂时不用"; if (dgvRow.Cells[6].Value == null || string.IsNullOrEmpty(dgvRow.Cells[6].Value.ToString())) { MessageBox.Show("对不起,请输入考核指标"); return; } if (dgvRow.Cells[7].Value == null || string.IsNullOrEmpty(dgvRow.Cells[7].Value.ToString())) { MessageBox.Show("对不起,请输入阶段经费(万)"); return; } ProjectAndStep pas = ConnectionManager.Context.table("ProjectAndStep").where ("StepID='" + step.ID + "'").select("*").getItem <ProjectAndStep>(new ProjectAndStep()); pas.StepDest = dgvRow.Cells[3].Value.ToString(); pas.StepContent = dgvRow.Cells[4].Value.ToString(); pas.StepResult = dgvRow.Cells[5].Value.ToString(); pas.StepTarget = dgvRow.Cells[6].Value.ToString(); pas.Money = decimal.Parse(dgvRow.Cells[7].Value.ToString()); pas.copyTo(ConnectionManager.Context.table("ProjectAndStep")).where ("ID='" + pas.ID + "'").update(); } } UpdateStepList(); }
private void UpdateStepList() { if (PublicReporterLib.PluginLoader.getLocalPluginRoot <PluginRoot>().projectObj != null) { KeTiList = ConnectionManager.Context.table("Project").where ("Type='" + "课题" + "' and ParentID='" + PublicReporterLib.PluginLoader.getLocalPluginRoot <PluginRoot>().projectObj.ID + "'").select("*").getList <Project>(new Project()); StepList = ConnectionManager.Context.table("Step").where ("ProjectID in (select ID from Project where Type='" + "课题" + "' and ParentID='" + PublicReporterLib.PluginLoader.getLocalPluginRoot <PluginRoot>().projectObj.ID + "')").select("*").getList <Step>(new Step()); if (StepList != null && KeTiList != null && StepList.Count >= 1 && KeTiList.Count >= 1) { //数据行列表,先生成然后等待排序 List <DataGridViewRow> rowList = new List <DataGridViewRow>(); int indexx = 0; foreach (Step step in StepList) { ProjectAndStep projectAndStep = ConnectionManager.Context.table("ProjectAndStep").where ("StepID='" + step.ID + "'").select("*").getItem <ProjectAndStep>(new ProjectAndStep()); Project ketiProject = null; foreach (Project pp in KeTiList) { if (pp.ID != null && pp.ID.Equals(step.ProjectID)) { ketiProject = pp; break; } } if (ketiProject == null || projectAndStep == null) { continue; } indexx++; List <object> cells = new List <object>(); cells.Add(indexx + ""); cells.Add(ketiProject.Name); cells.Add(step.StepIndex); cells.Add(projectAndStep.StepDest); cells.Add(projectAndStep.StepContent); cells.Add(projectAndStep.StepResult); cells.Add(projectAndStep.StepTarget); cells.Add(projectAndStep.Money); DataGridViewRow dgvRow = new DataGridViewRow(); dgvRow.CreateCells(dgvDetail, cells.ToArray()); dgvRow.Tag = step; rowList.Add(dgvRow); } foreach (DataGridViewColumn col in dgvDetail.Columns) { col.SortMode = DataGridViewColumnSortMode.NotSortable; } dgvDetail.Rows.Clear(); foreach (IGrouping <object, DataGridViewRow> group in rowList.GroupBy(x => x.Cells[1].Value)) { foreach (DataGridViewRow student in group.OrderBy(a => (int)a.Cells[2].Value))//不排序直接输出的话:Student student in group { dgvDetail.Rows.Add(student); } } } } }
public void SaveOnly() { try { foreach (DataGridViewRow dgvRow in dgvDetail.Rows) { int lastStepIndex = -1; #region 添加Step到项目 Step step = null; if (dgvRow.Tag == null) { //新行 step = new Step(); step.ProjectID = PublicReporterLib.PluginLoader.getLocalPluginRoot <ProjectReporterPlugin.PluginRoot>().projectObj.ID; } else { //已在数据 step = (Step)dgvRow.Tag; //当前的StepIndex lastStepIndex = step.StepIndex != null ? step.StepIndex.Value : -1; } if (dgvRow.Cells[1].Value == null) { dgvRow.Cells[1].Value = 0; } if (dgvRow.Cells[2].Value == null) { dgvRow.Cells[2].Value = 6; } if (dgvRow.Cells[3].Value == null) { dgvRow.Cells[3].Value = string.Empty; } dgvRow.Cells[4].Value = "暂时不用"; if (dgvRow.Cells[4].Value == null || string.IsNullOrEmpty(dgvRow.Cells[4].Value.ToString())) { MessageBox.Show("对不起,请输入完成内容"); return; } if (dgvRow.Cells[5].Value == null) { dgvRow.Cells[5].Value = string.Empty; } dgvRow.Cells[6].Value = "暂时不用"; if (dgvRow.Cells[6].Value == null || string.IsNullOrEmpty(dgvRow.Cells[6].Value.ToString())) { MessageBox.Show("对不起,请输入考核指标"); return; } if (dgvRow.Cells[7].Value == null) { dgvRow.Cells[7].Value = 0; } step.StepIndex = Int32.Parse(((DataGridViewTextBoxCell)dgvRow.Cells[1]).Value.ToString()); step.StepTime = Int32.Parse(((DataGridViewTextBoxCell)dgvRow.Cells[2]).Value.ToString()); step.StepDest = dgvRow.Cells[3].Value.ToString(); step.StepContent = dgvRow.Cells[4].Value.ToString(); step.StepResult = dgvRow.Cells[5].Value.ToString(); step.StepTarget = dgvRow.Cells[6].Value.ToString(); step.StepMoney = decimal.Parse(dgvRow.Cells[7].Value.ToString()); if (string.IsNullOrEmpty(step.ID)) { step.ID = Guid.NewGuid().ToString(); step.copyTo(ConnectionManager.Context.table("Step")).insert(); } else { step.copyTo(ConnectionManager.Context.table("Step")).where ("ID='" + step.ID + "'").update(); } #endregion #region 添加课题的Step if (KeTiList != null) { if (lastStepIndex == -1) { lastStepIndex = step.StepIndex != null ? step.StepIndex.Value : -1; } foreach (Project keti in KeTiList) { Step ketiStep = ConnectionManager.Context.table("Step").where ("ProjectID='" + keti.ID + "' and StepIndex = " + lastStepIndex).select("*").getItem <Step>(new Step()); if (ketiStep != null && !string.IsNullOrEmpty(ketiStep.ID)) { //已存在 ketiStep.StepIndex = step.StepIndex; ketiStep.StepTime = step.StepTime; ketiStep.copyTo(ConnectionManager.Context.table("Step")).where ("ID='" + ketiStep.ID + "'").update(); } else { //要添加 ketiStep = new Step(); ketiStep.ID = Guid.NewGuid().ToString(); ketiStep.ProjectID = keti.ID; ketiStep.StepIndex = step.StepIndex; ketiStep.StepTime = step.StepTime; ketiStep.copyTo(ConnectionManager.Context.table("Step")).insert(); //添加ProjectAndStep数据 ProjectAndStep projectAndStep = new ProjectAndStep(); projectAndStep.ID = Guid.NewGuid().ToString(); projectAndStep.StepID = ketiStep.ID; projectAndStep.copyTo(ConnectionManager.Context.table("ProjectAndStep")).insert(); } } } #endregion } } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); } }
public override void OnSaveEvent() { base.OnSaveEvent(); try { foreach (DataGridViewRow dgvRow in dgvDetail.Rows) { int lastStepIndex = -1; #region 添加Step到项目 Step step = null; if (dgvRow.Tag == null) { //新行 step = new Step(); step.ProjectID = MainForm.Instance.ProjectObj.ID; } else { //已在数据 step = (Step)dgvRow.Tag; //当前的StepIndex lastStepIndex = step.StepIndex != null ? step.StepIndex.Value : -1; } if (dgvRow.Cells[1].Value == null) { break; } if (dgvRow.Cells[2].Value == null) { MessageBox.Show("对不起,请输入阶段时长(月)"); break; } if (dgvRow.Cells[3].Value == null || string.IsNullOrEmpty(dgvRow.Cells[3].Value.ToString())) { MessageBox.Show("对不起,请输入完成内容及阶段目标"); return; } dgvRow.Cells[4].Value = "暂时不用"; if (dgvRow.Cells[4].Value == null || string.IsNullOrEmpty(dgvRow.Cells[4].Value.ToString())) { MessageBox.Show("对不起,请输入完成内容"); return; } if (dgvRow.Cells[5].Value == null || string.IsNullOrEmpty(dgvRow.Cells[5].Value.ToString())) { MessageBox.Show("对不起,请输入阶段成果、考核指标及考核方式"); return; } dgvRow.Cells[6].Value = "暂时不用"; if (dgvRow.Cells[6].Value == null || string.IsNullOrEmpty(dgvRow.Cells[6].Value.ToString())) { MessageBox.Show("对不起,请输入考核指标"); return; } if (dgvRow.Cells[7].Value == null || string.IsNullOrEmpty(dgvRow.Cells[7].Value.ToString())) { MessageBox.Show("对不起,请输入阶段经费(万)"); return; } step.StepIndex = Int32.Parse(((KryptonDataGridViewNumericUpDownCell)dgvRow.Cells[1]).Value.ToString()); step.StepTime = Int32.Parse(((KryptonDataGridViewNumericUpDownCell)dgvRow.Cells[2]).Value.ToString()); step.StepDest = dgvRow.Cells[3].Value.ToString(); step.StepContent = dgvRow.Cells[4].Value.ToString(); step.StepResult = dgvRow.Cells[5].Value.ToString(); step.StepTarget = dgvRow.Cells[6].Value.ToString(); step.StepMoney = decimal.Parse(dgvRow.Cells[7].Value.ToString()); if (string.IsNullOrEmpty(step.ID)) { step.ID = Guid.NewGuid().ToString(); step.copyTo(ConnectionManager.Context.table("Step")).insert(); } else { step.copyTo(ConnectionManager.Context.table("Step")).where ("ID='" + step.ID + "'").update(); } #endregion #region 添加课题的Step if (KeTiList != null) { if (lastStepIndex == -1) { lastStepIndex = step.StepIndex != null ? step.StepIndex.Value : -1; } foreach (Project keti in KeTiList) { Step ketiStep = ConnectionManager.Context.table("Step").where ("ProjectID='" + keti.ID + "' and StepIndex = " + lastStepIndex).select("*").getItem <Step>(new Step()); if (ketiStep != null && !string.IsNullOrEmpty(ketiStep.ID)) { //已存在 ketiStep.StepIndex = step.StepIndex; ketiStep.StepTime = step.StepTime; ketiStep.copyTo(ConnectionManager.Context.table("Step")).where ("ID='" + ketiStep.ID + "'").update(); } else { //要添加 ketiStep = new Step(); ketiStep.ID = Guid.NewGuid().ToString(); ketiStep.ProjectID = keti.ID; ketiStep.StepIndex = step.StepIndex; ketiStep.StepTime = step.StepTime; ketiStep.copyTo(ConnectionManager.Context.table("Step")).insert(); //添加ProjectAndStep数据 ProjectAndStep projectAndStep = new ProjectAndStep(); projectAndStep.ID = Guid.NewGuid().ToString(); projectAndStep.StepID = ketiStep.ID; projectAndStep.copyTo(ConnectionManager.Context.table("ProjectAndStep")).insert(); } } } #endregion } //刷新当前页 RefreshView(); //刷新课题阶段划分表 foreach (BaseEditor be in MainForm.Instance.EditorMaps.Values) { if (be is KeTiJieDuanHuaFenEditor) { //刷新列表 be.RefreshView(); break; } } } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); } }