-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomerForm.vb
70 lines (64 loc) · 2.41 KB
/
CustomerForm.vb
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
Public Class CustomerForm
Public CustomerLink As Customer
Public Mode As Integer = 0
Private Sub ConfirmedButton_Click(sender As Object, e As EventArgs) Handles ConfirmedButton.Click
Dim isValid = True
'Kiem tra SDT nhap vao co phai la so khong
If Not IsNumeric(SDT.Text) Or SDT.Text.Length < 10 Then
SDTError.Visible = True
isValid = False
Else
SDTError.Visible = False
End If
'Kiem tra CMND nhap vao co dung khong
If Not IsNumeric(CMND.Text) Or CMND.Text.Length < 9 Or (CMND.Text.Length < 12 And CMND.Text.Length > 9) Then
CMNDError.Visible = True
isValid = False
Else
CMNDError.Visible = False
End If
If isValid = True Then
Dim gender As String
If Nam.Checked Then
gender = "Nam"
Else
gender = "Nữ"
End If
If Mode = 0 Then
CustomerLink.Add({MaKH.Text, TenKH.Text, gender, DiaChi.Text, CMND.Text, SDT.Text})
Else
CustomerLink.Edit(CustomerLink.CustomerLV.FocusedItem.Index, {MaKH.Text, TenKH.Text, gender, DiaChi.Text, CMND.Text, SDT.Text})
End If
Close()
End If
End Sub
Private Sub CustomerForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Owner.Enabled = False
MaKH.Enabled = False
If Mode = 0 Then
Dim number As Integer
Do
number = Fix(999999999 * Rnd())
Loop While App.Exist(number, "../../database/customers.txt", 0)
MaKH.Text = number
ElseIf Mode = 1 Then
For Each i As ListViewItem In CustomerLink.CustomerLV.SelectedItems
MaKH.Text = i.SubItems(0).Text
TenKH.Text = i.SubItems(1).Text
If i.SubItems(2).Text = "Nam" Then
Nam.Checked = True
Nu.Checked = False
Else
Nam.Checked = False
Nu.Checked = True
End If
DiaChi.Text = i.SubItems(3).Text
CMND.Text = i.SubItems(4).Text
SDT.Text = i.SubItems(5).Text
Next
End If
End Sub
Private Sub Customer_Closed(sender As Object, e As EventArgs) Handles Me.Closed
Owner.Enabled = True
End Sub
End Class