📄 main_jbxx_client.frm
字号:
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Enabled = 0 'False
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 3
Left = 1350
TabIndex = 22
Top = 1620
Width = 7350
End
Begin VB.TextBox txt
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Enabled = 0 'False
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 2
Left = 1350
TabIndex = 21
Top = 1185
Width = 7350
End
Begin VB.TextBox txt
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Enabled = 0 'False
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 1
Left = 1350
TabIndex = 20
Top = 750
Width = 7350
End
Begin VB.TextBox txt
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Enabled = 0 'False
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 0
Left = 1350
TabIndex = 19
Top = 345
Width = 7335
End
Begin VB.Label Label5
Caption = "开户银行: 银行账号: 纳税人登记:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1200
Left = 195
TabIndex = 38
Top = 3300
Width = 1200
End
Begin VB.Label Label6
Caption = "网址邮箱:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 195
TabIndex = 37
Top = 4590
Width = 1200
End
Begin VB.Label Label2
Caption = "联系人:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 195
TabIndex = 36
Top = 2850
Width = 1185
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "传真: 联系人电话:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 690
Left = 5505
TabIndex = 35
Top = 2505
Width = 1260
End
Begin VB.Label Label3
Caption = "邮政编码:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 270
Left = 5520
TabIndex = 34
Top = 2070
Width = 1020
End
Begin VB.Label Label1
Caption = "客户编号: 客户全称: 客户拼音码: 客户地址: 所属地区: 电话: "
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2400
Left = 180
TabIndex = 33
Top = 375
Width = 1200
End
End
End
End
Attribute VB_Name = "main_jbxx_client"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
'定义数据集对象
Dim rs1 As New ADODB.Recordset
Public Sub ViewData()
For i = 0 To 13
If Adodc1.Recordset.Fields(i) <> "" Then txt(i).Text = Adodc1.Recordset.Fields(i)
Next i
End Sub
Private Sub cmdMoveData_Click(Index As Integer)
With Adodc1.Recordset
Select Case Index
Case 0 '移到第一条记录
If Not .BOF Then .MoveFirst
Case 1 '移到上一条记录
If .RecordCount > 0 Then
If .BOF = False Then .MovePrevious
If .BOF = True Then .MoveFirst
End If
Case 2
If .RecordCount > 0 Then
If .EOF = False Then .MoveNext
If .EOF = True Then .MoveLast
End If
Case 3
If Not Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
Call ViewData
End Select
End With
Call ViewData
End Sub
Private Sub Form_Load()
'向combo1中添加查询字段
Combo1.AddItem ("客户编号")
Combo1.AddItem ("客户名称")
Combo1.AddItem ("拼音码")
Combo1.AddItem ("所属地区")
Combo1.AddItem ("邮政编码")
Combo1.ListIndex = 1
'向combo2中添加查询条件
Combo2.AddItem ("like")
Combo2.AddItem ("=")
Combo2.AddItem (">")
Combo2.AddItem ("<")
Combo2.ListIndex = 0
rs1.Open "select * from tb_client", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
For i = 0 To 13
If rs1.Fields(i) <> "" Then txt(i).Text = rs1.Fields(i)
Next i
End If
rs1.Close
End Sub
Private Sub txt_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn And Index < 13 Then txt(Index + 1).SetFocus '回车获得焦点
If KeyCode = vbKeyReturn And Index = 13 Then cmdSave.SetFocus
If KeyCode = vbKeyUp And Index > 1 Then txt(Index - 1).SetFocus
If KeyCode = vbKeyReturn And Index = 1 Then '自动生成拼音码
txt(2) = ""
a = Len(txt(1))
For i = 1 To a
rs1.Open "select * from py where 汉字='" + Mid(txt(1), i, 1) + "'", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
txt(2) = txt(2) & rs1.Fields("编码")
End If
rs1.Close
Next i
txt(3).SetFocus
End If
End Sub
Private Sub cmdFind_Click() '查询客户信息
If Combo2.Text = "like" Then
Adodc1.RecordSource = "select * from tb_client where tb_client." & Combo1 & " like +'%'+ '" + Text1.Text + "'+'%'"
Adodc1.Refresh
Else
Adodc1.RecordSource = "select * from tb_client where tb_client." & Combo1 & Combo2 & "'" + Text1.Text + "'"
Adodc1.Refresh
End If
Call ViewData
End Sub
Private Sub cmdAdd_Click()
Dim note As Integer
rs1.Open "select * from tb_client order by 客户编号", cnn, adOpenKeyset, adLockOptimistic
'创建客户编号
If rs1.RecordCount > 0 Then
If Not rs1.EOF Then rs1.MoveLast
If rs1.Fields("客户编号") <> "" Then
note = rs1.Fields("客户编号") + 1
txt(0).Text = note
End If
Else
txt(0).Text = "1"
End If
rs1.Close
For i = 1 To 13
txt(i).Enabled = True
txt(i).Text = ""
Next i
'设置控件状态
cmdSave.Enabled = True
cmdCancel.Enabled = True
cmdAdd.Enabled = False
cmdModify.Enabled = False
cmdDelete.Enabled = False
SSTab1.Tab = 0
txt(1).SetFocus
End Sub
Private Sub cmdModify_Click() '允许用户修改
If Adodc1.Recordset.RecordCount > 0 Then
For i = 0 To 13
txt(i).Enabled = True
Next i
cmdSave.Enabled = True
cmdCancel.Enabled = True
cmdAdd.Enabled = False
cmdModify.Enabled = False
cmdDelete.Enabled = False
Else
MsgBox ("没有要修改的数据!")
End If
End Sub
Private Sub cmdDelete_Click() '删除客户信息
If Adodc1.Recordset.RecordCount > 0 Then
a = MsgBox("您确实要删除这条数据吗?", vbYesNo)
If a = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
For i = 0 To 13
txt(i).Text = Adodc1.Recordset.Fields(i)
Next i
End If
cmdSave.Enabled = False
cmdCancel.Enabled = False
cmdAdd.Enabled = True
cmdModify.Enabled = True
cmdDelete.Enabled = True
End If
Else
MsgBox "没有要删除的数据!"
End If
End Sub
Private Sub cmdSave_Click() '保存客户信息
rs1.Open "select * from tb_client where 客户编号='" & txt(0).Text & "'order by 客户编号", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
Dim a As Long
a = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If a = vbYes Then
For i = 1 To 13
If txt(1).Text <> "" Then rs1.Fields(i) = Trim(txt(i).Text)
txt(i).Enabled = False
Next i
rs1.Update
Adodc1.Refresh
End If
Else
If txt(1).Text = "" Then
MsgBox "系统不允许客户名称为空!"
Exit Sub
End If
'添加客户信息
rs1.AddNew
For i = 0 To 13
rs1.Fields(i) = Trim(txt(i).Text)
txt(i).Enabled = False
Next i
rs1.Update
Adodc1.Refresh
End If
rs1.Close
'设置控件状态
cmdSave.Enabled = False
cmdCancel.Enabled = False
cmdAdd.Enabled = True
cmdModify.Enabled = True
cmdDelete.Enabled = True
End Sub
Private Sub cmdCancel_Click() '取消操作
For i = 0 To 13
txt(i).Text = ""
txt(i).Enabled = False
Next i
'设置控件状态
cmdSave.Enabled = False
cmdCancel.Enabled = False
cmdAdd.Enabled = True
cmdModify.Enabled = True
cmdDelete.Enabled = True
End Sub
Private Sub cmdQuit_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -