/// <summary> /// 检查时间与金额一致性 /// </summary> /// <returns></returns> private bool IsRightMoneyOrTime() { //项目总时间 int totalTime = ConnectionManager.Context.table("Project").where ("Type = '项目'").select("TotalTime").getValue <int>(0); //项目总金额 decimal totalMoney = ConnectionManager.Context.table("Project").where ("Type = '项目'").select("TotalMoney").getValue <decimal>(0); //经费表总额 string projectMoneyStr = ConnectionManager.Context.table("MoneyAndYear").where ("Name = 'ProjectRFA'").select("Value").getValue <string>("0"); decimal projectMoney = 0; try { projectMoney = decimal.Parse(projectMoneyStr); } catch (Exception ex) { } //阶段总额 long totalStepMoney = ConnectionManager.Context.table("Step").where ("ProjectID = '" + MainForm.Instance.ProjectObj.ID + "'").select("sum(StepMoney)").getValue <long>(0); //阶段总时间 long totalStepTime = (long)Math.Round(ConnectionManager.Context.table("Step").where ("ProjectID = '" + MainForm.Instance.ProjectObj.ID + "'").select("sum(StepTime)").getValue <long>(0) / 12d); //课题阶段经费总额 long totalKetiStepMoney = ConnectionManager.Context.table("ProjectAndStep").where ("StepID in (select ID from Step where ProjectID in (select ID from Project where Type = '课题'))").select("sum(Money)").getValue <long>(0); //阶段经费表 Noear.Weed.DataList dlStepList = ConnectionManager.Context.table("Step").where ("ProjectID = '" + MainForm.Instance.ProjectObj.ID + "'").select("StepIndex,StepMoney").getDataList(); //课题阶段经费表 int totalRightStepCount = 0; int totalStepCount = 0; if (dlStepList != null && dlStepList.getRowCount() >= 1) { //阶段数量 totalStepCount = dlStepList.getRowCount(); //检查课题阶段金额 foreach (Noear.Weed.DataItem di in dlStepList.getRows()) { try { int stepIndex = di.getInt("StepIndex"); long stepMoney = long.Parse(di.get("StepMoney").ToString()); long subjectStepMoney = ConnectionManager.Context.table("ProjectAndStep").where ("StepID in (select ID from Step where ProjectID in (select ID from Project where Type = '课题') and StepIndex = " + stepIndex + ")").select("sum(Money)").getValue <long>(0); //判断阶段经费是不是相等 if (stepMoney == subjectStepMoney) { totalRightStepCount++; } } catch (Exception ex) { } } } if (totalMoney != projectMoney) { MessageBox.Show("对不起,项目总金额与经费表总金额不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (totalMoney != totalStepMoney) { MessageBox.Show("对不起,项目总金额与阶段总金额不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (totalMoney != totalKetiStepMoney) { MessageBox.Show("对不起,项目总金额与课题阶段总金额不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (totalTime != totalStepTime) { MessageBox.Show("对不起,项目总时间与阶段总时间不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (totalRightStepCount != totalStepCount) { MessageBox.Show("对不起,阶段金额与课题阶段金额不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //判断条件是否符合 return(totalMoney == projectMoney && totalMoney == totalStepMoney && totalMoney == totalKetiStepMoney && totalTime == totalStepTime && totalRightStepCount == totalStepCount); }
/// <summary> /// 检查时间与金额一致性 /// </summary> /// <returns></returns> private bool isRightMoneyOrTime() { //项目总时间 decimal totalTime = convertToDecimal(ConnectionManager.Context.table("Project").where ("Type = '项目'").select("TotalTime").getValue()); //项目总金额 decimal totalMoney = convertToDecimal(ConnectionManager.Context.table("Project").where ("Type = '项目'").select("TotalMoney").getValue()); //经费表总额 decimal projectMoney = convertToDecimal(ConnectionManager.Context.table("MoneyAndYear").where ("Name = 'ProjectRFA'").select("Value").getValue()); //阶段总额 decimal totalStepMoney = convertToDecimal(ConnectionManager.Context.table("Step").where ("ProjectID = '" + projectObj.ID + "'").select("sum(StepMoney)").getValue()); //阶段总时间 decimal totalStepTime = Math.Round(convertToDecimal(ConnectionManager.Context.table("Step").where ("ProjectID = '" + projectObj.ID + "'").select("sum(StepTime)").getValue()) / (decimal)12); //课题阶段经费总额 decimal totalKetiStepMoney = convertToDecimal(ConnectionManager.Context.table("ProjectAndStep").where ("StepID in (select ID from Step where ProjectID in (select ID from Project where Type = '课题'))").select("sum(Money)").getValue()); //阶段经费表 Noear.Weed.DataList dlStepList = ConnectionManager.Context.table("Step").where ("ProjectID = '" + projectObj.ID + "'").select("StepIndex,StepMoney").getDataList(); //课题阶段经费表 int totalRightStepCount = 0; int totalStepCount = 0; if (dlStepList != null && dlStepList.getRowCount() >= 1) { //阶段数量 totalStepCount = dlStepList.getRowCount(); //检查课题阶段金额 foreach (Noear.Weed.DataItem di in dlStepList.getRows()) { try { int stepIndex = di.getInt("StepIndex"); decimal stepMoney = convertToDecimal(di.get("StepMoney")); decimal subjectStepMoney = convertToDecimal(ConnectionManager.Context.table("ProjectAndStep").where ("StepID in (select ID from Step where ProjectID in (select ID from Project where Type = '课题') and StepIndex = " + stepIndex + ")").select("sum(Money)").getValue()); //判断阶段经费是不是相等 if (stepMoney == subjectStepMoney) { totalRightStepCount++; } } catch (Exception ex) { } } } if (totalMoney != projectMoney) { MessageBox.Show("对不起,项目总金额与经费表总金额不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (totalMoney != totalStepMoney) { MessageBox.Show("对不起,项目总金额与阶段总金额不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (totalMoney != totalKetiStepMoney) { MessageBox.Show("对不起,项目总金额与课题阶段总金额不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (totalTime != totalStepTime) { MessageBox.Show("对不起,项目总时间与阶段总时间不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (totalRightStepCount != totalStepCount) { MessageBox.Show("对不起,阶段金额与课题阶段金额不同,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //判断条件是否符合 return(totalMoney == projectMoney && totalMoney == totalStepMoney && totalMoney == totalKetiStepMoney && totalTime == totalStepTime && totalRightStepCount == totalStepCount); }