public string Imp_Src_Step3_Init() { DataSet ds = new DataSet(); string SColumns = this.GetRequestVal("SColumns"); SFDBSrc src = new SFDBSrc(this.GetRequestVal("FK_SFDBSrc")); DataTable tableColumns = src.GetColumns(this.GetRequestVal("STable")); //01.添加列 DataTable dt = tableColumns.Clone(); foreach (DataRow dr in tableColumns.Rows) { if (SColumns.Contains(dr["no"].ToString())) { dt.ImportRow(dr); } } dt.TableName = "Columns"; ds.Tables.Add(dt); //02.添加枚举 SysEnums ens = new SysEnums(MapAttrAttr.MyDataType); ds.Tables.Add(ens.ToDataTableField("EnumsDataType")); ens = new SysEnums(MapAttrAttr.LGType); ds.Tables.Add(ens.ToDataTableField("EnumsLGType")); return(BP.Tools.Json.ToJson(ds)); }
public string DTSBTableExt_Init() { //定义数据容器. DataSet ds = new DataSet(); //获得数据表列. SFDBSrc src = new SFDBSrc(this.GetRequestVal("FK_DBSrc")); DataTable dtColms = src.GetColumns(this.GetRequestVal("TableName")); dtColms.TableName = "Cols"; if (SystemConfig.AppCenterDBType == DBType.Oracle || SystemConfig.AppCenterDBType == DBType.PostgreSQL) { dtColms.Columns["NO"].ColumnName = "No"; dtColms.Columns["NAME"].ColumnName = "Name"; } ds.Tables.Add(dtColms); //属性列表. MapAttrs attrs = new MapAttrs("ND" + int.Parse(this.FK_Flow) + "Rpt"); DataTable dtAttrs = attrs.ToDataTableStringField("Sys_MapAttr"); ds.Tables.Add(dtAttrs); //转化成json,返回. return(BP.Tools.Json.DataSetToJson(ds, false)); }
public string SF2_GetCols() { string src = this.GetRequestVal("src"); string table = this.GetRequestVal("table"); if (string.IsNullOrWhiteSpace(src)) { throw new Exception("err@参数不正确"); } if (string.IsNullOrWhiteSpace(table)) { return("[]"); } SFDBSrc sr = new SFDBSrc(src); DataTable dt = sr.GetColumns(table); foreach (DataRow r in dt.Rows) { r["Name"] = r["No"] + (r["Name"] == null || r["Name"] == DBNull.Value || string.IsNullOrWhiteSpace(r["Name"].ToString()) ? "" : string.Format("[{0}]", r["Name"])); } return(BP.Tools.Json.ToJson(dt)); }
/// <summary> /// 获取表字段 /// </summary> /// <returns></returns> public string Imp_Src_Step2_GetColumns() { DataSet ds = new DataSet(); //01.当前节点表单已经存在的列 MapAttrs attrs = new MapAttrs(this.FK_MapData); ds.Tables.Add(attrs.ToDataTableField("MapAttrs")); //02.数据源表中的列 SFDBSrc src = new SFDBSrc(this.GetRequestVal("FK_SFDBSrc")); DataTable tableColumns = src.GetColumns(this.GetRequestVal("STable")); tableColumns.TableName = "TableColumns"; ds.Tables.Add(tableColumns); return(BP.Tools.Json.ToJson(ds)); }
protected void Page_Load(object sender, EventArgs e) { //this.Response.Redirect("ImpTableField1504.aspx?EnsName=" + this.FK_MapData, // true); //return; #region 第1步. if (this.Step == 1) { BP.Sys.SFDBSrcs ens = new BP.Sys.SFDBSrcs(); ens.RetrieveAll(); Pub1.AddTable("class='Table' cellSpacing='0' cellPadding='0' border='0' style='width:100%'"); Pub1.AddTR(); Pub1.AddTDGroupTitle("", "第1步:请选择数据源"); Pub1.AddTREnd(); Pub1.AddTR(); Pub1.AddTDBegin(); Pub1.AddUL("class='navlist'"); foreach (BP.Sys.SFDBSrc item in ens) { Pub1.AddLi("<div><a href='ImpTableField.aspx?Step=2&FK_MapData=" + this.FK_MapData + "&FK_SFDBSrc=" + item.No + "'><span class='nav'>" + item.No + " - " + item.Name + "</span></a></div>"); } Pub1.AddLi("<div><a href=\"javascript:WinOpen('/WF/Comm/RefFunc/UIEn.aspx?EnsName=BP.Sys.SFDBSrcs')\" ><img src='../Img/New.gif' align='middle' /><span class='nav'>新建数据源</span></a></div>"); Pub1.AddULEnd(); Pub1.AddTDEnd(); Pub1.AddTREnd(); Pub1.AddTableEnd(); } #endregion 第1步. #region 第2步. if (this.Step == 2) { SFDBSrc src = new SFDBSrc(this.FK_SFDBSrc); this.Pub1.Add("<div class='easyui-layout' data-options=\"fit:true\">"); this.Pub1.Add(string.Format("<div data-options=\"region:'west',split:true,title:'选择 {0} 数据表/视图'\" style='width:200px;'>", src.DBName)); DataTable dt = src.GetTables(); this.Pub1.AddUL(); foreach (DataRow dr in dt.Rows) { string url = "?Step=" + this.Step + "&FK_MapData=" + this.FK_MapData + "&FK_SFDBSrc=" + this.FK_SFDBSrc + "&STable=" + dr["No"].ToString(); if (dr["No"].ToString() == this.STable) { this.Pub1.Add("<li><font color=red><b>" + dr["Name"] + "</font></b></li>"); } else { this.Pub1.Add("<li><a href='" + url + "' >" + dr["Name"] + "</a></li>"); } } this.Pub1.AddULEnd(); Pub1.AddDivEnd(); this.Pub1.Add("<div data-options=\"region:'center',title:'第2步:请选择要导入的数据列(" + this.STable + ")'\" style='padding:5px;'>"); //加载选中数据表/视图的列信息 this.Pub1.AddTable(); // ("id='maintable' class='Table' cellSpacing='0' cellPadding='0' border='0' style='width:100%'"); this.Pub1.AddTR(); var cb = new CheckBox(); cb.ID = "CB_CheckAll"; cb.Attributes["onclick"] = "CheckAll(this.checked)"; this.Pub1.AddTDGroupTitle("style='width:40px;text-align:center'", cb); this.Pub1.AddTDGroupTitle("序"); this.Pub1.AddTDGroupTitle("字段名"); this.Pub1.AddTDGroupTitle("中文描述"); this.Pub1.AddTDGroupTitle("style='width:80px;text-align:center'", "类型"); this.Pub1.AddTDGroupTitle("style='width:50px;text-align:center'", "最大长度"); this.Pub1.AddTREnd(); MapAttrs attrs = new MapAttrs(this.FK_MapData); bool isHave = false; var tableColumns = src.GetColumns(this.STable); foreach (DataRow dr in tableColumns.Rows) { cb = new CheckBox(); cb.ID = "CB_Col_" + dr["name"]; cb.Checked = this.SColumns == null ? false : this.SColumns.Contains(dr["name"] + ","); //如果已经有该字段,就放弃. if (attrs.Contains(MapAttrAttr.KeyOfEn, dr["name"].ToString())) { continue; cb.Enabled = false; } this.Pub1.AddTR(); this.Pub1.AddTD(cb); this.Pub1.AddTD(dr["colid"].ToString()); this.Pub1.AddTD(dr["name"].ToString()); this.Pub1.AddTD(dr["Desc"].ToString()); this.Pub1.AddTD(dr["type"].ToString()); this.Pub1.AddTD(Convert.ToInt32(dr["length"])); this.Pub1.AddTREnd(); } this.Pub1.AddTableEnd(); this.Pub1.AddBR(); this.Pub1.AddBR(); this.Pub1.AddSpace(1); var btn = new LinkBtn(false, NamesOfBtn.Next, "下一步"); btn.Click += new EventHandler(btn_Click); this.Pub1.Add(btn); this.Pub1.AddSpace(1); this.Pub1.Add(string.Format("<a href='{0}?Step=1&FK_MapData={1}' class='easyui-linkbutton'>上一步</a>", Request.Url.AbsolutePath, this.FK_MapData)); this.Pub1.AddBR(); this.Pub1.AddBR(); this.Pub1.AddDivEnd(); this.Pub1.AddDivEnd(); } #endregion 第2步. #region 第3步. if (this.Step == 3) { SFDBSrc src = new SFDBSrc(this.FK_SFDBSrc); this.Pub1.AddTable(); // ("id='maintable' class='Table' cellSpacing='0' cellPadding='0' border='0' style='width:100%'"); this.Pub1.AddTDGroupTitle("序"); this.Pub1.AddTDGroupTitle("字段名"); this.Pub1.AddTDGroupTitle("中文描述"); this.Pub1.AddTDGroupTitle("数据类型"); this.Pub1.AddTDGroupTitle("逻辑类型"); this.Pub1.AddTDGroupTitle("绑定值(双击选择)"); this.Pub1.AddTDGroupTitle("最大长度"); this.Pub1.AddTDGroupTitle("顺序"); this.Pub1.AddTREnd(); var tableColumns = src.GetColumns(this.STable); var idx = 0; foreach (DataRow dr in tableColumns.Rows) { if (this.SColumns.Contains(dr["name"] + ",") == false) { continue; } string typeString = dr["type"].ToString().ToLower(); int mydatatype = 1; if (typeString.Contains("int")) { mydatatype = BP.DA.DataType.AppInt; } if (typeString.Contains("float")) { mydatatype = BP.DA.DataType.AppFloat; } if (typeString.Contains("double")) { mydatatype = BP.DA.DataType.AppDouble; } idx++; this.Pub1.AddTR(); this.Pub1.AddTDIdx(idx); this.Pub1.AddTD(dr["name"].ToString()); //中文描述. var tb = new TB(); tb.ID = "TB_Desc_" + dr["name"]; tb.Columns = 20; tb.Text = dr["Desc"].ToString(); if (tb.Text.Length == 0) { tb.Text = dr["name"].ToString(); } this.Pub1.AddTD(tb); //数据类型. var ddl = new DDL(); ddl.ID = "DDL_DBType_" + dr["name"]; ddl.SelfBindSysEnum(MapAttrAttr.MyDataType); ddl.SetSelectItem(mydatatype); //设置选择的项目. this.Pub1.AddTD(ddl); //逻辑类型. ddl = new DDL(); ddl.ID = "DDL_LogicType_" + dr["name"]; ddl.SelfBindSysEnum(MapAttrAttr.LGType); this.Pub1.AddTD(ddl); //绑定的逻辑类型. tb = new TB(); tb.ID = "TB_BindKey_" + dr["name"]; tb.Columns = 30; tb.Text = dr["name"].ToString(); tb.Attributes["ondblclick"] = "OpenSelectBindKey(this)"; this.Pub1.AddTD(tb); //最大长度. //绑定的逻辑类型. tb = new TB(); tb.ID = "TB_Len_" + dr["name"]; tb.Columns = 5; tb.Text = dr["length"].ToString(); this.Pub1.AddTD(tb); this.Pub1.AddTDBegin("style='text-align:center'"); var hiddenIdx = new HiddenField(); hiddenIdx.ID = "HID_Idx_" + dr["name"]; hiddenIdx.Value = idx.ToString(); this.Pub1.Add(hiddenIdx); this.Pub1.Add("<a href='javascript:void(0)' onclick='up(this, 6)' class='easyui-linkbutton' data-options=\"iconCls:'icon-up'\"></a> "); this.Pub1.Add("<a href='javascript:void(0)' onclick='down(this, 6)' class='easyui-linkbutton' data-options=\"iconCls:'icon-down'\"></a>"); this.Pub1.AddTDEnd(); this.Pub1.AddTREnd(); } this.Pub1.AddTableEnd(); this.Pub1.AddBR(); this.Pub1.AddBR(); this.Pub1.AddSpace(1); var btn = new LinkBtn(false, NamesOfBtn.Save, "导入字段,生成表单"); btn.Click += new EventHandler(btn_Save_Click); this.Pub1.Add(btn); this.Pub1.AddSpace(1); this.Pub1.Add(string.Format("<a href='{0}' class='easyui-linkbutton'>上一步</a>", Request.Url.ToString().Replace("Step=3", "Step=2"))); this.Pub1.AddBR(); this.Pub1.AddBR(); } #endregion 第3步. }
/// <summary> /// 与业务表数据同步 /// </summary> /// <returns></returns> public string DTSBTable_Save() { Flow flow = new Flow(this.FK_Flow); BP.WF.Template.FlowDTSWay dtsWay = (BP.WF.Template.FlowDTSWay) this.GetRequestValInt("RB_DTSWay"); flow.DTSWay = dtsWay; if (flow.DTSWay == FlowDTSWay.None) { flow.Update(); return("保存成功."); } flow.DTSDBSrc = this.GetRequestVal("DDL_DBSrc"); flow.DTSBTable = this.GetRequestVal("DDL_Table"); DTSField field = (DTSField)this.GetRequestValInt("DTSField"); if (field == 0) { field = DTSField.SameNames; } flow.DTSField = field; SFDBSrc s = new SFDBSrc("local"); if (field == DTSField.SameNames) { DataTable dt = s.GetColumns(flow.PTable); s = new SFDBSrc(flow.DTSDBSrc); // this.src); DataTable ywDt = s.GetColumns(flow.DTSBTable); // this.ywTableName); string str = ""; string ywStr = ""; foreach (DataRow ywDr in ywDt.Rows) { foreach (DataRow dr in dt.Rows) { if (ywDr["No"].ToString().ToUpper() == dr["No"].ToString().ToUpper()) { if (dr["No"].ToString().ToUpper() == "OID") { flow.DTSBTablePK = "OID"; } str += dr["No"].ToString() + ","; ywStr += ywDr["No"].ToString() + ","; } } } if (!DataType.IsNullOrEmpty(str)) { flow.DTSFields = str.TrimEnd(',') + "@" + ywStr.TrimEnd(','); } else { PubClass.Alert("未检测到业务主表【" + flow.PTable + "】与表【" + flow.DTSBTable + "】有相同的字段名."); return("");//不执行保存 } } else//按设置的字段匹配 检查在 { try { s = new SFDBSrc("local"); string str = flow.DTSFields; string[] arr = str.Split('@'); string sql = "SELECT " + arr[0] + " FROM " + flow.PTable; s.RunSQL(sql); s = new SFDBSrc(flow.DTSDBSrc); sql = "SELECT " + arr[1] + ", " + flow.DTSBTablePK + " FROM " + flow.DTSBTable; s.RunSQL(sql); } catch { //PubClass.Alert(ex.Message); PubClass.Alert("设置的字段有误.【" + flow.DTSFields + "】"); return("");//不执行保存 } } flow.Update(); return(flow.ToJson()); }
/// <summary> /// 保存数据同步 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnSave_Click(object sender, EventArgs e) { Flow flow = new Flow(this.FK_Flow); #region 步 if (this.RB_DTSWay0.Checked) { flow.DTSWay = FlowDTSWay.None; } #endregion #region 步 if (this.RB_DTSWay1.Checked) { flow.DTSDBSrc = this.DDL_DBSrc.SelectedValue; flow.DTSBTable = this.DDL_Table.SelectedValue; DTSField field = DTSField.SameNames; if (this.RB_DTSField1.Checked) { field = DTSField.SpecField; } flow.DTSField = field; FlowDTSTime time = FlowDTSTime.AllNodeSend; if (this.RB_DTSTime1.Checked) { time = FlowDTSTime.SpecNodeSend; } if (this.RB_DTSTime2.Checked) { time = FlowDTSTime.WhenFlowOver; } if (time == FlowDTSTime.SpecNodeSend) { string specNodes = this.HiddenField.Value.TrimEnd(','); if (string.IsNullOrEmpty(specNodes)) { PubClass.Alert("没有设置要同步的节点"); return; } else { flow.DTSSpecNodes = specNodes.TrimEnd(','); } } flow.DTSTime = time; flow.DTSWay = FlowDTSWay.Syn; #region 字段名相同 SFDBSrc s = new SFDBSrc("local"); if (field == DTSField.SameNames) { DataTable dt = s.GetColumns(flow.PTable); s = new SFDBSrc(this.DDL_DBSrc.SelectedValue); // this.src); DataTable ywDt = s.GetColumns(this.DDL_Table.SelectedValue); // this.ywTableName); string str = ""; string ywStr = ""; foreach (DataRow ywDr in ywDt.Rows) { foreach (DataRow dr in dt.Rows) { if (ywDr["No"].ToString().ToUpper() == dr["No"].ToString().ToUpper()) { if (dr["No"].ToString().ToUpper() == "OID") { flow.DTSBTablePK = "OID"; } str += dr["No"].ToString() + ","; ywStr += ywDr["No"].ToString() + ","; } } } if (!string.IsNullOrEmpty(str)) { flow.DTSFields = str.TrimEnd(',') + "@" + ywStr.TrimEnd(','); } else { PubClass.Alert("未检测到业务主表【" + flow.PTable + "】与表【" + this.DDL_Table.SelectedValue + "】有相同的字段名."); return;//不执行保存 } } else//按设置的字段匹配 检查在 { try { s = new SFDBSrc("local"); string str = flow.DTSFields; string[] arr = str.Split('@'); string sql = "SELECT " + arr[0] + " FROM " + flow.PTable; s.RunSQL(sql); s = new SFDBSrc(this.DDL_DBSrc.SelectedValue); sql = "SELECT " + arr[1] + ", " + flow.DTSBTablePK + " FROM " + flow.DTSBTable; s.RunSQL(sql); } catch { //PubClass.Alert(ex.Message); PubClass.Alert("设置的字段有误.【" + flow.DTSFields + "】"); return;//不执行保存 } } #endregion } #endregion flow.Update(); }
/// <summary> /// 加载选中表的所有列信息 /// </summary> private void ShowSelectedTableColumns() { var src = new SFDBSrc(this.FK_SFDBSrc); var colTables = src.GetColumns(this.Pub1.GetLBByID("LB_Table").SelectedItemStringVal); colTables.Columns.Add("text", typeof(string)); var cols = new List <string>(); string type; var length = 0; foreach (DataRow dr in colTables.Rows) { cols.Add(dr["name"].ToString()); type = dr["type"].ToString().ToLower(); length = int.Parse(dr["length"].ToString()); dr["text"] = dr["name"] + " (" + (LengthTypes.Contains(type) ? (string.Format("{0}{1}", type, (length == -1 || length == 0) ? (MaxTypes.Contains(type) ? "(max)" : "") : string.Format("({0})", length))) : type) + ")"; } //自动判断是否符合规则 var regColValue = cols.FirstOrDefault(o => regs[0].Contains(o.ToLower())); var regColText = cols.FirstOrDefault(o => regs[1].Contains(o.ToLower())); var regColParentNo = cols.FirstOrDefault(o => regs[2].Contains(o.ToLower())); var ddl = this.Pub1.GetDDLByID("DDL_ColValue"); ddl.Items.Clear(); ddl.Bind(colTables, "name", "text"); if (regColValue != null) { ddl.SetSelectItem(regColValue); } ddl = this.Pub1.GetDDLByID("DDL_ColText"); ddl.Items.Clear(); ddl.Bind(colTables, "name", "text"); if (regColText != null) { ddl.SetSelectItem(regColText); } ddl = this.Pub1.GetDDLByID("DDL_ColParentNo"); ddl.Items.Clear(); ddl.Bind(colTables, "name", "text"); if (regColParentNo != null) { ddl.SetSelectItem(regColParentNo); } Pub1.GetTBByID("TB_SelectStatement").Text = string.Empty; Pub1.GetDDLByID("DDL_SFTableType").SetSelectItem((regColValue != null && regColText != null && regColParentNo != null) ? "1" : "0"); }
void btn_Create_Local_Click(object sender, EventArgs e) { SFTable table = new SFTable(); table = this.Pub1.Copy(table) as SFTable; table.FK_SFDBSrc = Request.QueryString["FK_SFDBSrc"]; table.SrcTable = table.No; table.ColumnText = "Name"; table.ColumnValue = "No"; table.IsTree = false; if (BP.DA.DBAccess.IsExitsObject(table.No)) { //判断已经存在的表是否符合NoName规则,如果符合,则自动加入到SFTable中 var src = new SFDBSrc(this.FK_SFDBSrc); var columns = src.GetColumns(table.No); var cols = new List <string>(); foreach (DataRow dr in columns.Rows) { cols.Add(dr["name"].ToString()); } var regColValue = cols.FirstOrDefault(o => regs[0].Contains(o.ToLower())); var regColText = cols.FirstOrDefault(o => regs[1].Contains(o.ToLower())); var regColParentNo = cols.FirstOrDefault(o => regs[2].Contains(o.ToLower())); if (regColValue != null && regColText != null && regColParentNo != null) { table.SFTableType = 1; table.IsTree = true; table.ColumnValue = regColValue; table.ColumnText = regColText; table.ParentValue = regColParentNo; table.FK_SFDBSrc = "local"; table.Save(); EasyUiHelper.AddEasyUiMessagerAndGo(this, "您所创建的“" + table.No + "” 名称的字典表,本地库已经存在,已成功注册!编辑数据……", "提示", "info", "../../MapDef/SFTableEditData.aspx?RefNo=" + table.No); } else if (regColValue != null && regColText != null) { table.SFTableType = 0; table.IsTree = false; table.ColumnValue = regColValue; table.ColumnText = regColText; table.ParentValue = null; table.FK_SFDBSrc = "local"; table.Save(); EasyUiHelper.AddEasyUiMessagerAndGo(this, "您所创建的“" + table.No + "” 名称的字典表,本地库已经存在,已成功注册!编辑数据……", "提示", "info", "../../MapDef/SFTableEditData.aspx?RefNo=" + table.No); } else { EasyUiHelper.AddEasyUiMessagerAndBack(this, "@对象(" + table.No + ")已经存在.", "错误", "error"); } return; } var sql = new StringBuilder(); sql.AppendLine(string.Format("CREATE TABLE dbo.{0}", table.No)); sql.AppendLine("("); sql.AppendLine("No NVARCHAR(50) NOT NULL PRIMARY KEY,"); sql.AppendLine("Name NVARCHAR(100) NULL"); sql.AppendLine(") "); BP.DA.DBAccess.RunSQL(sql.ToString()); sql.Clear(); sql.Append("INSERT INTO [dbo].[{0}] ([No], [Name]) VALUES ('0{1}', 'Item{1}')"); for (var i = 1; i < 4; i++) { BP.DA.DBAccess.RunSQL(string.Format(sql.ToString(), table.No, i)); } sql.Clear(); sql.AppendFormat( "EXECUTE sp_addextendedproperty N'MS_Description', N'{0}', N'SCHEMA', N'dbo', N'TABLE', N'{1}', NULL, NULL", table.Name, table.No); BP.DA.DBAccess.RunSQL(sql.ToString()); table.Save(); EasyUiHelper.AddEasyUiMessagerAndGo(this, "创建成功!编辑数据……", "提示", "info", "../../MapDef/SFTableEditData.aspx?RefNo=" + table.No); }
protected void Page_Load(object sender, EventArgs e) { string rpt = "ND" + int.Parse(this.FK_Flow) + "Rpt"; MapAttrs attrs = new MapAttrs(rpt); Flow fl = new Flow(this.FK_Flow); fl.RetrieveFromDBSources(); fl.No = this.FK_Flow; if (string.IsNullOrEmpty(this.TableName) == true) { this.Pub1.AddFieldSet("配置错误", "请关闭该窗口,在流程属性里配置业务表名,然后点保存按钮,之后打开该功能界面。"); return; } //获得数据表列. SFDBSrc src = new SFDBSrc(this.FK_DBSrc); DataTable dt = src.GetColumns(this.TableName); foreach (DataRow dr in dt.Rows) { string fType = dr["DBType"].ToString(); string desc = dr["Name"].ToString(); dr["Name"] = dr["No"] + " " + dr["DBType"] + "(" + dr["DBLength"] + ") " + dr["Name"]; } this.Pub1.AddTable(); this.Pub1.AddCaptionLeft("请设置流程字段与业务表字段的同步映射"); this.Pub1.AddTR(); string textCenter = " style='text-align:center;'"; this.Pub1.AddTDTitle(textCenter, "序"); this.Pub1.AddTDTitle(textCenter, "是否同步"); this.Pub1.AddTDTitle(textCenter, "类型"); this.Pub1.AddTDTitle(textCenter, "业务表(" + fl.DTSBTable + ")"); this.Pub1.AddTREnd(); int idx = 0; Hashtable ht = new Hashtable(); if (string.IsNullOrEmpty(fl.DTSFields)) { fl.DTSFields = "@"; } string[] fieldArr = fl.DTSFields.Split('@'); string[] lcArr = fieldArr[0].Split(','); string[] ywArr = fieldArr[1].Split(','); for (int i = 0; i < lcArr.Length; i++) { ht.Add(lcArr[i], ywArr[i]); } #region 锁定workid 在第一行上. //guid workid必须选择一项 BP.Web.Controls.RadioBtn rb_workId = new BP.Web.Controls.RadioBtn(); rb_workId.ID = "rb_workId"; rb_workId.GroupName = "RB_KEY"; rb_workId.Text = "OID - WorkID"; BP.Web.Controls.RadioBtn rb_guid = new BP.Web.Controls.RadioBtn(); rb_guid.ID = "rb_guid"; rb_guid.GroupName = "RB_KEY"; rb_guid.Text = "GUID"; foreach (DictionaryEntry de in ht) { if (de.Key.ToString().ToUpper() == "OID") { rb_workId.Checked = true; } else { rb_guid.Checked = true; } } this.Pub1.AddTR(); this.Pub1.AddTDIdx("1"); this.Pub1.AddTDBegin(); this.Pub1.Add(rb_workId); this.Pub1.Add(rb_guid); this.Pub1.AddTDEnd(); this.Pub1.AddTD("主键<img src='../../Img/PRI/2.png' border=0/>"); BP.Web.Controls.DDL ddl = new BP.Web.Controls.DDL(); ddl.Width = 250; ddl.ID = "DDL_OID"; ddl.Bind(dt, dt.Columns["No"].ToString(), dt.Columns["Name"].ToString()); ddl.SetSelectItem(fl.DTSBTablePK); this.Pub1.AddTD(textCenter, ddl); this.Pub1.AddTREnd(); #endregion 锁定workid 在第一行上. bool is1 = false; foreach (MapAttr attr in attrs) { if (attr.KeyOfEn.ToUpper() == "OID" || attr.KeyOfEn.ToUpper() == "GUID") { continue; } idx++; is1 = this.Pub1.AddTR(is1); this.Pub1.AddTDIdx(idx); CheckBox cb = new CheckBox(); cb.ID = "CB_" + attr.KeyOfEn; cb.Text = attr.KeyOfEn + " - " + attr.Name; foreach (DictionaryEntry de in ht) { if (attr.KeyOfEn == de.Key.ToString()) { cb.Checked = true; } } this.Pub1.AddTD(cb); this.Pub1.AddTD(attr.MyDataTypeStr); ddl = new BP.Web.Controls.DDL(); ddl.ID = "DDL_" + attr.KeyOfEn; ddl.Width = 250; ddl.Bind(dt, dt.Columns["No"].ToString(), dt.Columns["Name"].ToString()); if (cb.Checked == true) { try { ddl.SetSelectItem(ht[attr.KeyOfEn].ToString()); } catch { } } //类似的默认选中 区分大小写 方法if(ddl.SetSelectItem(attr.KeyOfEn)){cb.Checked = true;}不适用 foreach (DataRow dr in dt.Rows) { if (attr.KeyOfEn.ToUpper() == dr[0].ToString().ToUpper()) { ddl.SetSelectItem(dr[0].ToString()); cb.Checked = true; break; } } this.Pub1.AddTD(textCenter, ddl); this.Pub1.AddTREnd(); } this.Pub1.AddTableEnd(); this.Pub1.AddBR(); this.Pub1.AddBR(); Button btn = new Button(); btn.ID = "Btn_Save"; btn.Text = "保存"; btn.Click += new EventHandler(btn_Save_Click); Button btnClose = new Button(); btnClose.ID = "Btn_Close"; btnClose.Text = "取消"; btnClose.Click += new EventHandler(btnClose_Click); this.Pub1.Add(btn); this.Pub1.Add(btnClose); this.Pub1.AddBR(); this.Pub1.AddBR(); this.Pub1.AddBR(); }