From f5b68343056a31c0d221e6aa0d671a9f8ef798cd Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期一, 05 五月 2025 11:25:17 +0800
Subject: [PATCH] 结案

---
 DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs |  855 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 677 insertions(+), 178 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs b/DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs
index d75c1fb..c48a70f 100644
--- a/DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs
+++ b/DevApp/Gs.DevApp/DevFrm/Sys/EasyCode.cs
@@ -1,300 +1,799 @@
-锘縰sing DevExpress.XtraEditors;
-using System;
+锘縰sing System;
 using System.Collections.Generic;
-using System.ComponentModel;
+using System.Configuration;
 using System.Data;
 using System.Data.SqlClient;
-using System.Drawing;
-using System.Linq;
+using System.IO;
+using System.Net;
+using System.Net.Http;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using DevExpress.XtraEditors;
+using Gs.DevApp.ToolBox;
+using Newtonsoft.Json;
+using Oracle.ManagedDataAccess.Client;
 
 namespace Gs.DevApp.DevFrm.Sys
 {
-    public partial class EasyCode : DevExpress.XtraEditors.XtraForm
+    public partial class EasyCode : XtraForm
     {
+        private readonly string oracleCon =
+            "User Id=system;Password=admin110;Data Source=localhost:1521/MYTEST2;";
+
+        //this.txt_sqlconn.Text = "Data Source=2kn4sh70028.vicp.fun,26144;Initial Catalog=gs_Mes;User ID=sa;Password =admin110";
+        private readonly string sqlCon =
+            "Data Source=192.168.1.146;Initial Catalog=GS_MES;User ID=sa;Password =qixi123";
+
         public EasyCode()
         {
             InitializeComponent();
-            this.txt_sqlconn.Text = "Data Source=2kn4sh70028.vicp.fun,26144;Initial Catalog=gs_Mes;User ID=sa;Password =admin110";
             getTable();
+            btnPathSelect.Click += (s, e) =>
+            {
+                var _GetfilePath = FileSelector.BrowseFilePathForSave();
+                txtPath.Text = _GetfilePath;
+            };
+            btnUpSelect.Click += BtnUpSelect_Click;
+            btnUp.Click += BtnUp_Click;
         }
-        /// <summary>
-        /// 璇诲彇鏁版嵁搴撹〃
-        /// </summary>
-        private void getTable()
+
+        #region 鎵归噺璇诲彇
+
+        private void btnTable_Click(object sender, EventArgs e)
         {
-            string strConn = txt_sqlconn.Text.Trim();
-            DataSet dset = new DataSet();
-            using (SqlConnection connection = new SqlConnection(strConn))
+            using (var connection = new OracleConnection(oracleCon))
             {
-                connection.Open();
-                SqlCommand cmd = new SqlCommand();
-                cmd.Connection = connection;
-                cmd.CommandText = "SELECT '--璇烽�夋嫨--' as TABLE_NAME union all SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' order by TABLE_NAME desc";
-                using (SqlDataAdapter dt = new SqlDataAdapter(cmd))
+                try
                 {
-                    dt.Fill(dset, "0");
+                    connection.Open();
+                    using (var command = connection.CreateCommand())
+                    {
+                        command.CommandText =
+                            "SELECT * FROM " + txtTable1.Text.Trim();
+                        using (var oracleDataReader = command.ExecuteReader())
+                        {
+                            using (var bulkCopy = new SqlBulkCopy(sqlCon))
+                            {
+                                bulkCopy.DestinationTableName =
+                                    txtTable1.Text.Trim();
+                                bulkCopy.WriteToServer(oracleDataReader);
+                            }
+                        }
+                    }
+
+                    MsgHelper.ShowInformation("鎻愮ず锛屾搷浣滄垚鍔燂紒");
                 }
-            }
-            if (dset != null && dset.Tables.Count > 0)
-            {
-                txt_table.DataSource = dset.Tables[0];
-                txt_table.DisplayMember = "TABLE_NAME";
-                txt_table.ValueMember = "TABLE_NAME";
-                txt_category.SelectedIndex = txt_table.SelectedIndex = 0;
+                catch (Exception ex)
+                {
+                    Console.WriteLine(ex.Message);
+                    MsgHelper.ShowError("鎻愮ず锛�" + ex.Message);
+                }
+                finally
+                {
+                    if (connection.State != ConnectionState.Closed)
+                        connection.Close();
+                }
             }
         }
 
+        #endregion
+
+        #region 鎵归噺鍑嗗
+
+        private void btnRemark_Click(object sender, EventArgs e)
+        {
+            if (txtTable2.Text.Trim().Length <= 0)
+            {
+                MessageBox.Show("璇疯緭鍏ヨ〃鍚�");
+                return;
+            }
+
+            using (var conn = new SqlConnection(sqlCon))
+            {
+                using (var cmd = new SqlCommand("[tmp_property]", conn))
+                {
+                    try
+                    {
+                        conn.Open();
+                        cmd.CommandType = CommandType.StoredProcedure;
+                        SqlParameter[] parameters =
+                        {
+                            new SqlParameter("@tabname", txtTable2.Text.Trim()),
+                            new SqlParameter("@com", txtOracleDec.Text.Trim())
+                        };
+                        foreach (var parameter in parameters)
+                            cmd.Parameters.Add(parameter);
+                        cmd.ExecuteNonQuery();
+                        MsgHelper.ShowInformation("鎻愮ず锛屾搷浣滄垚鍔燂紒");
+                    }
+                    catch (Exception ex)
+                    {
+                        MsgHelper.ShowError("鎻愮ず锛�" + ex.Message);
+                    }
+                    finally
+                    {
+                        conn.Close();
+                    }
+                }
+            }
+        }
+
+        #endregion
+
+        #region 浠g爜鐢熸垚
+
         /// <summary>
-        /// 閫夋嫨鐢熸垚璺緞
+        ///     纭畾鐢熸垚
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-        private void btnToPath_Click(object sender, EventArgs e)
-        {
-            string _GetfilePath = FileSelector.BrowseFilePathForSave();
-            txtCreateDBPath.Text = _GetfilePath;
-        }
-
         private void btnOk_Click(object sender, EventArgs e)
         {
-            if (txt_sqlconn.Text.Trim() == "")
-            {
-                MessageBox.Show("璇疯緭鍏ユ暟鎹簱杩炴帴涓�");
-                return;
-            }
-            if (txt_table.SelectedIndex <= 0)
+            if (txt_table.EditValue == null ||
+                string.IsNullOrEmpty(txt_table.EditValue.ToString()))
             {
                 MessageBox.Show("璇烽�夋嫨琛�");
                 return;
             }
-            if (txt_category.SelectedIndex <= 0)
-            {
-                MessageBox.Show("璇烽�夋嫨绫诲瀷");
-                return;
-            }
-            if (txtCreateDBPath.Text.Trim() == "")
+
+            if (txtPath.Text.Trim() == "")
             {
                 MessageBox.Show("璇烽�夋嫨鐢熸垚璺緞");
                 return;
             }
-            DataTable dt = _getCol();
-            string _strName = _getClassName();
-            ReadMainFile(dt, _strName);
-            ReadDesignerFile(dt, _strName);
-            ReadResxFile(dt, _strName);
-            string path = txtCreateDBPath.Text;
+
+            var _strName = _getClassName();
+            var list = txt_table.Properties.Items.GetCheckedValues();
+            var dt1 = _getCol(_getTableName(list[0].ToString()));
+            var dtList = new List<DataTable>();
+            var j = 0;
+            foreach (var obj in list)
+            {
+                if (j > 0)
+                    dtList.Add(_getCol(_getTableName(obj.ToString())));
+                j++;
+            }
+
+            ReadMainFile(dt1, _strName, dtList);
+            ReadDesignerFile(dt1, _strName, dtList);
+            ReadResxFile(dt1, _strName);
+            var path = txtPath.Text;
             lbMsg.Text = "鐢熸垚鎴愬姛锛岃矾寰勶細" + path;
         }
+
         /// <summary>
-        /// 璇诲彇鍒楀悕
+        ///     璇诲彇鏁版嵁搴撹〃
         /// </summary>
-        /// <returns></returns>
-        private DataTable _getCol()
+        private void getTable()
         {
-            string strConn = txt_sqlconn.Text.Trim();
-            DataSet dset = new DataSet();
-            using (SqlConnection connection = new SqlConnection(strConn))
+            var dset = new DataSet();
+            using (var connection = new SqlConnection(sqlCon))
             {
                 connection.Open();
-                SqlCommand cmd = new SqlCommand();
+                var 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() + "'";
-                using (SqlDataAdapter dt = new SqlDataAdapter(cmd))
+                cmd.CommandText =
+                    "SELECT TABLE_NAME,(SELECT top 1 value AS ExtendedPropertyValue FROM sys.extended_properties WHERE minor_id=0 and major_id = OBJECT_ID(''+TABLE_NAME+''))  as TABLE_DESC  FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' order by TABLE_NAME asc";
+                using (var dt = new SqlDataAdapter(cmd))
                 {
                     dt.Fill(dset, "0");
                 }
             }
+
             if (dset != null && dset.Tables.Count > 0)
             {
-                return dset.Tables[0];
+                txt_table.Properties.Items.Clear();
+                var strs = new string[dset.Tables[0].Rows.Count];
+                for (var i = 0; i < dset.Tables[0].Rows.Count; i++)
+                    strs[i] = dset.Tables[0].Rows[i]["TABLE_NAME"] + "(" +
+                              dset.Tables[0].Rows[i]["TABLE_DESC"] + ")";
+                txt_table.Properties.Items.AddRange(strs);
             }
+        }
+
+        /// <summary>
+        ///     璇诲彇鍒楀悕
+        /// </summary>
+        /// <returns></returns>
+        private DataTable _getCol(string tableName)
+        {
+            var 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 = '" + tableName + "'");
+            sb.Append(" order by  a.id, a.colorder");
+            var dset = new DataSet();
+            using (var connection = new SqlConnection(sqlCon))
+            {
+                connection.Open();
+                var cmd = new SqlCommand();
+                cmd.Connection = connection;
+                cmd.CommandText = sb.ToString();
+                using (var dt = new SqlDataAdapter(cmd))
+                {
+                    dt.Fill(dset, "0");
+                }
+            }
+
+            if (dset != null && dset.Tables.Count > 0) return dset.Tables[0];
             return null;
         }
+
         /// <summary>
-        /// 妯$増璺緞
+        ///     璇绘ā鐗堣矾寰�
         /// </summary>
         /// <param name="fileType">cs,Designer.cs</param>
         /// <returns></returns>
         private string _getTemple(string fileType)
         {
-            return (@"\templeEasyCode\category1\category1." + fileType);
+            if (txt_table.Properties.Items.GetCheckedValues().Count < 2)
+                return @"\templeEasyCode\category1\category." + fileType;
+            return @"\templeEasyCode\category2\category." + fileType;
         }
+
         /// <summary>
-        /// 璇诲彇绫诲悕
+        ///     璇诲彇鏂囦欢绫诲悕
         /// </summary>
         /// <returns></returns>
         private string _getClassName()
         {
-            return "Frm" + txt_table.SelectedValue.ToString();
+            var str = UtilityHelper.ToCamelCase(_getMainTable());
+            var result = str.Substring(0, 1).ToUpper() + str.Substring(1);
+            return "Frm_" + result;
         }
+
         /// <summary>
-        /// 绗竴涓枃浠�
+        ///     璇诲彇涓昏〃
+        /// </summary>
+        /// <returns></returns>
+        private string _getMainTable()
+        {
+            var ckList = txt_table.Properties.Items.GetCheckedValues();
+            var _strName = ckList[0].ToString();
+            foreach (string str in ckList)
+                if (str.Length < _strName.Length)
+                    _strName = str;
+            return _getTableName(_strName);
+        }
+
+        /// <summary>
+        ///     鎴彇琛ㄥ悕
+        /// </summary>
+        /// <param name="strName"></param>
+        /// <returns></returns>
+        private string _getTableName(string strName)
+        {
+            var _tableName = strName.Split('(')[0];
+            return _tableName;
+        }
+
+        /// <summary>
+        ///     绗竴涓枃浠�
         /// </summary>
         /// <param name="dt"></param>
         /// <param name="_FileName"></param>
-        void ReadMainFile(DataTable dt, string _FileName)
+        private void ReadMainFile(DataTable dt, string _FileName,
+            List<DataTable> dtList = null)
         {
-            string _Temppath = Application.StartupPath + _getTemple("cs");
-            string contents = System.IO.File.ReadAllText(_Temppath);
-            string line = Environment.NewLine;
-            StringBuilder strbuilder = new StringBuilder();
-            strbuilder.Append(contents);
-            strbuilder.Replace("{clsName}", _getClassName());
-            string _fullPath = txtCreateDBPath.Text + "\\" + _FileName + ".cs";
-            if (System.IO.File.Exists(_fullPath))
-                System.IO.File.Delete(_fullPath);
-            System.IO.StreamWriter sw = System.IO.File.CreateText(_fullPath);
-            sw.Write(strbuilder.ToString());
+            var _tempPath = Application.StartupPath + _getTemple("cs");
+            var contents = File.ReadAllText(_tempPath);
+            var line = Environment.NewLine;
+            var sb = new StringBuilder();
+            sb.Append(contents);
+            sb.Replace("{clsName}", _getClassName());
+            var _fullPath = txtPath.Text + "\\" + _FileName + ".cs";
+            if (File.Exists(_fullPath))
+                File.Delete(_fullPath);
+            var sw = File.CreateText(_fullPath);
+            sw.Write(sb.ToString());
             sw.Close();
             sw.Dispose();
         }
+
         /// <summary>
-        /// 绗簩涓枃浠�
+        ///     绗簩涓枃浠�
         /// </summary>
         /// <param name="dt"></param>
         /// <param name="_FileName"></param>
-        void ReadDesignerFile(DataTable dt, string _FileName)
+        private void ReadDesignerFile(DataTable dt, string _FileName,
+            List<DataTable> dtList = null)
         {
-            string _Temppath = Application.StartupPath + _getTemple("Designer.cs");
-            string contents = System.IO.File.ReadAllText(_Temppath);
-            StringBuilder strbuilder = new StringBuilder();
-            string line = Environment.NewLine;
+            var _tempPath = Application.StartupPath + _getTemple("Designer.cs");
+            var contents = File.ReadAllText(_tempPath);
+            var strbuilder = new StringBuilder();
+            var line = Environment.NewLine;
             strbuilder.Append(contents);
             strbuilder.Replace("{clsName}", _getClassName());
-            int _RowCount = dt.Rows.Count;
+            var _RowCount = dt.Rows.Count;
             if (dt.Rows.Count > 0)
             {
-                string _FieldName = "";//瀛楁鍚�
-                string _FieldText = "";//
-                string _prefix = "txt_";
-                string _Lbfix = "lb_";
-                string _gvFix = "gv_";
+                var _FieldName = ""; //瀛楁鍚�
+                var _FieldText = ""; //瀛楁鏂囨湰
+                var _FieldNameSql = ""; //鍘熷瀛楁鍚嶏紝涓昏鐢ㄤ簬鏌ヨ
                 int _x = 0, _y = 0, _Tabindex = 210;
-                string _ControlType = "";
-                string _lbType = "LabelControl";
-                System.Text.StringBuilder _gvItemCol = new StringBuilder();
-                for (int c = 0; c < _RowCount; c++)
+                var _ControlType = "TextEdit"; //鎺т欢绫诲瀷锛岀洰鍓嶄笉浣滃垽鏂兘涓烘枃鏈
+                var _lbType = "LabelControl";
+                var _gvItemCol = new StringBuilder();
+                for (var c = 0; c < _RowCount; c++)
                 {
-                    _x = 20 + c % 4 * 250;//璁$畻鎺т欢鍦╔杞翠綅缃�
-                    if (c % 4 == 0)
-                    {
-                        _y = 20 + 32 * c / 4;//璁$畻鎺т欢鍦╕杞寸殑浣嶇疆
-                    }
+                    _x = 20 + c % 4 * 250; //璁$畻鎺т欢鍦╔杞翠綅缃�
+                    if (c % 4 == 0) _y = 20 + 32 * c / 4; //璁$畻鎺т欢鍦╕杞寸殑浣嶇疆
                     _Tabindex = c % 4 + c / 4 + _Tabindex;
-                    //澶氭帶浠剁被鍨� 杩欒竟鍙互鏍规嵁鍏蜂綋鐨勯渶姹傝繘琛屾帶浠剁殑鎵╁睍锛岀洰鍓嶉兘鏄枃鏈�
                     switch (dt.Rows[c]["DATA_TYPE"].ToString())
                     {
-                        case "1111":
-                            break;
                         default:
-                            _FieldName = ToolBox.UtilityHelper.ToCamelCase(dt.Rows[c]["COLUMN_NAME"].ToString());
-                            _FieldText = ToolBox.UtilityHelper.ToCamelCase(dt.Rows[c]["COLUMN_NAME"].ToString());
-                            _ControlType = "TextEdit";
+                            _FieldName = UtilityHelper.ToCamelCase(
+                                dt.Rows[c]["COLUMN_NAME"].ToString().Trim());
+                            _FieldText = dt.Rows[c]["REMARK"].ToString().Trim();
+                            _FieldNameSql = "query_a." +
+                                            dt.Rows[c]["COLUMN_NAME"].ToString()
+                                                .Trim();
                             break;
                     }
-                    string _labName = _Lbfix + _FieldName;//label鍚�
-                    string _ControlName = _prefix + _FieldName;//鏂囨湰妗嗗悕
-                    string _gvName = _gvFix + _FieldName;//gv涓殑鍒楀悕
+
+                    var _labName = "lb_" + _FieldName; //label鍚�
+                    var _txtName = "txt_" + _FieldName; //鏂囨湰妗嗗悕
+                    var _gvName = "gv_" + _FieldName; //gv涓殑鍒楀悕
                     if (_gvItemCol.Length > 0)
                         _gvItemCol.Append(",");
                     _gvItemCol.Append("this." + _gvName);
                     //BQSetControlObject  瀹炰緥鍖栨帶浠�
-                    string BQSetControlObject = ("BQSetControlObject" + line + "this." + _labName + " =  new DevExpress.XtraEditors." + _lbType + "();" + line);
-                    BQSetControlObject = (BQSetControlObject + "this." + _ControlName + " = new DevExpress.XtraEditors." + _ControlType + "(); " + line);
-                    BQSetControlObject = (BQSetControlObject + "this." + _gvName + " = new DevExpress.XtraGrid.Columns.GridColumn(); " + line);
-                    strbuilder.Replace("BQSetControlObject", BQSetControlObject);
-                    //鍒涘缓瀵硅薄缁撴潫鍚�     this.SuspendLayout();
-                    //BQSetControlInfo  璁剧疆鎺т欢淇℃伅  浣嶇疆 澶у皬 鍚嶇О
-                    string _ControlName02 = "\"" + _labName + "\"";//缁欐帶浠禩ext 璧嬪�肩殑鏄甫鏈夊弻寮曞彿鐨勫瓧绗︿覆 鍥犳杩欎釜閲岃鐗规畩澶勭悊涓�
-                    string _FieldName02 = "\"" + _FieldName + "\"";
-                    string _FieldText02 = "\"" + (_FieldText + "锛�") + "\"";
-                    string BQSetControlInfo = "BQSetControlInfo" + line
-                             //label
-                             + "//" + line
-                             + "//" + _labName + line
-                             + "//" + line
-                             + "this." + _labName + ".Location = new System.Drawing.Point(" + _x + ", " + _y + ");" + line//浣嶇疆
-                             + "this." + _labName + ".Name = " + _ControlName02 + ";" + line//缁橬ame璧嬪��
-                             + "this." + _labName + ".Size = new System.Drawing.Size(150,21);" + line//澶у皬
-                             + "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
-                            //鏂囨湰 
-                            + "//" + line
-                            + "//" + _ControlName + line
-                            + "//" + line
-                            + "this." + _ControlName + ".Location = new System.Drawing.Point(" + (_x + 60) + ", " + _y + ");" + line//浣嶇疆
-                            + "this." + _ControlName + ".Name = " + _ControlName02 + ";" + line
-                            + "this." + _ControlName + ".Size = new System.Drawing.Size(150,21);" + line
-                            + "this." + _ControlName + ".TabIndex = " + _Tabindex + ";" + line
-                            + "this." + _ControlName + ".Tag = " + _FieldName02 + ";" + line
-                            + "this." + _ControlName + ".Properties.Appearance.Font = new System.Drawing.Font(\"Tahoma\", 10F);" + line
-                           //gv
-                           + "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 + ".MinWidth = 25;" + line
-                           + "this." + _gvName + ".Visible = true;" + line
-                           + "this." + _gvName + ".Width =94;" + line
-                           + "this." + _gvName + ".OptionsColumn.AllowEdit = false;" + line
-                           + "this." + _gvName + ".VisibleIndex = 0;" + line;
-
-
+                    var BQSetControlObject = "BQSetControlObject" + line +
+                                             "this." + _labName +
+                                             " =  new DevExpress.XtraEditors." +
+                                             _lbType + "();" + line;
+                    BQSetControlObject = BQSetControlObject + "this." +
+                                         _txtName +
+                                         " = new DevExpress.XtraEditors." +
+                                         _ControlType + "(); " + line;
+                    BQSetControlObject = BQSetControlObject + "this." +
+                                         _gvName +
+                                         " = new DevExpress.XtraGrid.Columns.GridColumn(); " +
+                                         line;
+                    strbuilder.Replace("BQSetControlObject",
+                        BQSetControlObject);
+                    //BQSetControlInfo  璁剧疆鎺т欢淇℃伅浣嶇疆澶у皬鍚嶇О
+                    var BQSetControlInfo = "BQSetControlInfo" + line
+                        //label
+                        + "//" + line
+                        + "//" + _labName + line
+                        + "//" + line
+                        + "this." + _labName +
+                        ".Location = new System.Drawing.Point(" + _x + ", " +
+                        _y + ");" + line
+                        + "this." + _labName + ".Name = \"" + _labName + "\";" +
+                        line
+                        + "this." + _labName +
+                        ".Size = new System.Drawing.Size(150,21);" + line
+                        + "this." + _labName + ".TabIndex = " + _Tabindex +
+                        ";" + line
+                        + "this." + _labName +
+                        ".Appearance.Font = new System.Drawing.Font(\"Tahoma\", 10F);" +
+                        line
+                        + "this." + _labName + ".Text = \"" + _FieldText +
+                        " \";" + line
+                        //鏂囨湰
+                        + "//" + line
+                        + "//" + _txtName + line
+                        + "//" + line
+                        + "this." + _txtName +
+                        ".Location = new System.Drawing.Point(" + (_x + 60) +
+                        ", " + _y + ");" + line
+                        + "this." + _txtName + ".Name = \"" + _txtName + "\";" +
+                        line
+                        + "this." + _txtName +
+                        ".Size = new System.Drawing.Size(150,21);" + line
+                        + "this." + _txtName + ".TabIndex = " + _Tabindex +
+                        ";" + line
+                        + "this." + _txtName +
+                        ".Properties.Appearance.Font = new System.Drawing.Font(\"Tahoma\", 10F);" +
+                        line
+                        //涓籫ridView
+                        + "//" + line
+                        + "//" + _gvName + line
+                        + "//" + line
+                        + "this." + _gvName +
+                        ".AppearanceCell.Font = new System.Drawing.Font(\"Tahoma\", 10F);" +
+                        line
+                        + "this." + _gvName +
+                        ".AppearanceCell.Options.UseFont = true;" + line
+                        + "this." + _gvName + ".FieldName = \"" + _FieldName +
+                        "\";" + line
+                        + "this." + _gvName + ".Caption =  \"" + _FieldText +
+                        " \";" + line
+                        + "this." + _gvName + ".Tag = \"" + _FieldNameSql +
+                        "\";" + line
+                        + "this." + _gvName + ".MinWidth =50;" + line
+                        + "this." + _gvName + ".Visible = true;" + line
+                        + "this." + _gvName + ".Width =94;" + line
+                        + "this." + _gvName +
+                        ".OptionsColumn.AllowEdit = false;" + line
+                        + "this." + _gvName + ".VisibleIndex = 0;" + line;
                     strbuilder.Replace("BQSetControlInfo", BQSetControlInfo);
-                    //BQAddControltoMContainer//灏嗘帶浠舵坊鍔犲埌Form 瀹瑰櫒涓�  杩欎釜瀹瑰櫒鍙互鏄� panel 鍙互鏄痝roupbox 绛夌瓑 
-                    string BQAddControltoMContainer = "BQAddControltoMContainer" + line + "  this.panel1.Controls.Add(this." + _labName + ");" + line;
-                    BQAddControltoMContainer += " this.panel1.Controls.Add(this." + _ControlName + ");" + line;
-                    strbuilder.Replace("BQAddControltoMContainer", BQAddControltoMContainer);
+                    //BQAddControltoMContainer//灏嗘帶浠舵坊鍔犲埌panel1瀹瑰櫒涓�
+                    var BQAddControltoMContainer = "BQAddControltoMContainer" +
+                                                   line +
+                                                   "  this.panel1.Controls.Add(this." +
+                                                   _labName + ");" + line;
+                    BQAddControltoMContainer +=
+                        " this.panel1.Controls.Add(this." + _txtName + ");" +
+                        line;
+                    strbuilder.Replace("BQAddControltoMContainer",
+                        BQAddControltoMContainer);
                     //BQCreateConrolObejct //鍒涘缓鎺т欢 
-                    string BQCreateConrolObejct = "BQCreateConrolObejct" + line + "private DevExpress.XtraEditors." + _lbType + " " + _labName + ";" + line;
-                    BQCreateConrolObejct += "private DevExpress.XtraEditors." + _ControlType + " " + _ControlName + ";" + line;
-                    BQCreateConrolObejct += " private DevExpress.XtraGrid.Columns.GridColumn " + _gvName + ";" + line;
-                    strbuilder.Replace("BQCreateConrolObejct", BQCreateConrolObejct);
+                    var BQCreateConrolObejct = "BQCreateConrolObejct" + line +
+                                               "private DevExpress.XtraEditors." +
+                                               _lbType + " " + _labName + ";" +
+                                               line;
+                    BQCreateConrolObejct += "private DevExpress.XtraEditors." +
+                                            _ControlType + " " + _txtName +
+                                            ";" + line;
+                    BQCreateConrolObejct +=
+                        " private DevExpress.XtraGrid.Columns.GridColumn " +
+                        _gvName + ";" + line;
+                    strbuilder.Replace("BQCreateConrolObejct",
+                        BQCreateConrolObejct);
                 }
+
+                //鎶婂垪鍔犲叆鍒癵ridview涓�
                 strbuilder.Replace("{colList}", _gvItemCol.ToString());
-                System.IO.File.Delete(txtCreateDBPath.Text + "\\" + _FileName + ".Designer.cs");
-                string path = txtCreateDBPath.Text;
-                System.IO.StreamWriter sw = System.IO.File.CreateText(path + "\\" + _FileName + ".Designer.cs");
+                //鏋勫缓鏄庣粏gridview1
+                if (dtList != null && dtList.Count > 0)
+                {
+                    var _idx = 1;
+                    var _tabItem = new StringBuilder();
+                    foreach (var dt2 in dtList)
+                    {
+                        var _tabMxPage = "tabMxPage" + _idx;
+                        var _gcMx = "gcMx" + _idx;
+                        var _gvMx = "gvMx" + _idx;
+                        if (_tabItem.Length > 0)
+                            _tabItem.Append(",");
+                        _tabItem.Append("this." + _tabMxPage);
+                        //BQSetControlObject 瀹炰緥鍖栨帶浠�
+                        var ss = "BQSetControlObject" + line;
+                        ss += " this." + _tabMxPage +
+                              " = new DevExpress.XtraTab.XtraTabPage();" + line;
+                        ss += " this." + _gcMx +
+                              " = new DevExpress.XtraGrid.GridControl();" +
+                              line;
+                        ss += " this." + _gvMx +
+                              " = new DevExpress.XtraGrid.Views.Grid.GridView();";
+                        strbuilder.Replace("BQSetControlObject", ss);
+                        //BQSetControlInfo 璁剧疆鎺т欢淇℃伅浣嶇疆澶у皬鍚嶇О
+                        var inf = "BQSetControlInfo" + line
+                            + "this." + _tabMxPage + ".Controls.Add(this." +
+                            _gcMx + ");"
+                            + "this." + _tabMxPage + ".Name = \"" + _tabMxPage +
+                            "\";" + line
+                            + "this." + _tabMxPage +
+                            ".Size = new System.Drawing.Size(1186, 112);" + line
+                            + "this." + _tabMxPage + ".Text = \"鏄庣粏" + _idx +
+                            "\";" + line
+                            + "//" + line
+                            + "//" + _gcMx + line
+                            + "//" + line
+                            + " this." + _gcMx +
+                            ".Dock = System.Windows.Forms.DockStyle.Fill;" +
+                            line
+                            + " this." + _gcMx +
+                            ".Location = new System.Drawing.Point(0, 0);" + line
+                            + " this." + _gcMx + ".MainView = this." + _gvMx +
+                            ";" + line
+                            + " this." + _gcMx + ".Name = \"" + _gcMx + "\";" +
+                            line
+                            + " this." + _gcMx +
+                            ".Size = new System.Drawing.Size(1124, 215);" + line
+                            + " this." + _gcMx + ".TabIndex = 0;" + line
+                            + " this." + _gcMx +
+                            ".ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { this." +
+                            _gvMx + "});" + line
+                            + "//" + line
+                            + "//" + _gvMx + line
+                            + "//" + line
+                            + " this." + _gvMx + ".GridControl = this." +
+                            _gcMx + ";" + line
+                            + " this." + _gvMx + ".Name = \"" + _gvMx + "\";" +
+                            line
+                            + " this." + _gvMx +
+                            ".OptionsFind.ShowSearchNavButtons = false;" + line
+                            + " this." + _gvMx +
+                            ".OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;" +
+                            line
+                            + " this." + _gvMx +
+                            ".OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.True;" +
+                            line
+                            + " this." + _gvMx +
+                            ".OptionsView.ShowGroupPanel = false;" + line
+                            + " this." + _gvMx +
+                            ".Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] { {colMx1List}});";
+                        strbuilder.Replace("BQSetControlInfo", inf);
+                        //BQCreateConrolObejct //鍒涘缓鎺т欢 
+                        var _cc = "BQCreateConrolObejct" + line;
+                        _cc += " private DevExpress.XtraTab.XtraTabPage " +
+                               _tabMxPage + ";" + line;
+                        _cc += " private DevExpress.XtraGrid.GridControl " +
+                               _gcMx + ";" + line;
+                        _cc +=
+                            " private DevExpress.XtraGrid.Views.Grid.GridView " +
+                            _gvMx + ";";
+                        strbuilder.Replace("BQCreateConrolObejct", _cc);
+                        var _layout = new StringBuilder();
+                        _layout.Append("this.tabMxPage1.SuspendLayout();");
+                        strbuilder.Replace("{layoutList}", _layout.ToString());
+                        var _resume = new StringBuilder();
+                        _resume.Append("this.tabMxPage1.ResumeLayout(false);");
+                        strbuilder.Replace("{resumeLayout}",
+                            _resume.ToString());
+                        var _beg = new StringBuilder();
+                        _beg.Append(
+                            "((System.ComponentModel.ISupportInitialize)(this." +
+                            _gcMx + ")).BeginInit();" + line);
+                        _beg.Append(
+                            " ((System.ComponentModel.ISupportInitialize)(this." +
+                            _gvMx + ")).BeginInit();" + line);
+                        strbuilder.Replace("{begInit}", _beg.ToString());
+                        ///////////////////
+                        _RowCount = dt2.Rows.Count;
+                        _gvItemCol = new StringBuilder();
+                        for (var c = 0; c < _RowCount; c++)
+                        {
+                            switch (dt2.Rows[c]["DATA_TYPE"].ToString())
+                            {
+                                default:
+                                    _FieldName =
+                                        UtilityHelper.ToCamelCase(
+                                            dt2.Rows[c]["COLUMN_NAME"]
+                                                .ToString());
+                                    _FieldText = dt2.Rows[c]["REMARK"]
+                                        .ToString();
+                                    _FieldNameSql = "query_a." +
+                                                    dt2.Rows[c]["COLUMN_NAME"];
+                                    break;
+                            }
+
+                            var _gvColName = _gvMx + _FieldName;
+                            if (_gvItemCol.Length > 0)
+                                _gvItemCol.Append(",");
+                            _gvItemCol.Append("this." + _gvColName);
+                            //BQSetControlObject  瀹炰緥鍖栨帶浠�
+                            var BQSetControlObject =
+                                "BQSetControlObject" + line;
+                            BQSetControlObject += "this." + _gvColName +
+                                                  " = new DevExpress.XtraGrid.Columns.GridColumn(); ";
+                            strbuilder.Replace("BQSetControlObject",
+                                BQSetControlObject);
+                            //BQSetControlInfo  璁剧疆鎺т欢淇℃伅浣嶇疆澶у皬鍚嶇О
+                            var BQSetControlInfo = "BQSetControlInfo" + line
+                                + "this." + _gvColName +
+                                ".AppearanceCell.Font = new System.Drawing.Font(\"Tahoma\", 10F);" +
+                                line
+                                + "this." + _gvColName +
+                                ".AppearanceCell.Options.UseFont = true;" + line
+                                + "this." + _gvColName + ".FieldName = \"" +
+                                _FieldName + "\";" + line
+                                + "this." + _gvColName + ".Caption =  \"" +
+                                _FieldText + " \";" + line
+                                + "this." + _gvColName + ".Tag = \"" +
+                                _FieldNameSql + "\";" + line
+                                + "this." + _gvColName + ".MinWidth = 50;" +
+                                line
+                                + "this." + _gvColName + ".Visible = true;" +
+                                line
+                                + "this." + _gvColName + ".Width =94;" + line
+                                + "this." + _gvColName +
+                                ".OptionsColumn.AllowEdit = true;" + line
+                                + "this." + _gvColName + ".VisibleIndex = 0;" +
+                                line;
+                            strbuilder.Replace("BQSetControlInfo",
+                                BQSetControlInfo);
+                            //BQCreateConrolObejct //鍒涘缓鎺т欢 
+                            var BQCreateConrolObejct =
+                                "BQCreateConrolObejct" + line;
+                            BQCreateConrolObejct +=
+                                " private DevExpress.XtraGrid.Columns.GridColumn " +
+                                _gvColName + ";";
+                            strbuilder.Replace("BQCreateConrolObejct",
+                                BQCreateConrolObejct);
+                        }
+
+                        strbuilder.Replace("{colMx1List}",
+                            _gvItemCol.ToString());
+                        _idx++;
+                    }
+
+                    strbuilder.Replace("{tabMx1List}", _tabItem.ToString());
+                }
+
+                File.Delete(txtPath.Text + "\\" + _FileName + ".Designer.cs");
+                var path = txtPath.Text;
+                var sw =
+                    File.CreateText(path + "\\" + _FileName + ".Designer.cs");
                 sw.Write(strbuilder.ToString());
                 sw.Close();
                 sw.Dispose();
             }
         }
+
+
         /// <summary>
-        /// 绗笁涓枃浠�
+        ///     绗笁涓枃浠�
         /// </summary>
         /// <param name="dt"></param>
         /// <param name="_FileName"></param>
-        void ReadResxFile(DataTable dt, string _FileName)
+        private void ReadResxFile(DataTable dt, string _FileName)
         {
-            string _Temppath = Application.StartupPath + _getTemple("resx");
-            string contents = System.IO.File.ReadAllText(_Temppath);
-            StringBuilder strbuilder = new StringBuilder();
-            string line = Environment.NewLine;
+            var _Temppath = Application.StartupPath + _getTemple("resx");
+            var contents = File.ReadAllText(_Temppath);
+            var strbuilder = new StringBuilder();
+            var line = Environment.NewLine;
             strbuilder.Append(contents);
-            System.IO.File.Delete(txtCreateDBPath.Text + "\\" + _FileName + ".resx");
-            string path = txtCreateDBPath.Text;
-            System.IO.StreamWriter sw = System.IO.File.CreateText(path + "\\" + _FileName + ".resx");
+            File.Delete(txtPath.Text + "\\" + _FileName + ".resx");
+            var path = txtPath.Text;
+            var sw = File.CreateText(path + "\\" + _FileName + ".resx");
             sw.Write(strbuilder.ToString());
             sw.Close();
             sw.Dispose();
         }
 
-        private void btnToPath_Click_1(object sender, EventArgs e)
+        #endregion
+
+
+        #region 鏂囦欢涓婁紶
+
+        /// <summary>
+        ///     閫夋嫨涓婁紶鏂囦欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void BtnUpSelect_Click(object sender, EventArgs e)
         {
-            string _GetfilePath = FileSelector.BrowseFilePathForSave();
-            txtCreateDBPath.Text = _GetfilePath;
+            var openFileDialog = new OpenFileDialog();
+            // 璁剧疆鍒濆鐩綍
+            openFileDialog.InitialDirectory = "c:\\";
+            // 璁剧疆鏂囦欢杩囨护閫夐」锛屽锛�"鏂囨湰鏂囦欢 (*.txt)|*.txt|鎵�鏈夋枃浠� (*.*)|*.*"
+            openFileDialog.Filter = "鏂囨湰鏂囦欢 (*.txt)|*.txt|鎵�鏈夋枃浠� (*.*)|*.*";
+            // 璁剧疆鏍囬
+            openFileDialog.Title = "閫夋嫨鏂囦欢";
+            // 鏄剧ず瀵硅瘽妗�
+            var result = openFileDialog.ShowDialog();
+            // 纭鐢ㄦ埛娌℃湁鍙栨秷鎿嶄綔
+            if (result == DialogResult.OK)
+            {
+                // 鑾峰彇閫変腑鐨勬枃浠惰矾寰�
+                var filePath = openFileDialog.FileName;
+                Console.WriteLine($"閫変腑鐨勬枃浠�: {filePath}");
+                txtUpUrl.Text = filePath;
+            }
         }
 
-        private void button1_Click(object sender, EventArgs e)
+        /// <summary>
+        ///     纭畾涓婁紶
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private async  void BtnUp_Click(object sender, EventArgs e)
         {
-            EasyRpt frm = new EasyRpt("001");
-            frm.Show();
+            var WebApiUrl = ConfigurationSettings.AppSettings.Get("WebApiUrl");
+            var address = WebApiUrl + "Upload/UploadFile";
+            var filePath = txtUpUrl.Text.Trim();
+            var apiUrl = address; // 鏇挎崲涓轰綘鐨凙PI鍦板潃
+            await UploadFileAsync(apiUrl, filePath);
         }
+
+        private async  Task UploadFileAsync(string url, string filePath)
+        {
+            using (var httpClient = new HttpClient())
+            using (var form = new MultipartFormDataContent())
+            {
+                httpClient.DefaultRequestHeaders.Add("token",
+                    UtilityHelper.GetBasicAuthTicket());
+                using (var fs = File.OpenRead(filePath))
+                using (var streamContent = new StreamContent(fs))
+                {
+                    form.Add(streamContent, "file", Path.GetFileName(filePath));
+                    var response = await httpClient.PostAsync(url, form);
+                    var responseString =
+                        await response.Content.ReadAsStringAsync();
+                    MessageBox.Show(responseString);
+                }
+            }
+        }
+
+        #endregion
+
+
+        #region 鎺ㄩ�佹祴璇�
+
+        /// <summary>
+        ///     纭畾鎺ㄩ��
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void btnMes_Click(object sender, EventArgs e)
+        {
+            var _list = new List<dynamic>();
+            for (var i = 0; i < 20; i++)
+                _list.Add(new
+                {
+                    t1 = "test1_" + i, //鍗曚綅缂栧彿
+                    t2 = "hi2_" + i //鍗曚綅鍚嶇О
+                });
+            var _json = new
+            {
+                category = "鍗曚綅淇℃伅",
+                list = _list
+            };
+            try
+            {
+                var _apiUrl = "http://localhost:5263/";
+                var _strReturnJson = HttpPost(_apiUrl,
+                    "ErpMes/PushMesByCategory",
+                    JsonConvert.SerializeObject(_json));
+                txtMesResult.Text = _strReturnJson;
+            }
+            catch (Exception ex)
+            {
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// </summary>
+        /// <param name="url">apiUrl鏍瑰湴鍧�</param>
+        /// <param name="meth">apiUrl鏂规硶鍚�</param>
+        /// <param name="param">json鍙傛暟</param>
+        /// <returns></returns>
+        public static string HttpPost(string url, string meth, string param)
+        {
+            //杩欐槸涓�涓櫄鎷熺殑token锛屼笉鑳藉垹闄�
+            var token = Guid.NewGuid() + "~" + Guid.NewGuid();
+            var request = (HttpWebRequest)WebRequest.Create(url + meth);
+            request.Method = "POST";
+            request.ContentType = "application/json";
+            request.Headers.Add("token", token);
+            request.Accept = "*/*";
+            request.Timeout = 15000;
+            request.AllowAutoRedirect = false;
+            StreamWriter requestStream = null;
+            WebResponse response = null;
+            string responseStr = null;
+            try
+            {
+                requestStream = new StreamWriter(request.GetRequestStream());
+                requestStream.Write(param);
+                requestStream.Close();
+                response = request.GetResponse();
+                if (response != null)
+                {
+                    var reader = new StreamReader(response.GetResponseStream(),
+                        Encoding.UTF8);
+                    responseStr = reader.ReadToEnd();
+                    reader.Close();
+                }
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+            finally
+            {
+                request = null;
+                requestStream = null;
+                response = null;
+            }
+
+            return responseStr;
+        }
+
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3