private void SetRow(HtmlTableRow row, PBSTypeLayout.LayoutInfo info, string celltype, string PBSTypeCode) { if (PBSTypeCode != "") { m_RowIndex++; HtmlInputHidden txtPBSTypeCode = new HtmlInputHidden(); txtPBSTypeCode.Name = "txtPBSTypeCode" + m_RowIndex.ToString(); txtPBSTypeCode.ID = txtPBSTypeCode.Name; txtPBSTypeCode.Value = PBSTypeCode; row.Cells[0].Controls.Add(txtPBSTypeCode); } HtmlTableCell cell; cell = NewCell(row, BLL.MathRule.GetDecimalShowString(info.FloorSpace), "right", celltype, "FloorSpace"); cell = NewCell(row, BLL.MathRule.GetDecimalShowString(info.VolumeRate), "right", celltype, "VolumeRate"); cell = NewCell(row, BLL.MathRule.GetDecimalShowString(info.BuildingSpace), "right", celltype, "BuildingSpace"); cell = NewCell(row, BLL.MathRule.GetDecimalShowString(info.SaleRate), "right", celltype, "SaleRate"); cell = NewCell(row, BLL.MathRule.GetDecimalShowString(info.SaleArea), "right", celltype, "SaleArea"); cell = NewCell(row, "", "right", "cap", ""); cell.Style.Add("display", "none"); cell = NewCell(row, BLL.MathRule.GetDecimalShowString(info.HouseAreaAvg), "right", celltype, "HouseAreaAvg"); cell = NewCell(row, BLL.MathRule.GetIntShowString(info.HouseCount), "right", celltype, "HouseCount"); }
/// <summary> /// 汇总更新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnRead_ServerClick(object sender, System.EventArgs e) { try { DataTable tbBuilding = BuildingTotalGroupByPBSTypeCode(this.txtProjectCode.Value); if (tbBuilding.Rows.Count == 0) { return; } DataTable tbLayout = ScreenToTable(); int count = tbLayout.Rows.Count - 1; for (int i = 0; i < count; i++) { DataRow drLayout = tbLayout.Rows[i]; string PBSTypeCode = drLayout["PBSTypeCode"].ToString(); string PBSTypeName = BLL.PBSRule.GetPBSTypeName(PBSTypeCode); PBSTypeLayout.LayoutInfo info = new PBSTypeLayout.LayoutInfo(); info.SetInfo(drLayout); DataRow[] drs = tbBuilding.Select("PBSTypeCode='" + PBSTypeCode + "'"); if (drs.Length > 0) { info.BuildingSpace = BLL.ConvertRule.ToDecimal(drs[0]["Area"].ToString()); info.HouseCount = BLL.ConvertRule.ToDecimal(drs[0]["HouseCount"].ToString()); info.CalcVolumeRate(); info.CalcSaleArea(); info.CalcHouseAreaAvg(); } else { info.BuildingSpace = 0; info.HouseCount = 0; } info.SaveToDataRow(drLayout); } TableToScreen(tbLayout); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "汇总更新失败:" + ex.Message)); } }
private void CreateDataGrid() { try { EntityData entity = DAL.EntityDAO.PBSDAO.GetPBSTypeByProject(this.txtProjectCode.Value); HtmlTableRow row; HtmlTableCell cell; PBSTypeLayout.LayoutInfo info = new PBSTypeLayout.LayoutInfo(); //第一层 DataRow[] drs = entity.CurrentTable.Select("ParentCode=''"); foreach (DataRow dr in drs) { string code = dr["PBSTypeCode"].ToString(); string name = dr["PBSTypeName"].ToString(); //第二层 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(); row = NewRow(); //合并大类 if (i == 0) { cell = NewCell(row, name, "center", "cap", ""); cell.RowSpan = iCount2; // cell.RowSpan = iCount2 + 1; } NewCell(row, name2, "center", "cap", ""); SetRow(row, info, "", code2); tbDtl.Rows.Add(row); } //第二层小计 if (iCount2 > 0) { row = NewRow(); row.Style.Add("display", "none"); NewCell(row, "小计", "center", "sum", ""); SetRow(row, info, "sum", ""); tbDtl.Rows.Add(row); } } //总计 row = NewRow(); row.Style.Add("display", "none"); cell = NewCell(row, "总计", "center", "sum", ""); cell.ColSpan = 2; SetRow(row, info, "sum", ""); tbDtl.Rows.Add(row); entity.Dispose(); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "初始化页面出错:" + ex.Message)); } }
// private void ClearDataGrid() // { // int count = this.tbDtl.Rows.Count; // for (int i=count-1;i>0;i--) // { // this.tbDtl.Rows.Remove(this.tbDtl.Rows[i]); // } // } private void TableToScreen(DataTable tbLayout) { try { int count = this.tbDtl.Rows.Count; int RowIndex = 0; int StartCol = 0; PBSTypeLayout.LayoutInfo total = new PBSTypeLayout.LayoutInfo(); HtmlTableRow row; for (int i = 1; i < count; i++) { RowIndex++; row = this.tbDtl.Rows[i]; if (row.Cells.Count >= 10) { StartCol = 1; } else { StartCol = 0; } HtmlInputHidden txtPBSTypeCode = null; try { txtPBSTypeCode = (HtmlInputHidden)row.Cells[0].Controls[1]; //.FindControl("txtPBSTypeCode" + RowIndex.ToString()); } catch { } if ((txtPBSTypeCode != null) && (txtPBSTypeCode.Value.Trim() != "")) { HtmlInputText txtFloorSpace = (HtmlInputText)row.Cells[StartCol + 1].Controls[0]; //.FindControl("txtFloorSpace" + RowIndex.ToString()); HtmlInputText txtBuildingSpace = (HtmlInputText)row.Cells[StartCol + 3].Controls[0]; //.FindControl("txtFloorSpace" + RowIndex.ToString()); HtmlInputText txtVolumeRate = (HtmlInputText)row.Cells[StartCol + 2].Controls[0]; //.FindControl("txtFloorSpace" + RowIndex.ToString()); HtmlInputText txtSaleRate = (HtmlInputText)row.Cells[StartCol + 4].Controls[0]; //.FindControl("txtFloorSpace" + RowIndex.ToString()); HtmlInputText txtSaleArea = (HtmlInputText)row.Cells[StartCol + 5].Controls[0]; //.FindControl("txtFloorSpace" + RowIndex.ToString()); // HtmlInputText txtFloorSpace = (HtmlInputText)row.Cells[StartCol + 6].Controls[0];//.FindControl("txtFloorSpace" + RowIndex.ToString()); HtmlInputText txtHouseAreaAvg = (HtmlInputText)row.Cells[StartCol + 7].Controls[0]; //.FindControl("txtFloorSpace" + RowIndex.ToString()); HtmlInputText txtHouseCount = (HtmlInputText)row.Cells[StartCol + 8].Controls[0]; //.FindControl("txtFloorSpace" + RowIndex.ToString()); string PBSTypeCode = txtPBSTypeCode.Value.Trim(); DataRow[] drsLayout = tbLayout.Select("PBSTypeCode='" + PBSTypeCode + "'"); if (drsLayout.Length > 0) { txtFloorSpace.Value = BLL.MathRule.GetDecimalShowString(drsLayout[0]["FloorSpace"]); txtBuildingSpace.Value = BLL.MathRule.GetDecimalShowString(drsLayout[0]["BuildingSpace"]); txtVolumeRate.Value = BLL.MathRule.GetDecimalShowString(drsLayout[0]["VolumeRate"]); txtSaleRate.Value = BLL.MathRule.GetDecimalShowString(drsLayout[0]["SaleRate"]); txtSaleArea.Value = BLL.MathRule.GetDecimalShowString(drsLayout[0]["SaleArea"]); txtHouseAreaAvg.Value = BLL.MathRule.GetDecimalShowString(drsLayout[0]["HouseAreaAvg"]); txtHouseCount.Value = BLL.ConvertRule.ToDecimal(drsLayout[0]["HouseCount"]).ToString("#"); } } } } catch (Exception ex) { throw ex; } }