张泳健 8 лет назад
Родитель
Сommit
92564b052c

Двоичные данные
.vs/GWSocketClient/v15/.suo Просмотреть файл


+ 12 - 12
GWSocketClient/Form1.Designer.cs Просмотреть файл

@@ -31,6 +31,7 @@
31 31
             this.components = new System.ComponentModel.Container();
32 32
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
33 33
             this.groupBox1 = new System.Windows.Forms.GroupBox();
34
+            this.btnTextCmd = new System.Windows.Forms.Button();
34 35
             this.buttonCmdManager = new System.Windows.Forms.Button();
35 36
             this.label7 = new System.Windows.Forms.Label();
36 37
             this.tfTmpResponse = new System.Windows.Forms.TextBox();
@@ -63,7 +64,6 @@
63 64
             this.cmslistboxRightMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
64 65
             this.rightMenuCopyCmd = new System.Windows.Forms.ToolStripMenuItem();
65 66
             this.rightMenuClearInfo = new System.Windows.Forms.ToolStripMenuItem();
66
-            this.btnTextCmd = new System.Windows.Forms.Button();
67 67
             this.groupBox1.SuspendLayout();
68 68
             this.menuStrip1.SuspendLayout();
69 69
             this.statusStrip1.SuspendLayout();
@@ -104,6 +104,16 @@
104 104
             this.groupBox1.TabStop = false;
105 105
             this.groupBox1.Text = "基本信息栏";
106 106
             // 
107
+            // btnTextCmd
108
+            // 
109
+            this.btnTextCmd.Location = new System.Drawing.Point(596, 61);
110
+            this.btnTextCmd.Name = "btnTextCmd";
111
+            this.btnTextCmd.Size = new System.Drawing.Size(75, 33);
112
+            this.btnTextCmd.TabIndex = 18;
113
+            this.btnTextCmd.Text = "测试读取";
114
+            this.btnTextCmd.UseVisualStyleBackColor = true;
115
+            this.btnTextCmd.Click += new System.EventHandler(this.btnTextCmd_Click);
116
+            // 
107 117
             // buttonCmdManager
108 118
             // 
109 119
             this.buttonCmdManager.Location = new System.Drawing.Point(515, 61);
@@ -243,7 +253,7 @@
243 253
             this.tbEquipmentAddress.Name = "tbEquipmentAddress";
244 254
             this.tbEquipmentAddress.Size = new System.Drawing.Size(182, 23);
245 255
             this.tbEquipmentAddress.TabIndex = 5;
246
-            this.tbEquipmentAddress.Text = "4442832E833C";
256
+            this.tbEquipmentAddress.Text = "4442832E833D";
247 257
             this.tbEquipmentAddress.TextChanged += new System.EventHandler(this.tbEquipmentAddress_TextChanged);
248 258
             // 
249 259
             // tbPort
@@ -413,16 +423,6 @@
413 423
             this.rightMenuClearInfo.Text = "清空信息(&L)";
414 424
             this.rightMenuClearInfo.Click += new System.EventHandler(this.rightMenuClearInfo_Click);
415 425
             // 
416
-            // btnTextCmd
417
-            // 
418
-            this.btnTextCmd.Location = new System.Drawing.Point(596, 61);
419
-            this.btnTextCmd.Name = "btnTextCmd";
420
-            this.btnTextCmd.Size = new System.Drawing.Size(75, 33);
421
-            this.btnTextCmd.TabIndex = 18;
422
-            this.btnTextCmd.Text = "测试读取";
423
-            this.btnTextCmd.UseVisualStyleBackColor = true;
424
-            this.btnTextCmd.Click += new System.EventHandler(this.btnTextCmd_Click);
425
-            // 
426 426
             // Form1
427 427
             // 
428 428
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);

+ 5 - 5
GWSocketClient/Form1.cs Просмотреть файл

@@ -37,8 +37,8 @@ namespace GWSocketClient
37 37
 
38 38
         private void Form1_Load(object sender, EventArgs e)
39 39
         {
40
-//            XmlLoader xmlLoader = new XmlLoader();
41
-//            vcarecityProtocolBean = xmlLoader.loadXml();
40
+            XmlLoader xmlLoader = new XmlLoader();
41
+            vcarecityProtocolBean = xmlLoader.loadXml();
42 42
             if (vcarecityProtocolBean != null)
43 43
             {
44 44
                 this.Text = vcarecityProtocolBean.ProtocolName + " - " + vcarecityProtocolBean.ProtocolNo + " - " +
@@ -120,7 +120,7 @@ namespace GWSocketClient
120 120
 
121 121
             if (!(funcode == 16 || funcode == 32))
122 122
             {
123
-                Console.WriteLine(funcode + " 这个功能码不用回复!");
123
+                Console.WriteLine("功能码10进制="+funcode + ",所以不用回复!");
124 124
                 return;
125 125
             }
126 126
 
@@ -216,8 +216,8 @@ namespace GWSocketClient
216 216
         {
217 217
             try
218 218
             {
219
-                /*if (!showTopForNoLoadXML())
220
-                    return;*/
219
+                if (!showTopForNoLoadXML())
220
+                    return;
221 221
 
222 222
                 ip = tbIpaddress.Text.Trim();
223 223
                 port = tbPort.Text.Trim();

+ 1 - 0
GWSocketClient/GWSocketClient.csproj Просмотреть файл

@@ -59,6 +59,7 @@
59 59
   </ItemGroup>
60 60
   <ItemGroup>
61 61
     <Compile Include="db\AccsessDbLoader.cs" />
62
+    <Compile Include="excel\ExcelLoader.cs" />
62 63
     <Compile Include="Form1.cs">
63 64
       <SubType>Form</SubType>
64 65
     </Compile>

+ 2 - 0
GWSocketClient/IdItemEditor.Designer.cs Просмотреть файл

@@ -324,6 +324,8 @@
324 324
             this.MaximizeBox = false;
325 325
             this.MinimizeBox = false;
326 326
             this.Name = "IdItemEditor";
327
+            this.ShowIcon = false;
328
+            this.ShowInTaskbar = false;
327 329
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
328 330
             this.Text = "IdItemEditor";
329 331
             this.Load += new System.EventHandler(this.IdItemEditor_Load);

+ 4 - 20
GWSocketClient/IdItemEditor.cs Просмотреть файл

@@ -269,28 +269,15 @@ namespace GWSocketClient
269 269
             {
270 270
                 e.Handled = true;
271 271
             }
272
-            /*int ascii = (int) (e.KeyChar);
273
-            if ((ascii >= 48 && ascii <= 57) && ascii == 45)
274
-            {
275
-                e.Handled = true;
276
-            }*/
277 272
         }
278 273
 
279 274
 
280 275
         private void hex_Valid_KeyPress(object sender, KeyPressEventArgs e)
281 276
         {
282 277
             int ascii = (int) (e.KeyChar);
283
-            Console.WriteLine(e.KeyChar + ": " + ascii);
284 278
 
285
-            if ((ascii >= 48 && ascii <= 57) || e.KeyChar != 8)
286
-            {
287
-                e.Handled = true;
288
-            }
289
-            else if (ascii >= 65 && ascii <= 70)
290
-            {
291
-                e.Handled = true;
292
-            }
293
-            else if (ascii >= 97 && ascii <= 102)
279
+            if (ascii != 8 && !(ascii >= 48 && ascii <= 57) && !(ascii >= 65 && ascii <= 70) &&
280
+                !(ascii >= 97 && ascii <= 102))
294 281
             {
295 282
                 e.Handled = true;
296 283
             }
@@ -299,11 +286,8 @@ namespace GWSocketClient
299 286
         private void tbLen_KeyPress(object sender, KeyPressEventArgs e)
300 287
         {
301 288
             int ascii = (int) (e.KeyChar);
302
-            if (ascii >= 48 && ascii <= 57)
303
-            {
304
-                e.Handled = false;
305
-            }
306
-            else if (ascii == 45)
289
+
290
+            if (ascii != 8 && !(ascii >= 48 && ascii <= 57) && ascii != 45)
307 291
             {
308 292
                 e.Handled = true;
309 293
             }

+ 53 - 5
GWSocketClient/InfoEditor.Designer.cs Просмотреть файл

@@ -37,6 +37,9 @@
37 37
             this.buttonRefresh = new System.Windows.Forms.Button();
38 38
             this.btnResetUserdata = new System.Windows.Forms.Button();
39 39
             this.btnClosedThis = new System.Windows.Forms.Button();
40
+            this.btnLoadFromExcel = new System.Windows.Forms.Button();
41
+            this.InfoEditorTip = new System.Windows.Forms.RichTextBox();
42
+            this.btnClearAll = new System.Windows.Forms.Button();
40 43
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
41 44
             this.contextMenuStrip1.SuspendLayout();
42 45
             this.SuspendLayout();
@@ -76,7 +79,7 @@
76 79
             // buttonDeleteSelect
77 80
             // 
78 81
             this.buttonDeleteSelect.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
79
-            this.buttonDeleteSelect.Location = new System.Drawing.Point(174, 76);
82
+            this.buttonDeleteSelect.Location = new System.Drawing.Point(174, 34);
80 83
             this.buttonDeleteSelect.Name = "buttonDeleteSelect";
81 84
             this.buttonDeleteSelect.Size = new System.Drawing.Size(75, 30);
82 85
             this.buttonDeleteSelect.TabIndex = 3;
@@ -87,7 +90,7 @@
87 90
             // buttonAddCmd
88 91
             // 
89 92
             this.buttonAddCmd.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
90
-            this.buttonAddCmd.Location = new System.Drawing.Point(12, 76);
93
+            this.buttonAddCmd.Location = new System.Drawing.Point(12, 34);
91 94
             this.buttonAddCmd.Name = "buttonAddCmd";
92 95
             this.buttonAddCmd.Size = new System.Drawing.Size(75, 30);
93 96
             this.buttonAddCmd.TabIndex = 4;
@@ -98,7 +101,7 @@
98 101
             // buttonRefresh
99 102
             // 
100 103
             this.buttonRefresh.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
101
-            this.buttonRefresh.Location = new System.Drawing.Point(93, 76);
104
+            this.buttonRefresh.Location = new System.Drawing.Point(93, 34);
102 105
             this.buttonRefresh.Name = "buttonRefresh";
103 106
             this.buttonRefresh.Size = new System.Drawing.Size(75, 30);
104 107
             this.buttonRefresh.TabIndex = 5;
@@ -108,8 +111,9 @@
108 111
             // 
109 112
             // btnResetUserdata
110 113
             // 
114
+            this.btnResetUserdata.DialogResult = System.Windows.Forms.DialogResult.Cancel;
111 115
             this.btnResetUserdata.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
112
-            this.btnResetUserdata.Location = new System.Drawing.Point(255, 76);
116
+            this.btnResetUserdata.Location = new System.Drawing.Point(255, 34);
113 117
             this.btnResetUserdata.Name = "btnResetUserdata";
114 118
             this.btnResetUserdata.Size = new System.Drawing.Size(111, 30);
115 119
             this.btnResetUserdata.TabIndex = 6;
@@ -119,8 +123,9 @@
119 123
             // 
120 124
             // btnClosedThis
121 125
             // 
126
+            this.btnClosedThis.DialogResult = System.Windows.Forms.DialogResult.Cancel;
122 127
             this.btnClosedThis.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
123
-            this.btnClosedThis.Location = new System.Drawing.Point(372, 76);
128
+            this.btnClosedThis.Location = new System.Drawing.Point(495, 34);
124 129
             this.btnClosedThis.Name = "btnClosedThis";
125 130
             this.btnClosedThis.Size = new System.Drawing.Size(75, 30);
126 131
             this.btnClosedThis.TabIndex = 8;
@@ -128,12 +133,51 @@
128 133
             this.btnClosedThis.UseVisualStyleBackColor = true;
129 134
             this.btnClosedThis.Click += new System.EventHandler(this.btnClosedThis_Click);
130 135
             // 
136
+            // btnLoadFromExcel
137
+            // 
138
+            this.btnLoadFromExcel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
139
+            this.btnLoadFromExcel.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
140
+            this.btnLoadFromExcel.Location = new System.Drawing.Point(372, 34);
141
+            this.btnLoadFromExcel.Name = "btnLoadFromExcel";
142
+            this.btnLoadFromExcel.Size = new System.Drawing.Size(117, 30);
143
+            this.btnLoadFromExcel.TabIndex = 9;
144
+            this.btnLoadFromExcel.Text = "从Excel导入";
145
+            this.btnLoadFromExcel.UseVisualStyleBackColor = true;
146
+            this.btnLoadFromExcel.Click += new System.EventHandler(this.btnLoadFromExcel_Click);
147
+            // 
148
+            // InfoEditorTip
149
+            // 
150
+            this.InfoEditorTip.BackColor = System.Drawing.SystemColors.Window;
151
+            this.InfoEditorTip.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
152
+            this.InfoEditorTip.ForeColor = System.Drawing.Color.Red;
153
+            this.InfoEditorTip.Location = new System.Drawing.Point(12, 94);
154
+            this.InfoEditorTip.Name = "InfoEditorTip";
155
+            this.InfoEditorTip.ReadOnly = true;
156
+            this.InfoEditorTip.Size = new System.Drawing.Size(1217, 90);
157
+            this.InfoEditorTip.TabIndex = 10;
158
+            this.InfoEditorTip.Text = "";
159
+            // 
160
+            // btnClearAll
161
+            // 
162
+            this.btnClearAll.DialogResult = System.Windows.Forms.DialogResult.Cancel;
163
+            this.btnClearAll.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
164
+            this.btnClearAll.Location = new System.Drawing.Point(576, 34);
165
+            this.btnClearAll.Name = "btnClearAll";
166
+            this.btnClearAll.Size = new System.Drawing.Size(75, 30);
167
+            this.btnClearAll.TabIndex = 11;
168
+            this.btnClearAll.Text = "清空数据";
169
+            this.btnClearAll.UseVisualStyleBackColor = true;
170
+            this.btnClearAll.Click += new System.EventHandler(this.btnClearAll_Click);
171
+            // 
131 172
             // InfoEditor
132 173
             // 
133 174
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
134 175
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
135 176
             this.CancelButton = this.btnClosedThis;
136 177
             this.ClientSize = new System.Drawing.Size(1241, 761);
178
+            this.Controls.Add(this.btnClearAll);
179
+            this.Controls.Add(this.InfoEditorTip);
180
+            this.Controls.Add(this.btnLoadFromExcel);
137 181
             this.Controls.Add(this.btnClosedThis);
138 182
             this.Controls.Add(this.btnResetUserdata);
139 183
             this.Controls.Add(this.buttonRefresh);
@@ -141,6 +185,7 @@
141 185
             this.Controls.Add(this.buttonDeleteSelect);
142 186
             this.Controls.Add(this.dataGridView1);
143 187
             this.Name = "InfoEditor";
188
+            this.ShowInTaskbar = false;
144 189
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
145 190
             this.Text = "InfoEditor";
146 191
             this.Load += new System.EventHandler(this.InfoEditor_Load);
@@ -160,5 +205,8 @@
160 205
         private System.Windows.Forms.Button buttonRefresh;
161 206
         private System.Windows.Forms.Button btnResetUserdata;
162 207
         private System.Windows.Forms.Button btnClosedThis;
208
+        private System.Windows.Forms.Button btnLoadFromExcel;
209
+        private System.Windows.Forms.RichTextBox InfoEditorTip;
210
+        private System.Windows.Forms.Button btnClearAll;
163 211
     }
164 212
 }

+ 46 - 2
GWSocketClient/InfoEditor.cs Просмотреть файл

@@ -9,6 +9,7 @@ using System.Text;
9 9
 using System.Threading.Tasks;
10 10
 using System.Windows.Forms;
11 11
 using GWSocketClient.db;
12
+using GWSocketClient.excel;
12 13
 using GWSocketClient.model;
13 14
 
14 15
 namespace GWSocketClient
@@ -56,7 +57,7 @@ namespace GWSocketClient
56 57
 
57 58
         private void Iie_HandlerResult(string topmost)
58 59
         {
59
-            MessageBox.Show(topmost);
60
+            InfoEditorTip.Text = topmost;
60 61
             dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
61 62
         }
62 63
 
@@ -82,6 +83,10 @@ namespace GWSocketClient
82 83
                 AccsessDbLoader.getInstance().delete4Db(int.Parse(dataGridView1[0, selectIndex].Value + ""));
83 84
                 dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
84 85
             }
86
+            else
87
+            {
88
+                InfoEditorTip.Text = "请重新选择一行数据";
89
+            }
85 90
         }
86 91
 
87 92
         //刷新数据
@@ -100,13 +105,52 @@ namespace GWSocketClient
100 105
 
101 106
         private void btnResetUserdata_Click(object sender, EventArgs e)
102 107
         {
103
-            AccsessDbLoader.getInstance().resetUserData();
108
+            int res = AccsessDbLoader.getInstance().resetUserData();
109
+            InfoEditorTip.Text = res > 0 ? "重置数据成功" : "重置失败";
104 110
             dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
111
+
112
+            this.DialogResult = DialogResult.None;
105 113
         }
106 114
 
107 115
         private void btnClosedThis_Click(object sender, EventArgs e)
108 116
         {
109 117
             this.Close();
110 118
         }
119
+
120
+        private void btnLoadFromExcel_Click(object sender, EventArgs e)
121
+        {
122
+            OpenFileDialog openFileDialog = new OpenFileDialog();
123
+            openFileDialog.Filter = "Excel文件|*.xls;*.xlsx|所有文件|*.*";
124
+            openFileDialog.InitialDirectory = Application.StartupPath;
125
+            if (openFileDialog.ShowDialog() == DialogResult.OK)
126
+            {
127
+                List<WvBean> wvBeans = new ExcelLoader(openFileDialog.FileName, InfoEditorTip).loadExcelFile()
128
+                    .getExcelList();
129
+                insertList2DB(wvBeans);
130
+            }
131
+
132
+            this.DialogResult = DialogResult.None;
133
+        }
134
+
135
+        private void insertList2DB(List<WvBean> list)
136
+        {
137
+            for (var i = 0; i < list.Count; i++)
138
+            {
139
+                int res = AccsessDbLoader.getInstance().insert2Db(list[i]);
140
+                InfoEditorTip.Text += (res > 0 ? "插入成功:" : "插入失败") + list[i].ToString() + "\n";
141
+            }
142
+            dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
143
+        }
144
+
145
+        private void btnClearAll_Click(object sender, EventArgs e)
146
+        {
147
+            if (DialogResult.OK == MessageBox.Show("你确定要清空所有数据?", "确定清空", MessageBoxButtons.OKCancel,
148
+                    MessageBoxIcon.Warning))
149
+            {
150
+                AccsessDbLoader.getInstance().deleteAllData();
151
+                dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
152
+            }
153
+            this.DialogResult = DialogResult.None;
154
+        }
111 155
     }
112 156
 }

Двоичные данные
GWSocketClient/bin/Debug/dbfile/ID_INFO.accdb Просмотреть файл


+ 9 - 1
GWSocketClient/db/AccsessDbLoader.cs Просмотреть файл

@@ -58,7 +58,7 @@ namespace GWSocketClient.db
58 58
             reloadAccessDb();
59 59
         }
60 60
 
61
-        private static string strConnection = "Provider = Microsoft.ACE.OLEDB.12.0;" + "Data Source = ";
61
+        private static string strConnection = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source = ";
62 62
 
63 63
 
64 64
         private OleDbConnection objConnection = null;
@@ -214,6 +214,14 @@ namespace GWSocketClient.db
214 214
             return inst.ExecuteNonQuery();
215 215
         }
216 216
 
217
+        public int deleteAllData()
218
+        {
219
+            string sql = "delete from fw";
220
+            Console.WriteLine(sql);
221
+            OleDbCommand inst = new OleDbCommand(sql, objConnection);
222
+            return inst.ExecuteNonQuery();
223
+        }
224
+
217 225
         private string calcNull(string ojb)
218 226
         {
219 227
             if (ojb.Trim().Equals("") || ojb == null)

+ 102 - 0
GWSocketClient/excel/ExcelLoader.cs Просмотреть файл

@@ -0,0 +1,102 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Data;
4
+using System.Data.OleDb;
5
+using System.Linq;
6
+using System.Text;
7
+using System.Threading.Tasks;
8
+using System.Windows.Forms;
9
+using GWSocketClient.model;
10
+using GWSocketClient.util;
11
+
12
+namespace GWSocketClient.excel
13
+{
14
+    public class ExcelLoader
15
+    {
16
+        private string excelConn = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source = ";
17
+
18
+        private RichTextBox richTextBox;
19
+
20
+        private List<WvBean> excelList = new List<WvBean>();
21
+
22
+        public ExcelLoader(string excelPath, RichTextBox richTextBox)
23
+        {
24
+            this.richTextBox = richTextBox;
25
+            excelConn += excelPath + ";Extended Properties='Excel 12.0; HDR=NO; IMEX=1'";
26
+        }
27
+
28
+        public List<WvBean> getExcelList()
29
+        {
30
+            return excelList;
31
+        }
32
+
33
+        public ExcelLoader loadExcelFile()
34
+        {
35
+            using (OleDbConnection conn = new OleDbConnection(excelConn))
36
+            {
37
+                conn.Open();
38
+                DataSet dataSet = new DataSet();
39
+
40
+                try
41
+                {
42
+                    OleDbDataAdapter odda = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", conn);
43
+                    odda.Fill(dataSet, "Sheet1$");
44
+
45
+                    if (dataSet.Tables.Count > 0)
46
+                    {
47
+                        DataTable dt = dataSet.Tables[0];
48
+
49
+                        int hang = dt.Rows.Count;
50
+
51
+                        excelList.Clear();
52
+
53
+                        for (int i = 1; i < hang; i++)
54
+                        {
55
+                            WvBean wb = null;
56
+                            try
57
+                            {
58
+                                int myIndex = int.Parse(dt.Rows[i][0] + "");
59
+                                string myId = Utils.stringWith0(Utils.tenToHex(myIndex), 4);
60
+                                string idInfo = dt.Rows[i][1].ToString().Trim();
61
+                                string len = dt.Rows[i][2].ToString().Trim();
62
+                                string mode = dt.Rows[i][3].ToString().Trim();
63
+                                string desp = dt.Rows[i][4].ToString().Trim();
64
+                                string defaultValue = dt.Rows[i][5].ToString().Trim();
65
+                                string remark = dt.Rows[i][6].ToString().Trim();
66
+
67
+                                if (len.Equals("") || mode.Equals("") || defaultValue.Equals(""))
68
+                                {
69
+                                    richTextBox.Text += "第" + i + "行;长度,模式,默认值不能为空\n";
70
+                                    continue;
71
+                                }
72
+
73
+                                wb = new WvBean();
74
+                                wb.index = myIndex;
75
+                                wb.myId = myId;
76
+                                wb.idInfo = idInfo;
77
+                                wb.len = len;
78
+                                wb.mode = mode;
79
+                                wb.desp = desp;
80
+                                wb.defalutValue = defaultValue;
81
+                                wb.userValue = defaultValue;
82
+                                wb.remark = remark;
83
+                                excelList.Add(wb);
84
+                            }
85
+                            catch (Exception exception)
86
+                            {
87
+                                richTextBox.Text += "第" + i + "行;" + exception.Message + "\n";
88
+                                Console.WriteLine(exception);
89
+                            }
90
+                        }
91
+                    }
92
+                }
93
+                catch (Exception exception)
94
+                {
95
+                    Console.WriteLine(exception.Message);
96
+                    richTextBox.Text = "请确定Excel表名为\"Sheet1\"\n" + exception.Message + "\n";
97
+                }
98
+            }
99
+            return this;
100
+        }
101
+    }
102
+}

+ 2 - 1
GWSocketClient/xml/XmlLoader.cs Просмотреть файл

@@ -41,7 +41,8 @@ namespace GWSocketClient.xml
41 41
 
42 42
         public XmlLoader()
43 43
         {
44
-            string xmlFilePath = @"D:\TestProject\GW\config\dtu.xml";
44
+//            string xmlFilePath = @"D:\TestProject\GW\config\dtu.xml";
45
+            string xmlFilePath = Application.StartupPath + "/xml/dtu.xml";
45 46
             loadXmlDocument(xmlFilePath);
46 47
         }
47 48
 

Двоичные данные
excel/Template.xlsx Просмотреть файл