public static void AddColumnTargetHis(DataTable tbDtl, EntityData entityTargetHis) { try { if (entityTargetHis != null) { DataView view = new DataView(entityTargetHis.CurrentTable, "", "VerID desc", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { string text = ConvertRule.ToString(view2.Row["VerID"]); if (text != "") { string name = "BudgetMoneyHis_" + text; if (!tbDtl.Columns.Contains(name)) { tbDtl.Columns.Add(name); } } } } } 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; } }
public static string GetParentSubjectCode(string subjectCode, string ruleCode) { string text3; try { string[] textArray = ruleCode.Split(".".ToCharArray()); string text = ""; string text2 = subjectCode; for (int i = 0; i < textArray.Length; i++) { int length = ConvertRule.ToInt(textArray[i]); if (text2.Length > length) { text = text + text2.Substring(0, length); text2 = text2.Substring(length, text2.Length - length); } else { break; } } text3 = text; } catch (Exception exception) { throw exception; } return(text3); }
public static decimal CalcInvestByVisualProgress(decimal TotalInvest, string VisualProgress, int TotalFloorCount, int CurrFloorCount) { decimal num2; try { decimal num = 0M; QueryAgent agent = new QueryAgent(); try { string format = "select dbo.GetTotalCompleteInvestNew({0}, '{1}', {2}, {3})"; format = string.Format(format, new object[] { TotalInvest, VisualProgress, TotalFloorCount, CurrFloorCount }); num = ConvertRule.ToDecimal(agent.ExecuteScalar(format)); } finally { agent.Dispose(); } num2 = num; } catch (Exception exception) { throw exception; } return(num2); }
private void AddApportion(string ContractCode, string CostCode, string PBSCode, string RecordType, string MoneyField, decimal Money) { try { DataRow row; DataRow[] rowArray = this.tbApportion.Select("ContractCode = '" + ContractCode + "' and CostCode='" + CostCode + "' and PBSCode = '" + PBSCode + "'"); if (rowArray.Length == 0) { row = this.tbApportion.NewRow(); row["RecordType"] = RecordType; row["ContractCode"] = ContractCode; row["CostCode"] = CostCode; row["PBSCode"] = PBSCode; this.tbApportion.Rows.Add(row); } else { row = rowArray[0]; } row[MoneyField] = ConvertRule.ToDecimal(row[MoneyField]) + Money; CostBudgetPageRule.CostBudgetDtlCalcField(row, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0); } catch (Exception exception) { throw exception; } }
public static string GetSystemReportDtlString(DataTable tb) { string text2; try { string text = ""; int num = -1; foreach (DataRow row in tb.Rows) { num++; if (num > 0) { text = text + ";"; } text = text + ConvertRule.ToString(row["FieldName"]) + "=" + ConvertRule.ToString(row["FieldDispName"]); } text2 = text; } catch (Exception exception) { throw exception; } return(text2); }
public void ResetTitleHtml() { try { this.m_TitleHtml1 = ""; this.m_TitleHtmlArea = ""; this.m_TitleHtmlAreaPercent = ""; foreach (DataRow row in this.tbPBS.Rows) { if (ConvertRule.ToString(row["PBSType"]) == "B") { this.m_TitleHtml1 = this.m_TitleHtml1 + string.Format("<th align=center nowrap>{0}</th>", CostBudgetPageRule.GetBuildingHref(ConvertRule.ToString(row["PBSCode"]), ConvertRule.ToString(row["PBSName"])) + " "); } else { this.m_TitleHtml1 = this.m_TitleHtml1 + string.Format("<th align=center nowrap>{0}</th>", ConvertRule.ToString(row["PBSName"]) + " "); } this.m_TitleHtmlArea = this.m_TitleHtmlArea + string.Format("<th align=center nowrap style='border-top:0'>{0}</th>", StringRule.BuildShowNumberString(row["Area"], "#,##0.##") + " "); this.m_TitleHtmlAreaPercent = this.m_TitleHtmlAreaPercent + string.Format("<th align=center nowrap style='border-top:0'>{0}</th>", StringRule.BuildShowPercentString(row["AreaPercent"]) + " "); } } catch (Exception exception) { throw exception; } }
static void Main(string[] args) { string[] testStrings = { "abcd123fi5g 8k2973'$", " kefi 48524 dkfgigf 24574 s3 31!", "I'm John", }; Converter converter = new Converter(); foreach (var item in testStrings) { Console.WriteLine(converter.Convert(item, RemoveDigits)); } Console.WriteLine(); foreach (var item in testStrings) { Console.WriteLine(converter.Convert(item, RemoveSpaces)); } Console.WriteLine(); ConvertRule myDel = RemoveDigits; myDel += RemoveSpaces; foreach (var item in testStrings) { Console.WriteLine(converter.Convert(item, myDel)); } Console.WriteLine(); }
public static DataTable GetSystemAccessDistinctRelation(DataTable tb) { DataTable table2; try { DataTable table = new DataTable(); table.Columns.Add("SystemID"); table.Columns.Add("AccessRangeType"); table.Columns.Add("RelationCode"); int num = 0; foreach (DataRow row in tb.Rows) { string text = ConvertRule.ToString(row["AccessRangeType"]); string text2 = ConvertRule.ToString(row["RelationCode"]); string filterExpression = string.Format("AccessRangeType='{0}' and RelationCode='{1}'", text, text2); if (table.Select(filterExpression).Length == 0) { DataRow row2 = table.NewRow(); num++; row2["SystemID"] = num; row2["AccessRangeType"] = text; row2["RelationCode"] = text2; table.Rows.Add(row2); } } table2 = table; } catch (Exception exception) { throw exception; } return(table2); }
public static int GetPBSUnitFloorCount(string PBSUnitCode) { int num2; try { int num = 0; BuildingStrategyBuilder builder = new BuildingStrategyBuilder(); builder.AddStrategy(new Strategy(BuildingStrategyName.PBSUnitCode, PBSUnitCode)); builder.AddOrder("FloorCount", false); QueryAgent agent = new QueryAgent(); agent.SetTopNumber(1); string queryString = builder.BuildMainQueryString(); DataTable table = agent.ExecSqlForDataSet(queryString).Tables[0]; if (table.Rows.Count > 0) { num = ConvertRule.ToInt(table.Rows[0]["IFloorCount"]); } agent.Dispose(); num2 = num; } catch (Exception exception) { throw exception; } return(num2); }
public static void SaveSalBudgetOneDtl(string ProjectCode, string BudgetCode, EntityData entityDtl, int y, int m, string PBSTypeCode, string FieldName, string val) { try { DataRow row; DataRow[] rowArray = entityDtl.CurrentTable.Select("IYear=" + y.ToString() + " and IMonth=" + m.ToString() + " and PBSTypeCode='" + PBSTypeCode + "'"); if (rowArray.Length == 0) { row = entityDtl.CurrentTable.NewRow(); row["BudgetCode"] = BudgetCode; row["SystemID"] = SystemManageDAO.GetNewSysCode("SalBudgetSystemID"); row["ProjectCode"] = ProjectCode; row["IYear"] = y; row["IMonth"] = m; row["PBSTypeCode"] = PBSTypeCode; entityDtl.CurrentTable.Rows.Add(row); } else { row = rowArray[0]; } row[FieldName] = ConvertRule.ToDecimalObj(val); } catch (Exception exception) { throw exception; } }
public static string GetSalProjectNameByCode(string ProjectCode) { string text2; try { string text = ""; if (ProjectCode == "") { return(text); } SalService service = new SalService(); DataTable table = service.GetSalProjectByCode(ProjectCode).Tables[0]; if (table.Rows.Count > 0) { text = ConvertRule.ToString(table.Rows[0]["Proj_Name"]); } text2 = text; } catch (Exception exception) { throw exception; } return(text2); }
public static string[] BuildArrayFieldByMonth(string StartY, string EndY, int StartM, int EndM, string FieldPre) { string[] textArray2; try { string[] textArray = new string[0]; int num = ConvertRule.ToInt(StartY); int num2 = ConvertRule.ToInt(EndY); int num3 = (EndM - StartM) + 1; if (num > 0) { int num4 = ((num2 - num) + 1) * num3; if (num4 > 0) { textArray = new string[num4]; int index = -1; for (int i = num; i <= num2; i++) { for (int j = StartM; j <= EndM; j++) { index++; string text = ConvertRule.FormatYYYYMM(i, j); textArray[index] = FieldPre + text; } } } } textArray2 = textArray; } catch (Exception exception) { throw exception; } return(textArray2); }
public static void AddMonthField(DataTable tb, string aStartY, string aEndY, string FieldName) { try { string val = aStartY; string text2 = aEndY; if ((val != "") && (text2 == "")) { text2 = val; } if ((text2 != "") && (val == "")) { val = text2; } if ((val != "") && (text2 != "")) { int num = ConvertRule.ToInt(val); int num2 = ConvertRule.ToInt(text2); for (int i = num; i <= num2; i++) { for (int j = 0; j <= 12; j++) { string text3 = ConvertRule.FormatYYYYMM(i, j); tb.Columns.Add(FieldName + text3, typeof(decimal)); } } } } catch (Exception exception) { throw exception; } }
public static void SplitPubBuildingName(DataTable tb) { try { tb.Columns.Add("BuildingNameH", typeof(string)); tb.Columns.Add("BuildingNameP", typeof(string)); foreach (DataRow row in tb.Rows) { row["BuildingNameH"] = row["BuildingName"]; row["BuildingNameP"] = row["BuildingName"]; } DataRow[] rowArray = tb.Select("PBSTypeFullName like '住宅%'", "BuildingName"); foreach (DataRow row in rowArray) { string text = ConvertRule.ToString(row["BuildingName"]); DataRow[] rowArray2 = tb.Select(string.Format("BuildingName like '{0}%' and PBSTypeFullName not like '住宅%'", text)); foreach (DataRow row2 in rowArray2) { string text2 = ConvertRule.ToString(row2["BuildingName"]); string text3 = text2.Substring(text.Length, text2.Length - text.Length); row2["BuildingNameH"] = text; row2["BuildingNameP"] = text3; } } } catch (Exception exception) { throw exception; } }
public static void SetSystemGroupParent(DataRow drNew, DataRow drParent) { try { string text = ""; int num = 0; string text2 = ""; if (drParent != null) { text = ConvertRule.ToString(drParent["GroupCode"]); num = ConvertRule.ToInt(drParent["Deep"]); text2 = ConvertRule.ToString(drParent["FullID"]); } string text3 = drNew["GroupCode"].ToString(); int num2 = num + 1; string text4 = text2; if (text4.Length > 0) { text4 = text4 + "-" + text3; } else { text4 = text3; } drNew["deep"] = num2; drNew["FullID"] = text4; drNew["ParentCode"] = text; } catch (Exception exception) { throw exception; } }
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); }
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); }
private void PBSApport() { try { CostApportion apportion = new CostApportion(); apportion.RoundDec = 2; DataView view = new DataView(this.tbPBS, "PBSType = 'B'", "", DataViewRowState.CurrentRows); foreach (DataRowView view2 in view) { apportion.SetArea(ConvertRule.ToString(view2.Row["PBSCode"]), ConvertRule.ToDecimal(view2.Row["Area"])); } apportion.SetTotalMoney("AreaPercent", 100M); apportion.DoApportion(); this.m_TotalPBSArea = apportion.TotalArea; foreach (DataRowView view2 in view) { DataRow[] rowArray = apportion.tbArea.Select("ID = '" + ConvertRule.ToString(view2.Row["PBSCode"]) + "'"); if (rowArray.Length > 0) { DataRow row = rowArray[0]; view2.Row["AreaPercent"] = row["AreaPercent"]; } } } 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 void AddConstructProgressLastReportDate(string PBSUnitCode, DataTable tb) { try { tb.Columns.Add("IsEnd", typeof(int)); foreach (DataRow row in tb.Rows) { string visualProgress = ConvertRule.ToString(row["VisualProgress"]); if (row["EndDate"] == DBNull.Value) { row["IsEnd"] = 0; EntityData lastConstructProgressReportByVisualProgress = GetLastConstructProgressReportByVisualProgress(PBSUnitCode, visualProgress); if (lastConstructProgressReportByVisualProgress.HasRecord()) { row["EndDate"] = ConvertRule.ToDate(lastConstructProgressReportByVisualProgress.CurrentRow["ReportDate"]); } lastConstructProgressReportByVisualProgress.Dispose(); } else { row["IsEnd"] = 1; } } } catch (Exception exception) { throw exception; } }
public static decimal GetTotalCost(string projectCode) { decimal num2; try { decimal num = 0M; QueryAgent agent = new QueryAgent(); try { string format = "select sum(isnull(money, 0)) as TotalCost from Payout where ProjectCode = '{0}'"; num = ConvertRule.ToDecimal(agent.ExecuteScalar(string.Format(format, projectCode))); } finally { agent.Dispose(); } num2 = num; } catch (Exception exception) { throw exception; } return(num2); }
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; } }
private static void ReCalcLastMoney(DataTable dtTemp, decimal TotalMoney, string MoneyField) { try { decimal num = 0M; if (dtTemp.Rows.Count > 0) { int count = dtTemp.Rows.Count; for (int i = 0; i < count; i++) { DataRow row = dtTemp.Rows[i]; if (i < (count - 1)) { num += ConvertRule.ToDecimal(row[MoneyField]); } else { row[MoneyField] = TotalMoney - num; } } } } catch (Exception exception) { throw exception; } }
private void FillContractChangeCostCode(DataTable tbTemp) { try { QueryAgent agent = new QueryAgent(); foreach (DataRow row in tbTemp.Rows) { if (ConvertRule.ToString(row["ContractCostCode"]) == "") { string text = ConvertRule.ToString(row["ContractCode"]); string text2 = ConvertRule.ToString(row["CostCode"]); string text3 = ConvertRule.ToString(row["CostBudgetSetCode"]); string text4 = ""; string queryString = string.Format("select ContractCostCode from ContractCost where ContractCode = '{0}' and CostCode = '{1}' and CostBudgetSetCode = '{2}'", text, text2, text3); DataTable table = agent.ExecSqlForDataSet(queryString).Tables[0]; foreach (DataRow row2 in table.Rows) { text4 = text4 + ((text4 == "") ? "" : ","); text4 = text4 + ConvertRule.ToString(row2["ContractCostCode"]); } row["ContractCostCode"] = text4; } } agent.Dispose(); } catch (Exception exception) { throw exception; } }
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 string GetSalPayItemName(string SalPayCode, string ContractCode) { string text2; try { string text = ""; if ((SalPayCode == "") || (ContractCode == "")) { return(text); } DataTable salPayItem = GetSalPayItem(SalPayCode, ContractCode); int count = salPayItem.Rows.Count; for (int i = 0; i < count; i++) { DataRow row = salPayItem.Rows[i]; if (text != "") { text = text + ","; } text = text + ConvertRule.ToString(row["ItemName"]); } text2 = text; } catch (Exception exception) { throw exception; } return(text2); }
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; } }
public static void DeleteAllSupplier() { try { QueryAgent agent = new QueryAgent(); try { string queryString = "select top 1 a.ContractName, b.SupplierName from Contract a, Supplier b where a.SupplierCode = b.SupplierCode"; DataSet set = agent.ExecSqlForDataSet(queryString); try { if (set.Tables[0].Rows.Count > 0) { throw new Exception(string.Format("供应商“{0}”已生成合同,不能删除", ConvertRule.ToString(set.Tables[0].Rows[0]["SupplierName"]))); } } finally { set.Dispose(); } agent.ExecuteSql("delete SupplierSubjectSet"); agent.ExecuteSql("delete Supplier"); } finally { agent.Dispose(); } } catch (Exception exception) { throw exception; } }
public static string GetTd(object objText, object objClass) { string text4; try { string text = ""; string text2 = ConvertRule.ToString(objText); string text3 = ConvertRule.ToString(objClass); if (text2 == "") { text = "<td></td>"; } else { text = "<td"; if (text3 != "") { text = text + " class='" + text3 + "'"; } text = (text + ">") + text2 + "</td>"; } text4 = text; } catch (Exception exception) { throw exception; } return(text4); }