public static DataTable UnionHouse(DataTable tb) { DataTable table2; try { DataTable tbDst = tb.Clone(); DataRow[] rowArray = tb.Select("PBSTypeFullName like '住宅%'", "BuildingName"); string[] columnNames = new string[] { "TotalInvest", "TotalCompleteInvest", "PCurrentYearInvest", "BeforInvestAccout", "PTotalConstructSize", "PHouseConstructSize", "PToBuildConstructSize", "POtherConstructSize", "PTotalCompleteSize", "PHouseCompleteSize", "PToBuildCompleteSize", "POtherCompleteSize", "HouseArea", "HouseSize", "ToBuildSize", "OtherSize", "RoomArea", "HouseRoomSize", "ToBuildRoomSize", "OtherRoomSize" }; foreach (DataRow row in rowArray) { DataRow drDst = tbDst.NewRow(); ConvertRule.DataRowCopy(row, drDst, tb, tbDst); string text = ConvertRule.ToString(drDst["BuildingName"]); DataRow[] rowArray2 = tb.Select(string.Format("BuildingName like '{0}%' and PBSTypeFullName not like '住宅%'", text)); foreach (DataRow row3 in rowArray2) { ConvertRule.DataRowAddDecimal(drDst, row3, columnNames); } tbDst.Rows.Add(drDst); } table2 = tbDst; } catch (Exception exception) { throw exception; } return(table2); }
private static void SaveTempToFormalByCost(DataTable dtTemp, DataTable dt) { try { foreach (DataRow row in dtTemp.Rows) { string text = ConvertRule.ToString(row["AlloType"]); string text2 = ConvertRule.ToString(row["buildingCode"]); string text3 = ConvertRule.ToString(row["costCode"]); DataRow[] rowArray = dt.Select(string.Format(" AlloType='{0}' and BuildingCode='{1}' and CostCode='{2}' ", text, text2, text3)); DataRow drDst = null; if (rowArray.Length > 0) { drDst = rowArray[0]; drDst["ApportionMoney"] = ConvertRule.ToDecimal(drDst["ApportionMoney"]) + ConvertRule.ToDecimal(row["ApportionMoney"]); } else { drDst = dt.NewRow(); ConvertRule.DataRowCopy(row, drDst, dtTemp, dt); dt.Rows.Add(drDst); } } } catch (Exception exception) { throw exception; } }
public static void NewYearConstructAnnualPlan(string ProjectCode, int IYear, string UserCode) { try { if ((ProjectCode != "") && (IYear > 0)) { DataRow drDst; int num = IYear + 1; EntityData constructPlanStepByProjectYear = ConstructDAO.GetConstructPlanStepByProjectYear(ProjectCode, IYear); EntityData entity = new EntityData("ConstructPlanStep"); foreach (DataRow row in constructPlanStepByProjectYear.CurrentTable.Rows) { drDst = entity.CurrentTable.NewRow(); ConvertRule.DataRowCopy(row, drDst, constructPlanStepByProjectYear.CurrentTable, entity.CurrentTable); drDst["ConstructPlanStepCode"] = SystemManageDAO.GetNewSysCode("ConstructPlanStepCode"); drDst["IYear"] = num; entity.CurrentTable.Rows.Add(drDst); } ConstructDAO.InsertConstructPlanStep(entity); entity.Dispose(); constructPlanStepByProjectYear.Dispose(); EntityData data3 = PBSDAO.GetV_PBSUnitByProject(ProjectCode); EntityData constructAnnualPlanByProjectYear = ConstructDAO.GetConstructAnnualPlanByProjectYear(ProjectCode, IYear); entity = new EntityData("ConstructAnnualPlan"); foreach (DataRow row3 in data3.CurrentTable.Rows) { string pBSUnitCode = ConvertRule.ToString(row3["PBSUnitCode"]); string code = ConvertRule.ToString(row3["VisualProgress"]); decimal num2 = ConvertRule.ToDecimal(row3["TotalBuildArea"]); drDst = entity.CurrentTable.NewRow(); drDst["AnnualPlanCode"] = SystemManageDAO.GetNewSysCode("AnnualPlanCode"); entity.CurrentTable.Rows.Add(drDst); drDst["IYear"] = num; drDst["PBSUnitCode"] = pBSUnitCode; drDst["ProjectCode"] = ProjectCode; drDst["PlanDate"] = DateTime.Now; drDst["PlanPerson"] = UserCode; decimal num3 = CalcPBSUnitCompleteInvest(pBSUnitCode); drDst["InvestBefore"] = num3; EntityData visualProgressByCode = ConstructDAO.GetVisualProgressByCode(code); if (visualProgressByCode.HasRecord() && (visualProgressByCode.GetInt("ProgressType") >= 0)) { drDst["LCFArea"] = num2; } visualProgressByCode.Dispose(); ConstructDAO.InsertConstructAnnualPlan(entity); } entity.Dispose(); constructAnnualPlanByProjectYear.Dispose(); data3.Dispose(); } } catch (Exception exception) { throw exception; } }
public static DataTable GenerateConstructPlanTable(string ProjectCode, int IYear) { DataTable table3; try { DataTable tbDst = CreateConstructPlanTable(); EntityData data = PBSDAO.GetV_PBSUnitByProject(ProjectCode); EntityData constructAnnualPlanByProjectYear = ConstructDAO.GetConstructAnnualPlanByProjectYear(ProjectCode, IYear); DataTable tbSrc = constructAnnualPlanByProjectYear.CurrentTable; int num = 0; int count = data.CurrentTable.Rows.Count; for (int i = 0; i < count; i++) { data.SetCurrentRow(i); string text = data.GetString("PBSUnitCode"); DataRow drDst = tbDst.NewRow(); drDst["PBSUnitCode"] = text; DataRow[] rowArray = tbSrc.Select("PBSUnitCode='" + text + "'"); if (rowArray.Length > 0) { ConvertRule.DataRowCopy(rowArray[0], drDst, tbSrc, tbDst); } else { num++; drDst["AnnualPlanCode"] = -num; } drDst["PBSUnitName"] = data.GetString("PBSUnitName"); drDst["TotalBuildArea"] = data.GetDecimal("TotalBuildArea"); drDst["PTotalInvest"] = data.GetDecimal("PInvest"); tbDst.Rows.Add(drDst); } constructAnnualPlanByProjectYear.Dispose(); data.Dispose(); table3 = tbDst; } catch (Exception exception) { throw exception; } return(table3); }
public bool CopyAttachment(string oldMastCode, string newMasterCode, string AttachmentType) { EntityData entity = DAOFactory.GetAttachmentDAO().GetAttachMentByMasterCode(AttachmentType, oldMastCode); if (!entity.HasRecord()) { return(false); } DataRow drSrc = entity.CurrentRow; DataRow row = entity.GetNewRecord(); entity.CurrentTable.Rows.Add(row); ConvertRule.DataRowCopy(drSrc, row, entity.CurrentTable, entity.CurrentTable); row["AttachmentCode"] = SystemManageDAO.GetNewSysCode("AttachMentCode"); row["MasterCode"] = newMasterCode; DAOFactory.GetAttachmentDAO().SubmitAllAttachMent(entity); entity.Dispose(); return(true); }
public static DataTable FilterPubBuild(DataTable tb) { DataTable table2; try { DataTable tbDst = tb.Clone(); DataRow[] rowArray = tb.Select("PBSTypeFullName like '公建%'", "BuildingName"); foreach (DataRow row in rowArray) { DataRow drDst = tbDst.NewRow(); ConvertRule.DataRowCopy(row, drDst, tb, tbDst); tbDst.Rows.Add(drDst); } table2 = tbDst; } catch (Exception exception) { throw exception; } return(table2); }
private void SetPayment() { try { this.tbPayment.Clear(); QueryAgent agent = new QueryAgent(); try { string queryString = "select a.CostCode, c.FullCode, isnull(a.PBSType, '') as PBSType, isnull(a.PBSCode, '') as PBSCode, sum(isnull(a.ItemMoney, 0)) as PaymentMoney from PaymentItem a left join CBS c on c.CostCode = a.CostCode, Payment b where a.PaymentCode = b.PaymentCode and b.ProjectCode = '{0}' and b.Status in (1, 2)"; if (this.StartDate != "") { queryString = queryString + string.Format(" and CheckDate >= convert(DateTime, '{0}', 121)", this.StartDate); } if (this.EndDate != "") { queryString = queryString + string.Format(" and CheckDate < convert(DateTime, '{0}', 121) + 1", this.EndDate); } queryString = string.Format(queryString + " group by a.CostCode, c.FullCode, isnull(a.PBSType, ''), isnull(a.PBSCode, '')", this.ProjectCode); DataTable tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0]; foreach (DataRow row in tbSrc.Rows) { DataRow drDst = this.tbPayment.NewRow(); ConvertRule.DataRowCopy(row, drDst, tbSrc, this.tbPayment); this.tbPayment.Rows.Add(drDst); } } finally { agent.Dispose(); } } catch (Exception exception) { throw exception; } }
public void Generate() { try { this.InitCostBudgetSet(); this.SetRelationContract(); this.SetRelationNoContract(); 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(); string text = 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); DataRow[] rowArray = this.tbContract.Select("CostCode = '" + text + "'"); foreach (DataRow row3 in rowArray) { string text2 = row3["ContractCode"].ToString(); DataRow drDst = this.tb.NewRow(); ConvertRule.DataRowCopy(row3, drDst, this.tbContract, this.tb); drDst["DtlCode"] = "C_" + text + ":" + text2; drDst["RecordType"] = row3["RecordType"]; drDst["Deep"] = row2["Deep"]; drDst["ParentCode"] = row2["ParentCode"]; drDst["ChildCount"] = 0; drDst["ClassTd"] = CostBudgetPageRule.m_ClassTdContract; this.tb.Rows.Add(drDst); DataRow[] rowArray2 = this.tbApportion.Select("ContractCode = '" + text2 + "' and CostCode = '" + text + "'"); foreach (DataRow row5 in rowArray2) { string costBudgetSetCode = ConvertRule.ToString(row5["PBSCode"]); drDst = this.tb.NewRow(); ConvertRule.DataRowCopy(row5, drDst, this.tbApportion, this.tb); drDst["DtlCode"] = "A_" + text + ":" + text2 + "@" + costBudgetSetCode; drDst["RecordType"] = "Apportion"; drDst["PBSCode"] = costBudgetSetCode; drDst["Deep"] = row2["Deep"]; drDst["ParentCode"] = row2["ParentCode"]; drDst["ChildCount"] = 0; drDst["ClassTd"] = CostBudgetPageRule.m_ClassTdApportion; drDst["ContractName"] = " " + this.GetCostBudgetSetName(costBudgetSetCode); this.tb.Rows.Add(drDst); } } } this.ReCalcByRelation("", ""); this.RefreshDateRange(); } catch (Exception exception) { throw exception; } }
private void SumDs() { try { DataRow[] drsChild; DataRow drDtl; this.tb.Rows.Clear(); this.tbMonth.Rows.Clear(); this.tbContractMonth.Rows.Clear(); DataRow row = this.tb.NewRow(); row["CostBudgetDtlCode"] = "R_0"; row["CostName"] = this.m_entityGroup.GetString("GroupName") + "合计"; row["Deep"] = 1; row["ParentCode"] = ""; row["ChildCount"] = 1; row["IsExpand"] = 1; this.tb.Rows.Add(row); EntityData rootCBSByGroup = CostBudgetRule.GetRootCBSByGroup(this.ProjectCode, this.GroupCode); foreach (DataRow row2 in rootCBSByGroup.CurrentTable.Rows) { string text = ConvertRule.ToString(row2["CostCode"]); drDtl = this.tb.NewRow(); drDtl["CostBudgetDtlCode"] = text; CostBudgetPageRule.FillCostBudgetDtlCBSData(drDtl, row2); drDtl["Deep"] = ConvertRule.ToInt(row["Deep"]) + 1; drDtl["ParentCode"] = row["CostBudgetDtlCode"]; drDtl["ChildCount"] = 1; this.tb.Rows.Add(drDtl); this.AddCostChildDyn(drDtl); drsChild = this.tb.Select("ParentCode = '" + text + "'"); this.CalcByChilds(drDtl, drsChild); } rootCBSByGroup.Dispose(); drsChild = this.tb.Select("ParentCode = '" + row["CostBudgetDtlCode"].ToString() + "'"); this.CalcByChilds(row, drsChild); if ((this.StartY != "") && (this.EndY != "")) { foreach (CostBudgetDynamic dynamic in this.m_arrDyn) { foreach (DataRow row4 in dynamic.tbMonth.Rows) { drDtl = this.tbMonth.NewRow(); ConvertRule.DataRowCopy(row4, drDtl, dynamic.tbMonth, this.tbMonth); drDtl["CostBudgetSetCode"] = dynamic.CostBudgetSetCode; this.tbMonth.Rows.Add(drDtl); } foreach (DataRow row5 in dynamic.tbContractMonth.Rows) { drDtl = this.tbContractMonth.NewRow(); ConvertRule.DataRowCopy(row5, drDtl, dynamic.tbContractMonth, this.tbContractMonth); drDtl["CostBudgetSetCode"] = dynamic.CostBudgetSetCode; this.tbContractMonth.Rows.Add(drDtl); } } } } catch (Exception exception) { throw exception; } }
public void RefreshHtml() { try { DataRow drDst; if (!this.ds.Tables.Contains("Html")) { this.ds.Tables.Add(CostBudgetPageRule.CreateDynamicHtmlTable(this.StartY, this.EndY, this.tb)); } this.tbHtml.Clear(); foreach (DataRow row in this.tb.Rows) { drDst = this.tbHtml.NewRow(); ConvertRule.DataRowCopy(row, drDst, this.tb, this.tbHtml); this.tbHtml.Rows.Add(drDst); } if ((this.StartY != "") && (this.EndY != "")) { DataRow[] drsChild; DataView view = new DataView(this.tbHtml, "Deep = 3", "", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { int objYear; int objMonth; string text4; string name; drDst = view2.Row; string text = ConvertRule.ToString(drDst["CostCode"]); string text2 = ConvertRule.ToString(drDst["FullCode"]); string text3 = ConvertRule.ToString(drDst["CostBudgetSetCode"]); DataRow[] rowArray = this.tbMonth.Select(string.Format("CostCode = '{0}' and CostBudgetSetCode = '{1}'", text, text3)); foreach (DataRow row3 in rowArray) { objYear = ConvertRule.ToInt(row3["IYear"]); objMonth = ConvertRule.ToInt(row3["IMonth"]); text4 = ConvertRule.FormatYYYYMM(objYear, objMonth); name = "BudgetMoney_" + text4; if (this.tbHtml.Columns.Contains(name)) { drDst[name] = ConvertRule.ToDecimal(drDst[name]) + ConvertRule.ToDecimal(row3["Money"]); } } rowArray = this.tbContractMonth.Select(string.Format("FullCode like '{0}%' and CostBudgetSetCode = '{1}'", text2, text3)); foreach (DataRow row3 in rowArray) { objYear = ConvertRule.ToInt(row3["IYear"]); objMonth = ConvertRule.ToInt(row3["IMonth"]); text4 = ConvertRule.FormatYYYYMM(objYear, objMonth); name = "ContractMoney_" + text4; if (this.tbHtml.Columns.Contains(name)) { drDst[name] = ConvertRule.ToDecimal(drDst[name]) + ConvertRule.ToDecimal(row3["Money"]); } text4 = ConvertRule.FormatYYYYMM(objYear, 0); name = "ContractMoney_" + text4; if (this.tbHtml.Columns.Contains(name)) { drDst[name] = ConvertRule.ToDecimal(drDst[name]) + ConvertRule.ToDecimal(row3["Money"]); } } } view = new DataView(this.tbHtml, "Deep = 2", "", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { drDst = view2.Row; drsChild = this.tbHtml.Select("ParentCode = '" + ConvertRule.ToString(drDst["CostBudgetDtlCode"]) + "'"); this.CalcByChilds(drDst, drsChild); } view = new DataView(this.tbHtml, "Deep = 1", "", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { drDst = view2.Row; drsChild = this.tbHtml.Select("ParentCode = '" + ConvertRule.ToString(drDst["CostBudgetDtlCode"]) + "'"); this.CalcByChilds(drDst, drsChild); } } foreach (DataRow row2 in this.tbHtml.Rows) { string text6 = ConvertRule.ToString(row2["RecordType"]); string classTd = ConvertRule.ToString(row2["ClassTd"]); if (text6 == "") { row2["PlanDataHtml"] = CostBudgetPageRule.GenerateCostBudgetPlanDataHtml(row2, this.iStartY, this.iEndY, new string[] { "BudgetMoney_", "ContractMoney_" }, new string[] { classTd, CostBudgetPageRule.m_ClassTdContract }, new string[] { "预算", "合同" }); } else { row2["PlanDataHtml"] = CostBudgetPageRule.GenerateCostBudgetPlanDataHtml(row2, this.iStartY, this.iEndY, "ContractMoney_", classTd); } } } catch (Exception exception) { throw exception; } }
public static DataTable GenerateSalBudgetDtlTableInfra(string ProjectCode, int IYear) { DataTable table4; try { int num; DataTable tb = new DataTable("SalBudget"); tb.Columns.Add(new DataColumn("sno", typeof(int))); tb.Columns.Add(new DataColumn("ItemName", typeof(string))); tb.Columns.Add(new DataColumn("FieldName", typeof(string))); tb.Columns.Add(new DataColumn("Unit", typeof(string))); tb.Columns.Add(new DataColumn("ItemDesc", typeof(string))); tb.Columns.Add(new DataColumn("FieldType", typeof(string))); tb.Columns.Add(new DataColumn("PBSTypeCode", typeof(string))); tb.Columns.Add(new DataColumn("PBSTypeName", typeof(string))); tb.Columns.Add(new DataColumn("PBSTypeSortID", typeof(int))); tb.Columns.Add(new DataColumn("PBSTypeFullID", typeof(string))); tb.Columns.Add(new DataColumn("Deep", typeof(int))); tb.Columns.Add(new DataColumn("ParentCode", typeof(string))); tb.Columns.Add(new DataColumn("IsAct", typeof(int))); tb.Columns.Add(new DataColumn("IsActName", typeof(string))); tb.Columns.Add(new DataColumn("y0", typeof(string))); for (num = 0; num <= 12; num++) { tb.Columns.Add(new DataColumn("m" + num.ToString(), typeof(string))); } for (num = 1; num <= 2; num++) { tb.Columns.Add(new DataColumn("y" + num.ToString(), typeof(string))); } DataTable tbPBSType = GetSalPBSType(true); EntityData entityBudget = SalDAO.GetSalBudgetDtlByProjectYear(ProjectCode, IYear); FillSalBudgetDtlByYMInfra(tb, ProjectCode, IYear, -1, "y0", tbPBSType, entityBudget); for (int i = 0; i <= 12; i++) { FillSalBudgetDtlByYMInfra(tb, ProjectCode, IYear, i, "m" + i.ToString(), tbPBSType, entityBudget); } for (num = 1; num <= 2; num++) { EntityData salBudgetDtlByProjectYear = SalDAO.GetSalBudgetDtlByProjectYear(ProjectCode, IYear + num); FillSalBudgetDtlByYMInfra(tb, ProjectCode, IYear + num, 0, "y" + num.ToString(), tbPBSType, salBudgetDtlByProjectYear); salBudgetDtlByProjectYear.Dispose(); } DataTable tbSrc = tb.Clone(); foreach (DataRow row in tb.Rows) { DataRow row2 = tbSrc.NewRow(); row2["sno"] = row["sno"]; row2["IsAct"] = 1; row2["IsActName"] = "实际"; row2["ItemName"] = row["ItemName"]; row2["FieldName"] = row["FieldName"]; row2["Unit"] = row["Unit"]; row2["ItemDesc"] = row["ItemDesc"]; row2["FieldType"] = row["FieldType"]; row2["PBSTypeCode"] = row["PBSTypeCode"]; row2["PBSTypeName"] = row["PBSTypeName"]; row2["PBSTypeSortID"] = row["PBSTypeSortID"]; row2["PBSTypeFullID"] = row["PBSTypeFullID"]; row2["Deep"] = row["Deep"]; row2["ParentCode"] = row["ParentCode"]; tbSrc.Rows.Add(row2); } foreach (DataRow row2 in tbSrc.Rows) { DataRow drDst = tb.NewRow(); ConvertRule.DataRowCopy(row2, drDst, tbSrc, tb); tb.Rows.Add(drDst); } entityBudget.Dispose(); table4 = tb; } catch (Exception exception) { throw exception; } return(table4); }
public void Generate() { try { this.InitCostBudgetSet(); this.SetRelationContract(); this.SetRelationNoContract(); string subjectSetCode = ProjectRule.GetSubjectSetCodeByProject(this.ProjectCode); DataView view = new DataView(SubjectDAO.GetSubjectBySubjectSet(subjectSetCode).CurrentTable, "", "SubjectCode", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { DataRow row2 = view2.Row; DataRow row = this.tb.NewRow(); string subjectCode = row2["SubjectCode"].ToString(); row["DtlCode"] = row2["SubjectCode"]; row["RecordType"] = ""; row["CostCode"] = row2["SubjectCode"]; row["CostName"] = row2["SubjectName"]; row["SortID"] = row2["SubjectCode"]; row["ParentCode"] = SubjectRule.GetSubjectParentCode(subjectCode, subjectSetCode); row["Deep"] = row2["Layer"]; row["FullCode"] = row2["SubjectCode"]; row["ChildCount"] = row2["ChildNodesCount"]; row["IsLeafCBS"] = ConvertRule.ToInt(row["ChildCount"]) <= 0; this.tb.Rows.Add(row); DataRow[] rowArray = this.tbContract.Select("CostCode = '" + subjectCode + "'"); foreach (DataRow row3 in rowArray) { string text3 = row3["ContractCode"].ToString(); DataRow drDst = this.tb.NewRow(); ConvertRule.DataRowCopy(row3, drDst, this.tbContract, this.tb); drDst["DtlCode"] = "C_" + subjectCode + ":" + text3; drDst["RecordType"] = row3["RecordType"]; drDst["Deep"] = row["Deep"]; drDst["ParentCode"] = row["ParentCode"]; drDst["ChildCount"] = 0; drDst["ClassTd"] = CostBudgetPageRule.m_ClassTdContract; this.tb.Rows.Add(drDst); DataRow[] rowArray2 = this.tbApportion.Select("ContractCode = '" + text3 + "' and CostCode = '" + subjectCode + "'"); foreach (DataRow row5 in rowArray2) { string costBudgetSetCode = ConvertRule.ToString(row5["PBSCode"]); drDst = this.tb.NewRow(); ConvertRule.DataRowCopy(row5, drDst, this.tbApportion, this.tb); drDst["DtlCode"] = "A_" + subjectCode + ":" + text3 + "@" + costBudgetSetCode; drDst["RecordType"] = "Apportion"; drDst["PBSCode"] = costBudgetSetCode; drDst["Deep"] = row["Deep"]; drDst["ParentCode"] = row["ParentCode"]; drDst["ChildCount"] = 0; drDst["ClassTd"] = CostBudgetPageRule.m_ClassTdApportion; drDst["ContractName"] = " " + this.GetCostBudgetSetName(costBudgetSetCode); this.tb.Rows.Add(drDst); } } } this.ReCalcByRelation("", ""); this.RefreshDateRange(); for (int i = this.tb.Rows.Count - 1; i >= 0; i--) { DataRow row6 = this.tb.Rows[i]; if (((ConvertRule.ToString(row6["RecordType"]) == "") && (ConvertRule.ToString(row6["FullCode"]) != "")) && (ConvertRule.ToInt(row6["IsExistsContract"]) == 0)) { this.tb.Rows.Remove(row6); } } } catch (Exception exception) { throw exception; } }
public static EntityData GetFinanceSubjectSetWithProject(DataTable tbRelation, string SubjectSetCode, string ProjectCode) { EntityData data3; try { EntityData allSubjectSet; EntityData data = new EntityData("SupplierSubjectSet"); data.CurrentTable.Columns.Add("SubjectSetName"); data.CurrentTable.Columns.Add("ProjectName"); if (SubjectSetCode == "") { allSubjectSet = SubjectDAO.GetAllSubjectSet(); } else { allSubjectSet = SubjectDAO.GetSubjectSetByCode(SubjectSetCode); } QueryAgent agent = new QueryAgent(); try { foreach (DataRow row in allSubjectSet.CurrentTable.Rows) { string text = ConvertRule.ToString(row["FinanceInterfaceSupplierCode"]); string queryString = "select * from ( select a.SubjectSetCode + '_' + p.ProjectCode as SupplierSubjectSetCode, a.SubjectSetCode, a.SubjectSetName, p.ProjectCode, p.ProjectName from SubjectSet a, Project p where a.SubjectSetCode = p.SubjectSetCode union all select a.SubjectSetCode + '_' as SupplierSubjectSetCode, a.SubjectSetCode, a.SubjectSetName, '', '集团' from SubjectSet a) as a where 1 = 1 and SubjectSetCode = '" + ConvertRule.ToString(row["SubjectSetCode"]) + "'"; if (text.ToUpper() == "ByGroup".ToUpper()) { queryString = queryString + " and ProjectCode = ''"; } else if (ProjectCode != "") { queryString = queryString + " and ProjectCode = '" + ProjectCode + "'"; } else { queryString = queryString + " and ProjectCode <> ''"; } queryString = queryString + " order by SubjectSetName, ProjectName"; DataTable tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0]; foreach (DataRow row2 in tbSrc.Rows) { DataRow drDst = data.CurrentTable.NewRow(); ConvertRule.DataRowCopy(row2, drDst, tbSrc, data.CurrentTable); data.CurrentTable.Rows.Add(drDst); } } } finally { agent.Dispose(); } foreach (DataRow row4 in tbRelation.Rows) { string text3 = ConvertRule.ToString(row4["SubjectSetCode"]); string text4 = ConvertRule.ToString(row4["ProjectCode"]); string text5 = ConvertRule.ToString(row4["U8Code"]); DataRow[] rowArray = data.CurrentTable.Select(string.Format("SubjectSetCode='{0}' and ProjectCode='{1}'", text3, text4)); if (rowArray.Length > 0) { rowArray[0]["U8Code"] = text5; } } allSubjectSet.Dispose(); data3 = data; } catch (Exception exception) { throw exception; } return(data3); }
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); }
public void Generate() { try { this.SetRelationContract(); this.SetRelationBidding(); this.SetRelationNoContract(); this.SetRelationBalance(); DataView view = new DataView(CostBudgetRule.GetAllCBSBySet(this.ProjectCode, this.CostBudgetSetCode).CurrentTable, "", "SortID, Deep", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { DataRow drDst; DataRow row = view2.Row; DataRow row2 = this.tb.NewRow(); string text = 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); bool flag = false; DataRow[] rowArray = this.tbContract.Select("CostCode = '" + text + "'"); foreach (DataRow row3 in rowArray) { drDst = this.tb.NewRow(); ConvertRule.DataRowCopy(row3, drDst, this.tbContract, this.tb); drDst["DtlCode"] = "C_" + text + ":" + drDst["ContractCode"].ToString(); drDst["RecordType"] = row3["RecordType"]; drDst["Deep"] = row2["Deep"]; drDst["ParentCode"] = row2["ParentCode"]; drDst["ChildCount"] = 0; string text2 = ConvertRule.ToString(row3["RecordType"]); if ((text2 != null) && (text2 == "Balance")) { drDst["ClassTd"] = CostBudgetPageRule.m_ClassTdBalance; flag = true; } else { drDst["ClassTd"] = CostBudgetPageRule.m_ClassTdContract; } this.tb.Rows.Add(drDst); } if (!this.ReadOnly && !((ConvertRule.ToInt(row2["ChildCount"]) != 0) || flag)) { drDst = this.tb.NewRow(); drDst["ContractCode"] = "Balance_" + text; drDst["ContractName"] = "预留金额"; drDst["CostCode"] = text; drDst["FullCode"] = row2["FullCode"]; drDst["DtlCode"] = "C_" + text + ":" + drDst["ContractCode"].ToString(); drDst["RecordType"] = "Balance"; drDst["Deep"] = row2["Deep"]; drDst["ParentCode"] = row2["ParentCode"]; drDst["ChildCount"] = 0; drDst["ClassTd"] = CostBudgetPageRule.m_ClassTdBalance; this.tb.Rows.Add(drDst); } } this.ReCalcByRelation("", ""); this.RefreshDateRange(); } catch (Exception exception) { throw exception; } }