public void BindAttrs(Attrs attrs) { //this.HisEn =en; bool isReadonly = false; this.IsReadonly = false; this.IsShowDtl = false; this.Attributes["visibility"] = "hidden"; this.Add("<table width='100%' id='a1' border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' >"); bool isLeft = true; object val = null; bool isAddTR = true; foreach (Attr attr in attrs) { if (attr.UIVisible == false) { continue; } if (attr.Key == "MyNum") { continue; } if (isLeft) { isAddTR = true; this.AddTR(); } val = attr.DefaultVal; if (attr.UIContralType == UIContralType.TB) { if (attr.MyFieldType == FieldType.RefText) { this.SetValByKey(attr.Key, val.ToString()); continue; } else if (attr.MyFieldType == FieldType.MultiValues) { /* 如果是多值的.*/ LB lb = new LB(attr); lb.Visible = true; lb.Height = 128; lb.SelectionMode = ListSelectionMode.Multiple; Entities ens = ClassFactory.GetEns(attr.UIBindKey); ens.RetrieveAll(); this.Controls.Add(lb); } else { if (attr.UIVisible == false) { //不可见控件 TB tb = new TB(); tb.LoadMapAttr(attr); tb.ID = "TB_" + attr.Key; tb.Attributes["Visible"] = "false"; this.Controls.Add(tb); continue; } else { if (attr.UIHeight != 0) { TB area = new TB(); area.LoadMapAttr(attr); area.ID = "TB_" + attr.Key; area.Text = val.ToString(); area.Rows = 8; area.TextMode = TextBoxMode.MultiLine; area.Attributes["onchange"] += "Change('TB_" + attr.Key + "');"; if (isReadonly) { area.Enabled = false; } this.AddContral(attr.Desc, area); } else { TB tb = new TB(); tb.LoadMapAttr(attr); tb.ID = "TB_" + attr.Key; if (isReadonly) { tb.Enabled = false; } switch (attr.MyDataType) { case DataType.AppMoney: tb.Text = decimal.Parse(val.ToString()).ToString("0.00"); break; default: tb.Text = val.ToString(); break; } tb.Attributes["width"] = "100%"; tb.Attributes["onchange"] += "Change('TB_" + attr.Key + "');"; this.AddContral(attr.Desc, tb); } } } } else if (attr.UIContralType == UIContralType.CheckBok) { CheckBox cb = new CheckBox(); if (attr.DefaultVal.ToString() == "1") { cb.Checked = true; } else { cb.Checked = false; } if (isReadonly) { cb.Enabled = false; } else { cb.Enabled = attr.UIVisible; } cb.ID = "CB_" + attr.Key; cb.Attributes["onmousedown"] = "Change('CB_" + attr.Key + "')"; this.AddContral(attr.Desc, cb); } else if (attr.UIContralType == UIContralType.DDL) { if (isReadonly || !attr.UIIsReadonly) { /* 如果是 DDLIsEnable 的, 就要找到. */ if (attr.MyFieldType == FieldType.Enum) { /* 如果是 enum 类型 */ int enumKey = 0; try { enumKey = int.Parse(val.ToString()); } catch { throw new Exception("默认值错误:" + attr.Key + " = " + val.ToString()); } BP.Sys.SysEnum enEnum = new BP.Sys.SysEnum(attr.UIBindKey, "CH", enumKey); //DDL ddl = new DDL(attr,text,en.Lab,false); DDL ddl = new DDL(); ddl.Items.Add(new ListItem(enEnum.Lab, val.ToString())); ddl.Items[0].Selected = true; ddl.Enabled = false; ddl.ID = "DDL_" + attr.Key; this.AddContral(attr.Desc, ddl, true); } else { /* 如果是 ens 类型 */ Entities ens = ClassFactory.GetEns(attr.UIBindKey); Entity en1 = ens.GetNewEntity; en1.SetValByKey(attr.UIRefKeyValue, val.ToString()); string lab = ""; try { en1.Retrieve(); lab = en1.GetValStringByKey(attr.UIRefKeyText); } catch { if (SystemConfig.IsDebug == false) { lab = "" + val.ToString(); } else { lab = "" + val.ToString(); } } DDL ddl = new DDL(attr, val.ToString(), lab, false, this.Page.Request.ApplicationPath); ddl.ID = "DDL_" + attr.Key; this.AddContral(attr.Desc, ddl, true); } } else { /* 可以使用的情况. */ DDL ddl1 = new DDL(attr, val.ToString(), "enumLab", true, this.Page.Request.ApplicationPath); ddl1.ID = "DDL_" + attr.Key; ddl1.Attributes["onchange"] = "Change('DDL_" + attr.Key + "')"; this.AddContral(attr.Desc, ddl1, true); } } else if (attr.UIContralType == UIContralType.RadioBtn) { // Sys.SysEnums enums = new BP.Sys.SysEnums(attr.UIBindKey); // foreach(SysEnum en in enums) // { // return ; // } } if (isLeft == false) { isAddTR = false; this.AddTREnd(); } isLeft = !isLeft; } // 结束循环. //补充TR if (isAddTR == true) { this.AddTD(""); this.AddTD(""); this.AddTREnd(); } this.Add("</TABLE>"); }
public void Bind() { #region 生成标题 Entity en = this.HisEn; Map map = this.HisEn.EnMap; Attrs attrs = map.Attrs; bool isFJ = false; if (attrs.Contains("MyFileName")) { isFJ = true; } this.ucsys1.AddTable(); this.ucsys1.AddTR(); this.ucsys1.AddTDTitle(); string str1 = "<INPUT id='checkedAll' onclick='SelectAll(this);' type='checkbox' name='checkedAll'>"; this.ucsys1.AddTDTitle(str1); foreach (Attr attr in attrs) { if (attr.UIVisible == false) { continue; } this.ucsys1.AddTDTitle(attr.Desc); } if (isFJ) { this.ucsys1.AddTDTitle(); } this.ucsys1.AddTREnd(); #endregion 生成标题 this.Page.Title = en.EnDesc; Entities dtls = this.HisEns; QueryObject qo = new QueryObject(dtls); qo.AddWhere(this.RefKey, this.RefVal); #region 生成翻页 this.ucsys2.Clear(); try { this.ucsys2.BindPageIdx(qo.GetCount(), BP.SystemConfig.PageSize, this.PageIdx, "Dtl.aspx?EnName=" + this.EnName + "&PK=" + this.RefVal + "&EnsName=" + this.EnsName + "&RefVal=" + this.RefVal + "&RefKey=" + this.RefKey + "&MainEnsName=" + this.MainEnsName); qo.DoQuery(en.PK, this.PageSize, this.PageIdx, false); } catch { dtls.GetNewEntity.CheckPhysicsTable(); // this.Response.Redirect("Ens.aspx?EnsName=" + this.EnsName + "&RefPKVal=" + this.RefPKVal, true); return; } #endregion 生成翻页 UAC uac = en.HisUAC; if (uac.IsDelete == false) { this.ToolBar1.GetBtnByID(NamesOfBtn.Delete).Enabled = false; } if (uac.IsInsert) { en.PKVal = "0"; dtls.AddEntity(en); } DDL ddl = new DDL(); CheckBox cb = new CheckBox(); bool is1 = false; #region 生成数据 int i = 0; foreach (Entity dtl in dtls) { i++; if (dtl.PKVal == "0" || dtl.PKVal == "") { this.ucsys1.AddTRSum(); this.ucsys1.AddTD("colspan=2", "<b>*</B>"); } else { // is1 = this.ucsys1.AddTR(is1, "ondblclick=\"WinOpen( 'UIEn.aspx?EnsName=" + this.EnsName + "&PK=" + dtl.PKVal + "', 'cd' )\""); is1 = this.ucsys1.AddTR(is1); // is1 = this.ucsys1.AddTR(is1); this.ucsys1.AddTDIdx(i); cb = new CheckBox(); cb.ID = "CB_" + dtl.PKVal; this.ucsys1.AddTD(cb); } foreach (Attr attr in attrs) { if (attr.UIVisible == false) { continue; } if (attr.Key == "OID") { continue; } string val = dtl.GetValByKey(attr.Key).ToString(); switch (attr.UIContralType) { case UIContralType.TB: TB tb = new TB(); this.ucsys1.AddTD(tb); tb.LoadMapAttr(attr); tb.ID = "TB_" + attr.Key + "_" + dtl.PKVal; tb.Attributes["style"] = "width:" + attr.UIWidth + "px;border-width:0px;"; switch (attr.MyDataType) { case DataType.AppMoney: case DataType.AppRate: tb.TextExtMoney = decimal.Parse(val); break; case DataType.AppDate: tb.Text = val.ToString(); tb.ShowType = TBType.Date; if (attr.UIIsReadonly == false) { tb.Attributes["onfocus"] = "WdatePicker();"; } break; case DataType.AppDateTime: tb.Text = val.ToString(); tb.ShowType = TBType.DateTime; if (attr.UIIsReadonly == false) { tb.Attributes["onfocus"] = "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"; } break; default: tb.Text = val; break; } if (attr.IsNum && attr.IsFKorEnum == false) { if (tb.Enabled) { // OnKeyPress="javascript:return VirtyNum(this);" // tb.Attributes["OnKeyDown"] = "javascript:return VirtyNum(this);"; // tb.Attributes["onkeyup"] += "javascript:C" + dtl.PKVal + "();C" + attr.Key + "();"; tb.Attributes["class"] = "TBNum"; } else { // tb.Attributes["onpropertychange"] += "C" + attr.Key + "();"; tb.Attributes["class"] = "TBNumReadonly"; } } break; case UIContralType.DDL: ddl = new DDL(); ddl.ID = "DDL_" + attr.Key + "_" + dtl.PKVal; if (attr.UIIsReadonly == false) { ddl.Items.Add(new ListItem(dtl.GetValRefTextByKey(attr.Key), val)); ddl.Enabled = false; } else { if (attr.IsEnum) { ddl.BindSysEnum(attr.UIBindKey); } else { ddl.BindEntities(attr.HisFKEns, attr.UIRefKeyValue, attr.UIRefKeyText); } } this.ucsys1.AddTD(ddl); ddl.SetSelectItem(val); break; case UIContralType.CheckBok: cb = new CheckBox(); cb.ID = "CB_" + attr.Key + "_" + dtl.PKVal; cb.Text = attr.Desc; if (val == "1") { cb.Checked = true; } else { cb.Checked = false; } this.ucsys1.AddTD("nowarp=true", cb); break; default: break; } } if (isFJ) { string ext = dtl.GetValStrByKey("MyFileExt"); if (ext != "") { this.ucsys1.AddTD("<img src='../Images/FileType/" + ext + ".gif' border=0/>" + dtl.GetValStrByKey("MyFileName")); } } this.ucsys1.AddTREnd(); } #region 生成合计 //this.ucsys1.AddTRSum(); //this.ucsys1.AddTD("colspan=2", "合计"); //foreach (Attr attr in attrs) //{ // if (attr.UIVisible == false) // continue; // if (attr.IsNum && attr.IsFKorEnum == false) // { // TB tb = new TB(); // tb.ID = "TB_" + attr.Key; // tb.Text = attr.DefaultVal.ToString(); // tb.ShowType = attr.HisTBType; // tb.ReadOnly = true; // tb.Font.Bold = true; // tb.BackColor = System.Drawing.Color.FromName("infobackground"); // switch (attr.MyDataType) // { // case DataType.AppRate: // case DataType.AppMoney: // tb.TextExtMoney = dtls.GetSumDecimalByKey(attr.Key); // break; // case DataType.AppInt: // tb.TextExtInt = dtls.GetSumIntByKey(attr.Key); // break; // case DataType.AppFloat: // tb.TextExtFloat = dtls.GetSumFloatByKey(attr.Key); // break; // default: // break; // } // this.ucsys1.AddTD(tb); // } // else // { // this.ucsys1.AddTD(); // } //} //this.ucsys1.AddTD(); //this.ucsys1.AddTREnd(); #endregion 生成合计 #endregion 生成数据 this.ucsys1.AddTableEnd(); }
public void Bind() { #region 生成标题 Entity en = this.HisEn; Map map = this.HisEn.EnMap; EnCfg cfg = new EnCfg(en.ToString()); UIConfig uicfg = new UIConfig(en); Attrs attrs = map.Attrs; if (attrs.Count >= 4) { this.ucsys1.Add("<table border=0 cellpadding='0' style='border-collapse: collapse;width:100%' cellspacing='0' >"); } else { this.ucsys1.Add("<table border=0 cellpadding='0' style='border-collapse: collapse;width:50%' cellspacing='0' >"); } this.ucsys1.AddTR(); CheckBox cb = new CheckBox(); string str1 = "<INPUT id='checkedAll' onclick='SelectAll()' type='checkbox' name='checkedAll'>"; this.ucsys1.AddTDGroupTitle(str1); foreach (Attr attr in attrs) { if (attr.UIVisible == false) { continue; } this.ucsys1.AddTDGroupTitle(attr.Desc); } if (map.IsHaveFJ) { this.ucsys1.AddTDGroupTitle("附件"); } this.ucsys1.AddTDGroupTitle(); this.ucsys1.AddTREnd(); #endregion 生成标题 this.Title = en.EnDesc; Entities ens = this.HisEns; QueryObject qo = new QueryObject(ens); #region 用户界面属性设置- del //BP.Web.Comm.UIRowStyleGlo tableStyle = (UIRowStyleGlo)ens.GetEnsAppCfgByKeyInt("UIRowStyleGlo"); // 界面风格。 //bool IsEnableDouclickGlo = ens.GetEnsAppCfgByKeyBoolen("IsEnableDouclickGlo"); // 是否启用双击 //bool IsEnableRefFunc = ens.GetEnsAppCfgByKeyBoolen("IsEnableRefFunc"); // 是否显示相关功能。 //bool IsEnableFocusField = ens.GetEnsAppCfgByKeyBoolen("IsEnableFocusField"); //是否启用焦点字段。 //bool isShowOpenICON = ens.GetEnsAppCfgByKeyBoolen("IsEnableOpenICON"); //是否启用 OpenICON 。 //string FocusField = null; //if (IsEnableFocusField) // FocusField = ens.GetEnsAppCfgByKeyString("FocusField"); //int WinCardH = ens.GetEnsAppCfgByKeyInt("WinCardH"); // 弹出窗口高度 //int WinCardW = ens.GetEnsAppCfgByKeyInt("WinCardW"); // 弹出窗口宽度. #endregion 用户界面属性设置 #region 生成翻页 try { this.ucsys2.Clear(); this.ucsys2.BindPageIdx(qo.GetCount(), BP.Sys.SystemConfig.PageSize, this.PageIdx, "Ens.aspx?EnsName=" + this.EnsName); qo.DoQuery(en.PK, BP.Sys.SystemConfig.PageSize, this.PageIdx, false); } catch (Exception ex) { //自动创建表. Log.DebugWriteInfo(ex.Message); ens.GetNewEntity.CheckPhysicsTable(); return; } #endregion 生成翻页 en.PKVal = "0"; ens.AddEntity(en); DDL ddl = new DDL(); bool is1 = false; #region 生成数据 int i = 0; foreach (Entity dtl in ens) { string urlExt = "\"javascript:ShowEn('./RefFunc/UIEn.aspx?EnsName=" + ens.ToString() + "&PK=" + dtl.PKVal + "', 'cd');\""; i++; if (Equals(dtl.PKVal, "0")) { this.ucsys1.AddTRSum(); this.ucsys1.AddTDIdx("<b>*</b>"); } else { is1 = this.ucsys1.AddTR(is1, "ondblclick=" + urlExt); cb = new CheckBox(); cb.ID = "IDX_" + dtl.PKVal; cb.Text = i.ToString(); this.ucsys1.AddTDIdx(cb); } foreach (Attr attr in attrs) { if (attr.UIVisible == false) { continue; } if (attr.Key == "OID") { continue; } string val = dtl.GetValByKey(attr.Key).ToString(); switch (attr.UIContralType) { case UIContralType.TB: TB tb = new TB(); tb.LoadMapAttr(attr); this.ucsys1.AddTD(tb); tb.ID = "TB_" + attr.Key + "_" + dtl.PKVal; switch (attr.MyDataType) { case DataType.AppMoney: case DataType.AppRate: tb.TextExtMoney = decimal.Parse(val); break; default: tb.Text = val; break; } if (attr.IsNum && attr.IsFKorEnum == false) { if (tb.Enabled) { // OnKeyPress="javascript:return VirtyNum(this);" // tb.Attributes["OnKeyDown"] = "javascript:return VirtyNum(this);"; // tb.Attributes["onkeyup"] += "javascript:C" + dtl.PKVal + "();C" + attr.Key + "();"; tb.Attributes["class"] = "TBNum"; } else { // tb.Attributes["onpropertychange"] += "C" + attr.Key + "();"; tb.Attributes["class"] = "TBNumReadonly"; } } break; case UIContralType.DDL: if (attr.UIIsReadonly) { ddl = new DDL(); ddl.LoadMapAttr(attr); ddl.ID = "DDL_" + attr.Key + "_" + dtl.PKVal; // this.ucsys1.AddTD(ddl); this.ucsys1.AddTD(ddl); ddl.SetSelectItem(val); } else { this.ucsys1.AddTD(dtl.GetValRefTextByKey(attr.Key)); } break; case UIContralType.CheckBok: cb = new CheckBox(); cb.ID = "CB_" + attr.Key + "_" + dtl.PKVal; //cb.Text = attr.Name; if (val == "1") { cb.Checked = true; } else { cb.Checked = false; } this.ucsys1.AddTDCenter(cb); break; default: break; } } if (map.IsHaveFJ) { string ext = dtl.GetValStrByKey("MyFileExt"); if (ext == null || ext.Length > 1) { this.ucsys1.AddTD("<a href='" + cfg.FJWebPath + "/" + dtl.PKVal + "." + ext + "' target=_blank ><img src='../Images/FileType/" + dtl.GetValStrByKey("MyFileExt") + ".gif' border=0/>" + dtl.GetValStrByKey("MyFileName") + "</a>"); } else { this.ucsys1.AddTD(); } } if (uicfg.IsEnableOpenICON) { this.ucsys1.Add("<TD class='TD' style='cursor:hand;' nowrap=true><a href=" + urlExt + " ><img src='../Img/Btn/Open.gif' border=0/></a></TD>"); } else { this.ucsys1.AddTD(); } this.ucsys1.AddTREnd(); } #region 生成合计,屏蔽 //if (false) //{ // this.ucsys1.AddTRSum(); // this.ucsys1.AddTD("colspan=1", "合计"); // foreach (Attr attr in attrs) // { // if (attr.UIVisible == false) // continue; // if (attr.IsNum && attr.IsFKorEnum == false) // { // TB tb = new TB(); // tb.ID = "TB_" + attr.Key; // tb.Text = attr.DefaultVal.ToString(); // tb.ShowType = attr.HisTBType; // tb.ReadOnly = true; // tb.Font.Bold = true; // tb.BackColor = System.Drawing.Color.FromName("#FFFFFF"); // switch (attr.MyDataType) // { // case DataType.AppRate: // case DataType.AppMoney: // tb.TextExtMoney = ens.GetSumDecimalByKey(attr.Key); // break; // case DataType.AppInt: // tb.TextExtInt = ens.GetSumIntByKey(attr.Key); // break; // case DataType.AppFloat: // tb.TextExtFloat = ens.GetSumFloatByKey(attr.Key); // break; // default: // break; // } // this.ucsys1.AddTD(tb); // } // else // { // this.ucsys1.AddTD(); // } // } // if (map.IsHaveFJ) // this.ucsys1.AddTD(); // this.ucsys1.AddTD(); // this.ucsys1.AddTREnd(); //} #endregion 生成合计 #endregion 生成数据 this.ucsys1.AddTableEnd(); }