private string SaveToSession() { string alertMsg = ""; try { string wbsCode = Request["WBSCode"] + ""; EntityData entity = (EntityData)Session["WBSEntity"]; foreach (DataGridItem li in this.dgCostList.Items) { string itemName = ((HtmlInputText)li.FindControl("txtItemName")).Value.Trim(); string planningPayDate = ((AspWebControl.Calendar)li.FindControl("dtPlanningPayDate")).Value; string costCode = ((HtmlInputHidden)li.FindControl("txtcostCode")).Value.Trim(); string costName = BLL.CBSRule.GetCostName(costCode); string money = ((HtmlInputText)li.FindControl("txtMoney")).Value.Trim(); if (costCode != "") { if (!CBSRule.CheckCBSLeafNode(costCode)) { costCode = ""; alertMsg += itemName + ":费用项必须指定到明细费用项 !" + "\n"; } } if (money != "") { if (!Rms.Check.StringCheck.IsNumber(money)) { money = ""; alertMsg += itemName + ":金额格式不正确 !" + "\n"; } } string taskBudgetCode = li.Cells[0].Text; foreach (DataRow dr in entity.Tables["TaskBudget"].Select(String.Format("TaskBudgetCode='{0}'", taskBudgetCode))) { dr["CostCode"] = costCode; dr["CostName"] = costName; dr["ItemName"] = itemName; if (money != "") { dr["Money"] = decimal.Parse(money); } else { dr["Money"] = decimal.Zero; } if (planningPayDate != "") { dr["PlanningPayDate"] = planningPayDate; } else { dr["PlanningPayDate"] = System.DBNull.Value; } } } Session["WBSEntity"] = entity; entity.Dispose(); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "保存出错:" + ex.Message)); } return(alertMsg); }
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); }
protected void Page_Load(object sender, System.EventArgs e) { try { m_TreeType = Request["TreeType"] + ""; m_CheckBalance = Request["CheckBalance"] + ""; m_CostBudgetSetCode = Request.QueryString["CostBudgetSetCode"] + ""; //预算设置表编号 string m_strGetType = Request.QueryString["GetType"] + ""; //数据分类 string m_strLayer = Request.QueryString["Layer"] + ""; //需要取的层数 string m_strNodeId = Request.QueryString["NodeId"] + ""; //父节点编号 string[] m_Layers = (Request.QueryString["Layers"] + "").Split('.'); //定点展开的序列 string m_strSelectedLayer = Request.QueryString["SelectedLayer"] + ""; //定层展开的深度 string fromNodeCode = Request["FromNodeCode"] + ""; DataTable m_Table = new DataTable("CBS"); m_Table.Columns.Add("CostCode"); // 费用编号 m_Table.Columns.Add("ParentCode"); // 父Code m_Table.Columns.Add("CostName"); // 费用项名称 m_Table.Columns.Add("Description"); // 说明 m_Table.Columns.Add("Layer"); // 层数---对应deep深度 m_Table.Columns.Add("ChildNodesCount"); // 子节点数目 m_Table.Columns.Add("ShowChildNodes"); // 是否显示子节点 m_Table.Columns.Add("SortID"); // 费用项编号 m_Table.Columns.Add("DisplayHref"); // 是否显示费用项链接 m_Table.Columns.Add("DisplaySpan"); // 是否显示费用项文字 string projectCode = Request["ProjectCode"] + ""; string accountPoint = Request["AccountPoint"] + ""; EntityData m_Cost = null; if (m_strGetType == "CostBudgetSetRoot") { m_Cost = BLL.CostBudgetRule.GetRootCBSBySet(projectCode, m_CostBudgetSetCode); } else { if (accountPoint == "AccountPoint") { string budgetCode = CBSRule.GetCurrentDynamicCode(projectCode); m_Cost = CBSDAO.GetCBSByBudgetCodeAccountPoint(budgetCode); } else { m_Cost = CBSDAO.GetCBSByProject(projectCode); } } DataTable m_DataTable = m_Cost.CurrentTable; string filter = ""; if (m_strGetType == "") { #region 取第一层 filter = " isnull(ParentCode,'') =''"; DataView m_DV = new DataView(m_DataTable, filter, " SortID ", DataViewRowState.CurrentRows); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row, m_DataTable); m_Table.Rows.Add(m_NewRow); } #endregion } else if (m_strGetType == "CostBudgetSetRoot") { #region 取第一层(针对某张预算设置表) DataView m_DV = new DataView(m_DataTable, filter, " SortID ", DataViewRowState.CurrentRows); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRowCostBudgetDtl(ref m_NewRow, m_Row, m_DataTable); m_Table.Rows.Add(m_NewRow); } #endregion } else if (m_strGetType == "ChildNodes") { #region 取某节点子目录 filter = "ParentCode='" + m_strNodeId + "'"; DataView m_DV = new DataView(m_DataTable, filter, "SortID", DataViewRowState.CurrentRows); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row, m_DataTable); m_Table.Rows.Add(m_NewRow); } #endregion } else if (m_strGetType == "SelectLayer") { #region 取指定层数结果 filter = "Deep='1'"; DataView m_DV = new DataView(m_DataTable, filter, "SortID", DataViewRowState.CurrentRows); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row, m_DataTable); m_Table.Rows.Add(m_NewRow); if (int.Parse(m_strSelectedLayer) > 1) { m_NewRow["ShowChildNodes"] = "1"; this.FillSelectedLayerData(ref m_Table, m_Row["CostCode"].ToString(), 2, int.Parse(m_strSelectedLayer), m_DataTable); } } #endregion } else if (m_strGetType == "All") { #region 取所有结果 filter = "ParentCode='1'"; DataView m_DV = new DataView(m_DataTable, filter, " SortID ", DataViewRowState.CurrentRows); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row, m_DataTable); m_Table.Rows.Add(m_NewRow); if (int.Parse(m_NewRow["ChildNodesCount"].ToString()) > 0) { m_NewRow["ShowChildNodes"] = "1"; this.FillAllData(ref m_Table, m_Row["CostCode"].ToString(), 2, m_DataTable); } } #endregion } else if (m_strGetType == "SingleNode") { #region 单个节点 filter = "CostCode='" + Request.QueryString["NodeId"] + "" + "'"; DataView m_DV = new DataView(m_DataTable, filter, " SortID ", DataViewRowState.CurrentRows); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row, m_DataTable); m_Table.Rows.Add(m_NewRow); } #endregion } m_Cost.Dispose(); Response.Write(RmsPM.WebControls.TreeView.XmlTree.GetDataToXmlString(m_Table)); Response.End(); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); } }