From c685ae1bcb234616e8930621a4b087f4e8fd98bb Mon Sep 17 00:00:00 2001
From: lg <999544862qq.com>
Date: 星期五, 13 九月 2024 12:00:43 +0800
Subject: [PATCH] 基础资料

---
 DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs b/DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs
index d75c1fb..ae9b595 100644
--- a/DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs
+++ b/DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs
@@ -95,13 +95,21 @@
         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");
@@ -168,7 +176,7 @@
             if (dt.Rows.Count > 0)
             {
                 string _FieldName = "";//瀛楁鍚�
-                string _FieldText = "";//
+                string _FieldText = "";//瀛楁鏂囨湰
                 string _prefix = "txt_";
                 string _Lbfix = "lb_";
                 string _gvFix = "gv_";
@@ -190,8 +198,9 @@
                         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;
                     }
@@ -222,7 +231,7 @@
                              + "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
@@ -237,7 +246,7 @@
                            + "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

--
Gitblit v1.9.3