public static decimal CalcPBSUnitCompleteInvest(string PBSUnitCode) { decimal num5; try { decimal num = 0M; EntityData data = PBSDAO.GetV_PBSUnitByCode(PBSUnitCode); if (data.HasRecord()) { decimal totalInvest = data.GetDecimal("PInvest"); string visualProgress = data.GetString("VisualProgress"); int totalFloorCount = PBSRule.GetPBSUnitFloorCount(PBSUnitCode); int currFloorCount = PBSRule.GetPBSUnitCurrentFloorCount(PBSUnitCode); num = CalcInvestByVisualProgress(totalInvest, visualProgress, totalFloorCount, currFloorCount); } data.Dispose(); num5 = num; } catch (Exception exception) { throw exception; } return(num5); }
public static void UpdateConstructAnnualPlanInvest(string PBSUnitCode) { try { if (PBSUnitCode != "") { EntityData pBSUnitByCode = PBSDAO.GetPBSUnitByCode(PBSUnitCode); if (pBSUnitByCode.HasRecord()) { decimal totalInvest = ConvertRule.ToDecimal(pBSUnitByCode.CurrentRow["PInvest"]); EntityData entity = ConstructDAO.GetConstructAnnualPlanByPBSUnit(PBSUnitCode); foreach (DataRow row2 in entity.CurrentTable.Rows) { string visualProgress = ConvertRule.ToString(row2["VisualProgress"]); int currFloorCount = ConvertRule.ToInt(row2["CurrentFloor"]); int totalFloorCount = PBSRule.GetPBSUnitFloorCount(PBSUnitCode); decimal num4 = CalcInvestByVisualProgress(totalInvest, visualProgress, totalFloorCount, currFloorCount); decimal num5 = ConvertRule.ToDecimal(row2["InvestBefore"]); decimal num6 = num4 - num5; row2["PInvest"] = num6; } ConstructDAO.UpdateConstructAnnualPlan(entity); entity.Dispose(); pBSUnitByCode.Dispose(); } } } catch (Exception exception) { throw exception; } }
public static DataTable ApportionAllPayout(string projectCode, string AreaField) { DataTable table2; try { EntityData buildings = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode); EntityData pBSUnits = PBSDAO.GetPBSUnitByProject(projectCode); DataTable dtApportion = BuildApportionTable(); EntityData payoutByProjectCode = PaymentDAO.GetPayoutByProjectCode(projectCode); foreach (DataRow row in payoutByProjectCode.CurrentTable.Rows) { string payoutCode = ConvertRule.ToString(row["PayoutCode"]); ApportionOnePayout(projectCode, payoutCode, pBSUnits, buildings, dtApportion, AreaField); } payoutByProjectCode.Dispose(); pBSUnits.Dispose(); buildings.Dispose(); table2 = dtApportion; } catch (Exception exception) { throw exception; } return(table2); }
public static DataTable GetSalPBSType(bool IsAddAll) { DataTable table2; try { EntityData pBSTypeByProject = PBSDAO.GetPBSTypeByProject("0"); DataTable currentTable = pBSTypeByProject.CurrentTable; if (IsAddAll) { DataRow row = currentTable.NewRow(); row["PBSTypeCode"] = ""; row["PBSTypeName"] = "所有"; row["Deep"] = 0; row["ParentCode"] = ""; currentTable.Rows.InsertAt(row, 0); } pBSTypeByProject.Dispose(); table2 = currentTable; } catch (Exception exception) { throw exception; } return(table2); }
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 void DeletePBSUnit(string PBSUnitCode) { try { EntityData entity = ProductDAO.GetBuildingByPBSUnitCode(PBSUnitCode); foreach (DataRow row in entity.CurrentTable.Rows) { string text = row["BuildingCode"].ToString(); row["PBSUnitCode"] = DBNull.Value; } ProductDAO.UpdateBuilding(entity); entity.Dispose(); entity = ConstructDAO.GetConstructAnnualPlanByPBSUnit(PBSUnitCode); if (entity.HasRecord()) { ConstructDAO.DeleteConstructAnnualPlan(entity); } entity.Dispose(); entity = ConstructDAO.GetConstructPlanStepByPBSUnit(PBSUnitCode); if (entity.HasRecord()) { ConstructDAO.DeleteConstructPlanStep(entity); } entity.Dispose(); entity = ConstructDAO.GetConstructProgressRiskByPBSUnitCode(PBSUnitCode); if (entity.HasRecord()) { ConstructDAO.DeleteConstructProgressRisk(entity); } entity.Dispose(); entity = ConstructDAO.GetConstructProgressByPBSUnit(PBSUnitCode); if (entity.HasRecord()) { ConstructDAO.DeleteConstructProgress(entity); } entity.Dispose(); entity = ConstructDAO.GetConstructProgressStepByPBSUnit(PBSUnitCode); if (entity.HasRecord()) { ConstructDAO.DeleteConstructProgressStep(entity); } entity.Dispose(); entity = PBSDAO.GetPBSUnitByCode(PBSUnitCode); if (entity.HasRecord()) { PBSDAO.DeletePBSUnit(entity); } entity.Dispose(); } catch (Exception exception) { throw exception; } }
public static void UpdatePBSUnitByConstructProgressReport(string PBSUnitCode) { try { EntityData entity = PBSDAO.GetPBSUnitByCode(PBSUnitCode); if (entity.HasRecord()) { DataRow currentRow = entity.CurrentRow; string text = ""; int @int = 0; EntityData lastConstructProgressReport = GetLastConstructProgressReport(PBSUnitCode); if (lastConstructProgressReport.HasRecord()) { text = lastConstructProgressReport.GetString("VisualProgress"); @int = lastConstructProgressReport.GetInt("CurrentLayer"); } lastConstructProgressReport.Dispose(); if (text == "") { currentRow["VisualProgress"] = DBNull.Value; } else { currentRow["VisualProgress"] = text; } object constructProgressStepFirstKg = GetConstructProgressStepFirstKg(PBSUnitCode); currentRow["StartDate"] = constructProgressStepFirstKg; object constructProgressStepFirstJg = GetConstructProgressStepFirstJg(PBSUnitCode); currentRow["EndDate"] = constructProgressStepFirstJg; EntityData buildingByPBSUnitCode = ProductDAO.GetBuildingByPBSUnitCode(PBSUnitCode); if (buildingByPBSUnitCode.HasRecord()) { foreach (DataRow row2 in buildingByPBSUnitCode.CurrentTable.Rows) { row2["CurrentLayer"] = @int; ProductDAO.UpdateBuilding(buildingByPBSUnitCode); } } buildingByPBSUnitCode.Dispose(); PBSDAO.UpdatePBSUnit(entity); lastConstructProgressReport.Dispose(); } entity.Dispose(); } catch (Exception exception) { throw exception; } }
public static void DeletePBSType(string PBSTypeCode) { try { if (PBSTypeCode != "") { PBSDAO.DeletePBSType(PBSDAO.GetPBSTypeAllChildByParentCode(PBSTypeCode)); EntityData entity = PBSDAO.GetPBSTypeByCode(PBSTypeCode); PBSDAO.DeletePBSType(entity); entity.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 static DataTable ApportionOnePayout(string projectCode, string payoutCode, string AreaField) { DataTable table2; try { EntityData buildings = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode); EntityData pBSUnits = PBSDAO.GetAllPBSUnit(); DataTable dtApportion = BuildApportionTable(); ApportionOnePayout(projectCode, payoutCode, pBSUnits, buildings, dtApportion, AreaField); pBSUnits.Dispose(); buildings.Dispose(); table2 = dtApportion; } catch (Exception exception) { throw exception; } return(table2); }
public static DataTable BuildingCostApportionAllPayout(string projectCode, string DateBegin, string DateEnd, string AreaField) { DataTable table2; try { EntityData buildings = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode); EntityData pBSUnits = PBSDAO.GetPBSUnitByProject(projectCode); EntityData cBS = CBSDAO.GetCBSByProject(projectCode); DataTable dtApportion = BuildBuildingCostApportionTable(); PayoutStrategyBuilder builder = new PayoutStrategyBuilder("Payout"); builder.AddStrategy(new Strategy(PayoutStrategyName.ProjectCode, projectCode)); if ((DateBegin != "") || (DateEnd != "")) { ArrayList pas = new ArrayList(); pas.Add(DateBegin); pas.Add(DateEnd); builder.AddStrategy(new Strategy(PayoutStrategyName.PayoutDateRange, pas)); } string queryString = builder.BuildMainQueryString(); QueryAgent agent = new QueryAgent(); EntityData data4 = agent.FillEntityData("Payout", queryString); agent.Dispose(); foreach (DataRow row in data4.CurrentTable.Rows) { string payoutCode = ConvertRule.ToString(row["PayoutCode"]); BuildingCostApportionOnePayout(projectCode, payoutCode, pBSUnits, buildings, cBS, dtApportion, AreaField); } data4.Dispose(); pBSUnits.Dispose(); buildings.Dispose(); cBS.Dispose(); table2 = dtApportion; } catch (Exception exception) { throw exception; } return(table2); }
public static void InsertDefaultConstructAnnualPlan(string ProjectCode) { try { string val = GetConstructPlanCurrYearByProject(ProjectCode); if (val == "") { val = DateTime.Today.Year.ToString(); } int iYear = ConvertRule.ToInt(val); EntityData pBSUnitByProject = PBSDAO.GetPBSUnitByProject(ProjectCode); EntityData constructAnnualPlanByProjectYear = ConstructDAO.GetConstructAnnualPlanByProjectYear(ProjectCode, iYear); EntityData entity = new EntityData("ConstructAnnualPlan"); foreach (DataRow row in pBSUnitByProject.CurrentTable.Rows) { string text2 = row["PBSUnitCode"].ToString(); if (constructAnnualPlanByProjectYear.CurrentTable.Select("PBSUnitCode='" + text2 + "'").Length == 0) { DataRow row2 = entity.CurrentTable.NewRow(); row2["AnnualPlanCode"] = SystemManageDAO.GetNewSysCode("AnnualPlanCode"); row2["PBSUnitCode"] = text2; row2["ProjectCode"] = ProjectCode; row2["IYear"] = iYear; entity.CurrentTable.Rows.Add(row2); } } ConstructDAO.SubmitAllConstructAnnualPlan(entity); entity.Dispose(); constructAnnualPlanByProjectYear.Dispose(); pBSUnitByProject.Dispose(); } catch (Exception exception) { throw exception; } }
public static string GetPBSUnitName(object PBSUnitCode) { string text2; try { string text = ""; if ((PBSUnitCode != null) && (PBSUnitCode.ToString() != "")) { EntityData pBSUnitByCode = PBSDAO.GetPBSUnitByCode(PBSUnitCode.ToString()); if (pBSUnitByCode.HasRecord()) { text = pBSUnitByCode.GetString("PBSUnitName"); } pBSUnitByCode.Dispose(); } text2 = text; } catch (Exception exception) { throw exception; } return(text2); }
public static void ProjectCostApportion(string projectCode, string AreaField) { try { decimal cost; string text3; DataTable table = ApportionAllPayout(projectCode, AreaField); EntityData entity = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode); EntityData pBSUnitByProject = PBSDAO.GetPBSUnitByProject(projectCode); entity.CurrentTable.Columns.Add("BuildingArea", Type.GetType("System.Decimal")); foreach (DataRow row in entity.CurrentTable.Rows) { row["TotalCost"] = DBNull.Value; row["CostPrice"] = DBNull.Value; row["BuildingArea"] = row[AreaField]; } foreach (DataRow row in table.Rows) { decimal num3; string text = ConvertRule.ToString(row["AlloType"]); decimal totalMoney = ConvertRule.ToDecimal(row["ApportionMoney"]); decimal num2 = ConvertRule.ToDecimal(row["BuildingArea"]); if (num2 <= 0M) { break; } switch (text) { case "P": { DataTable dtTemp = new DataTable(); dtTemp.Columns.Add("BuildingCode"); dtTemp.Columns.Add("BuildingArea", typeof(decimal)); dtTemp.Columns.Add("TotalCost", typeof(decimal)); foreach (DataRow row2 in entity.CurrentTable.Rows) { num3 = ConvertRule.ToDecimal(row2["BuildingArea"]); cost = ConvertRule.ToDecimal(row2["TotalCost"]); DataRow row3 = dtTemp.NewRow(); row3["BuildingCode"] = row2["BuildingCode"]; row3["BuildingArea"] = row2["BuildingArea"]; row3["TotalCost"] = Math.Round((decimal)((num3 * totalMoney) / num2), 2); dtTemp.Rows.Add(row3); } ReCalcLastMoney(dtTemp, totalMoney, "TotalCost"); SaveBuildingCostTempToFormal(dtTemp, entity.CurrentTable); break; } case "U": { string text2 = ConvertRule.ToString(row["BuildingCode"]); foreach (DataRow row2 in entity.CurrentTable.Select(string.Format("PBSUnitCode='{0}'", text2))) { num3 = ConvertRule.ToDecimal(row2["BuildingArea"]); cost = ConvertRule.ToDecimal(row2["TotalCost"]); row2["TotalCost"] = cost + Math.Round((decimal)((num3 * totalMoney) / num2), 2); } break; } case "B": text3 = ConvertRule.ToString(row["BuildingCode"]); foreach (DataRow row2 in entity.CurrentTable.Select(string.Format("BuildingCode='{0}'", text3))) { cost = ConvertRule.ToDecimal(row2["TotalCost"]); row2["TotalCost"] = cost + totalMoney; } break; } } EntityData roomByProjectCode = ProductDAO.GetRoomByProjectCode(projectCode); foreach (DataRow row2 in entity.CurrentTable.Rows) { text3 = ConvertRule.ToString(row2["BuildingCode"]); decimal area = ConvertRule.ToDecimal(row2["BuildingArea"]); cost = ConvertRule.ToDecimal(row2["TotalCost"]); decimal price = GetPrice(cost, area); row2["CostPrice"] = price; DataRow[] rowArray = roomByProjectCode.CurrentTable.Select(string.Format("BuildingCode='{0}'", text3)); int length = rowArray.Length; decimal num8 = 0M; for (int i = 0; i < length; i++) { DataRow row4 = rowArray[i]; decimal num10 = ConvertRule.ToDecimal(row4["BuildArea"]); row4["CostPrice"] = price; if (i < (length - 1)) { decimal num11 = Math.Round((decimal)(num10 * price), 2); num8 += num11; row4["Cost"] = num11; } else { row4["Cost"] = cost - num8; } } } ProductDAO.SubmitAllBuilding(entity); ProductDAO.SubmitAllRoom(roomByProjectCode); table.Dispose(); entity.Dispose(); roomByProjectCode.Dispose(); pBSUnitByProject.Dispose(); } catch (Exception exception) { throw exception; } }
public static DataTable CostApportionExcel(string projectCode, string AreaField) { DataTable table4; try { DataTable table = BuildingCostApportionAllPayout(projectCode, "", "", AreaField); EntityData buildingNotAreaByProjectCode = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode); EntityData pBSUnitByProject = PBSDAO.GetPBSUnitByProject(projectCode); DataTable currentTable = buildingNotAreaByProjectCode.CurrentTable; currentTable.Columns.Add("BuildingArea", Type.GetType("System.Decimal")); currentTable.Columns.Add("CostTd", typeof(decimal)); currentTable.Columns.Add("CostQq", typeof(decimal)); currentTable.Columns.Add("CostKf", typeof(decimal)); currentTable.Columns.Add("CostZt", typeof(decimal)); currentTable.Columns.Add("CostTj", typeof(decimal)); currentTable.Columns.Add("CostQt", typeof(decimal)); DataTable dtTemp = new DataTable(); dtTemp.Columns.Add("BuildingCode"); dtTemp.Columns.Add("BuildingArea", typeof(decimal)); dtTemp.Columns.Add("TotalCost", typeof(decimal)); foreach (DataRow row in buildingNotAreaByProjectCode.CurrentTable.Rows) { row["TotalCost"] = DBNull.Value; row["CostPrice"] = DBNull.Value; row["BuildingArea"] = row["Area"]; } foreach (DataRow row in table.Rows) { DataRow row3; dtTemp.Clear(); string text = ConvertRule.ToString(row["AlloType"]); decimal totalMoney = ConvertRule.ToDecimal(row["ApportionMoney"]); decimal num2 = ConvertRule.ToDecimal(row["BuildingArea"]); string costCode = ConvertRule.ToString(row["CostCode"]); string costSortID = ConvertRule.ToString(row["CostSortID"]); if (num2 <= 0M) { break; } switch (text) { case "P": foreach (DataRow row2 in buildingNotAreaByProjectCode.CurrentTable.Rows) { decimal num3 = ConvertRule.ToDecimal(row2["BuildingArea"]); decimal num4 = ConvertRule.ToDecimal(row2["TotalCost"]); row3 = dtTemp.NewRow(); row3["BuildingCode"] = row2["BuildingCode"]; row3["BuildingArea"] = row2["BuildingArea"]; row3["TotalCost"] = Math.Round((decimal)((num3 * totalMoney) / num2), 2); dtTemp.Rows.Add(row3); } ReCalcLastMoney(dtTemp, totalMoney, "TotalCost"); SaveBuildingCostTempToFormalByCostCode(dtTemp, buildingNotAreaByProjectCode.CurrentTable, costCode, costSortID); break; case "U": { string text4 = ConvertRule.ToString(row["BuildingCode"]); foreach (DataRow row2 in buildingNotAreaByProjectCode.CurrentTable.Select(string.Format("PBSUnitCode='{0}'", text4))) { row3 = dtTemp.NewRow(); row3["BuildingCode"] = row2["BuildingCode"]; row3["BuildingArea"] = row2["BuildingArea"]; row3["TotalCost"] = Math.Round((decimal)((ConvertRule.ToDecimal(row2["BuildingArea"]) * totalMoney) / num2), 2); dtTemp.Rows.Add(row3); } SaveBuildingCostTempToFormalByCostCode(dtTemp, buildingNotAreaByProjectCode.CurrentTable, costCode, costSortID); break; } default: if (text == "B") { row3 = dtTemp.NewRow(); row3["BuildingCode"] = row["BuildingCode"]; row3["BuildingArea"] = num2; row3["TotalCost"] = totalMoney; dtTemp.Rows.Add(row3); SaveBuildingCostTempToFormalByCostCode(dtTemp, buildingNotAreaByProjectCode.CurrentTable, costCode, costSortID); } break; } } table.Dispose(); pBSUnitByProject.Dispose(); table4 = currentTable; } catch (Exception exception) { throw exception; } return(table4); }
/// <summary> /// 保存 /// </summary> /// <param name="code"></param> /// <param name="parentCode"></param> private void SavaData(string code, string parentCode) { try { string curCode = ""; int deep = 0; string fullID = ""; int sortID = 0; if (parentCode.Length > 0) { EntityData entityParent = PBSDAO.GetPBSTypeByCode(parentCode); if (entityParent.HasRecord()) { deep = entityParent.GetInt("Deep"); fullID = entityParent.GetString("fullID"); } entityParent.Dispose(); } EntityData entity = RmsPM.DAL.EntityDAO.PBSDAO.GetPBSTypeByCode(code); DataRow dr = null; bool IsNew = false; if (entity.HasRecord()) { IsNew = false; dr = entity.CurrentRow; } else { dr = entity.GetNewRecord(); IsNew = true; curCode = SystemManageDAO.GetNewSysCode("PBSTypeCode"); sortID = PBSDAO.GetPBSTypeMaxSortID(this.txtProjectCode.Value, parentCode); dr["PBSTypeCode"] = curCode; dr["Deep"] = deep + 1; if (fullID.Length > 0) { dr["FullID"] = fullID + "-" + curCode; } else { dr["FullID"] = curCode; } dr["ParentCode"] = parentCode; dr["ProjectCode"] = this.txtProjectCode.Value; dr["SortID"] = sortID + 1; } dr["PBSTypeName"] = this.txtPBSTypeName.Value; dr["Description"] = this.txtDescription.Value; if (IsNew) { entity.AddNewRecord(dr); PBSDAO.InsertPBSType(entity); } else { PBSDAO.UpdatePBSType(entity); } entity.Dispose(); } catch (Exception ex) { throw ex; } }