| | |
| | | private DataTable _getCol() |
| | | { |
| | | string strConn = txt_sqlconn.Text.Trim(); |
| | | System.Text.StringBuilder sb = new StringBuilder(); |
| | | sb.Append("SELECT COLUMN_NAME = a.name, DATA_TYPE = b.name, REMARK = isnull(g.[value],a.name) "); |
| | | sb.Append(" FROM syscolumns a left join systypes b on a.xusertype = b.xusertype inner join sysobjects d on a.id = d.id and d.xtype = 'U' and d.name<>'dtproperties' "); |
| | | sb.Append(" left join syscomments e on a.cdefault = e.id "); |
| | | sb.Append(" left join sys.extended_properties g on a.id = G.major_id and a.colid = g.minor_id "); |
| | | sb.Append(" left join sys.extended_properties f on d.id = f.major_id and f.minor_id = 0 "); |
| | | sb.Append(" where d.name = '" + txt_table.SelectedValue.ToString() + "'"); |
| | | sb.Append(" order by a.id, a.colorder"); |
| | | DataSet dset = new DataSet(); |
| | | using (SqlConnection connection = new SqlConnection(strConn)) |
| | | { |
| | | connection.Open(); |
| | | SqlCommand cmd = new SqlCommand(); |
| | | cmd.Connection = connection; |
| | | cmd.CommandText = "SELECT COLUMN_NAME,DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = N'" + txt_table.SelectedValue.ToString() + "'"; |
| | | cmd.CommandText = sb.ToString(); |
| | | using (SqlDataAdapter dt = new SqlDataAdapter(cmd)) |
| | | { |
| | | dt.Fill(dset, "0"); |
| | |
| | | if (dt.Rows.Count > 0) |
| | | { |
| | | string _FieldName = "";//字段名 |
| | | string _FieldText = "";// |
| | | string _FieldText = "";//字段文本 |
| | | string _prefix = "txt_"; |
| | | string _Lbfix = "lb_"; |
| | | string _gvFix = "gv_"; |
| | |
| | | case "1111": |
| | | break; |
| | | default: |
| | | _FieldName = ToolBox.UtilityHelper.ToCamelCase(dt.Rows[c]["COLUMN_NAME"].ToString()); |
| | | _FieldText = ToolBox.UtilityHelper.ToCamelCase(dt.Rows[c]["COLUMN_NAME"].ToString()); |
| | | string _tf = ToolBox.UtilityHelper.ToCamelCase(dt.Rows[c]["COLUMN_NAME"].ToString()); |
| | | _FieldName = _tf; |
| | | _FieldText = dt.Rows[c]["REMARK"].ToString(); |
| | | _ControlType = "TextEdit"; |
| | | break; |
| | | } |
| | |
| | | + "this." + _labName + ".TabIndex = " + _Tabindex + ";" + line |
| | | + "this." + _labName + ".Tag = " + _FieldName02 + ";" + line//Tag值 |
| | | + "this." + _labName + ".Appearance.Font = new System.Drawing.Font(\"Tahoma\", 10F);" + line |
| | | + "this." + _labName + ".Text = " + _FieldText02 + ";" + line |
| | | + "this." + _labName + ".Text = " + (_FieldText02) + ";" + line |
| | | //文本 |
| | | + "//" + line |
| | | + "//" + _ControlName + line |
| | |
| | | + "this." + _gvName + ".AppearanceCell.Font = new System.Drawing.Font(\"Tahoma\", 10F);" + line |
| | | + "this." + _gvName + ".AppearanceCell.Options.UseFont = true;" + line |
| | | + "this." + _gvName + ".FieldName = " + _FieldName02 + ";" + line |
| | | + "this." + _gvName + ".Caption = " + _FieldName02 + ";" + line |
| | | + "this." + _gvName + ".Caption = " + _FieldText02 .Replace(":","")+ ";" + line |
| | | + "this." + _gvName + ".MinWidth = 25;" + line |
| | | + "this." + _gvName + ".Visible = true;" + line |
| | | + "this." + _gvName + ".Width =94;" + line |