Pārlūkot izejas kodu

Add Auto Responce!!

张泳健 8 gadus atpakaļ
vecāks
revīzija
ba739d4b21

+ 3 - 0
.gitignore Parādīt failu

@@ -31,3 +31,6 @@ GWSocketClient/obj/Debug/GWSocketClient.Form1.resources
31 31
 GWSocketClient/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
32 32
 GWSocketClient/obj/Debug/DesignTimeResolveAssemblyReferences.cache
33 33
 GWSocketClient/obj/Debug/CoreCompileInputs.cache
34
+GWSocketClient/obj/Release/GWSocketClient.InfoEditor.resources
35
+GWSocketClient/obj/Debug/GWSocketClient.IdItemEditor.resources
36
+GWSocketClient/obj/Release/GWSocketClient.MyMessageBox.resources

Binārs
.vs/GWSocketClient/v15/.suo Parādīt failu


+ 35 - 21
GWSocketClient/Form1.Designer.cs Parādīt failu

@@ -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.buttonCmdManager = new System.Windows.Forms.Button();
34 35
             this.label7 = new System.Windows.Forms.Label();
35 36
             this.tfTmpResponse = new System.Windows.Forms.TextBox();
36 37
             this.label6 = new System.Windows.Forms.Label();
@@ -62,7 +63,7 @@
62 63
             this.cmslistboxRightMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
63 64
             this.rightMenuCopyCmd = new System.Windows.Forms.ToolStripMenuItem();
64 65
             this.rightMenuClearInfo = new System.Windows.Forms.ToolStripMenuItem();
65
-            this.button1 = new System.Windows.Forms.Button();
66
+            this.btnTextCmd = new System.Windows.Forms.Button();
66 67
             this.groupBox1.SuspendLayout();
67 68
             this.menuStrip1.SuspendLayout();
68 69
             this.statusStrip1.SuspendLayout();
@@ -74,7 +75,8 @@
74 75
             // 
75 76
             this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
76 77
             | System.Windows.Forms.AnchorStyles.Right)));
77
-            this.groupBox1.Controls.Add(this.button1);
78
+            this.groupBox1.Controls.Add(this.btnTextCmd);
79
+            this.groupBox1.Controls.Add(this.buttonCmdManager);
78 80
             this.groupBox1.Controls.Add(this.label7);
79 81
             this.groupBox1.Controls.Add(this.tfTmpResponse);
80 82
             this.groupBox1.Controls.Add(this.label6);
@@ -102,6 +104,16 @@
102 104
             this.groupBox1.TabStop = false;
103 105
             this.groupBox1.Text = "基本信息栏";
104 106
             // 
107
+            // buttonCmdManager
108
+            // 
109
+            this.buttonCmdManager.Location = new System.Drawing.Point(515, 61);
110
+            this.buttonCmdManager.Name = "buttonCmdManager";
111
+            this.buttonCmdManager.Size = new System.Drawing.Size(75, 33);
112
+            this.buttonCmdManager.TabIndex = 17;
113
+            this.buttonCmdManager.Text = "命令管理";
114
+            this.buttonCmdManager.UseVisualStyleBackColor = true;
115
+            this.buttonCmdManager.Click += new System.EventHandler(this.buttonCmdManager_Click);
116
+            // 
105 117
             // label7
106 118
             // 
107 119
             this.label7.AutoSize = true;
@@ -113,10 +125,10 @@
113 125
             // 
114 126
             // tfTmpResponse
115 127
             // 
116
-            this.tfTmpResponse.Location = new System.Drawing.Point(55, 102);
128
+            this.tfTmpResponse.Location = new System.Drawing.Point(79, 102);
117 129
             this.tfTmpResponse.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
118 130
             this.tfTmpResponse.Name = "tfTmpResponse";
119
-            this.tfTmpResponse.Size = new System.Drawing.Size(374, 23);
131
+            this.tfTmpResponse.Size = new System.Drawing.Size(350, 23);
120 132
             this.tfTmpResponse.TabIndex = 15;
121 133
             // 
122 134
             // label6
@@ -124,9 +136,9 @@
124 136
             this.label6.AutoSize = true;
125 137
             this.label6.Location = new System.Drawing.Point(7, 106);
126 138
             this.label6.Name = "label6";
127
-            this.label6.Size = new System.Drawing.Size(35, 17);
139
+            this.label6.Size = new System.Drawing.Size(59, 17);
128 140
             this.label6.TabIndex = 14;
129
-            this.label6.Text = "回复:";
141
+            this.label6.Text = "临时回复:";
130 142
             // 
131 143
             // tfTmpSendData
132 144
             // 
@@ -162,7 +174,7 @@
162 174
             // 
163 175
             // btnPressureTest
164 176
             // 
165
-            this.btnPressureTest.Location = new System.Drawing.Point(437, 64);
177
+            this.btnPressureTest.Location = new System.Drawing.Point(329, 61);
166 178
             this.btnPressureTest.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
167 179
             this.btnPressureTest.Name = "btnPressureTest";
168 180
             this.btnPressureTest.Size = new System.Drawing.Size(87, 33);
@@ -174,7 +186,7 @@
174 186
             // label4
175 187
             // 
176 188
             this.label4.AutoSize = true;
177
-            this.label4.Location = new System.Drawing.Point(294, 71);
189
+            this.label4.Location = new System.Drawing.Point(196, 69);
178 190
             this.label4.Name = "label4";
179 191
             this.label4.Size = new System.Drawing.Size(56, 17);
180 192
             this.label4.TabIndex = 9;
@@ -183,7 +195,7 @@
183 195
             // tbPresureTestCount
184 196
             // 
185 197
             this.tbPresureTestCount.ForeColor = System.Drawing.Color.Blue;
186
-            this.tbPresureTestCount.Location = new System.Drawing.Point(364, 67);
198
+            this.tbPresureTestCount.Location = new System.Drawing.Point(258, 66);
187 199
             this.tbPresureTestCount.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
188 200
             this.tbPresureTestCount.Name = "tbPresureTestCount";
189 201
             this.tbPresureTestCount.Size = new System.Drawing.Size(65, 23);
@@ -192,7 +204,7 @@
192 204
             // 
193 205
             // btnSendData
194 206
             // 
195
-            this.btnSendData.Location = new System.Drawing.Point(198, 64);
207
+            this.btnSendData.Location = new System.Drawing.Point(422, 61);
196 208
             this.btnSendData.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
197 209
             this.btnSendData.Name = "btnSendData";
198 210
             this.btnSendData.Size = new System.Drawing.Size(87, 33);
@@ -203,7 +215,7 @@
203 215
             // 
204 216
             // btnQuickLogout
205 217
             // 
206
-            this.btnQuickLogout.Location = new System.Drawing.Point(103, 64);
218
+            this.btnQuickLogout.Location = new System.Drawing.Point(103, 61);
207 219
             this.btnQuickLogout.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
208 220
             this.btnQuickLogout.Name = "btnQuickLogout";
209 221
             this.btnQuickLogout.Size = new System.Drawing.Size(87, 33);
@@ -214,7 +226,7 @@
214 226
             // 
215 227
             // btnLogin
216 228
             // 
217
-            this.btnLogin.Location = new System.Drawing.Point(7, 64);
229
+            this.btnLogin.Location = new System.Drawing.Point(7, 61);
218 230
             this.btnLogin.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
219 231
             this.btnLogin.Name = "btnLogin";
220 232
             this.btnLogin.Size = new System.Drawing.Size(87, 33);
@@ -401,15 +413,15 @@
401 413
             this.rightMenuClearInfo.Text = "清空信息(&L)";
402 414
             this.rightMenuClearInfo.Click += new System.EventHandler(this.rightMenuClearInfo_Click);
403 415
             // 
404
-            // button1
416
+            // btnTextCmd
405 417
             // 
406
-            this.button1.Location = new System.Drawing.Point(586, 71);
407
-            this.button1.Name = "button1";
408
-            this.button1.Size = new System.Drawing.Size(75, 23);
409
-            this.button1.TabIndex = 17;
410
-            this.button1.Text = "button1";
411
-            this.button1.UseVisualStyleBackColor = true;
412
-            this.button1.Click += new System.EventHandler(this.button1_Click);
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);
413 425
             // 
414 426
             // Form1
415 427
             // 
@@ -426,6 +438,7 @@
426 438
             this.Name = "Form1";
427 439
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
428 440
             this.Text = "DTU模拟器";
441
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
429 442
             this.Load += new System.EventHandler(this.Form1_Load);
430 443
             this.groupBox1.ResumeLayout(false);
431 444
             this.groupBox1.PerformLayout();
@@ -474,7 +487,8 @@
474 487
         private System.Windows.Forms.TextBox tfTmpResponse;
475 488
         private System.Windows.Forms.Label label6;
476 489
         private System.Windows.Forms.ToolStripMenuItem rightMenuClearInfo;
477
-        private System.Windows.Forms.Button button1;
490
+        private System.Windows.Forms.Button buttonCmdManager;
491
+        private System.Windows.Forms.Button btnTextCmd;
478 492
     }
479 493
 }
480 494
 

+ 61 - 18
GWSocketClient/Form1.cs Parādīt failu

@@ -12,6 +12,7 @@ using System.Text.RegularExpressions;
12 12
 using System.Threading;
13 13
 using System.Threading.Tasks;
14 14
 using System.Windows.Forms;
15
+using GWSocketClient.db;
15 16
 using GWSocketClient.model;
16 17
 using GWSocketClient.util;
17 18
 using GWSocketClient.xml;
@@ -113,7 +114,7 @@ namespace GWSocketClient
113 114
         //处理回复信息
114 115
         private void handleResponse(SocketHelper.Sockets sks, string reqData)
115 116
         {
116
-            string resp = tfTmpSendData.Text.Trim();
117
+            string resp = tfTmpResponse.Text.Trim();
117 118
 
118 119
             if (resp.Equals(""))
119 120
             {
@@ -123,6 +124,45 @@ namespace GWSocketClient
123 124
             string functionWord = reqData.Substring(18, 2);
124 125
             int funcode = Utils.hexToTen(functionWord);
125 126
 
127
+            //16 表示要读数据,返回数据库中的数据
128
+            //32 表示返回结果 成功:00 失败:01 
129
+
130
+
131
+            //数据长度
132
+            int dataLen = Utils.hexToTen(reqData.Substring(20, 4));
133
+            string readlData = "";
134
+            try
135
+            {
136
+                readlData = reqData.Substring(24, dataLen);
137
+            }
138
+            catch (Exception e)
139
+            {
140
+                Console.WriteLine(e.Message);
141
+                addToListboxItem("数据长度与帧长度对不上!!");
142
+                return;
143
+            }
144
+
145
+            string myId = readlData.Substring(6, 4);
146
+            string idInfo = readlData.Substring(10);
147
+
148
+            if (funcode == 32)
149
+            {
150
+                //设置数据
151
+                int res = AccsessDbLoader.getInstance().setReceiveData(myId, idInfo);
152
+                if (res > 0)
153
+                {
154
+                    //00
155
+                }
156
+                else
157
+                {
158
+                    //01
159
+                }
160
+            }
161
+            else if (funcode == 16)
162
+            {
163
+                //返回数据库的数据
164
+            }
165
+
126 166
 
127 167
             if (funcode == 16 || funcode == 32)
128 168
             {
@@ -361,27 +401,30 @@ namespace GWSocketClient
361 401
             }
362 402
         }
363 403
 
364
-        private void button1_Click(object sender, EventArgs e)
404
+        private void buttonCmdManager_Click(object sender, EventArgs e)
365 405
         {
366 406
             InfoEditor ie = new InfoEditor();
367
-            ie.Show();
368
-
369
-
370
-//            var persons = JsonConvert.DeserializeObject<List<WvBean>>(json);
371
-//            var ja = JArray.Parse(jsonString);
372
-
373
-            /*WvBean wb = new WvBean();
374
-            wb.id = "0502";
375
-            wb.idInfo = "alkflkaslkjfjsalfjlf";
376
-            wb.len = "-1";
377
-            wb.mode = "R/W";
378
-            wb.desp = "DESPPPPPPP";
379
-            wb.remark = "alkskjlajslkf------------------------------";*/
407
+            ie.ShowDialog();
408
+        }
380 409
 
381
-            //            Console.WriteLine(wb.ToString());
410
+        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
411
+        {
412
+            AccsessDbLoader.getInstance().closeConnection();
413
+        }
382 414
 
383
-            //            WebViewForm wf = new WebViewForm();
384
-            //            wf.ShowDialog();
415
+        private void btnTextCmd_Click(object sender, EventArgs e)
416
+        {
417
+            try
418
+            {
419
+                Dictionary<string, string> abc = AccsessDbLoader.getInstance().getUserIdInfo();
420
+                MessageBox.Show(abc.Count + "");
421
+                string ac = abc["0400"];
422
+                MessageBox.Show(ac);
423
+            }
424
+            catch (Exception exception)
425
+            {
426
+                Console.WriteLine(exception);
427
+            }
385 428
         }
386 429
     }
387 430
 }

+ 9 - 1
GWSocketClient/GWSocketClient.csproj Parādīt failu

@@ -65,6 +65,12 @@
65 65
     <Compile Include="Form1.Designer.cs">
66 66
       <DependentUpon>Form1.cs</DependentUpon>
67 67
     </Compile>
68
+    <Compile Include="IdItemEditor.cs">
69
+      <SubType>Form</SubType>
70
+    </Compile>
71
+    <Compile Include="IdItemEditor.Designer.cs">
72
+      <DependentUpon>IdItemEditor.cs</DependentUpon>
73
+    </Compile>
68 74
     <Compile Include="InfoEditor.cs">
69 75
       <SubType>Form</SubType>
70 76
     </Compile>
@@ -83,7 +89,6 @@
83 89
     <Compile Include="property\PropertiesLoader.cs" />
84 90
     <Compile Include="util\CheckUtil.cs" />
85 91
     <Compile Include="util\HexUtil.cs" />
86
-    <Compile Include="util\JsonHelper.cs" />
87 92
     <Compile Include="util\Utils.cs" />
88 93
     <Compile Include="WebViewForm.cs">
89 94
       <SubType>Form</SubType>
@@ -102,6 +107,9 @@
102 107
     <EmbeddedResource Include="Form1.resx">
103 108
       <DependentUpon>Form1.cs</DependentUpon>
104 109
     </EmbeddedResource>
110
+    <EmbeddedResource Include="IdItemEditor.resx">
111
+      <DependentUpon>IdItemEditor.cs</DependentUpon>
112
+    </EmbeddedResource>
105 113
     <EmbeddedResource Include="InfoEditor.resx">
106 114
       <DependentUpon>InfoEditor.cs</DependentUpon>
107 115
     </EmbeddedResource>

+ 362 - 0
GWSocketClient/IdItemEditor.Designer.cs Parādīt failu

@@ -0,0 +1,362 @@
1
+namespace GWSocketClient
2
+{
3
+    partial class IdItemEditor
4
+    {
5
+        /// <summary>
6
+        /// Required designer variable.
7
+        /// </summary>
8
+        private System.ComponentModel.IContainer components = null;
9
+
10
+        /// <summary>
11
+        /// Clean up any resources being used.
12
+        /// </summary>
13
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14
+        protected override void Dispose(bool disposing)
15
+        {
16
+            if (disposing && (components != null))
17
+            {
18
+                components.Dispose();
19
+            }
20
+            base.Dispose(disposing);
21
+        }
22
+
23
+        #region Windows Form Designer generated code
24
+
25
+        /// <summary>
26
+        /// Required method for Designer support - do not modify
27
+        /// the contents of this method with the code editor.
28
+        /// </summary>
29
+        private void InitializeComponent()
30
+        {
31
+            this.labelId = new System.Windows.Forms.Label();
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.label2 = new System.Windows.Forms.Label();
34
+            this.tbId = new System.Windows.Forms.TextBox();
35
+            this.tbDesp = new System.Windows.Forms.TextBox();
36
+            this.tbLen = new System.Windows.Forms.TextBox();
37
+            this.tbInfo = new System.Windows.Forms.TextBox();
38
+            this.tbDv = new System.Windows.Forms.TextBox();
39
+            this.tbUv = new System.Windows.Forms.TextBox();
40
+            this.tbRemark = new System.Windows.Forms.TextBox();
41
+            this.label3 = new System.Windows.Forms.Label();
42
+            this.label4 = new System.Windows.Forms.Label();
43
+            this.label5 = new System.Windows.Forms.Label();
44
+            this.label6 = new System.Windows.Forms.Label();
45
+            this.label7 = new System.Windows.Forms.Label();
46
+            this.label8 = new System.Windows.Forms.Label();
47
+            this.label9 = new System.Windows.Forms.Label();
48
+            this.label10 = new System.Windows.Forms.Label();
49
+            this.buttonSubmit = new System.Windows.Forms.Button();
50
+            this.tbIndex = new System.Windows.Forms.TextBox();
51
+            this.buttonCancle = new System.Windows.Forms.Button();
52
+            this.labelDefaultlen = new System.Windows.Forms.Label();
53
+            this.labelUserLen = new System.Windows.Forms.Label();
54
+            this.richTextBoxTip = new System.Windows.Forms.RichTextBox();
55
+            this.checkBoxWrite = new System.Windows.Forms.CheckBox();
56
+            this.checkBoxRead = new System.Windows.Forms.CheckBox();
57
+            this.SuspendLayout();
58
+            // 
59
+            // labelId
60
+            // 
61
+            this.labelId.AutoSize = true;
62
+            this.labelId.Location = new System.Drawing.Point(390, 9);
63
+            this.labelId.Name = "labelId";
64
+            this.labelId.Size = new System.Drawing.Size(23, 19);
65
+            this.labelId.TabIndex = 0;
66
+            this.labelId.Text = "ID";
67
+            // 
68
+            // label1
69
+            // 
70
+            this.label1.AutoSize = true;
71
+            this.label1.Location = new System.Drawing.Point(345, 9);
72
+            this.label1.Name = "label1";
73
+            this.label1.Size = new System.Drawing.Size(23, 19);
74
+            this.label1.TabIndex = 1;
75
+            this.label1.Text = "ID";
76
+            // 
77
+            // label2
78
+            // 
79
+            this.label2.AutoSize = true;
80
+            this.label2.Location = new System.Drawing.Point(457, 9);
81
+            this.label2.Name = "label2";
82
+            this.label2.Size = new System.Drawing.Size(68, 19);
83
+            this.label2.TabIndex = 3;
84
+            this.label2.Text = "ID:10进制";
85
+            // 
86
+            // tbId
87
+            // 
88
+            this.tbId.Location = new System.Drawing.Point(63, 55);
89
+            this.tbId.Name = "tbId";
90
+            this.tbId.Size = new System.Drawing.Size(836, 25);
91
+            this.tbId.TabIndex = 1;
92
+            // 
93
+            // tbDesp
94
+            // 
95
+            this.tbDesp.Location = new System.Drawing.Point(63, 179);
96
+            this.tbDesp.Name = "tbDesp";
97
+            this.tbDesp.Size = new System.Drawing.Size(836, 25);
98
+            this.tbDesp.TabIndex = 5;
99
+            // 
100
+            // tbLen
101
+            // 
102
+            this.tbLen.Location = new System.Drawing.Point(63, 117);
103
+            this.tbLen.Name = "tbLen";
104
+            this.tbLen.Size = new System.Drawing.Size(836, 25);
105
+            this.tbLen.TabIndex = 3;
106
+            // 
107
+            // tbInfo
108
+            // 
109
+            this.tbInfo.Location = new System.Drawing.Point(63, 86);
110
+            this.tbInfo.Name = "tbInfo";
111
+            this.tbInfo.Size = new System.Drawing.Size(836, 25);
112
+            this.tbInfo.TabIndex = 2;
113
+            // 
114
+            // tbDv
115
+            // 
116
+            this.tbDv.Location = new System.Drawing.Point(63, 210);
117
+            this.tbDv.Name = "tbDv";
118
+            this.tbDv.Size = new System.Drawing.Size(836, 25);
119
+            this.tbDv.TabIndex = 6;
120
+            this.tbDv.TextChanged += new System.EventHandler(this.tbDv_TextChanged);
121
+            // 
122
+            // tbUv
123
+            // 
124
+            this.tbUv.Location = new System.Drawing.Point(61, 260);
125
+            this.tbUv.Name = "tbUv";
126
+            this.tbUv.Size = new System.Drawing.Size(836, 25);
127
+            this.tbUv.TabIndex = 7;
128
+            this.tbUv.TextChanged += new System.EventHandler(this.tbUv_TextChanged);
129
+            // 
130
+            // tbRemark
131
+            // 
132
+            this.tbRemark.Location = new System.Drawing.Point(63, 316);
133
+            this.tbRemark.Name = "tbRemark";
134
+            this.tbRemark.Size = new System.Drawing.Size(836, 25);
135
+            this.tbRemark.TabIndex = 8;
136
+            // 
137
+            // label3
138
+            // 
139
+            this.label3.AutoSize = true;
140
+            this.label3.Location = new System.Drawing.Point(12, 61);
141
+            this.label3.Name = "label3";
142
+            this.label3.Size = new System.Drawing.Size(36, 19);
143
+            this.label3.TabIndex = 12;
144
+            this.label3.Text = "ID值";
145
+            // 
146
+            // label4
147
+            // 
148
+            this.label4.AutoSize = true;
149
+            this.label4.Location = new System.Drawing.Point(12, 89);
150
+            this.label4.Name = "label4";
151
+            this.label4.Size = new System.Drawing.Size(35, 19);
152
+            this.label4.TabIndex = 12;
153
+            this.label4.Text = "功能";
154
+            // 
155
+            // label5
156
+            // 
157
+            this.label5.AutoSize = true;
158
+            this.label5.Location = new System.Drawing.Point(12, 120);
159
+            this.label5.Name = "label5";
160
+            this.label5.Size = new System.Drawing.Size(35, 19);
161
+            this.label5.TabIndex = 12;
162
+            this.label5.Text = "长度";
163
+            // 
164
+            // label6
165
+            // 
166
+            this.label6.AutoSize = true;
167
+            this.label6.Location = new System.Drawing.Point(12, 151);
168
+            this.label6.Name = "label6";
169
+            this.label6.Size = new System.Drawing.Size(41, 19);
170
+            this.label6.TabIndex = 12;
171
+            this.label6.Text = "读/写";
172
+            // 
173
+            // label7
174
+            // 
175
+            this.label7.AutoSize = true;
176
+            this.label7.Location = new System.Drawing.Point(12, 182);
177
+            this.label7.Name = "label7";
178
+            this.label7.Size = new System.Drawing.Size(35, 19);
179
+            this.label7.TabIndex = 12;
180
+            this.label7.Text = "描述";
181
+            // 
182
+            // label8
183
+            // 
184
+            this.label8.AutoSize = true;
185
+            this.label8.Location = new System.Drawing.Point(12, 213);
186
+            this.label8.Name = "label8";
187
+            this.label8.Size = new System.Drawing.Size(48, 19);
188
+            this.label8.TabIndex = 12;
189
+            this.label8.Text = "默认值";
190
+            // 
191
+            // label9
192
+            // 
193
+            this.label9.AutoSize = true;
194
+            this.label9.Location = new System.Drawing.Point(7, 263);
195
+            this.label9.Name = "label9";
196
+            this.label9.Size = new System.Drawing.Size(48, 19);
197
+            this.label9.TabIndex = 12;
198
+            this.label9.Text = "用户值";
199
+            // 
200
+            // label10
201
+            // 
202
+            this.label10.AutoSize = true;
203
+            this.label10.Location = new System.Drawing.Point(13, 319);
204
+            this.label10.Name = "label10";
205
+            this.label10.Size = new System.Drawing.Size(35, 19);
206
+            this.label10.TabIndex = 12;
207
+            this.label10.Text = "备注";
208
+            // 
209
+            // buttonSubmit
210
+            // 
211
+            this.buttonSubmit.Location = new System.Drawing.Point(721, 380);
212
+            this.buttonSubmit.Name = "buttonSubmit";
213
+            this.buttonSubmit.Size = new System.Drawing.Size(176, 43);
214
+            this.buttonSubmit.TabIndex = 9;
215
+            this.buttonSubmit.Text = "修改";
216
+            this.buttonSubmit.UseVisualStyleBackColor = true;
217
+            this.buttonSubmit.Click += new System.EventHandler(this.buttonSubmit_Click);
218
+            // 
219
+            // tbIndex
220
+            // 
221
+            this.tbIndex.Location = new System.Drawing.Point(531, 6);
222
+            this.tbIndex.Name = "tbIndex";
223
+            this.tbIndex.Size = new System.Drawing.Size(100, 25);
224
+            this.tbIndex.TabIndex = 0;
225
+            this.tbIndex.TextChanged += new System.EventHandler(this.tbIndex_TextChanged);
226
+            this.tbIndex.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbIndex_KeyPress);
227
+            // 
228
+            // buttonCancle
229
+            // 
230
+            this.buttonCancle.DialogResult = System.Windows.Forms.DialogResult.Cancel;
231
+            this.buttonCancle.Location = new System.Drawing.Point(539, 380);
232
+            this.buttonCancle.Name = "buttonCancle";
233
+            this.buttonCancle.Size = new System.Drawing.Size(176, 43);
234
+            this.buttonCancle.TabIndex = 10;
235
+            this.buttonCancle.Text = "取消/关闭";
236
+            this.buttonCancle.UseVisualStyleBackColor = true;
237
+            this.buttonCancle.Click += new System.EventHandler(this.buttonCancle_Click);
238
+            // 
239
+            // labelDefaultlen
240
+            // 
241
+            this.labelDefaultlen.AutoSize = true;
242
+            this.labelDefaultlen.Location = new System.Drawing.Point(59, 238);
243
+            this.labelDefaultlen.Name = "labelDefaultlen";
244
+            this.labelDefaultlen.Size = new System.Drawing.Size(25, 19);
245
+            this.labelDefaultlen.TabIndex = 16;
246
+            this.labelDefaultlen.Text = "00";
247
+            // 
248
+            // labelUserLen
249
+            // 
250
+            this.labelUserLen.AutoSize = true;
251
+            this.labelUserLen.Location = new System.Drawing.Point(59, 288);
252
+            this.labelUserLen.Name = "labelUserLen";
253
+            this.labelUserLen.Size = new System.Drawing.Size(25, 19);
254
+            this.labelUserLen.TabIndex = 17;
255
+            this.labelUserLen.Text = "00";
256
+            // 
257
+            // richTextBoxTip
258
+            // 
259
+            this.richTextBoxTip.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
260
+            this.richTextBoxTip.ForeColor = System.Drawing.Color.Red;
261
+            this.richTextBoxTip.Location = new System.Drawing.Point(11, 429);
262
+            this.richTextBoxTip.Name = "richTextBoxTip";
263
+            this.richTextBoxTip.ReadOnly = true;
264
+            this.richTextBoxTip.Size = new System.Drawing.Size(886, 120);
265
+            this.richTextBoxTip.TabIndex = 18;
266
+            this.richTextBoxTip.Text = "";
267
+            // 
268
+            // checkBoxWrite
269
+            // 
270
+            this.checkBoxWrite.AutoSize = true;
271
+            this.checkBoxWrite.Location = new System.Drawing.Point(110, 150);
272
+            this.checkBoxWrite.Name = "checkBoxWrite";
273
+            this.checkBoxWrite.Size = new System.Drawing.Size(41, 23);
274
+            this.checkBoxWrite.TabIndex = 19;
275
+            this.checkBoxWrite.Text = "写";
276
+            this.checkBoxWrite.UseVisualStyleBackColor = true;
277
+            // 
278
+            // checkBoxRead
279
+            // 
280
+            this.checkBoxRead.AutoSize = true;
281
+            this.checkBoxRead.Location = new System.Drawing.Point(63, 150);
282
+            this.checkBoxRead.Name = "checkBoxRead";
283
+            this.checkBoxRead.Size = new System.Drawing.Size(41, 23);
284
+            this.checkBoxRead.TabIndex = 20;
285
+            this.checkBoxRead.Text = "读";
286
+            this.checkBoxRead.UseVisualStyleBackColor = true;
287
+            // 
288
+            // IdItemEditor
289
+            // 
290
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 19F);
291
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
292
+            this.CancelButton = this.buttonCancle;
293
+            this.ClientSize = new System.Drawing.Size(911, 561);
294
+            this.Controls.Add(this.checkBoxRead);
295
+            this.Controls.Add(this.checkBoxWrite);
296
+            this.Controls.Add(this.richTextBoxTip);
297
+            this.Controls.Add(this.labelUserLen);
298
+            this.Controls.Add(this.labelDefaultlen);
299
+            this.Controls.Add(this.tbIndex);
300
+            this.Controls.Add(this.buttonCancle);
301
+            this.Controls.Add(this.buttonSubmit);
302
+            this.Controls.Add(this.label10);
303
+            this.Controls.Add(this.label9);
304
+            this.Controls.Add(this.label8);
305
+            this.Controls.Add(this.label7);
306
+            this.Controls.Add(this.label6);
307
+            this.Controls.Add(this.label5);
308
+            this.Controls.Add(this.label4);
309
+            this.Controls.Add(this.label3);
310
+            this.Controls.Add(this.tbDv);
311
+            this.Controls.Add(this.tbUv);
312
+            this.Controls.Add(this.tbRemark);
313
+            this.Controls.Add(this.tbInfo);
314
+            this.Controls.Add(this.tbLen);
315
+            this.Controls.Add(this.tbDesp);
316
+            this.Controls.Add(this.tbId);
317
+            this.Controls.Add(this.label2);
318
+            this.Controls.Add(this.label1);
319
+            this.Controls.Add(this.labelId);
320
+            this.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
321
+            this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
322
+            this.MaximizeBox = false;
323
+            this.MinimizeBox = false;
324
+            this.Name = "IdItemEditor";
325
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
326
+            this.Text = "IdItemEditor";
327
+            this.Load += new System.EventHandler(this.IdItemEditor_Load);
328
+            this.ResumeLayout(false);
329
+            this.PerformLayout();
330
+
331
+        }
332
+
333
+        #endregion
334
+
335
+        private System.Windows.Forms.Label labelId;
336
+        private System.Windows.Forms.Label label1;
337
+        private System.Windows.Forms.Label label2;
338
+        private System.Windows.Forms.TextBox tbId;
339
+        private System.Windows.Forms.TextBox tbDesp;
340
+        private System.Windows.Forms.TextBox tbLen;
341
+        private System.Windows.Forms.TextBox tbInfo;
342
+        private System.Windows.Forms.TextBox tbDv;
343
+        private System.Windows.Forms.TextBox tbUv;
344
+        private System.Windows.Forms.TextBox tbRemark;
345
+        private System.Windows.Forms.Label label3;
346
+        private System.Windows.Forms.Label label4;
347
+        private System.Windows.Forms.Label label5;
348
+        private System.Windows.Forms.Label label6;
349
+        private System.Windows.Forms.Label label7;
350
+        private System.Windows.Forms.Label label8;
351
+        private System.Windows.Forms.Label label9;
352
+        private System.Windows.Forms.Label label10;
353
+        private System.Windows.Forms.Button buttonSubmit;
354
+        private System.Windows.Forms.TextBox tbIndex;
355
+        private System.Windows.Forms.Button buttonCancle;
356
+        private System.Windows.Forms.Label labelDefaultlen;
357
+        private System.Windows.Forms.Label labelUserLen;
358
+        private System.Windows.Forms.RichTextBox richTextBoxTip;
359
+        private System.Windows.Forms.CheckBox checkBoxWrite;
360
+        private System.Windows.Forms.CheckBox checkBoxRead;
361
+    }
362
+}

+ 241 - 0
GWSocketClient/IdItemEditor.cs Parādīt failu

@@ -0,0 +1,241 @@
1
+using GWSocketClient.db;
2
+using GWSocketClient.model;
3
+using System;
4
+using System.Collections.Generic;
5
+using System.ComponentModel;
6
+using System.Data;
7
+using System.Drawing;
8
+using System.Linq;
9
+using System.Text;
10
+using System.Threading.Tasks;
11
+using System.Windows.Forms;
12
+using GWSocketClient.util;
13
+
14
+namespace GWSocketClient
15
+{
16
+    public delegate void OnHandlerResult(string topmost);
17
+
18
+    public partial class IdItemEditor : Form
19
+    {
20
+        private WvBean wbBean = null;
21
+        private bool addOrUpdate = true;
22
+
23
+        public event OnHandlerResult HandlerResult;
24
+
25
+        public IdItemEditor(WvBean wb = null)
26
+        {
27
+            InitializeComponent();
28
+            this.wbBean = wb;
29
+        }
30
+
31
+        private void IdItemEditor_Load(object sender, EventArgs e)
32
+        {
33
+            if (wbBean != null)
34
+            {
35
+                this.Text = "修改";
36
+                buttonSubmit.Text = "修改";
37
+                addOrUpdate = false;
38
+
39
+                addModifyText();
40
+            }
41
+            else
42
+            {
43
+                this.Text = "添加";
44
+                buttonSubmit.Text = "添加";
45
+                addOrUpdate = true;
46
+            }
47
+        }
48
+
49
+        private void addModifyText()
50
+        {
51
+            labelId.Text = wbBean.id + "";
52
+            tbIndex.Text = wbBean.index + "";
53
+            tbId.Text = wbBean.myId;
54
+            tbInfo.Text = wbBean.idInfo;
55
+            tbLen.Text = wbBean.len;
56
+
57
+            tbDesp.Text = wbBean.desp;
58
+            tbDv.Text = wbBean.defalutValue;
59
+            tbUv.Text = wbBean.userValue;
60
+            tbRemark.Text = wbBean.remark;
61
+
62
+            string mode = wbBean.mode.ToUpper();
63
+
64
+            if (mode.Contains("W"))
65
+            {
66
+                checkBoxWrite.Checked = true;
67
+            }
68
+            if (mode.Contains("R"))
69
+            {
70
+                checkBoxRead.Checked = true;
71
+            }
72
+
73
+
74
+            if (!tbLen.Text.Trim().Equals("-1"))
75
+            {
76
+                labelDefaultlen.Text = tbDv.Text.Trim().Length / 2.0 + " / " + tbLen.Text.Trim();
77
+            }
78
+            else
79
+            {
80
+                labelDefaultlen.Text = tbDv.Text.Trim().Length / 2.0 + "";
81
+            }
82
+
83
+            if (!tbLen.Text.Trim().Equals("-1"))
84
+            {
85
+                labelUserLen.Text = tbUv.Text.Trim().Length / 2.0 + " / " + tbLen.Text.Trim();
86
+            }
87
+            else
88
+            {
89
+                labelUserLen.Text = tbUv.Text.Trim().Length / 2.0 + "";
90
+            }
91
+        }
92
+
93
+
94
+        private void buttonSubmit_Click(object sender, EventArgs e)
95
+        {
96
+            string tbIndexString = tbIndex.Text.Trim();
97
+            string myIdString = tbId.Text.Trim();
98
+            string lenString = tbLen.Text.Trim();
99
+            string defalutValueString = tbDv.Text.Trim();
100
+
101
+            bool modeBool = checkBoxWrite.Checked || checkBoxRead.Checked;
102
+
103
+
104
+            if (tbIndexString.Equals(""))
105
+            {
106
+                richTextBoxTip.Text = "Index不能为空!";
107
+                return;
108
+            }
109
+
110
+            if (myIdString.Equals(""))
111
+            {
112
+                richTextBoxTip.Text = "ID 16进制不能为空!";
113
+                return;
114
+            }
115
+            if (lenString.Equals(""))
116
+            {
117
+                richTextBoxTip.Text = "长度不能为空!";
118
+
119
+                return;
120
+            }
121
+            if (!modeBool)
122
+            {
123
+                richTextBoxTip.Text = "读取不能为空!";
124
+                return;
125
+            }
126
+            if (defalutValueString.Equals(""))
127
+            {
128
+                richTextBoxTip.Text = "默认值不能为空!";
129
+                return;
130
+            }
131
+
132
+            string userValueString = tbUv.Text.Trim();
133
+
134
+            WvBean wb = new WvBean();
135
+
136
+            wb.index = int.Parse(tbIndexString);
137
+            wb.myId = myIdString;
138
+            wb.idInfo = tbInfo.Text.Trim();
139
+            wb.len = lenString;
140
+
141
+            string modeString = checkBoxRead.Checked ? "R" : "";
142
+            modeString += checkBoxWrite.Checked ? "W" : "";
143
+
144
+            wb.mode = modeString;
145
+            wb.desp = tbDesp.Text.Trim();
146
+
147
+            wb.defalutValue = defalutValueString;
148
+
149
+            if (userValueString.Equals(""))
150
+            {
151
+                userValueString = defalutValueString;
152
+            }
153
+            wb.userValue = userValueString;
154
+            wb.remark = tbRemark.Text.Trim();
155
+            int res = -1;
156
+            if (addOrUpdate)
157
+            {
158
+                //添加
159
+                try
160
+                {
161
+                    res = AccsessDbLoader.getInstance().insert2Db(wb);
162
+                }
163
+                catch (Exception exception)
164
+                {
165
+                    Console.WriteLine(exception);
166
+                    richTextBoxTip.Text = "异常:" + exception.Message;
167
+                }
168
+            }
169
+            else
170
+            {
171
+                //更新
172
+                wb.id = int.Parse(labelId.Text.Trim());
173
+                try
174
+                {
175
+                    res = AccsessDbLoader.getInstance().update2Db(wb);
176
+                }
177
+                catch (Exception exception)
178
+                {
179
+                    Console.WriteLine(exception);
180
+                    richTextBoxTip.Text = "异常:" + exception.Message;
181
+                }
182
+            }
183
+            if (res > 0)
184
+            {
185
+                HandlerResult("成功"); //执行委托实例  
186
+                this.Close();
187
+            }
188
+        }
189
+
190
+
191
+        private void buttonCancle_Click(object sender, EventArgs e)
192
+        {
193
+            this.Close();
194
+        }
195
+
196
+        private void tbUv_TextChanged(object sender, EventArgs e)
197
+        {
198
+            if (!tbLen.Text.Trim().Equals("-1"))
199
+            {
200
+                labelUserLen.Text = tbUv.Text.Trim().Length / 2.0 + " / " + tbLen.Text.Trim();
201
+            }
202
+            else
203
+            {
204
+                labelUserLen.Text = tbUv.Text.Trim().Length / 2.0 + "";
205
+            }
206
+        }
207
+
208
+        private void tbDv_TextChanged(object sender, EventArgs e)
209
+        {
210
+            if (!tbLen.Text.Trim().Equals("-1"))
211
+            {
212
+                labelDefaultlen.Text = tbDv.Text.Trim().Length / 2.0 + " / " + tbLen.Text.Trim();
213
+            }
214
+            else
215
+            {
216
+                labelDefaultlen.Text = tbDv.Text.Trim().Length / 2.0 + "";
217
+            }
218
+        }
219
+
220
+        private void tbIndex_TextChanged(object sender, EventArgs e)
221
+        {
222
+            string input = tbIndex.Text.Trim();
223
+            if (!input.Equals(""))
224
+            {
225
+                tbId.Text = Utils.stringWith0(Utils.tenToHex(Utils.validInput(input)), 4);
226
+            }
227
+            else
228
+            {
229
+                tbId.Text = "";
230
+            }
231
+        }
232
+
233
+        private void tbIndex_KeyPress(object sender, KeyPressEventArgs e)
234
+        {
235
+            if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar))
236
+            {
237
+                e.Handled = true;
238
+            }
239
+        }
240
+    }
241
+}

+ 123 - 0
GWSocketClient/IdItemEditor.resx Parādīt failu

@@ -0,0 +1,123 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+  <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
121
+    <value>True</value>
122
+  </metadata>
123
+</root>

+ 95 - 35
GWSocketClient/InfoEditor.Designer.cs Parādīt failu

@@ -28,77 +28,137 @@
28 28
         /// </summary>
29 29
         private void InitializeComponent()
30 30
         {
31
+            this.components = new System.ComponentModel.Container();
31 32
             this.dataGridView1 = new System.Windows.Forms.DataGridView();
32
-            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
33
-            this.文件FToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
34
-            this.tsmiUpdateDb = new System.Windows.Forms.ToolStripMenuItem();
33
+            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
34
+            this.CtsmIDeleteItem = new System.Windows.Forms.ToolStripMenuItem();
35
+            this.buttonDeleteSelect = new System.Windows.Forms.Button();
36
+            this.buttonAddCmd = new System.Windows.Forms.Button();
37
+            this.buttonRefresh = new System.Windows.Forms.Button();
38
+            this.btnResetUserdata = new System.Windows.Forms.Button();
39
+            this.btnClosedThis = new System.Windows.Forms.Button();
35 40
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
36
-            this.menuStrip1.SuspendLayout();
41
+            this.contextMenuStrip1.SuspendLayout();
37 42
             this.SuspendLayout();
38 43
             // 
39 44
             // dataGridView1
40 45
             // 
41
-            this.dataGridView1.AllowUserToOrderColumns = true;
46
+            this.dataGridView1.AllowUserToAddRows = false;
42 47
             this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
43 48
             | System.Windows.Forms.AnchorStyles.Left) 
44 49
             | System.Windows.Forms.AnchorStyles.Right)));
45 50
             this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
51
+            this.dataGridView1.ContextMenuStrip = this.contextMenuStrip1;
46 52
             this.dataGridView1.Location = new System.Drawing.Point(12, 190);
53
+            this.dataGridView1.MultiSelect = false;
47 54
             this.dataGridView1.Name = "dataGridView1";
55
+            this.dataGridView1.ReadOnly = true;
48 56
             this.dataGridView1.RowTemplate.Height = 23;
49
-            this.dataGridView1.Size = new System.Drawing.Size(1217, 400);
57
+            this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
58
+            this.dataGridView1.Size = new System.Drawing.Size(1217, 559);
50 59
             this.dataGridView1.TabIndex = 0;
51
-            
60
+            this.dataGridView1.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseClick);
61
+            this.dataGridView1.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseDoubleClick);
52 62
             // 
53
-            // menuStrip1
63
+            // contextMenuStrip1
54 64
             // 
55
-            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
56
-            this.文件FToolStripMenuItem});
57
-            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
58
-            this.menuStrip1.Name = "menuStrip1";
59
-            this.menuStrip1.Size = new System.Drawing.Size(1241, 25);
60
-            this.menuStrip1.TabIndex = 1;
61
-            this.menuStrip1.Text = "menuStrip1";
65
+            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
66
+            this.CtsmIDeleteItem});
67
+            this.contextMenuStrip1.Name = "contextMenuStrip1";
68
+            this.contextMenuStrip1.Size = new System.Drawing.Size(154, 26);
62 69
             // 
63
-            // 文件FToolStripMenuItem
70
+            // CtsmIDeleteItem
64 71
             // 
65
-            this.文件FToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
66
-            this.tsmiUpdateDb});
67
-            this.文件FToolStripMenuItem.Name = "文件FToolStripMenuItem";
68
-            this.文件FToolStripMenuItem.Size = new System.Drawing.Size(58, 21);
69
-            this.文件FToolStripMenuItem.Text = "文件(&F)";
72
+            this.CtsmIDeleteItem.Name = "CtsmIDeleteItem";
73
+            this.CtsmIDeleteItem.Size = new System.Drawing.Size(153, 22);
74
+            this.CtsmIDeleteItem.Text = "删除当前行(&D)";
70 75
             // 
71
-            // tsmiUpdateDb
76
+            // buttonDeleteSelect
72 77
             // 
73
-            this.tsmiUpdateDb.Name = "tsmiUpdateDb";
74
-            this.tsmiUpdateDb.Size = new System.Drawing.Size(152, 22);
75
-            this.tsmiUpdateDb.Text = "保存(&S)";
76
-            this.tsmiUpdateDb.Click += new System.EventHandler(this.tsmiUpdateDb_Click);
78
+            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);
80
+            this.buttonDeleteSelect.Name = "buttonDeleteSelect";
81
+            this.buttonDeleteSelect.Size = new System.Drawing.Size(75, 30);
82
+            this.buttonDeleteSelect.TabIndex = 3;
83
+            this.buttonDeleteSelect.Text = "删除选中";
84
+            this.buttonDeleteSelect.UseVisualStyleBackColor = true;
85
+            this.buttonDeleteSelect.Click += new System.EventHandler(this.buttonDeleteSelect_Click);
86
+            // 
87
+            // buttonAddCmd
88
+            // 
89
+            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);
91
+            this.buttonAddCmd.Name = "buttonAddCmd";
92
+            this.buttonAddCmd.Size = new System.Drawing.Size(75, 30);
93
+            this.buttonAddCmd.TabIndex = 4;
94
+            this.buttonAddCmd.Text = "添加命令";
95
+            this.buttonAddCmd.UseVisualStyleBackColor = true;
96
+            this.buttonAddCmd.Click += new System.EventHandler(this.buttonAddCmd_Click);
97
+            // 
98
+            // buttonRefresh
99
+            // 
100
+            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);
102
+            this.buttonRefresh.Name = "buttonRefresh";
103
+            this.buttonRefresh.Size = new System.Drawing.Size(75, 30);
104
+            this.buttonRefresh.TabIndex = 5;
105
+            this.buttonRefresh.Text = "刷新数据";
106
+            this.buttonRefresh.UseVisualStyleBackColor = true;
107
+            this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click);
108
+            // 
109
+            // btnResetUserdata
110
+            // 
111
+            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);
113
+            this.btnResetUserdata.Name = "btnResetUserdata";
114
+            this.btnResetUserdata.Size = new System.Drawing.Size(111, 30);
115
+            this.btnResetUserdata.TabIndex = 6;
116
+            this.btnResetUserdata.Text = "重置用户数据";
117
+            this.btnResetUserdata.UseVisualStyleBackColor = true;
118
+            this.btnResetUserdata.Click += new System.EventHandler(this.btnResetUserdata_Click);
119
+            // 
120
+            // btnClosedThis
121
+            // 
122
+            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);
124
+            this.btnClosedThis.Name = "btnClosedThis";
125
+            this.btnClosedThis.Size = new System.Drawing.Size(75, 30);
126
+            this.btnClosedThis.TabIndex = 8;
127
+            this.btnClosedThis.Text = "关闭";
128
+            this.btnClosedThis.UseVisualStyleBackColor = true;
129
+            this.btnClosedThis.Click += new System.EventHandler(this.btnClosedThis_Click);
77 130
             // 
78 131
             // InfoEditor
79 132
             // 
80 133
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
81 134
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
82
-            this.ClientSize = new System.Drawing.Size(1241, 602);
135
+            this.CancelButton = this.btnClosedThis;
136
+            this.ClientSize = new System.Drawing.Size(1241, 761);
137
+            this.Controls.Add(this.btnClosedThis);
138
+            this.Controls.Add(this.btnResetUserdata);
139
+            this.Controls.Add(this.buttonRefresh);
140
+            this.Controls.Add(this.buttonAddCmd);
141
+            this.Controls.Add(this.buttonDeleteSelect);
83 142
             this.Controls.Add(this.dataGridView1);
84
-            this.Controls.Add(this.menuStrip1);
85
-            this.MainMenuStrip = this.menuStrip1;
86 143
             this.Name = "InfoEditor";
144
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
87 145
             this.Text = "InfoEditor";
88 146
             this.Load += new System.EventHandler(this.InfoEditor_Load);
89 147
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
90
-            this.menuStrip1.ResumeLayout(false);
91
-            this.menuStrip1.PerformLayout();
148
+            this.contextMenuStrip1.ResumeLayout(false);
92 149
             this.ResumeLayout(false);
93
-            this.PerformLayout();
94 150
 
95 151
         }
96 152
 
97 153
         #endregion
98 154
 
99 155
         private System.Windows.Forms.DataGridView dataGridView1;
100
-        private System.Windows.Forms.MenuStrip menuStrip1;
101
-        private System.Windows.Forms.ToolStripMenuItem 文件FToolStripMenuItem;
102
-        private System.Windows.Forms.ToolStripMenuItem tsmiUpdateDb;
156
+        private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
157
+        private System.Windows.Forms.ToolStripMenuItem CtsmIDeleteItem;
158
+        private System.Windows.Forms.Button buttonDeleteSelect;
159
+        private System.Windows.Forms.Button buttonAddCmd;
160
+        private System.Windows.Forms.Button buttonRefresh;
161
+        private System.Windows.Forms.Button btnResetUserdata;
162
+        private System.Windows.Forms.Button btnClosedThis;
103 163
     }
104 164
 }

+ 81 - 4
GWSocketClient/InfoEditor.cs Parādīt failu

@@ -9,11 +9,14 @@ using System.Text;
9 9
 using System.Threading.Tasks;
10 10
 using System.Windows.Forms;
11 11
 using GWSocketClient.db;
12
+using GWSocketClient.model;
12 13
 
13 14
 namespace GWSocketClient
14 15
 {
15 16
     public partial class InfoEditor : Form
16 17
     {
18
+        private int selectIndex = -1;
19
+
17 20
         public InfoEditor()
18 21
         {
19 22
             InitializeComponent();
@@ -24,12 +27,86 @@ namespace GWSocketClient
24 27
             dataGridView1.DataSource = AccsessDbLoader.getInstance().getDataTable();
25 28
         }
26 29
 
27
-        private void tsmiUpdateDb_Click(object sender, EventArgs e)
30
+
31
+        private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
28 32
         {
29
-            
33
+            int col = dataGridView1.ColumnCount;
34
+            int row = dataGridView1.RowCount;
35
+            int x = e.RowIndex;
36
+            int y = e.ColumnIndex;
37
+            if (x >= 0 && y >= 0 && x < row && y < col)
38
+            {
39
+                WvBean wb = new WvBean();
40
+                wb.id = int.Parse(dataGridView1[0, x].Value + "");
41
+                wb.index = int.Parse(dataGridView1[1, x].Value + "");
42
+                wb.myId = dataGridView1[2, x].Value + "";
43
+                wb.idInfo = dataGridView1[3, x].Value + "";
44
+                wb.len = dataGridView1[4, x].Value + "";
45
+                wb.mode = dataGridView1[5, x].Value + "";
46
+                wb.desp = dataGridView1[6, x].Value + "";
47
+                wb.defalutValue = dataGridView1[7, x].Value + "";
48
+                wb.userValue = dataGridView1[8, x].Value + "";
49
+                wb.remark = dataGridView1[9, x].Value + "";
50
+
51
+                IdItemEditor iie = new IdItemEditor(wb);
52
+                iie.HandlerResult += Iie_HandlerResult;
53
+                iie.ShowDialog();
54
+            }
30 55
         }
31 56
 
32
-       
33
-        
57
+        private void Iie_HandlerResult(string topmost)
58
+        {
59
+            MessageBox.Show(topmost);
60
+            dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
61
+        }
62
+
63
+
64
+        private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
65
+        {
66
+            if (e.Button == MouseButtons.Left)
67
+            {
68
+                int x = e.RowIndex;
69
+
70
+                if (x >= 0 && x < dataGridView1.RowCount)
71
+                {
72
+                    selectIndex = x;
73
+                }
74
+            }
75
+        }
76
+
77
+        //选中数据
78
+        private void buttonDeleteSelect_Click(object sender, EventArgs e)
79
+        {
80
+            if (selectIndex >= 0)
81
+            {
82
+                AccsessDbLoader.getInstance().delete4Db(int.Parse(dataGridView1[0, selectIndex].Value + ""));
83
+                dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
84
+            }
85
+        }
86
+
87
+        //刷新数据
88
+        private void buttonRefresh_Click(object sender, EventArgs e)
89
+        {
90
+            dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
91
+        }
92
+
93
+        //添加命令
94
+        private void buttonAddCmd_Click(object sender, EventArgs e)
95
+        {
96
+            IdItemEditor iie = new IdItemEditor();
97
+            iie.HandlerResult += Iie_HandlerResult;
98
+            iie.ShowDialog();
99
+        }
100
+
101
+        private void btnResetUserdata_Click(object sender, EventArgs e)
102
+        {
103
+            AccsessDbLoader.getInstance().resetUserData();
104
+            dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
105
+        }
106
+
107
+        private void btnClosedThis_Click(object sender, EventArgs e)
108
+        {
109
+            this.Close();
110
+        }
34 111
     }
35 112
 }

+ 2 - 2
GWSocketClient/InfoEditor.resx Parādīt failu

@@ -117,7 +117,7 @@
117 117
   <resheader name="writer">
118 118
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119 119
   </resheader>
120
-  <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121
-    <value>17, 17</value>
120
+  <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121
+    <value>137, 17</value>
122 122
   </metadata>
123 123
 </root>

Binārs
GWSocketClient/bin/Debug/dbfile/ID_INFO.accdb Parādīt failu


+ 143 - 70
GWSocketClient/db/AccsessDbLoader.cs Parādīt failu

@@ -7,19 +7,20 @@ using System.Text;
7 7
 using System.Threading.Tasks;
8 8
 using System.Windows.Forms;
9 9
 using GWSocketClient.model;
10
+using GWSocketClient.util;
10 11
 using Newtonsoft.Json;
11 12
 
12 13
 namespace GWSocketClient.db
13 14
 {
14
-    class AccsessDbLoader
15
+    public class AccsessDbLoader
15 16
     {
16 17
         private static AccsessDbLoader INSTANCE = null;
17 18
 
18 19
         private DataTable dataTable = new DataTable();
19 20
         private OleDbDataAdapter dataAdapter;
20 21
 
21
-        private List<WvBean> wvBeans = new List<WvBean>();
22
-        public Dictionary<string, string> ID_INFO = new Dictionary<string, string>();
22
+//        private List<WvBean> wvBeans = new List<WvBean>();
23
+        private Dictionary<string, string> ID_INFO = new Dictionary<string, string>();
23 24
 
24 25
         public static AccsessDbLoader getInstance(string dbssPath = "")
25 26
         {
@@ -42,10 +43,10 @@ namespace GWSocketClient.db
42 43
             return ID_INFO;
43 44
         }
44 45
 
45
-        public string getWebViewJson()
46
-        {
47
-            return JsonConvert.SerializeObject(wvBeans);
48
-        }
46
+        /* public string getWebViewJson()
47
+         {
48
+             return JsonConvert.SerializeObject(wvBeans);
49
+         }*/
49 50
 
50 51
         private AccsessDbLoader(string dbPath = "")
51 52
         {
@@ -53,92 +54,164 @@ namespace GWSocketClient.db
53 54
             {
54 55
                 dbPath = Application.StartupPath + "/dbfile/ID_INFO.accdb;";
55 56
             }
56
-            reloadAccessDb(dbPath);
57
+            openConnection(dbPath);
58
+            reloadAccessDb();
57 59
         }
58 60
 
61
+        private static string strConnection = "Provider = Microsoft.ACE.OLEDB.12.0;" + "Data Source = ";
59 62
 
60
-        public AccsessDbLoader reloadAccessDb(string dbPath)
61
-        {
62
-            OleDbConnection mycon = null;
63
-            OleDbDataReader myReader = null;
64 63
 
65
-            OleDbCommand sqlcmd = null;
64
+        private OleDbConnection objConnection = null;
65
+
66
+        private void openConnection(string dbPath)
67
+        {
68
+            strConnection += dbPath;
69
+            objConnection = new OleDbConnection(strConnection);
70
+            objConnection.Open();
71
+        }
66 72
 
67
-            string strConnection = "Provider = Microsoft.ACE.OLEDB.12.0;" + "Data Source = " + dbPath;
73
+        public void closeConnection()
74
+        {
75
+            objConnection.Close();
76
+        }
68 77
 
78
+        public AccsessDbLoader reloadAccessDb()
79
+        {
69 80
             try
70 81
             {
71
-                using (OleDbConnection objConnection = new OleDbConnection(strConnection))
72
-                {
73
-                    objConnection.Open();
74
-                    sqlcmd = new OleDbCommand(@"select * from fw", objConnection); //sql语句     
75
-
76
-
77
-                    dataAdapter = new OleDbDataAdapter(sqlcmd);
82
+                OleDbCommand sqlcmd = new OleDbCommand(@"select * from fw", objConnection);
78 83
 
79
-                    dataAdapter.Fill(dataTable);
84
+                dataAdapter = new OleDbDataAdapter(sqlcmd);
85
+                dataTable.Clear();
86
+                ID_INFO.Clear();
87
+//                wvBeans.Clear();
88
+                dataAdapter.Fill(dataTable);
80 89
 
81
-                    using (OleDbDataReader reader = sqlcmd.ExecuteReader())
90
+                using (OleDbDataReader reader = sqlcmd.ExecuteReader())
91
+                {
92
+                    while (reader.Read()) //这个read调用很重要!不写的话运行时将提示找不到数据  
82 93
                     {
83
-                        if (reader.Read()) //这个read调用很重要!不写的话运行时将提示找不到数据  
84
-                        {
85
-                            WvBean wb = new WvBean();
86
-                            int id = 0;
87
-                            int index = 0;
88
-                            string myId = "";
89
-                            string idInfo = "";
90
-                            string len = "";
91
-                            string mode = "";
92
-                            string desp = "";
93
-                            string defalutValue = "";
94
-                            string userValue = "";
95
-                            string remark = "";
96
-                            try
97
-                            {
98
-                                id = reader.GetInt32(0);
99
-                                index = reader.GetInt32(1);
100
-                                myId = reader.GetString(2);
101
-                                idInfo = calcNull(reader.GetString(3));
102
-                                len = calcNull(reader.GetString(4));
103
-                                mode = calcNull(reader.GetString(5));
104
-                                desp = calcNull(reader.GetString(6));
105
-                                defalutValue = calcNull(reader.GetString(7));
106
-                                userValue = calcNull(reader.GetString(8));
107
-                                remark = calcNull(reader.GetString(9));
108
-                            }
109
-                            catch (Exception exception)
110
-                            {
111
-                            }
112
-
113
-                            wb.id = id;
114
-                            wb.index = index;
115
-                            wb.myId = myId;
116
-                            wb.idInfo = idInfo;
117
-                            wb.len = len;
118
-                            wb.mode = mode;
119
-                            wb.desp = desp;
120
-                            wb.defalutValue = defalutValue;
121
-                            wb.userValue = userValue;
122
-                            wb.remark = remark;
123
-
124
-                            ID_INFO.Add(myId, userValue);
125
-
126
-                            wvBeans.Add(wb);
127
-                        }
94
+                        WvBean wb = new WvBean();
95
+                        int id = 0;
96
+                        int index = 0;
97
+                        string myId = "";
98
+                        string idInfo = "";
99
+                        string len = "";
100
+                        string mode = "";
101
+                        string desp = "";
102
+                        string defalutValue = "";
103
+                        string userValue = "";
104
+                        string remark = "";
105
+                        /*try
106
+                        {*/
107
+                        id = reader.GetInt32(0);
108
+                        index = reader.GetInt32(1);
109
+                        myId = reader.GetString(2);
110
+                        idInfo = calcNull(reader.GetString(3));
111
+                        len = calcNull(reader.GetString(4));
112
+                        mode = calcNull(reader.GetString(5));
113
+                        desp = calcNull(reader.GetString(6));
114
+                        defalutValue = calcNull(reader.GetString(7));
115
+                        userValue = calcNull(reader.GetString(8));
116
+                        remark = calcNull(reader.GetString(9));
117
+                        /* }
118
+                         catch (Exception exception)
119
+                         {
120
+                         }*/
121
+
122
+                        wb.id = id;
123
+                        wb.index = index;
124
+                        wb.myId = myId;
125
+                        wb.idInfo = idInfo;
126
+                        wb.len = len;
127
+                        wb.mode = mode;
128
+                        wb.desp = desp;
129
+                        wb.defalutValue = defalutValue;
130
+                        wb.userValue = userValue;
131
+                        wb.remark = remark;
132
+
133
+                        ID_INFO.Add(myId, userValue);
134
+
135
+//                        wvBeans.Add(wb);
128 136
                     }
129 137
                 }
130
-                return this;
131 138
             }
132 139
             catch (OleDbException oe)
133 140
             {
134 141
                 MessageBox.Show(oe.Message);
135 142
             }
143
+
136 144
             catch (Exception exception)
137 145
             {
138 146
                 MyMessageBox.ShowMessageBox(exception.Message);
139 147
             }
140 148
 
141
-            return null;
149
+            return this;
150
+        }
151
+
152
+
153
+        public int insert2Db(WvBean wb)
154
+        {
155
+            string sql = "INSERT INTO fw(my_index,MY_ID,idInfo,len,mode,desp,default_value,user_value,remark) VALUES(";
156
+            sql += wb.index + ",";
157
+            sql += "'" + wb.myId + "',";
158
+            sql += "'" + wb.idInfo + "',";
159
+            sql += "'" + wb.len + "',";
160
+            sql += "'" + wb.mode + "',";
161
+            sql += "'" + wb.desp + "',";
162
+            sql += "'" + wb.defalutValue + "',";
163
+            sql += "'" + wb.userValue + "',";
164
+            sql += "'" + wb.remark + "')";
165
+            Console.WriteLine(sql);
166
+            OleDbCommand inst = new OleDbCommand(sql, objConnection);
167
+
168
+            return inst.ExecuteNonQuery();
169
+        }
170
+
171
+        public int delete4Db(int id)
172
+        {
173
+            string sql = "delete from fw where ID=" + id;
174
+            OleDbCommand inst = new OleDbCommand(sql, objConnection);
175
+            return inst.ExecuteNonQuery();
176
+        }
177
+
178
+        public int update2Db(WvBean wb)
179
+        {
180
+            /*string sql = "update fw set index=" + wb.index + ", MY_ID='" + wb.myId + "',idInfo='" + wb.idInfo +
181
+                         "',len='" + wb.len +
182
+                         "',mode='" +
183
+                         wb.mode + "',desp='" + wb.desp + "',default_value='" + wb.defalutValue + "',user_value='" +
184
+                         wb.userValue + "',remark='" + wb.remark + "' where ID=" + wb.id;*/
185
+
186
+            string sql = "update fw set my_index=" + wb.index + ",MY_ID=\"" + wb.myId + "\",idInfo=\"" + wb.idInfo +
187
+                         "\",len=\"" + wb.len +
188
+                         "\",mode=\"" +
189
+                         wb.mode + "\",desp=\"" + wb.desp + "\",default_value=\"" + wb.defalutValue +
190
+                         "\",user_value=\"" +
191
+                         wb.userValue + "\",remark=\"" + wb.remark + "\" where ID=" + wb.id;
192
+
193
+            Console.WriteLine(sql);
194
+            OleDbCommand inst = new OleDbCommand(sql, objConnection);
195
+
196
+            return inst.ExecuteNonQuery();
197
+        }
198
+
199
+        public int resetUserData()
200
+        {
201
+            string sql = "update fw set user_value=default_value";
202
+            Console.WriteLine(sql);
203
+            OleDbCommand inst = new OleDbCommand(sql, objConnection);
204
+            return inst.ExecuteNonQuery();
205
+        }
206
+
207
+
208
+        public int setReceiveData(string id, string value)
209
+        {
210
+            int idInt = Utils.hexToTen(id);
211
+            string sql = "update fw set user_value=\"" + (value.Trim()) + "\" where my_index=" + idInt;
212
+            Console.WriteLine(sql);
213
+            OleDbCommand inst = new OleDbCommand(sql, objConnection);
214
+            return inst.ExecuteNonQuery();
142 215
         }
143 216
 
144 217
         private string calcNull(string ojb)

+ 1 - 1
GWSocketClient/model/WvBean.cs Parādīt failu

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
6 6
 
7 7
 namespace GWSocketClient.model
8 8
 {
9
-    class WvBean
9
+    public class WvBean
10 10
     {
11 11
         public int id;
12 12
         public int index;

+ 0 - 30
GWSocketClient/util/JsonHelper.cs Parādīt failu

@@ -1,30 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.IO;
4
-using System.Linq;
5
-using System.Runtime.Serialization.Json;
6
-using System.Text;
7
-using System.Threading.Tasks;
8
-
9
-namespace GWSocketClient.util
10
-{
11
-    class JsonHelper
12
-    {
13
-        public static T parse<T>(string jsonString)
14
-        {
15
-            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)))
16
-            {
17
-                return (T) new DataContractJsonSerializer(typeof(T)).ReadObject(ms);
18
-            }
19
-        }
20
-
21
-        public static string stringify(object jsonObject)
22
-        {
23
-            using (var ms = new MemoryStream())
24
-            {
25
-                new DataContractJsonSerializer(jsonObject.GetType()).WriteObject(ms, jsonObject);
26
-                return Encoding.UTF8.GetString(ms.ToArray());
27
-            }
28
-        }
29
-    }
30
-}