|
@@ -44,6 +44,9 @@ namespace GWSocketClient
|
44
|
44
|
buttonSubmit.Text = "添加";
|
45
|
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
|
52
|
private void addModifyText()
|
|
@@ -97,9 +100,10 @@ namespace GWSocketClient
|
97
|
100
|
string myIdString = tbId.Text.Trim();
|
98
|
101
|
string lenString = tbLen.Text.Trim();
|
99
|
102
|
string defalutValueString = tbDv.Text.Trim();
|
100
|
|
-
|
|
103
|
+ string userValueString = tbUv.Text.Trim();
|
101
|
104
|
bool modeBool = checkBoxWrite.Checked || checkBoxRead.Checked;
|
102
|
105
|
|
|
106
|
+ #region ISNULL
|
103
|
107
|
|
104
|
108
|
if (tbIndexString.Equals(""))
|
105
|
109
|
{
|
|
@@ -129,10 +133,45 @@ namespace GWSocketClient
|
129
|
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
|
175
|
wb.index = int.Parse(tbIndexString);
|
137
|
176
|
wb.myId = myIdString;
|
138
|
177
|
wb.idInfo = tbInfo.Text.Trim();
|
|
@@ -143,13 +182,7 @@ namespace GWSocketClient
|
143
|
182
|
|
144
|
183
|
wb.mode = modeString;
|
145
|
184
|
wb.desp = tbDesp.Text.Trim();
|
146
|
|
-
|
147
|
185
|
wb.defalutValue = defalutValueString;
|
148
|
|
-
|
149
|
|
- if (userValueString.Equals(""))
|
150
|
|
- {
|
151
|
|
- userValueString = defalutValueString;
|
152
|
|
- }
|
153
|
186
|
wb.userValue = userValueString;
|
154
|
187
|
wb.remark = tbRemark.Text.Trim();
|
155
|
188
|
int res = -1;
|
|
@@ -236,6 +269,44 @@ namespace GWSocketClient
|
236
|
269
|
{
|
237
|
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
|
}
|