private void LoadDataGrid() { try { string ProjectCode = this.txtProjectCode.Value; EntityData entity = DAL.EntityDAO.PBSDAO.GetPBSTypeByProject(ProjectCode); // string CHref = "javascript:ShowPBSType('{0}');"; LayoutInfo total = new LayoutInfo(); HtmlTableRow row; HtmlTableCell cell; //第一层 DataRow[] drs = entity.CurrentTable.Select("ParentCode=''"); foreach (DataRow dr in drs) { string code = dr["PBSTypeCode"].ToString(); string name = dr["PBSTypeName"].ToString(); string href = ""; // string href = string.Format(CHref, code); LayoutInfo total2 = new LayoutInfo(); //第二层 DataRow[] drs2 = entity.CurrentTable.Select("ParentCode='" + code + "'"); int iCount2 = drs2.Length; for (int i = 0; i < iCount2; i++) { DataRow dr2 = drs2[i]; string code2 = dr2["PBSTypeCode"].ToString(); string name2 = dr2["PBSTypeName"].ToString(); string href2 = ""; // string href2 = string.Format(CHref, code2); row = NewRow(); //合并大类 if (i == 0) { cell = NewCell(row, name, "center", true, false, href); cell.RowSpan = iCount2 + 1; } NewCell(row, name2, "center", true, false, href2); //取产品的规划信息 LayoutInfo dtl = new LayoutInfo(); EntityData entityLayout = DAL.EntityDAO.PBSDAO.GetPBSTypeLayoutByProjectPBSType(ProjectCode, code2); if (entityLayout.HasRecord()) { dtl.FloorSpace = entityLayout.GetDecimal("FloorSpace"); dtl.BuildingSpace = entityLayout.GetDecimal("BuildingSpace"); dtl.VolumeRate = entityLayout.GetDecimal("VolumeRate"); dtl.SaleRate = entityLayout.GetDecimal("SaleRate"); dtl.SaleArea = entityLayout.GetDecimal("SaleArea"); dtl.HouseCount = entityLayout.GetDecimal("HouseCount"); dtl.HouseAreaAvg = entityLayout.GetDecimal("HouseAreaAvg"); total2.Plus(dtl); } entityLayout.Dispose(); SetRow(row, dtl, false); tbDtl.Rows.Add(row); } //计算产品比例 SetAreaPercent(this.tbDtl.Rows.Count - iCount2, iCount2, total2); //第二层空时插一条空的小计 if (iCount2 == 0) { row = NewRow(); cell = NewCell(row, name, "center", true, false, href); cell.RowSpan = iCount2 + 1; NewCell(row, "小计", "center", true, true, ""); LayoutInfo dtl = new LayoutInfo(); SetRow(row, dtl, true); tbDtl.Rows.Add(row); } //第二层小计 if (iCount2 > 0) { row = NewRow(); row.Attributes.Add("class", "sum"); NewCell(row, "小计", "center", true, true, ""); SetRow(row, total2, true); tbDtl.Rows.Add(row); total.Plus(total2); } } //总计 row = NewRow(); row.Attributes.Add("class", "sum"); cell = NewCell(row, "总计", "center", true, true, ""); cell.ColSpan = 2; SetRow(row, total, true); tbDtl.Rows.Add(row); entity.Dispose(); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "初始化页面出错:" + ex.Message)); } }