-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrmOrderReception.vb
More file actions
553 lines (493 loc) · 20.1 KB
/
frmOrderReception.vb
File metadata and controls
553 lines (493 loc) · 20.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic
Imports System
Imports System.Media
Imports System.Windows.Forms
Imports UpgradeHelpers.DB.ADO
Imports UpgradeHelpers.Gui
Imports UpgradeHelpers.Helpers
Partial Friend Class frmOrderReception
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
If m_vb6FormDefInstance Is Nothing Then
If m_InitializingDefInstance Then
m_vb6FormDefInstance = Me
Else
Try
'For the start-up form, the first instance created is the default instance.
If Not (System.Reflection.Assembly.GetExecutingAssembly().EntryPoint Is Nothing) AndAlso System.Reflection.Assembly.GetExecutingAssembly().EntryPoint.DeclaringType Is Me.GetType() Then
m_vb6FormDefInstance = Me
End If
Catch
End Try
End If
End If
'This call is required by the Windows Form Designer.
isInitializingComponent = True
InitializeComponent()
isInitializingComponent = False
ReLoadForm(False)
End Sub
Private Sub frmOrderReception_Activated(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Activated
If Not (UpgradeHelpers.Gui.ActivateHelper.myActiveForm Is eventSender) Then
UpgradeHelpers.Gui.ActivateHelper.myActiveForm = eventSender
End If
End Sub
Private currentProviderName As String = ""
Private currentIdProvider As Integer
Private currentContactName As String = ""
Private editingData As Boolean
Private currentSubTotal As Double
Private currentTotal As Double
Private currentTax As Double
Private currentFreightCharge As Double
Private currentTotalTax As Double
Private Sub cmdAddProducts_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles cmdAddProducts.Click
frmAddProductTo.DefInstance.Id = currentIdProvider
frmAddProductTo.DefInstance.ObjectReferred = "Provider " & txtProviderCompany.Text & "|" & txtProviderContact.Text
frmAddProductTo.DefInstance.Table = "ProductsByProvider"
frmAddProductTo.DefInstance.ColumnName = "ProviderId"
frmAddProductTo.DefInstance.LoadData()
frmAddProductTo.DefInstance.ShowDialog()
If frmAddProductTo.DefInstance.SavedChanges Then
LoadProductsById()
End If
End Sub
'UPGRADE_NOTE: (7001) The following declaration (txtName_Change) seems to be dead code More Information: https://www.mobilize.net/vbtonet/ewis/ewi7001
'Private Sub txtName_Change()
'DoSearchProvider()
'End Sub
Private Sub DoSearchProvider(Optional ByVal Id As Integer = 0)
Dim filter As String = ""
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not Id.Equals(0) Then
filter = "ProviderID = " & Id
End If
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not String.IsNullOrEmpty(txtProviderName.Text) Then
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not String.IsNullOrEmpty(filter) Then
filter = filter & " AND "
End If
filter = "ProviderName LIKE '%" & txtProviderName.Text & "%'"
End If
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not String.IsNullOrEmpty(txtContactName.Text) Then
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not String.IsNullOrEmpty(filter) Then
filter = filter & " AND "
End If
filter = filter & "ContactFirstName LIKE '%" & txtContactName.Text & "%'"
End If
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not String.IsNullOrEmpty(txtContactLastName.Text) Then
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not String.IsNullOrEmpty(filter) Then
filter = filter & " AND "
End If
filter = filter & "ContactLastName LIKE '%" & txtContactLastName.Text & "%'"
End If
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not String.IsNullOrEmpty(filter) Then
filter = "Where " & filter
End If
ExecuteSql("Select ProviderID, ProviderName, ContactFirstName, ContactLastName, City, StateOrProvince, 'Country/Region' From Providers " & filter)
lvProviders.Items.Clear()
Dim x As ListViewItem
If rs.RecordCount = 0 Then
LogStatus("There are no records with the selected criteria", Me)
Else
While Not rs.EOF
x = lvProviders.Items.Add(rs(0))
For i = 1 To (rs.FieldsMetadata.Count - 1)
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not (rs.GetField(i) Is Nothing) Then
ListViewHelper.GetListViewSubItem(x, i).Text = rs(i)
End If
Next i
rs.MoveNext()
End While
If lvProviders.Items.Count = 1 Then
lvProviders.Items(lvProviders.Items.Item(0).Index).Selected = True
End If
End If
End Sub
Private Sub cmdClose_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles cmdClose.Click
Me.Close()
End Sub
Private Sub cmdProviders_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles cmdProviders.Click
frmProviders.DefInstance.ShowDialog()
txtProviderName.Text = ""
txtContactLastName.Text = ""
txtContactName.Text = ""
DoSearchProvider(frmProviders.DefInstance.CurrentProviderID)
End Sub
Private Sub cmdSave_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles cmdSave.Click
Dim newOrderId As Integer
Try
ExecuteSql("Select * from OrderReceptions")
rs.AddNew()
rs("ProviderId") = currentIdProvider
rs("ReceivedBy") = UserId
rs("OrderDate") = DateTimeHelper.ToString(DateTime.Today)
rs("Notes") = txtNotes.Text
rs("FreightCharge") = currentFreightCharge
rs("SalesTaxRate") = currentTax * 0.01
rs("Status") = "RECEIVED"
rs.Update()
ExecuteSql("SELECT last_insert_rowid() ")
newOrderId = rs(0)
For i = 1 To fgProducts.RowsCount - 1
If Convert.ToString(fgProducts(i, 0).Value) <> "0" Then
ExecuteSql("Insert into OrderReceptionDetails (OrderID, ProductID, DateSold, Quantity, UnitPrice, SalePrice, SalesTax, LineTotal) Values (" & newOrderId & ", '" & Convert.ToString(fgProducts(i, 1).Value) & "', '" & DateTime.Today.ToString("MM/dd/yyyy") & "'," & Convert.ToString(fgProducts(i, 0).Value) & "," & Convert.ToString(fgProducts(i, 3).Value) & "," & Convert.ToString(fgProducts(i, 4).Value) & "," & CStr(currentTax * 0.01) & "," & Convert.ToString(fgProducts(i, 4).Value) & ")")
'UnitsInTransit
'ExecuteSql "Update Products Set UnitsOnOrder = UnitsOnOrder + " & fgProducts.TextMatrix(i, 0) & _
' '" Where ProductId = '" & fgProducts.TextMatrix(i, 1) & "'"
End If
Next i
editingData = False
If MessageBox.Show("Order reception added successfully" & Environment.NewLine & "Would you like to add a new order reception?", "New data", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = System.Windows.Forms.DialogResult.Yes Then
ClearFields()
Else
Me.Close()
End If
Catch excep As System.Exception
MessageBox.Show("An error has occurred adding the data. Error: (" & Information.Err().Number & ") " & excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub MakeTextBoxVisible(ByVal txtBox As TextBox, ByVal grid As UpgradeHelpers.DataGridViewFlex)
With grid
txtBox.Text = Convert.ToString(grid(.CurrentRowIndex, .CurrentColumnIndex).Value)
'txtBox.Move .CellLeft + .Left, .CellTop + .Top, .CellWidth, .CellHeight
txtBox.Visible = True
txtBox.Enabled = True
'DoEvents
txtBox.Focus()
SelectAll(txtBox)
End With
End Sub
Private Sub fgProducts_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles fgProducts.Click
If fgProducts.CurrentColumnIndex <> 0 Then Exit Sub
MakeTextBoxVisible(txtEntry, fgProducts)
End Sub
'UPGRADE_WARNING: (2050) MSFlexGridLib.MSFlexGrid Event fgProducts.EnterCell was not upgraded. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2050
Private Sub fgProducts_EnterCell()
SaveEdits()
End Sub
Private Sub fgProducts_KeyPress(ByVal eventSender As Object, ByVal eventArgs As KeyPressEventArgs) Handles fgProducts.KeyPress
Dim KeyAscii As Integer = Convert.ToInt32(eventArgs.KeyChar)
Try
If fgProducts.CurrentColumnIndex <> 0 Then
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
Exit Sub
End If
Select Case KeyAscii
Case 46, 48 To 57
'Case 45, 46, 47, 48 To 59, 65 To 90, 97 To 122
MakeTextBoxVisible(txtEntry, fgProducts)
txtEntry.Text = Strings.Chr(KeyAscii).ToString()
txtEntry.SelectionStart = 1
End Select
Finally
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
eventArgs.KeyChar = Convert.ToChar(KeyAscii)
End Try
End Sub
Private Sub txtEntry_KeyDown(ByVal eventSender As Object, ByVal eventArgs As KeyEventArgs) Handles txtEntry.KeyDown
Dim KeyCode As Integer = eventArgs.KeyCode
Dim Shift As Integer = eventArgs.KeyData / 65536
Try
EditKeyCode(fgProducts, txtEntry, KeyCode, Shift)
Finally
eventArgs.Handled = KeyCode = 0
End Try
End Sub
Private Sub EditKeyCode(ByVal grid As UpgradeHelpers.DataGridViewFlex, ByRef txtBox As TextBox, ByVal KeyCode As Integer, ByVal Shift As Integer)
Select Case KeyCode
Case 27 'ESC
txtBox.Text = ""
txtBox.Visible = False
grid.Focus()
Case 13 'Return
grid.Focus()
Case 37 'Left Arrow
grid.Focus()
Application.DoEvents()
If grid.CurrentColumnIndex > grid.FixedColumns Then
grid.CurrentColumnIndex -= 1
End If
Case 38 'Up Arrow
grid.Focus()
Application.DoEvents()
If grid.CurrentRowIndex > grid.FixedRows Then
grid.CurrentRowIndex -= 1
End If
Case 39 'Right Arrow
grid.Focus()
Application.DoEvents()
If grid.CurrentColumnIndex < grid.ColumnsCount - 1 Then
grid.CurrentColumnIndex += 1
End If
Case 40 'Down Arrow
grid.Focus()
Application.DoEvents()
If grid.CurrentRowIndex < grid.RowsCount - 1 Then
grid.CurrentRowIndex += 1
End If
End Select
End Sub
Private Sub txtEntry_Leave(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles txtEntry.Leave
SaveEdits()
End Sub
Private Sub fgProducts_CellLeave(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles fgProducts.CellLeave
SaveEdits()
End Sub
Private Sub txtEntry_KeyPress(ByVal eventSender As Object, ByVal eventArgs As KeyPressEventArgs) Handles txtEntry.KeyPress
Dim KeyAscii As Integer = Convert.ToInt32(eventArgs.KeyChar)
Try
Select Case KeyAscii
'dot and Numbers
Case 46, 48 To 57
'Alphanumeric
'Case 45, 46, 47, 48 To 59, 65 To 90, 97 To 122
Case Else
KeyAscii = 0
End Select
Finally
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
eventArgs.KeyChar = Convert.ToChar(KeyAscii)
End Try
End Sub
Private Sub SaveEdits()
If Not txtEntry.Visible Or Not ValidateTextBoxDouble(txtEntry, Me) Or Not ValidateTextDouble(Convert.ToString(fgProducts(fgProducts.CurrentRowIndex, 3).Value), Me) Or Not ValidateTextDouble(Convert.ToString(fgProducts(fgProducts.CurrentRowIndex, 4).Value), Me) Then Exit Sub
Dim previousLinePrice As Double = DoubleValue(Convert.ToString(fgProducts(fgProducts.CurrentRowIndex, 4).Value))
fgProducts(fgProducts.CurrentRowIndex, fgProducts.CurrentColumnIndex).Value = txtEntry.Text
Dim lineQuantity As Double = DoubleValue(txtEntry.Text)
Dim lineUnitPrice As Double = DoubleValue(Convert.ToString(fgProducts(fgProducts.CurrentRowIndex, 3).Value))
previousLinePrice = DoubleValue(Convert.ToString(fgProducts(fgProducts.CurrentRowIndex, 4).Value))
Dim linePrice As Double = lineQuantity * lineUnitPrice
fgProducts(fgProducts.CurrentRowIndex, 4).Value = CStr(linePrice)
ReCalculateTotals(previousLinePrice, linePrice)
txtEntry.Visible = False
editingData = True
End Sub
Private Sub ReCalculateTotals(ByVal previous As Double, ByVal current As Double)
currentSubTotal = currentSubTotal - previous + current
currentTotalTax = currentSubTotal * currentTax * 0.01
currentTotal = currentFreightCharge + currentSubTotal + currentTotalTax
txtSubTotal.Text = StringsHelper.Format(currentSubTotal, "#,##0.00")
txtTotalTax.Text = StringsHelper.Format(currentTotalTax, "#,##0.00")
txtTotal.Text = StringsHelper.Format(currentTotal, "#,##0.00")
End Sub
Private Sub Form_FormClosing(ByVal eventSender As Object, ByVal eventArgs As FormClosingEventArgs) Handles MyBase.FormClosing
Dim Cancel As Integer = IIf(eventArgs.Cancel, 1, 0)
Dim UnloadMode As Integer = CInt(eventArgs.CloseReason)
Try
Dim res As DialogResult
If editingData Then
res = MessageBox.Show("Do you want to save the edited data?", "Save data", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If res = System.Windows.Forms.DialogResult.Yes Then
cmdSave_Click(cmdSave, New EventArgs())
ElseIf res <> System.Windows.Forms.DialogResult.No Then
Cancel = True
End If
End If
Finally
eventArgs.Cancel = Cancel <> 0
End Try
End Sub
'UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
Private Sub Form_Load()
editingData = False
ClearFields()
End Sub
Private Sub lvProviders_ItemClick(ByVal Item As ListViewItem)
RetrieveDataProvider()
End Sub
Private Sub RetrieveDataProvider()
If editingData Then
If MessageBox.Show("Do you want to cancel previous edited data?", "Data edition", MessageBoxButtons.YesNo, MessageBoxIcon.Question) <> System.Windows.Forms.DialogResult.Yes Then
Exit Sub
End If
End If
'UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2080
If Not (lvProviders.FocusedItem Is Nothing) Then
With lvProviders.FocusedItem
currentIdProvider = CInt(lvProviders.FocusedItem.Text)
currentProviderName = ListViewHelper.GetListViewSubItem(lvProviders.FocusedItem, 1).Text
currentContactName = ListViewHelper.GetListViewSubItem(lvProviders.FocusedItem, 2).Text & " " & ListViewHelper.GetListViewSubItem(lvProviders.FocusedItem, 3).Text
End With
txtProviderCompany.Text = currentProviderName
txtProviderContact.Text = currentContactName
editingData = False
End If
LoadProductsById()
cmdSave.Enabled = True
cmdAddProducts.Enabled = True
End Sub
Private Sub LoadProductsById()
Dim Table As String = "ProductsByProvider"
Dim ColumnName As String = "ProviderId"
Dim Id As Integer = currentIdProvider
ExecuteSql("Select p.ProductID, p.ProductName, p.UnitPrice, p.UnitsInStock, p.UnitsOnOrder, p.QuantityPerUnit, p.Unit from Products as p, " & Table & " as pb Where pb." & ColumnName & " = " & CStr(Id) & " And pb.ProductId = p.ProductId")
'lvProducts.ListItems.Clear
'If rs.RecordCount > 0 Then
' With rs
' While Not .EOF
' Set x = lvProducts.ListItems.Add(, , 0)
' For i = 1 To 5
' If Not IsEmpty(.Fields(i - 1)) Then
' x.SubItems(i) = .Fields(i - 1)
' End If
' Next i
' x.SubItems(6) = .Fields(5) & .Fields(6)
' .MoveNext
' Wend
' End With
'End If
Dim lng As Integer
Dim intLoopCount As Integer
Const SCROOL_WIDTH As Integer = 320
Dim i As Integer
With fgProducts
.ColumnsCount = 8
.FixedColumns = 0
.RowsCount = 0
.AddItem("Quantity" & Constants.vbTab & "Code" & Constants.vbTab & "Product" & Constants.vbTab & "UnitPrice" & Constants.vbTab & "Price" & Constants.vbTab & "Existence" & Constants.vbTab & "Ordered" & Constants.vbTab & "Quantity per unit")
.RowsCount = rs.RecordCount + 1
If .RowsCount = 1 Then .FixedRows = 0 Else .FixedRows = 1
i = 1
While Not rs.EOF
fgProducts(i, 0).Value = "0"
For j As Integer = 1 To 6
If j = 4 Then
fgProducts(i, j).Value = "0"
ElseIf j < 4 Then
fgProducts(i, j).Value = rs(j - 1)
Else
fgProducts(i, j).Value = rs(j - 2)
End If
Next j
fgProducts(i, 7).Value = rs(5) & rs(6)
rs.MoveNext()
i += 1
End While
End With
End Sub
'UPGRADE_NOTE: (7001) The following declaration (lvProducts_ItemCheck) seems to be dead code More Information: https://www.mobilize.net/vbtonet/ewis/ewi7001
'Private Sub lvProducts_ItemCheck(ByVal Item As ListViewItem)
'If Item.Checked Then
'Item.Text = "1"
'Else
'Item.Text = "0"
'End If
'End Sub
Private isInitializingComponent As Boolean
Private Sub txtProviderName_TextChanged(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles txtProviderName.TextChanged
If isInitializingComponent Then
Exit Sub
End If
DoSearchProvider()
End Sub
Private Sub txtNotes_TextChanged(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles txtNotes.TextChanged
If isInitializingComponent Then
Exit Sub
End If
editingData = True
End Sub
Private Sub txtContactName_TextChanged(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles txtContactName.TextChanged
If isInitializingComponent Then
Exit Sub
End If
DoSearchProvider()
End Sub
Private Sub ClearFields()
fgProducts.RowsCount = 0
fgProducts.ColumnsCount = 0
currentSubTotal = 0
currentTotal = 0
currentTax = 0
currentTotalTax = 0
currentFreightCharge = 0
txtSubTotal.Text = ""
txtTotal.Text = ""
txtTotalTax.Text = ""
txtSalesTax.Text = ""
txtFreightCharge.Text = ""
txtProviderName.Text = ""
txtContactLastName.Text = ""
txtContactName.Text = ""
txtProviderContact.Text = ""
txtProviderCompany.Text = ""
cmdSave.Enabled = False
cmdAddProducts.Enabled = False
txtNotes.Text = ""
'txtProviderName.SetFocus
ReCalculateTotals(0, 0)
editingData = False
End Sub
Private Sub txtFreightCharge_TextChanged(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles txtFreightCharge.TextChanged
If isInitializingComponent Then
Exit Sub
End If
currentFreightCharge = DoubleValue(txtFreightCharge.Text)
ReCalculateTotals(0, 0)
editingData = True
End Sub
Private Sub txtFreightCharge_KeyPress(ByVal eventSender As Object, ByVal eventArgs As KeyPressEventArgs) Handles txtFreightCharge.KeyPress
Dim KeyAscii As Integer = Convert.ToInt32(eventArgs.KeyChar)
Try
Select Case KeyAscii
Case Keys.D0 To Keys.D9, Keys.Back, Keys.Clear, Keys.Delete, Keys.Left, Keys.Right, Keys.Up, Keys.Down, Keys.Tab
Case Else
KeyAscii = 0
SystemSounds.Beep.Play()
End Select
Finally
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
eventArgs.KeyChar = Convert.ToChar(KeyAscii)
End Try
End Sub
Private Sub txtContactLastName_TextChanged(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles txtContactLastName.TextChanged
If isInitializingComponent Then
Exit Sub
End If
editingData = True
End Sub
Private Sub txtSalesTax_TextChanged(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles txtSalesTax.TextChanged
If isInitializingComponent Then
Exit Sub
End If
currentTax = DoubleValue(txtSalesTax.Text)
ReCalculateTotals(0, 0)
editingData = True
End Sub
Private Sub txtSalesTax_KeyPress(ByVal eventSender As Object, ByVal eventArgs As KeyPressEventArgs) Handles txtSalesTax.KeyPress
Dim KeyAscii As Integer = Convert.ToInt32(eventArgs.KeyChar)
Try
Select Case KeyAscii
Case Keys.D0 To Keys.D9, Keys.Back, Keys.Clear, Keys.Delete, Keys.Left, Keys.Right, Keys.Up, Keys.Down, Keys.Tab
Case Else
KeyAscii = 0
SystemSounds.Beep.Play()
End Select
Finally
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
eventArgs.KeyChar = Convert.ToChar(KeyAscii)
End Try
End Sub
Private Sub Form_Closed(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles MyBase.Closed
End Sub
End Class