private void CalcByChilds(DataRow dr, DataRow[] drsChild) { try { string[] arrMoneyField; if (dr.Table.TableName == "Html") { string[] textArray2 = CostBudgetPageRule.BuildArrayFieldByMonth(this.StartY, this.EndY, "BudgetMoney_"); arrMoneyField = ConvertRule.ArrayConcat(this.m_arrMoneyField, textArray2); textArray2 = CostBudgetPageRule.BuildArrayFieldByMonth(this.StartY, this.EndY, "ContractMoney_"); arrMoneyField = ConvertRule.ArrayConcat(arrMoneyField, textArray2); } else { arrMoneyField = this.m_arrMoneyField; } decimal[] numArray = MathRule.SumColumn(drsChild, arrMoneyField); int index = -1; foreach (string text in arrMoneyField) { index++; dr[text] = numArray[index]; } CostBudgetPageRule.CalcPercent(dr, this.m_tbGroupArea.Rows[0]); } catch (Exception exception) { throw exception; } }
private void ReCalcByRelation(string AStartYm, string AEndYm) { try { DataView view = new DataView(this.tb, "RecordType = ''", "", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { DataRow dr = view2.Row; if (ConvertRule.ToString(dr["FullCode"]) != "") { DataRow[] drs = this.tbContract.Select("FullCode like '" + ConvertRule.ToString(dr["FullCode"]) + "%'"); string[] textArray = new string[] { "ContractMoney", "ContractChangeMoney", "ContractApplyMoney", "ContractPay", "ContractPayReal" }; string[] textArray2 = CostBudgetPageRule.BuildArrayFieldByYm(AStartYm, AEndYm, "PayoutMoneyYm_"); string[] arrColumnName = ConvertRule.ArrayConcat(textArray, textArray2); decimal[] numArray = MathRule.SumColumn(drs, arrColumnName); int index = -1; foreach (string text in arrColumnName) { index++; dr[text] = numArray[index]; } CostBudgetPageRule.CostBudgetDtlCalcField(dr, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0); } } } catch (Exception exception) { throw exception; } }
private static void GetBuildingInfo(string alloType, string buildingCode, ref string buildingName, ref decimal buildingArea, EntityData PBSUnits, EntityData buildings, string AreaField) { if (alloType == "P") { buildingName = ProjectRule.GetProjectName(buildingCode); buildingArea = MathRule.SumColumn(buildings.CurrentTable, AreaField); } else { DataRow[] rowArray; if (alloType == "U") { rowArray = PBSUnits.CurrentTable.Select(string.Format("PBSUnitCode='{0}'", buildingCode)); if (rowArray.Length > 0) { buildingName = ConvertRule.ToString(rowArray[0]["PBSUnitName"]); buildingArea = ConvertRule.ToDecimal(rowArray[0]["BuildingAreaSum"]); } } else if (alloType == "B") { rowArray = buildings.CurrentTable.Select(string.Format("BuildingCode='{0}'", buildingCode)); if (rowArray.Length > 0) { buildingName = ConvertRule.ToString(rowArray[0]["BuildingName"]); buildingArea = ConvertRule.ToDecimal(rowArray[0][AreaField]); } } } }
public static DataTable CreateGroupAreaTable(string GroupCode, string ProjectCode, string CostBudgetBackupCode) { DataTable table2; try { EntityData data; string[] arrColumnName = new string[] { "BuildingArea", "HouseCount", "HouseArea" }; DataTable table = new DataTable("GroupArea"); table.Columns.Add("GroupCode"); foreach (string text in arrColumnName) { table.Columns.Add(text, typeof(decimal)); } DataRow row = table.NewRow(); row["GroupCode"] = GroupCode; table.Rows.Add(row); if (CostBudgetBackupCode != "") { data = CostBudgetDAO.GetCostBudgetBackupSetByGroupCode(CostBudgetBackupCode, GroupCode, true); } else { data = CostBudgetDAO.GetV_CostBudgetSetByGroupCode(GroupCode, ProjectCode, CostBudgetRule.m_BaseSetType); } if (data.HasRecord()) { DataRow[] drs = data.CurrentTable.Select("PBSType = 'P'"); if (drs.Length > 0) { foreach (string text in arrColumnName) { row[text] = drs[0][text]; } } else { drs = data.CurrentTable.Select("PBSType = 'B'"); if (drs.Length > 0) { decimal[] numArray = MathRule.SumColumn(drs, arrColumnName); int index = -1; foreach (string text in arrColumnName) { index++; row[text] = numArray[index]; } } } } data.Dispose(); table2 = table; } catch (Exception exception) { throw exception; } return(table2); }
public void Generate() { try { string costCode; this.tb.Rows.Clear(); this.SetPBS(); this.SetPayment(); DataView view = new DataView(CBSDAO.GetCBSByProject(this.ProjectCode).CurrentTable, "", "SortID, Deep", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { DataRow row = view2.Row; DataRow row2 = this.tb.NewRow(); costCode = row["CostCode"].ToString(); row2["DtlCode"] = row["CostCode"]; row2["RecordType"] = ""; row2["CostCode"] = row["CostCode"]; row2["CostName"] = row["CostName"]; row2["SortID"] = row["SortID"]; row2["ParentCode"] = row["ParentCode"]; row2["Deep"] = row["Deep"]; row2["FullCode"] = row["FullCode"]; row2["ChildCount"] = row["ChildCount"]; row2["IsLeafCBS"] = ConvertRule.ToInt(row2["ChildCount"]) <= 0; this.tb.Rows.Add(row2); } foreach (DataRow row3 in this.tb.Rows) { costCode = ConvertRule.ToString(row3["CostCode"]); string text2 = ConvertRule.ToString(row3["FullCode"]); decimal num = 0M; string text3 = ""; foreach (DataRow row4 in this.tbPBS.Rows) { string text4 = ConvertRule.ToString(row4["PBSType"]); string text5 = ConvertRule.ToString(row4["PBSCode"]); decimal money = 0M; if (text2 != "") { string filterExpression = string.Format("FullCode like '{0}%' and isnull(PBSType, '') = '{1}' and isnull(PBSCode, '') = '{2}'", text2, text4, text5); money = MathRule.SumColumn(this.tbPayment.Select(filterExpression), "PaymentMoney"); } num += money; text3 = text3 + string.Format("<td align=right nowrap title='{1}'>{0}</td>", CostBudgetPageRule.GetContractPayHref(CostBudgetPageRule.GetMoneyShowString(money, CostBudgetPageRule.m_MoneyUnit.yuan), costCode, "", "", text4, text5), CostBudgetPageRule.GetWanDecimalShowHint(money)); } row3["Money"] = num; row3["MoneyHtml"] = text3; } this.ResetTitleHtml(); } catch (Exception exception) { throw exception; } }
public static decimal GetBuildingAreaByPBSUnit(string PBSUnitCode) { decimal num2; try { decimal num = 0M; EntityData buildingByPBSUnitCode = ProductDAO.GetBuildingByPBSUnitCode(PBSUnitCode); num = MathRule.SumColumn(buildingByPBSUnitCode.CurrentTable, "HouseArea"); buildingByPBSUnitCode.Dispose(); num2 = num; } catch (Exception exception) { throw exception; } return(num2); }
private void ReCalcByRelation() { try { DataView view = new DataView(this.tb, "", "", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { DataRow row = view2.Row; if (ConvertRule.ToString(row["FullCode"]) != "") { DataRow[] drs = this.tbPayout.Select("FullCode like '" + ConvertRule.ToString(row["FullCode"]) + "%'"); string[] arrColumnName = new string[] { "PayoutMoney" }; decimal[] numArray = MathRule.SumColumn(drs, arrColumnName); int index = -1; foreach (string text in arrColumnName) { index++; row[text] = numArray[index]; } if ((this.StartYm != "") && (this.EndYm != "")) { int monthsBetween = StringRule.GetMonthsBetween(this.StartYm, this.EndYm); for (int i = 0; i < monthsBetween; i++) { string text2 = StringRule.YmAddMonths(this.StartYm, i); decimal num4 = MathRule.SumColumn(this.tbPayoutYm.Select("FullCode like '" + ConvertRule.ToString(row["FullCode"]) + "%' and PayoutYm = '" + text2 + "'"), "PayoutMoney"); row["PayoutMoneyYm_" + text2] = num4; } } } } } catch (Exception exception) { throw exception; } }
private static decimal GetPBSUnitArea(string PBSUnitCode, EntityData PBSUnits) { return(MathRule.SumColumn(PBSUnits.CurrentTable, "BuildingAreaSum", string.Format("PBSUnitCode='{0}'", PBSUnitCode))); }
public DataTable GenerateCurrent() { DataTable table2; try { if (this.entityTargetHis != null) { this.entityTargetHis.Dispose(); } if (this.IsShowTargetMoneyHis) { this.entityTargetHis = CostBudgetRule.GetRelationCostBudget(this.ProjectCode, this.FirstCostBudgetCode, "1,2", this.CostBudgetCode); } DataTable table = CostBudgetPageRule.GenerateEmptyCostTargetDtl(this.StartY, this.EndY, this.entityTargetHis); EntityData allCBSBySet = CostBudgetRule.GetAllCBSBySet(this.ProjectCode, this.CostBudgetSetCode); if (allCBSBySet == null) { return(table); } if (this.ShowCostCode != "") { string cBSFullCode = CBSRule.GetCBSFullCode(this.ShowCostCode); DataRow[] rowArray = allCBSBySet.CurrentTable.Select(string.Format("FullCode not like '{0}%'", cBSFullCode)); foreach (DataRow row in rowArray) { allCBSBySet.CurrentTable.Rows.Remove(row); } CostBudgetRule.ResetCBSDeep(allCBSBySet.CurrentTable); } DataRow row2 = null; if (this.ShowCostCode == "") { row2 = table.NewRow(); row2["CostBudgetDtlCode"] = "R_0"; row2["CostCode"] = row2["CostBudgetDtlCode"]; row2["CostName"] = "合计"; row2["Deep"] = 1; row2["ParentCode"] = ""; row2["ChildCount"] = 1; row2["IsExpand"] = 1; table.Rows.Add(row2); } int num = 0; foreach (DataRow row3 in allCBSBySet.CurrentTable.Rows) { num--; DataRow drDtl = table.NewRow(); drDtl["CostBudgetDtlCode"] = num; CostBudgetPageRule.FillCostBudgetDtlCBSData(drDtl, row3); if (row2 != null) { if (ConvertRule.ToInt(drDtl["Deep"]) == 1) { drDtl["ParentCode"] = row2["CostBudgetDtlCode"]; } drDtl["Deep"] = ConvertRule.ToInt(drDtl["Deep"]) + 1; } else if (ConvertRule.ToInt(drDtl["Deep"]) == 1) { drDtl["ParentCode"] = ""; } table.Rows.Add(drDtl); } EntityData validCostBudget = CostBudgetRule.GetValidCostBudget(this.CostBudgetSetCode, 1); EntityData costBudgetDtlByCostBudgetCode = null; if (validCostBudget.HasRecord()) { costBudgetDtlByCostBudgetCode = CostBudgetDAO.GetCostBudgetDtlByCostBudgetCode(validCostBudget.GetString("CostBudgetCode")); } EntityData data4 = CostBudgetDAO.GetCostBudgetDtlByCostBudgetCode(this.CostBudgetCode); EntityData costBudgetMonthByCostBudgetCode = CostBudgetDAO.GetCostBudgetMonthByCostBudgetCode(this.CostBudgetCode); foreach (DataRow row5 in table.Rows) { DataRow[] rowArray2 = data4.CurrentTable.Select("CostCode='" + ConvertRule.ToString(row5["CostCode"]) + "'"); if (rowArray2.Length > 0) { row5["CostBudgetDtlCode"] = rowArray2[0]["CostBudgetDtlCode"]; row5["Price"] = rowArray2[0]["Price"]; row5["Qty"] = rowArray2[0]["Qty"]; row5["BudgetMoney"] = rowArray2[0]["BudgetMoney"]; row5["IsExpand"] = rowArray2[0]["IsExpand"]; row5["Description"] = rowArray2[0]["Description"]; row5["DescriptionHtml"] = rowArray2[0]["Description"]; } if (costBudgetDtlByCostBudgetCode != null) { DataRow[] rowArray3 = costBudgetDtlByCostBudgetCode.CurrentTable.Select("CostCode='" + ConvertRule.ToString(row5["CostCode"]) + "'"); if (rowArray3.Length > 0) { row5["BudgetValidMoney"] = rowArray3[0]["BudgetMoney"]; } } foreach (DataColumn column in table.Columns) { if (column.ColumnName.StartsWith("BudgetMoney_")) { string text2 = column.ColumnName.Replace("BudgetMoney_", ""); string val = text2.Substring(0, 4); string text4 = text2.Substring(4, 2); int num2 = ConvertRule.ToInt(val); int num3 = ConvertRule.ToInt(text4); DataRow[] rowArray4 = costBudgetMonthByCostBudgetCode.CurrentTable.Select("CostBudgetDtlCode = '" + ConvertRule.ToString(row5["CostBudgetDtlCode"]) + "' and IYear = " + num2.ToString() + " and IMonth = " + num3.ToString()); if (rowArray4.Length > 0) { row5[column.ColumnName] = rowArray4[0]["BudgetMoney"]; } } } if (!this.IsModify) { row5["PlanDataHtml"] = CostBudgetPageRule.GenerateCostBudgetPlanDataHtml(row5, this.iStartY, this.iEndY, "BudgetMoney_"); } } allCBSBySet.Dispose(); data4.Dispose(); costBudgetMonthByCostBudgetCode.Dispose(); validCostBudget.Dispose(); if (costBudgetDtlByCostBudgetCode != null) { costBudgetDtlByCostBudgetCode.Dispose(); } if (row2 != null) { DataRow[] drs = table.Select("ParentCode = '" + row2["CostBudgetDtlCode"].ToString() + "'"); string[] textArray = new string[] { "BudgetMoney", "BudgetValidMoney" }; string[] textArray2 = CostBudgetPageRule.BuildArrayFieldByMonth(this.StartY, this.EndY, "BudgetMoney_"); string[] arrColumnName = ConvertRule.ArrayConcat(textArray, textArray2); decimal[] numArray = MathRule.SumColumn(drs, arrColumnName); int index = -1; foreach (string text5 in arrColumnName) { index++; row2[text5] = numArray[index]; } if (!this.IsModify) { row2["PlanDataHtml"] = CostBudgetPageRule.GenerateCostBudgetPlanDataHtml(row2, this.iStartY, this.iEndY, "BudgetMoney_"); } } table2 = table; } catch (Exception exception) { throw exception; } return(table2); }
private void FillCostTargetHisHtml() { try { if (this.entityTargetHis != null) { string text2; ArrayList list = new ArrayList(); foreach (DataRowView view in this.dvTargetHis) { DataRow row = view.Row; string text = ConvertRule.ToString(row["VerID"]); if (text != "") { list.Add(text); text2 = "BudgetMoneyHis_" + text; EntityData costBudgetDtlByCostBudgetCode = CostBudgetDAO.GetCostBudgetDtlByCostBudgetCode(row["CostBudgetCode"].ToString()); if (costBudgetDtlByCostBudgetCode.HasRecord()) { foreach (DataRow row2 in this.tb.Rows) { DataRow[] rowArray = costBudgetDtlByCostBudgetCode.CurrentTable.Select("CostCode='" + ConvertRule.ToString(row2["CostCode"]) + "'"); if (rowArray.Length > 0) { row2[text2] = rowArray[0]["BudgetMoney"]; } } } costBudgetDtlByCostBudgetCode.Dispose(); } } if (this.tb.Rows.Count > 0) { DataRow row3 = this.tb.Rows[0]; DataRow[] drs = this.tb.Select("ParentCode = '" + row3["CostBudgetDtlCode"].ToString() + "'"); string[] arrColumnName = new string[list.Count]; int index = -1; foreach (string text in list) { index++; arrColumnName[index] = "BudgetMoneyHis_" + text; } decimal[] numArray = MathRule.SumColumn(drs, arrColumnName); int num2 = -1; foreach (string text3 in arrColumnName) { num2++; row3[text3] = numArray[num2]; } } foreach (DataRow row2 in this.tb.Rows) { string text4 = ""; foreach (string text in list) { text2 = "BudgetMoneyHis_" + text; text4 = text4 + string.Format("<td align=right nowrap title='{1}'>{0}</td>", CostBudgetPageRule.GetMoneyShowString(row2[text2], this.m_MoneyUnit), CostBudgetPageRule.GetWanDecimalShowHint(row2[text2])); } row2["BudgetMoneyHisHtml"] = text4; } } else { foreach (DataRow row2 in this.tb.Rows) { row2["BudgetMoneyHisHtml"] = ""; } } } catch (Exception exception) { throw exception; } }
public DataTable Generate() { DataTable tb; try { if (this.ShowTargetHis) { this.LoadTargetHis(); } this.tb = CostBudgetPageRule.GenerateEmptyCostTargetDtl(this.StartY, this.EndY, this.entityTargetHis); EntityData costBudgetDtlByCostBudgetCode = CostBudgetDAO.GetCostBudgetDtlByCostBudgetCode(this.CostBudgetCode); EntityData costBudgetMonthByCostBudgetCode = CostBudgetDAO.GetCostBudgetMonthByCostBudgetCode(this.CostBudgetCode); EntityData allCBSBySet = CostBudgetRule.GetAllCBSBySet(this.ProjectCode, this.CostBudgetSetCode); DataRow row = this.tb.NewRow(); row["CostBudgetDtlCode"] = "R_0"; row["CostCode"] = row["CostBudgetDtlCode"]; row["CostName"] = "合计"; row["Deep"] = 1; row["ParentCode"] = ""; row["ChildCount"] = 1; row["IsExpand"] = 1; this.tb.Rows.Add(row); foreach (DataRow row2 in costBudgetDtlByCostBudgetCode.CurrentTable.Rows) { string text = ConvertRule.ToString(row2["CostBudgetDtlCode"]); DataRow drDst = this.tb.NewRow(); ConvertRule.DataRowCopy(row2, drDst, costBudgetDtlByCostBudgetCode.CurrentTable, this.tb); DataRow[] rowArray = allCBSBySet.CurrentTable.Select("CostCode='" + ConvertRule.ToString(drDst["CostCode"]) + "'"); if (rowArray.Length > 0) { CostBudgetPageRule.FillCostBudgetDtlCBSData(drDst, rowArray[0]); } drDst["Deep"] = ConvertRule.ToInt(drDst["Deep"]) + 1; if (ConvertRule.ToInt(drDst["Deep"]) == (ConvertRule.ToInt(row["Deep"]) + 1)) { drDst["ParentCode"] = row["CostBudgetDtlCode"]; } foreach (DataColumn column in this.tb.Columns) { if (column.ColumnName.StartsWith("BudgetMoney_")) { string text2 = column.ColumnName.Replace("BudgetMoney_", ""); string val = text2.Substring(0, 4); string text4 = text2.Substring(4, 2); int num = ConvertRule.ToInt(val); int num2 = ConvertRule.ToInt(text4); DataRow[] rowArray2 = costBudgetMonthByCostBudgetCode.CurrentTable.Select("CostBudgetDtlCode = '" + text + "' and IYear = " + num.ToString() + " and IMonth = " + num2.ToString()); if (rowArray2.Length > 0) { drDst[column.ColumnName] = rowArray2[0]["BudgetMoney"]; } } } drDst["PlanDataHtml"] = CostBudgetPageRule.GenerateCostBudgetPlanDataHtml(drDst, this.iStartY, this.iEndY, "BudgetMoney_"); this.tb.Rows.Add(drDst); } costBudgetDtlByCostBudgetCode.Dispose(); costBudgetMonthByCostBudgetCode.Dispose(); allCBSBySet.Dispose(); DataRow[] drs = this.tb.Select("ParentCode = '" + row["CostBudgetDtlCode"].ToString() + "'"); string[] textArray = new string[] { "BudgetMoney" }; string[] textArray2 = CostBudgetPageRule.BuildArrayFieldByMonth(this.StartY, this.EndY, "BudgetMoney_"); string[] arrColumnName = ConvertRule.ArrayConcat(textArray, textArray2); decimal[] numArray = MathRule.SumColumn(drs, arrColumnName); int index = -1; foreach (string text5 in arrColumnName) { index++; row[text5] = numArray[index]; } row["PlanDataHtml"] = CostBudgetPageRule.GenerateCostBudgetPlanDataHtml(row, this.iStartY, this.iEndY, "BudgetMoney_"); CostBudgetPageRule.SetColumnTargetHis(this.tb, this.entityTargetHis); this.FillCostTargetHisHtml(); this.GenerateTargetHisHead(); tb = this.tb; } catch (Exception exception) { throw exception; } return(tb); }
private void SetRelationContract() { try { int index; DataRow[] rowArray = this.tbContract.Select("RecordType = 'Contract'"); int length = rowArray.Length; for (index = length - 1; index >= 0; index--) { this.tbContract.Rows.Remove(rowArray[index]); } rowArray = this.tbPlan.Select("RecordType = 'Contract'"); length = rowArray.Length; for (index = length - 1; index >= 0; index--) { this.tbPlan.Rows.Remove(rowArray[index]); } QueryAgent agent = new QueryAgent(); try { string queryString = "select c.FullCode, s.SupplierName, a.*, b.* from ContractCost a left join CBS c on c.CostCode = a.CostCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode where a.ContractCode = b.ContractCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status in (0, 2) and not exists (select * from ContractChange g where g.ContractCode = b.ContractCode)"; DataTable tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0]; this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractMoney"); queryString = "select c.FullCode, a.Money as Money, s.SupplierName, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode where a.ContractCode = b.ContractCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status in (0, 2, 4) and a.ContractChangeCode = (select min(ContractChangeCode) from ContractChange g where g.ContractCode = b.ContractCode) and exists (select * from ContractChange g where g.ContractCode = b.ContractCode)"; tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0]; this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractMoney"); queryString = "select c.FullCode, a.ChangeMoney as Money, s.SupplierName, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode, ContractChange g where a.ContractCode = b.ContractCode and b.ContractCode = g.ContractCode and a.ContractChangeCode = g.ContractChangeCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status not in (3) and g.Status in (0) and a.ChangeMoney <> 0"; tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0]; this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractChangeMoney"); queryString = "select c.FullCode, s.SupplierName, a.*, b.* from ContractCost a left join CBS c on c.CostCode = a.CostCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode where a.ContractCode = b.ContractCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status in (1, 7)"; tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0]; this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractApplyMoney"); queryString = "select c.FullCode, s.SupplierName, a.ChangeMoney as Money, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode, ContractChange g where a.ContractCode = b.ContractCode and b.ContractCode = g.ContractCode and a.ContractChangeCode = g.ContractChangeCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status not in (3) and g.Status in (1, 2) and a.ChangeMoney <> 0"; tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0]; this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractApplyMoney"); queryString = "select c.FullCode, 'Contract' as RecordType, a.CostCode, a.ContractCode, convert(varchar(6), p.PlanningPayDate, 112) as PlanYm, sum(isnull(p.Money, 0)) as PlanMoney from ContractCost a left join CBS c on c.CostCode = a.CostCode, Contract b, ContractCostPlan p where a.ContractCode = b.ContractCode and a.ContractCostCode = p.ContractCostCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and convert(varchar(6), p.PlanningPayDate, 112) between '" + this.StartYm + "' and '" + this.EndYm + "' group by c.FullCode, a.CostCode, a.ContractCode, convert(varchar(6), p.PlanningPayDate, 112)"; tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0]; this.AddPlan(tbSrc, ""); foreach (DataRow row in this.tbContract.Rows) { string text2 = ConvertRule.ToString(row["ContractCode"]); if (ConvertRule.ToString(row["AllContractCode"]) != "") { queryString = "select sum(isnull(a.ItemMoney, 0)) from PaymentItem a, Payment b where a.PaymentCode = b.PaymentCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status in (1, 2) and b.ContractCode in (" + ConvertRule.ToString(row["AllContractCode"]) + ") and a.CostCode = '" + ConvertRule.ToString(row["CostCode"]) + "'"; row["ContractPay"] = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString)); queryString = "select a.PayoutCode, b.PayoutDate, a.PayoutMoney as Money, '" + text2 + "' as ContractCode, mi.CostCode, c.FullCode from PayoutItem a inner join Payout b on b.PayoutCode = a.PayoutCode, PaymentItem mi left join CBS c on c.CostCode = mi.CostCode, Payment m where a.PaymentItemCode = mi.PaymentItemCode and mi.PaymentCode = m.PaymentCode and m.ProjectCode = '" + this.ProjectCode + "' and mi.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and m.ContractCode in (" + ConvertRule.ToString(row["AllContractCode"]) + ") and mi.CostCode = '" + ConvertRule.ToString(row["CostCode"]) + "'"; tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0]; row["ContractPayReal"] = MathRule.SumColumn(tbSrc, "Money"); } } CostBudgetPageRule.CostBudgetDtlCalcAllRow(this.tbContract, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0); } finally { agent.Dispose(); } } catch (Exception exception) { throw exception; } }