瀏覽代碼

有BUG,只能输入16进制,只能输入数字和负号还有问题.

Kerry 8 年之前
父節點
當前提交
3943b940f2
共有 4 個文件被更改,包括 82 次插入9 次删除
  1. 二進制
      .vs/GWSocketClient/v15/.suo
  2. 2 0
      GWSocketClient/IdItemEditor.Designer.cs
  3. 80 9
      GWSocketClient/IdItemEditor.cs
  4. 二進制
      GWSocketClient/bin/Debug/dbfile/ID_INFO.accdb

二進制
.vs/GWSocketClient/v15/.suo 查看文件


+ 2 - 0
GWSocketClient/IdItemEditor.Designer.cs 查看文件

87
             // 
87
             // 
88
             this.tbId.Location = new System.Drawing.Point(63, 55);
88
             this.tbId.Location = new System.Drawing.Point(63, 55);
89
             this.tbId.Name = "tbId";
89
             this.tbId.Name = "tbId";
90
+            this.tbId.ReadOnly = true;
90
             this.tbId.Size = new System.Drawing.Size(836, 25);
91
             this.tbId.Size = new System.Drawing.Size(836, 25);
91
             this.tbId.TabIndex = 1;
92
             this.tbId.TabIndex = 1;
92
             // 
93
             // 
103
             this.tbLen.Name = "tbLen";
104
             this.tbLen.Name = "tbLen";
104
             this.tbLen.Size = new System.Drawing.Size(836, 25);
105
             this.tbLen.Size = new System.Drawing.Size(836, 25);
105
             this.tbLen.TabIndex = 3;
106
             this.tbLen.TabIndex = 3;
107
+            this.tbLen.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbLen_KeyPress);
106
             // 
108
             // 
107
             // tbInfo
109
             // tbInfo
108
             // 
110
             // 

+ 80 - 9
GWSocketClient/IdItemEditor.cs 查看文件

44
                 buttonSubmit.Text = "添加";
44
                 buttonSubmit.Text = "添加";
45
                 addOrUpdate = true;
45
                 addOrUpdate = true;
46
             }
46
             }
47
+
48
+            this.tbDv.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.hex_Valid_KeyPress);
49
+            this.tbUv.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.hex_Valid_KeyPress);
47
         }
50
         }
48
 
51
 
49
         private void addModifyText()
52
         private void addModifyText()
97
             string myIdString = tbId.Text.Trim();
100
             string myIdString = tbId.Text.Trim();
98
             string lenString = tbLen.Text.Trim();
101
             string lenString = tbLen.Text.Trim();
99
             string defalutValueString = tbDv.Text.Trim();
102
             string defalutValueString = tbDv.Text.Trim();
100
-
103
+            string userValueString = tbUv.Text.Trim();
101
             bool modeBool = checkBoxWrite.Checked || checkBoxRead.Checked;
104
             bool modeBool = checkBoxWrite.Checked || checkBoxRead.Checked;
102
 
105
 
106
+            #region ISNULL
103
 
107
 
104
             if (tbIndexString.Equals(""))
108
             if (tbIndexString.Equals(""))
105
             {
109
             {
129
                 return;
133
                 return;
130
             }
134
             }
131
 
135
 
132
-            string userValueString = tbUv.Text.Trim();
136
+            #endregion
133
 
137
 
134
-            WvBean wb = new WvBean();
135
 
138
 
139
+            if (userValueString.Equals(""))
140
+            {
141
+                userValueString = defalutValueString;
142
+            }
143
+
144
+
145
+            if (lenString.Contains("-"))
146
+            {
147
+                if (defalutValueString.Length % 2 == 0)
148
+                {
149
+                    richTextBoxTip.Text = "默认值长度不是整数!!!defalutValueString.Length=" + (defalutValueString.Length / 2.0);
150
+                    return;
151
+                }
152
+                if (userValueString.Length % 2 == 0)
153
+                {
154
+                    richTextBoxTip.Text = "用户值长度不是整数!!!defalutValueString.Length=" + (userValueString.Length / 2.0);
155
+                    return;
156
+                }
157
+            }
158
+            else
159
+            {
160
+                int len = int.Parse(lenString);
161
+                if (defalutValueString.Length / 2 == len)
162
+                {
163
+                    richTextBoxTip.Text = "默认值长度不对.定义长度是=" + lenString + " ,你输入长度是=" +
164
+                                          (defalutValueString.Length / 2.0);
165
+                    return;
166
+                }
167
+                if (userValueString.Length / 2 == len)
168
+                {
169
+                    richTextBoxTip.Text = "默认值长度不对.定义长度是=" + lenString + " ,你输入长度是=" + (userValueString.Length / 2.0);
170
+                    return;
171
+                }
172
+            }
173
+
174
+            WvBean wb = new WvBean();
136
             wb.index = int.Parse(tbIndexString);
175
             wb.index = int.Parse(tbIndexString);
137
             wb.myId = myIdString;
176
             wb.myId = myIdString;
138
             wb.idInfo = tbInfo.Text.Trim();
177
             wb.idInfo = tbInfo.Text.Trim();
143
 
182
 
144
             wb.mode = modeString;
183
             wb.mode = modeString;
145
             wb.desp = tbDesp.Text.Trim();
184
             wb.desp = tbDesp.Text.Trim();
146
-
147
             wb.defalutValue = defalutValueString;
185
             wb.defalutValue = defalutValueString;
148
-
149
-            if (userValueString.Equals(""))
150
-            {
151
-                userValueString = defalutValueString;
152
-            }
153
             wb.userValue = userValueString;
186
             wb.userValue = userValueString;
154
             wb.remark = tbRemark.Text.Trim();
187
             wb.remark = tbRemark.Text.Trim();
155
             int res = -1;
188
             int res = -1;
236
             {
269
             {
237
                 e.Handled = true;
270
                 e.Handled = true;
238
             }
271
             }
272
+            /*int ascii = (int) (e.KeyChar);
273
+            if ((ascii >= 48 && ascii <= 57) && ascii == 45)
274
+            {
275
+                e.Handled = true;
276
+            }*/
277
+        }
278
+
279
+
280
+        private void hex_Valid_KeyPress(object sender, KeyPressEventArgs e)
281
+        {
282
+            int ascii = (int) (e.KeyChar);
283
+            Console.WriteLine(e.KeyChar + ": " + ascii);
284
+
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)
294
+            {
295
+                e.Handled = true;
296
+            }
297
+        }
298
+
299
+        private void tbLen_KeyPress(object sender, KeyPressEventArgs e)
300
+        {
301
+            int ascii = (int) (e.KeyChar);
302
+            if (ascii >= 48 && ascii <= 57)
303
+            {
304
+                e.Handled = false;
305
+            }
306
+            else if (ascii == 45)
307
+            {
308
+                e.Handled = true;
309
+            }
239
         }
310
         }
240
     }
311
     }
241
 }
312
 }

二進制
GWSocketClient/bin/Debug/dbfile/ID_INFO.accdb 查看文件