private void LoadDataGrid() { try { RoomStrategyBuilder sb = new RoomStrategyBuilder("V_ROOM"); string ProjectCode = this.txtProjectCode.Value; if (ProjectCode != "") { sb.AddStrategy(new Strategy(RoomStrategyName.ProjectCode, ProjectCode)); } if (this.tbSearchRoom.Visible) { ((SearchRoom)this.tbSearchRoom).AddSearch(sb); } sb.AddOrder("BuildingName", true); sb.AddOrder("ChamberCode", true); sb.AddOrder("FloorIndex", true); sb.AddOrder("RoomName", true); string sql = sb.BuildMainQueryString(); QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("V_ROOM", sql); qa.Dispose(); dgList.Columns[2].FooterText = entity.CurrentTable.Rows.Count.ToString() + " 条"; dgList.Columns[5].FooterText = BLL.MathRule.SumColumn(entity.CurrentTable, "BuildArea").ToString("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)); } }
private void LoadDataGridFromBuilding(string BuildingCode) { try { //检查是否可修改 string hint = BLL.ProductRule.CanModifyRoomArea(BuildingCode); if (hint != "") { Response.Write(Rms.Web.JavaScript.Alert(true, hint)); Response.Write(Rms.Web.JavaScript.WinClose(true)); return; } RoomStrategyBuilder sb = new RoomStrategyBuilder("V_ROOM"); sb.AddStrategy(new Strategy(RoomStrategyName.ProjectCode, this.txtProjectCode.Value)); sb.AddStrategy(new Strategy(RoomStrategyName.BuildingCode, BuildingCode)); sb.AddOrder("BuildingName", true); sb.AddOrder("ChamberCode", true); sb.AddOrder("FloorIndex", true); sb.AddOrder("RoomName", true); string sql = sb.BuildMainQueryString(); QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("V_ROOM", sql); qa.Dispose(); BindDataGrid(entity.CurrentTable); entity.Dispose(); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "初始化页面出错:" + ex.Message)); } }
private void LoadDataGrid(bool isEmpty) { try { RoomStrategyBuilder sb = new RoomStrategyBuilder("V_ROOM"); if (isEmpty) { sb.AddStrategy(new Strategy(RoomStrategyName.False)); } string ProjectCode = this.txtProjectCode.Value; if (ProjectCode != "") { sb.AddStrategy(new Strategy(RoomStrategyName.ProjectCode, ProjectCode)); } if (ProjectCode == "") { if (this.tbSearchRoomAll.Visible) { ((SearchRoomAll)this.tbSearchRoomAll).AddSearch(sb); } } else { if (this.tbSearchRoom.Visible) { ((SearchRoom)this.tbSearchRoom).AddSearch(sb); } } //排序 string sortsql = BLL.GridSort.GetSortSQL(ViewState); if (sortsql == "") { //缺省排序 if (ProjectCode == "") { sb.AddOrder("ProjectName", true); } sb.AddOrder("BuildingName", true); sb.AddOrder("ChamberCode", true); sb.AddOrder("FloorIndex", true); sb.AddOrder("RoomName", true); } string sql = sb.BuildMainQueryString(); if (sortsql != "") { //点列标题排序 sql = sql + " order by " + sortsql; } QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("V_ROOM", sql); qa.Dispose(); string[] arrField = { "BuildArea", "Cost", "TotalPayMoney" }; decimal[] arrSum = BLL.MathRule.SumColumn(entity.CurrentTable, arrField); ViewState["SumCount"] = entity.CurrentTable.Rows.Count.ToString() + "套"; ViewState["SumBuildArea"] = BLL.StringRule.BuildShowNumberString(arrSum[0]); ViewState["SumCost"] = BLL.StringRule.BuildShowNumberString(arrSum[1]); ViewState["SumTotalPayMoney"] = BLL.StringRule.BuildShowNumberString(arrSum[2]); dgList.DataSource = entity; dgList.DataBind(); if (this.GridPagination1.Visible) { this.GridPagination1.RowsCount = entity.CurrentTable.Rows.Count.ToString(); } entity.Dispose(); SetSelectRoomCode(); //显示工具栏 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)); } }