protected void Page_Load(object sender, EventArgs e) { FrmReportFields frmReportFields = new FrmReportFields(); BP.En.QueryObject obj = new BP.En.QueryObject(frmReportFields); obj.AddWhere(FrmReportFieldAttr.FK_MapData, this.FK_MapData); obj.addOrderBy(FrmReportFieldAttr.Idx); obj.DoQuery(); this.Pub1.AddTable("width='90%' align='center' id='myTable'"); this.Pub1.AddCaptionLeft("修改报表列属性"); this.Pub1.AddTR(); this.Pub1.AddTDTitle("序"); this.Pub1.AddTDTitle("字段"); this.Pub1.AddTDTitle("标签"); this.Pub1.AddTDTitle("显示宽度"); this.Pub1.AddTDTitle("显示顺序号"); this.Pub1.AddTDTitle("是否隐藏"); this.Pub1.AddTREnd(); int idx = 0; string tKey = DateTime.Now.ToString("HHmmss"); foreach (FrmReportField mattr in frmReportFields) { idx++; this.Pub1.AddTR(); this.Pub1.AddTDIdx(idx); this.Pub1.AddTD(mattr.KeyOfEn); TextBox tb = new TextBox(); tb.Text = mattr.Name; tb.ID = "TB_" + mattr.KeyOfEn; this.Pub1.AddTD(tb); //宽度 tb = new TextBox(); tb.ID = "TB_" + mattr.KeyOfEn + "_width"; tb.Text = mattr.UIWidth.ToString(); this.Pub1.AddTD(tb); //顺序. tb = new TextBox(); tb.ID = "TB_" + mattr.KeyOfEn + "_Idx"; tb.Text = mattr.Idx.ToString(); this.Pub1.AddTD(tb); CheckBox cb = new CheckBox(); cb.ID = "CB_" + mattr.KeyOfEn; cb.Checked = mattr.UIVisible == true ? false : true; this.Pub1.AddTD(cb); this.Pub1.AddTREnd(); } this.Pub1.AddTableEnd(); }
//保存 protected void Btn_Save_Click(object sender, EventArgs e) { FrmReportFields reportFields = new FrmReportFields(); reportFields.Delete(FrmReportFieldAttr.FK_MapData, this.FK_MapData); //OID默认必须有 FrmReportField reportFieldPK = new FrmReportField(); reportFieldPK.MyPK = this.FK_MapData + "_OID"; reportFieldPK.FK_MapData = this.FK_MapData; reportFieldPK.KeyOfEn = "OID"; reportFieldPK.Name = "编号"; reportFieldPK.UIWidth = "100"; reportFieldPK.Idx = 0; reportFieldPK.Insert(); //查询表单所有属性 MapAttrs mattrs = new MapAttrs(this.FK_MapData); foreach (MapAttr attr in mattrs) { CheckBox cb = this.Pub1.GetCBByID("CB_" + attr.KeyOfEn); if (cb == null || attr.KeyOfEn == "OID") { continue; } if (cb.Checked == false) { continue; } FrmReportField reportField = new FrmReportField(); reportField.MyPK = this.FK_MapData + "_" + attr.KeyOfEn; reportField.FK_MapData = this.FK_MapData; reportField.KeyOfEn = attr.KeyOfEn; reportField.Name = attr.Name; reportField.UIWidth = attr.UIWidth.ToString(); reportField.Idx = attr.Idx; reportField.Insert(); } this.Alert("保存成功。"); }
void cbAll_CheckedChanged(object sender, EventArgs e) { CheckBox cbAll = (CheckBox)sender; if (cbAll != null) { FrmReportFields reportFields = new FrmReportFields(); reportFields.Delete(FrmReportFieldAttr.FK_MapData, this.FK_MapData); if (cbAll.Checked) { //查询表单所有属性 MapAttrs mattrs = new MapAttrs(this.FK_MapData); //OID默认必须有 FrmReportField reportFieldPK = new FrmReportField(); reportFieldPK.MyPK = this.FK_MapData + "_OID"; reportFieldPK.FK_MapData = this.FK_MapData; reportFieldPK.KeyOfEn = "OID"; reportFieldPK.Name = "编号"; reportFieldPK.UIWidth = "100"; reportFieldPK.Idx = 0; reportFieldPK.Insert(); foreach (MapAttr attr in mattrs) { if (attr.KeyOfEn == "OID") { continue; } FrmReportField reportField = new FrmReportField(); reportField.MyPK = this.FK_MapData + "_" + attr.KeyOfEn; reportField.FK_MapData = this.FK_MapData; reportField.KeyOfEn = attr.KeyOfEn; reportField.Name = attr.Name; reportField.UIWidth = attr.UIWidth.ToString(); reportField.Idx = attr.Idx; reportField.Insert(); } this.Response.Redirect("Frm_ColsChose.aspx?IsChecked=true&FK_MapData=" + this.FK_MapData, true); } this.Response.Redirect("Frm_ColsChose.aspx?IsChecked=false&FK_MapData=" + this.FK_MapData, true); } }
protected void Btn_Save_Click(object sender, EventArgs e) { FrmReportFields frmReportFields = new FrmReportFields(); frmReportFields.RetrieveByAttr(FrmReportFieldAttr.FK_MapData, this.FK_MapData); foreach (FrmReportField item in frmReportFields) { TextBox tb = this.Pub1.GetTextBoxByID("TB_" + item.KeyOfEn); item.Name = tb.Text; tb = this.Pub1.GetTextBoxByID("TB_" + item.KeyOfEn + "_width"); item.UIWidth = tb.Text; tb = this.Pub1.GetTextBoxByID("TB_" + item.KeyOfEn + "_Idx"); item.Idx = int.Parse(tb.Text); CheckBox cb = this.Pub1.GetCBByID("CB_" + item.KeyOfEn); item.UIVisible = cb.Checked ? false : true; item.Update(); } this.Response.Redirect("Frm_ColsLabel.aspx?FK_MapData=" + this.FK_MapData, true); }
protected void Page_Load(object sender, EventArgs e) { this.Pub1.AddTable("width=90% align=center"); this.Pub1.AddCaptionLeft("请选择要显示的字段,然后点保存按钮."); MapAttrs mattrs = new MapAttrs(); QueryObject qo = new QueryObject(mattrs); qo.AddWhere(MapAttrAttr.FK_MapData, this.FK_MapData); qo.addOrderBy(MapAttrAttr.X, MapAttrAttr.Y); qo.DoQuery(); //已设置 FrmReportFields reportFields = new FrmReportFields(); reportFields.RetrieveByAttr(FrmReportFieldAttr.FK_MapData, FK_MapData); int cols = 4; //定义显示列数 从0开始。 int idx = -1; bool is1 = false; foreach (MapAttr attr in mattrs) { idx++; if (idx == 0) { is1 = this.Pub1.AddTR(is1); } CheckBox cb = new CheckBox(); cb.ID = "CB_" + attr.KeyOfEn; cb.Text = attr.Name + "(" + attr.KeyOfEn + ")"; cb.Checked = reportFields.Contains(FrmReportFieldAttr.KeyOfEn, attr.KeyOfEn); this.Pub1.AddTD(cb); if (idx == cols - 1) { idx = -1; this.Pub1.AddTREnd(); } } while (idx != -1) { idx++; if (idx == cols - 1) { idx = -1; this.Pub1.AddTD(); this.Pub1.AddTREnd(); } else { this.Pub1.AddTD(); } } CheckBox cbAll = new CheckBox(); cbAll.ID = "CB_CheckedAll"; cbAll.Text = "全选"; cbAll.AutoPostBack = true; cbAll.Checked = IsChecked == "true" ? true : false; cbAll.CheckedChanged += new EventHandler(cbAll_CheckedChanged); this.Pub1.AddTR(); this.Pub1.AddTD("colspan=4", cbAll); this.Pub1.AddTREnd(); this.Pub1.AddTableEnd(); }
/// <summary> /// 获取列表数据 /// </summary> /// <returns></returns> private string GetEnsGridData() { int totalRows = 0; //配置的列名 FrmReportFields rePortFields = new FrmReportFields(); QueryObject objFields = new QueryObject(rePortFields); objFields.AddWhere(FrmReportFieldAttr.FK_MapData, this.FK_MapData); objFields.addOrderBy(FrmReportFieldAttr.Idx); objFields.DoQuery(); if (rePortFields.Count == 0) { return(""); } //实体列名 Attrs mdAttrs = HisEns.GetNewEntity.EnMap.Attrs; //返回字符串 StringBuilder append = new StringBuilder(); append.Append("{"); //整理列名 append.Append("columns:["); foreach (FrmReportField field in rePortFields) { foreach (Attr mdAttr in mdAttrs) { if (field.KeyOfEn == mdAttr.Key) { if (field.UIVisible == false) { append.Append("{"); append.Append(string.Format("field:'{0}',title:'{1}',width:{2},hidden: true", field.KeyOfEn + "Text", field.Name, field.UIWidth)); append.Append("},"); continue; } if (mdAttr.IsRefAttr || mdAttr.IsFK || mdAttr.IsEnum) { append.Append("{"); append.Append(string.Format("field:'{0}',title:'{1}',width:{2},sortable:true", field.KeyOfEn + "Text", field.Name, field.UIWidth)); append.Append("},"); continue; } append.Append("{"); append.Append(string.Format("field:'{0}',title:'{1}',width:{2},sortable:true", mdAttr.Key, field.Name, field.UIWidth)); append.Append("},"); } } } if (append.Length > 10) { append = append.Remove(append.Length - 1, 1); } append.Append("]"); //整理数据 bool bHaveData = false; append.Append(",data:{rows:["); //获取数据 MapData md = new MapData(); md.No = this.FK_MapData; if (md.RetrieveFromDBSources() > 0) { //当前页 string pageNumber = getUTF8ToString("pageNumber"); int iPageNumber = string.IsNullOrEmpty(pageNumber) ? 1 : Convert.ToInt32(pageNumber); //每页多少行 string pageSize = getUTF8ToString("pageSize"); int iPageSize = string.IsNullOrEmpty(pageSize) ? 9999 : Convert.ToInt32(pageSize); QueryObject obj = new QueryObject(HisEns); obj = this.ToolBar1.GetnQueryObject(HisEns, HisEns.GetNewEntity); totalRows = obj.GetCount(); //查询 obj.DoQuery(HisEns.GetNewEntity.PK, iPageSize, iPageNumber); foreach (Entity en in HisEns) { bHaveData = true; append.Append("{"); foreach (Attr attr in mdAttrs) { if (attr.IsRefAttr || attr.IsFK || attr.IsEnum) { append.Append(attr.Key + "Text:'" + en.GetValRefTextByKey(attr.Key) + "',"); continue; } append.Append(attr.Key + ":'" + en.GetValStrByKey(attr.Key) + "',"); } append = append.Remove(append.Length - 1, 1); append.Append("},"); } } if (append.Length > 11 && bHaveData) { append = append.Remove(append.Length - 1, 1); } append.Append("],total:" + totalRows + "}"); append.Append("}"); return(ReplaceIllgalChart(append.ToString())); }