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); }
private void FillRow(ref DataRow m_NewRow, DataRowView m_Row) { int ChildCount = BLL.ProductRule.GetBuildingChildCount(m_Row["BuildingCode"].ToString()); string nodeType = ChildCount > 0 ? "folder" : "item"; m_NewRow["BuildingCode"] = m_Row["BuildingCode"].ToString(); if (m_strGetType == "ChildNodesOfProject") //项目下的一级楼栋 { m_NewRow["ParentCode"] = m_ProjectCode; } else { m_NewRow["ParentCode"] = m_Row["ParentCode"].ToString(); } m_NewRow["BuildingName"] = m_Row["BuildingName"].ToString(); m_NewRow["Layer"] = m_Row["Layer"].ToString(); m_NewRow["ChildNodesCount"] = ChildCount; m_NewRow["ShowChildNodes"] = "0"; m_NewRow["NodeType"] = nodeType; m_NewRow["IsArea"] = m_Row["IsArea"]; if (BLL.ConvertRule.ToInt(m_Row["IsArea"]) == 1) //区域 { //区域面积从楼栋累加 BuildingStrategyBuilder sb = new BuildingStrategyBuilder(); sb.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, m_ProjectCode)); sb.AddStrategy(new Strategy(BuildingStrategyName.ParentCode, m_Row["BuildingCode"].ToString())); DataTable tb = BuildStrategy(sb); decimal[] area = BLL.MathRule.SumColumn(tb, new string[] { "HouseArea", "RoomArea" }); m_NewRow["HouseArea"] = BLL.StringRule.BuildShowNumberString(area[0]); m_NewRow["RoomArea"] = BLL.StringRule.BuildShowNumberString(area[1]); m_NewRow["IconName"] = "BuildingArea.gif"; } else //楼栋 { m_NewRow["PBSTypeName"] = BLL.PBSRule.GetPBSTypeFullName(BLL.ConvertRule.ToString(m_Row["PBSTypeCode"])); m_NewRow["FloorCount"] = BLL.ConvertRule.ToInt(m_Row["IFloorCount"]); m_NewRow["HouseArea"] = BLL.MathRule.GetDecimalShowString(m_Row["HouseArea"]); m_NewRow["RoomArea"] = BLL.MathRule.GetDecimalShowString(m_Row["RoomArea"]); m_NewRow["PBSUnitCode"] = BLL.ConvertRule.ToString(m_Row["PBSUnitCode"]); m_NewRow["PBSUnitName"] = BLL.PBSRule.GetPBSUnitName(BLL.ConvertRule.ToString(m_Row["PBSUnitCode"])); m_NewRow["IconName"] = "Building.gif"; } m_NewRow["PBSType"] = "B"; m_NewRow["ShowSpan"] = "none"; m_NewRow["ShowHref"] = ""; }
private void LoadDataGrid() { string projectCode = Request["ProjectCode"] + ""; try { //面积字段 string BuildingAreaFieldName = BLL.CostRule.GetApportionAreaField(projectCode); string BuildingAreaFieldDesc = BLL.ProductRule.GetBuildingAreaFieldDesc(BuildingAreaFieldName); ((System.Web.UI.WebControls.TemplateColumn)dgList.Columns[4]).HeaderText = BuildingAreaFieldDesc + "(平米)"; BuildingStrategyBuilder sb = new BuildingStrategyBuilder(); sb.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, projectCode)); sb.AddStrategy(new Strategy(BuildingStrategyName.IsArea, "2")); sb.AddOrder("BuildingName", true); string sql = sb.BuildQueryViewString(); QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("Building", sql); qa.Dispose(); string[] arrField = { "RoomArea", "TotalCost" }; decimal[] arrSum = BLL.MathRule.SumColumn(entity.CurrentTable, arrField); ViewState["SumArea"] = BLL.StringRule.BuildShowNumberString(arrSum[0]); ViewState["SumCost"] = BLL.StringRule.BuildShowNumberString(arrSum[1]); DataTable tb = entity.CurrentTable; BLL.PaymentRule.AddBuildingCBVoucherCode(tb); //填面积 foreach (DataRow dr in tb.Rows) { dr["Area"] = dr[BuildingAreaFieldName]; } dgList.DataSource = tb; dgList.DataBind(); entity.Dispose(); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "显示数据出错:" + ex.Message)); } }
/// <summary> /// 按查询条件输出结果集 /// </summary> /// <param name="sb"></param> /// <returns></returns> private DataTable BuildStrategy(BuildingStrategyBuilder sb) { try { string sql = sb.BuildMainQueryString(); QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("Building", sql); qa.Dispose(); return(entity.CurrentTable); } catch (Exception ex) { throw ex; } }
public static decimal GetProjectArea(string projectCode) { decimal num2; try { BuildingStrategyBuilder builder = new BuildingStrategyBuilder(); builder.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, projectCode)); string queryString = builder.BuildQuerySumBuildAreaString(); QueryAgent agent = new QueryAgent(); decimal num = (decimal)agent.ExecuteScalar(queryString); agent.Dispose(); num2 = num; } catch (Exception exception) { throw exception; } return(num2); }
private void LoadDataGrid() { try { BuildingStrategyBuilder sb = new BuildingStrategyBuilder(); string ProjectCode = this.txtProjectCode.Value; if (ProjectCode != "") { sb.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, ProjectCode)); } sb.AddStrategy(new Strategy(BuildingStrategyName.IsArea, "2")); sb.AddOrder("BuildingName", true); string sql = sb.BuildMainQueryString(); QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("Building", sql); qa.Dispose(); //选择多个 if (this.m_Multi == "1") { DataRow dr = entity.CurrentTable.NewRow(); dr["BuildingCode"] = -1; dr["BuildingName"] = "多选楼栋..."; entity.CurrentTable.Rows.InsertAt(dr, 0); } dgList.DataSource = entity; dgList.DataBind(); entity.Dispose(); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "初始化页面出错:" + ex.Message)); } }
public static DataTable GetBuildingNoPBSUnit(string ProjectCode) { DataTable table2; try { BuildingStrategyBuilder builder = new BuildingStrategyBuilder(); builder.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, ProjectCode)); builder.AddStrategy(new Strategy(BuildingStrategyName.IsArea, "2")); builder.AddStrategy(new Strategy(BuildingStrategyName.NullPBSUnit)); builder.AddOrder("BuildingName", true); QueryAgent agent = new QueryAgent(); string queryString = builder.BuildMainQueryString(); DataTable table = agent.ExecSqlForDataSet(queryString).Tables[0]; agent.Dispose(); table2 = table; } catch (Exception exception) { throw exception; } return(table2); }
private void LoadData(string projectCode, string parentCode) { try { if (parentCode != "") { this.trArea.Style["display"] = ""; this.lblAreaName.Text = BLL.ProductRule.GetBuildingName(parentCode); } string CurrUrl = "Building_l.aspx?ProjectCode=" + this.txtProjectCode.Value; DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("ObjLeft", typeof(String))); dt.Columns.Add(new DataColumn("ObjTop", typeof(String))); dt.Columns.Add(new DataColumn("Events", typeof(String))); dt.Columns.Add(new DataColumn("BuildingName", typeof(String))); dt.Columns.Add(new DataColumn("BuildingCode", typeof(String))); dt.Columns.Add(new DataColumn("IsArea", typeof(String))); dt.Columns.Add("Color", typeof(string)); dt.Columns.Add("Desc", typeof(string)); dt.Columns.Add("RoomCount", typeof(int)); dt.Columns.Add("ChildCount", typeof(int)); DataRow dr = null; DataView dv = new DataView(); //查询房间套数 BuildingStrategyBuilder sb = new BuildingStrategyBuilder(); sb.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, projectCode)); sb.AddStrategy(new Strategy(BuildingStrategyName.ParentCode, parentCode)); string sql = sb.BuildQueryRoomCountString(); QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("Building", sql); qa.Dispose(); // EntityData entity=RmsPM.DAL.EntityDAO.ProductDAO.GetBuildingByProjectParentCode(projectCode,parentCode); if (entity.HasRecord()) { int x = 10; int y = 20; for (int i = 0; i <= entity.CurrentTable.Rows.Count - 1; i++) { entity.SetCurrentRow(i); dr = dt.NewRow(); int objX = 0; int objY = 0; if (i % 5 == 0) { y = y + 20; x = x; } string strX = entity.CurrentTable.Rows[i]["ObjectX"].ToString(); string strY = entity.CurrentTable.Rows[i]["ObjectY"].ToString(); if (strX.Length > 0) { if (int.Parse(strX) == 0) { objX = x; } else { objX = int.Parse(entity.CurrentTable.Rows[i]["ObjectX"].ToString()); } } else { objX = x; } if (strY.Length > 0) { if (int.Parse(strY) == 0) { objY = y + 40; } else { objY = int.Parse(entity.CurrentTable.Rows[i]["ObjectY"].ToString()); } } else { objY = y + 40; } x = x + 80; dr[0] = objX; dr[1] = objY; dr[3] = entity.CurrentTable.Rows[i]["BuildingName"]; dr[4] = entity.CurrentTable.Rows[i]["BuildingCode"]; dr[5] = entity.CurrentTable.Rows[i]["IsArea"]; dr["RoomCount"] = entity.GetInt("RoomCount"); dr["ChildCount"] = entity.GetInt("ChildCount"); //用颜色区分区域、楼栋 if (entity.CurrentTable.Rows[i]["IsArea"].ToString() == "1") { //区域 dr[2] = "doMapArea(\"" + entity.CurrentTable.Rows[i]["ProjectCode"] + "\",\"" + entity.CurrentTable.Rows[i]["BuildingCode"] + "\")"; dr["Color"] = "yellow"; dr["Desc"] = dr["BuildingName"].ToString() + " (" + BLL.ConvertRule.ToInt(dr["ChildCount"]).ToString() + "幢)"; } else { //楼栋 dr[2] = "doMapBuilding(\"" + entity.CurrentTable.Rows[i]["BuildingCode"] + "\",\"" + CurrUrl + "\")"; dr["Color"] = ""; dr["Desc"] = dr["BuildingName"].ToString() + " (" + BLL.ConvertRule.ToInt(dr["RoomCount"]).ToString() + "套)"; } dt.Rows.Add(dr); } dv = new DataView(dt); } entity.Dispose(); this.dlBuild.DataSource = dv; this.dlBuild.DataBind(); string fieldNameSrc = ""; if (parentCode.Length > 0) { EntityData entity1 = RmsPM.DAL.EntityDAO.ProductDAO.GetBuildingByCode(parentCode); fieldNameSrc = "AreaImageCode"; if (entity1.HasRecord()) { if ("" != entity1.GetString(fieldNameSrc) + "") { this.imgMain.Src = "ShowPicture.aspx?FileID=" + entity1.GetString(fieldNameSrc); } else { this.imgMain.Visible = false; } } entity1.Dispose(); } else { EntityData entity2 = RmsPM.DAL.EntityDAO.ProjectDAO.GetProjectByCode(projectCode); fieldNameSrc = "ImagePath"; if (entity2.HasRecord()) { if ("" != entity2.GetString(fieldNameSrc) + "") { this.imgMain.Src = "ShowPicture.aspx?FileID=" + entity2.GetString(fieldNameSrc); } else { this.imgMain.Visible = false; } } entity2.Dispose(); } //小区平面图汇总图例 //DataTable tbLegend = BLL.ProductRule.GetBuildingLocationLegend(entity.CurrentTable); //this.repLegend.DataSource = tbLegend; //this.repLegend.DataBind(); } catch (Exception ex) { throw ex; } }
private void LoadDataGrid(bool isEmpty) { try { BuildingStrategyBuilder sb = new BuildingStrategyBuilder("V_Building"); if (isEmpty) { sb.AddStrategy(new Strategy(BuildingStrategyName.False)); } string ProjectCode = this.txtProjectCode.Value; if (ProjectCode != "") { sb.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, ProjectCode)); } if (this.txtSearchProjectCode.Value != "") { sb.AddStrategy(new Strategy(BuildingStrategyName.InProjectCode, this.txtSearchProjectCode.Value)); } if (this.sltSearchProjectStatus.Value != "") { sb.AddStrategy(new Strategy(BuildingStrategyName.ProjectStatus, this.sltSearchProjectStatus.Value)); } if (this.txtSearchBuildingName.Value != "") { sb.AddStrategy(new Strategy(BuildingStrategyName.InBuildingName, this.txtSearchBuildingName.Value, "F")); } if (this.sltSearchPBSTypeCode.Value != "") { sb.AddStrategy(new Strategy(BuildingStrategyName.PBSTypeCodeAllChild, this.sltSearchPBSTypeCode.Value)); } if (this.txtSearchInvestType.Value != "") { sb.AddStrategy(new Strategy(BuildingStrategyName.InInvestType, this.txtSearchInvestType.Value, "F")); } //排序 string sortsql = BLL.GridSort.GetSortSQL(ViewState); if (sortsql == "") { //缺省排序 if (ProjectCode == "") { sb.AddOrder("ProjectName", true); } sb.AddOrder("BuildingName", true); } string sql = sb.BuildMainQueryString(); if (sortsql != "") { //点列标题排序 sql = sql + " order by " + sortsql; } QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("V_Building", sql); qa.Dispose(); string[] arrField = { "HouseArea", "RoomArea", "TotalCost" }; decimal[] arrSum = BLL.MathRule.SumColumn(entity.CurrentTable, arrField); ViewState["SumCount"] = entity.CurrentTable.Rows.Count.ToString() + "幢"; ViewState["SumHouseArea"] = BLL.StringRule.BuildShowNumberString(arrSum[0]); ViewState["SumRoomArea"] = BLL.StringRule.BuildShowNumberString(arrSum[1]); ViewState["SumTotalCost"] = BLL.StringRule.BuildShowNumberString(arrSum[2]); dgList.DataSource = entity; dgList.DataBind(); if (this.GridPagination1.Visible) { this.GridPagination1.RowsCount = entity.CurrentTable.Rows.Count.ToString(); } entity.Dispose(); //显示工具栏 if (entity.HasRecord()) { this.trToolBar.Style["display"] = ""; } else { this.trToolBar.Style["display"] = "none"; } } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "初始化页面出错:" + ex.Message)); } }
private void Page_Load(object sender, System.EventArgs e) { try { m_strGetType = Request.QueryString["GetType"] + ""; //数据分类 m_strLayer = Request.QueryString["Layer"] + ""; //需要取的层数 m_strNodeId = Request.QueryString["NodeId"] + ""; //父节点编号 string[] m_Layers = (Request.QueryString["Layers"] + "").Split('.'); //定点展开的序列 string m_strSelectedLayer = Request.QueryString["SelectedLayer"] + ""; //定层展开的深度 m_ProjectCode = Request.QueryString["ProjectCode"] + ""; m_strShowSum = Request.QueryString["ShowSum"] + ""; //是否显示合计行 DataTable m_Table = new DataTable("Building"); m_Table.Columns.Add("BuildingCode"); m_Table.Columns.Add("ParentCode"); m_Table.Columns.Add("BuildingName"); m_Table.Columns.Add("Layer"); m_Table.Columns.Add("ChildNodesCount"); m_Table.Columns.Add("ShowChildNodes"); m_Table.Columns.Add("NodeType"); m_Table.Columns.Add("IsArea"); m_Table.Columns.Add("IconName"); m_Table.Columns.Add("PBSTypeName"); m_Table.Columns.Add("FloorCount"); m_Table.Columns.Add("HouseArea"); m_Table.Columns.Add("RoomArea"); m_Table.Columns.Add("PBSUnitCode"); m_Table.Columns.Add("PBSUnitName"); m_Table.Columns.Add("PBSType"); //单位工程类型:P=项目;B=楼 m_Table.Columns.Add("dHouseArea", typeof(decimal)); m_Table.Columns.Add("dRoomArea", typeof(decimal)); m_Table.Columns.Add("ShowSpan"); m_Table.Columns.Add("ShowHref"); // EntityData m_Task=RmsPM.DAL.EntityDAO.ProductDAO.GetBuildingByProjectCode(ProjectCode); // DataTable m_DataTable=m_Task.Tables["Building"]; //查询条件 BuildingStrategyBuilder sb = new BuildingStrategyBuilder(); sb.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, m_ProjectCode)); if (m_strGetType == "") { #region 取第一层 // DataView m_DV=new DataView(m_DataTable,"ParentCode=''","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.ParentCode, "")); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } #endregion } else if (m_strGetType == "ChildNodes") { #region 取某节点子目录 // DataView m_DV=new DataView(m_DataTable,"ParentCode='"+m_strNodeId+"'","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.ParentCode, m_strNodeId)); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } if (m_strShowSum == "1") { AddSumRow(m_Table); } #endregion } else if (m_strGetType == "SelectLayer") { #region 取制定层数结果 // DataView m_DV=new DataView(m_DataTable,"Layer='1'","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.Layer, "1")); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); if (int.Parse(m_strSelectedLayer) > 1) { m_NewRow["ShowChildNodes"] = "1"; this.FillSelectedLayerData(ref m_Table, m_Row["PBSTypeCode"].ToString(), 2, int.Parse(m_strSelectedLayer), m_DataTable); } } #endregion } else if (m_strGetType == "All") { #region 取所有结果 // DataView m_DV=new DataView(m_DataTable,"Layer='1'","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.Layer, "1")); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); 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["PBSTypeCode"].ToString(), 2, m_DataTable); } } #endregion } else if (m_strGetType == "SingleNode") { #region 单个节点 // DataView m_DV=new DataView(m_DataTable,"BuildingCode='"+Request.QueryString["NodeId"]+""+"'","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.BuildingCode, m_strNodeId)); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } #endregion } else if (m_strGetType == "Project") { #region 项目 EntityData entityProject = DAL.EntityDAO.ProjectDAO.GetProjectByCode(m_ProjectCode); DataTable m_DataTable = entityProject.CurrentTable; DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRowProject(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } entityProject.Dispose(); #endregion } else if (m_strGetType == "ChildNodesOfProject") { #region 取某节点子目录 // DataView m_DV=new DataView(m_DataTable,"ParentCode='"+m_strNodeId+"'","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.ParentCode, "")); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } #endregion } Response.Write(RmsPM.WebControls.TreeView.XmlTree.GetDataToXmlString(m_Table)); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); } Response.End(); }
protected void Page_Load(object sender, System.EventArgs e) { 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 ProjectCode = Request.QueryString["ProjectCode"] + ""; string PBSTypeCode = Request.QueryString["PBSTypeCode"] + ""; m_Table = new DataTable("Building"); m_Table.Columns.Add("BuildingCode"); m_Table.Columns.Add("ParentCode"); m_Table.Columns.Add("BuildingName"); m_Table.Columns.Add("Description"); m_Table.Columns.Add("Layer"); m_Table.Columns.Add("ChildNodesCount"); m_Table.Columns.Add("ShowChildNodes"); m_Table.Columns.Add("NodeType"); m_Table.Columns.Add("IsArea"); m_Table.Columns.Add("NoSelectArea"); m_Table.Columns.Add("PBSUnitName"); m_Table.Columns.Add("IconName"); // EntityData entity = DAL.EntityDAO.ProductDAO.GetBuildingByProjectCode(ProjectCode); // m_DataTable=entity.CurrentTable; //查询条件 BuildingStrategyBuilder sb = new BuildingStrategyBuilder("V_Building"); sb.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, ProjectCode)); if (PBSTypeCode != "") { sb.AddStrategy(new Strategy(BuildingStrategyName.PBSTypeCodeAllChild, PBSTypeCode)); } if (m_strGetType == "") { #region 取第一层 // DataRow m_NewRow=m_Table.NewRow(); // this.FillRootRow(ref m_NewRow); // m_Table.Rows.Add(m_NewRow); //缺省打开根节点 // DataView m_DV=new DataView(m_DataTable,"isnull(ParentCode,'')=''","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.ParentCode, "")); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } #endregion } else if (m_strGetType == "ChildNodes") { #region 取某节点子目录 // DataView m_DV=new DataView(m_DataTable,"isnull(ParentCode,'')='"+m_strNodeId+"'","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.ParentCode, m_strNodeId)); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } #endregion } else if (m_strGetType == "SelectLayer") { #region 取制定层数结果 // DataView m_DV=new DataView(m_DataTable,"Deep='1'","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.Layer, "1")); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); if (int.Parse(m_strSelectedLayer) > 1) { m_NewRow["ShowChildNodes"] = "1"; this.FillSelectedLayerData(m_Row["BuildingCode"].ToString(), 2, int.Parse(m_strSelectedLayer)); } } #endregion } else if (m_strGetType == "All") { #region 取所有结果 // DataView m_DV=new DataView(m_DataTable,"isnull(ParentCode,'')=''","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.Layer, "1")); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); if (int.Parse(m_NewRow["ChildNodesCount"].ToString()) > 0) { m_NewRow["ShowChildNodes"] = "1"; this.FillAllData(m_Row["BuildingCode"].ToString(), 2); } } #endregion } else if (m_strGetType == "SingleNode") { #region 单个节点 // DataView m_DV=new DataView(m_DataTable,"BuildingCode='"+Request.QueryString["NodeId"]+""+"'","",DataViewRowState.CurrentRows); sb.AddStrategy(new Strategy(BuildingStrategyName.BuildingCode, m_strNodeId)); sb.AddOrder("BuildingName", true); DataTable m_DataTable = BuildStrategy(sb); DataView m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } #endregion } Response.Write(RmsPM.WebControls.TreeView.XmlTree.GetDataToXmlString(m_Table)); Response.End(); }
protected void Page_Load(object sender, System.EventArgs e) { 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 ProjectCode = Request.QueryString["ProjectCode"] + ""; string PBSTypeCode = Request.QueryString["PBSTypeCode"] + ""; m_Table = new DataTable("Building"); m_Table.Columns.Add("BuildingCode"); m_Table.Columns.Add("ParentCode"); m_Table.Columns.Add("BuildingName"); m_Table.Columns.Add("Description"); m_Table.Columns.Add("Layer"); m_Table.Columns.Add("ChildNodesCount"); m_Table.Columns.Add("ShowChildNodes"); m_Table.Columns.Add("NodeType"); m_Table.Columns.Add("IsPBSUnit"); m_Table.Columns.Add("NoSelectPBSUnit"); m_Table.Columns.Add("IconName"); m_Table.Columns.Add("PBSUnitName"); //查询条件 BuildingStrategyBuilder sb = new BuildingStrategyBuilder("V_Building"); sb.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, ProjectCode)); if (PBSTypeCode != "") { sb.AddStrategy(new Strategy(BuildingStrategyName.PBSTypeCodeAllChild, PBSTypeCode)); } EntityData entityU; DataTable m_DataTable; DataView m_DV; switch (m_strGetType.ToLower()) { case "pbsunit": #region 取第一层 单位工程,下分楼栋 entityU = DAL.EntityDAO.PBSDAO.GetPBSUnitByProject(ProjectCode); entityU.Dispose(); m_DataTable = entityU.CurrentTable; m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRowPBSUnit(ref m_NewRow, m_Row, true); m_Table.Rows.Add(m_NewRow); } break; #endregion case "onlypbsunit": #region 取单位工程 entityU = DAL.EntityDAO.PBSDAO.GetPBSUnitByProject(ProjectCode); entityU.Dispose(); m_DataTable = entityU.CurrentTable; m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRowPBSUnit(ref m_NewRow, m_Row, false); m_Table.Rows.Add(m_NewRow); } break; #endregion case "buildingofpbsunit": #region 取某单位工程下的楼栋 sb.AddStrategy(new Strategy(BuildingStrategyName.PBSUnitCode, m_strNodeId)); sb.AddOrder("BuildingName", true); m_DataTable = BuildStrategy(sb); m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } break; #endregion case "building": #region 取所有楼栋 sb.AddStrategy(new Strategy(BuildingStrategyName.IsArea, "2")); sb.AddOrder("BuildingName", true); m_DataTable = BuildStrategy(sb); m_DV = new DataView(m_DataTable); foreach (DataRowView m_Row in m_DV) { DataRow m_NewRow = m_Table.NewRow(); this.FillRow(ref m_NewRow, m_Row); m_Table.Rows.Add(m_NewRow); } break; #endregion default: break; } Response.Write(RmsPM.WebControls.TreeView.XmlTree.GetDataToXmlString(m_Table)); Response.End(); }