📄 user.frm
字号:
VERSION 5.00
Begin VB.Form user
BackColor = &H00FFC0C0&
BorderStyle = 3 'Fixed Dialog
Caption = "客户管理"
ClientHeight = 4485
ClientLeft = 2985
ClientTop = 2130
ClientWidth = 6270
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4485
ScaleWidth = 6270
ShowInTaskbar = 0 'False
Begin VB.Frame Frame1
BackColor = &H80000008&
ForeColor = &H8000000D&
Height = 15
Index = 1
Left = 120
TabIndex = 15
Top = 3360
Width = 6015
End
Begin VB.Frame Frame1
BackColor = &H80000008&
ForeColor = &H8000000D&
Height = 15
Index = 0
Left = 120
TabIndex = 14
Top = 840
Width = 6015
End
Begin VB.ComboBox comsel
Height = 300
Index = 0
ItemData = "user.frx":0000
Left = 3360
List = "user.frx":000A
TabIndex = 12
Text = "客户姓名"
Top = 360
Width = 1215
End
Begin VB.TextBox txtselect
Appearance = 0 'Flat
Height = 270
Index = 0
Left = 1680
TabIndex = 0
Top = 360
Width = 1455
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 270
Index = 4
Left = 1440
TabIndex = 5
Top = 2640
Width = 1575
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 270
Index = 3
Left = 4200
TabIndex = 4
Top = 1920
Width = 1575
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 270
Index = 2
Left = 1440
TabIndex = 3
Top = 1920
Width = 1575
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 270
Index = 1
Left = 4200
TabIndex = 2
Top = 1200
Width = 1575
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 270
Index = 0
Left = 1440
TabIndex = 1
Top = 1200
Width = 1575
End
Begin VB.Label qd
BackStyle = 0 'Transparent
Caption = " 确定"
Height = 375
Left = 2520
MouseIcon = "user.frx":0020
MousePointer = 99 'Custom
TabIndex = 6
Top = 3840
Width = 1455
End
Begin VB.Image Image2
Height = 195
Index = 0
Left = 2760
MouseIcon = "user.frx":032A
MousePointer = 99 'Custom
Picture = "user.frx":0634
Top = 3840
Width = 195
End
Begin VB.Image Image2
Height = 195
Index = 1
Left = 4440
MouseIcon = "user.frx":06AF
MousePointer = 99 'Custom
Picture = "user.frx":09B9
Top = 3840
Width = 195
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = " 返回"
Height = 300
Left = 4320
MouseIcon = "user.frx":0A34
MousePointer = 99 'Custom
TabIndex = 16
Top = 3840
Width = 1380
End
Begin VB.Image search
Height = 300
Index = 0
Left = 4800
MouseIcon = "user.frx":0D3E
MousePointer = 99 'Custom
Picture = "user.frx":1048
Top = 360
Width = 780
End
Begin VB.Label Labinfo
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "查询信息:"
Height = 180
Index = 1
Left = 600
TabIndex = 13
Top = 405
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "客户Email:"
Height = 180
Index = 4
Left = 480
TabIndex = 11
Top = 2640
Width = 990
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "客户OICQ:"
Height = 180
Index = 3
Left = 3240
TabIndex = 10
Top = 1920
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "客户电话:"
Height = 180
Index = 2
Left = 480
TabIndex = 9
Top = 1920
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "客户姓名:"
Height = 180
Index = 1
Left = 3240
TabIndex = 8
Top = 1200
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "客户号:"
Height = 180
Index = 0
Left = 480
TabIndex = 7
Top = 1200
Width = 720
End
Begin VB.Shape Shape1
BorderColor = &H00C0FFC0&
BorderWidth = 5
Height = 4455
Left = 0
Top = 0
Width = 6255
End
Begin VB.Image Image1
Height = 450
Index = 1
Left = 4200
MouseIcon = "user.frx":1273
MousePointer = 99 'Custom
Picture = "user.frx":157D
Stretch = -1 'True
Top = 3720
Width = 1395
End
Begin VB.Image Image1
Height = 450
Index = 0
Left = 2520
MouseIcon = "user.frx":19B0
MousePointer = 99 'Custom
Picture = "user.frx":1CBA
Stretch = -1 'True
Top = 3720
Width = 1395
End
End
Attribute VB_Name = "user"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim yn As New yn '定义yn为yn类
Option Explicit
Private Sub Form_Load()
Select Case msg
Case Is = "添加新会员" '标题赋为
Me.qd.Caption = " 添加"
Me.txtselect(0).Locked = True '设置为不可写
Me.txtselect(0).BackColor = &H80000004 '设置背景为灰色
Me.comsel(0).BackColor = &H80000004
Me.comsel(0).Locked = True
Call yn.opendb("select * from 客户") '查询条件在数据库中
If Not yn.myrec.EOF() Then
yn.myrec.MoveLast '移动到下一条
Me.Text1(0).Text = yn.myrec.Fields("客户号") + 1
Else
Me.Text1(0).Text = 1
End If
Call yn.closedb
Case Is = "修改会员"
Me.qd.Caption = " 修改"
Me.txtselect(0).Locked = False
Me.txtselect(0).BackColor = vbWhite
Me.comsel(0).BackColor = vbWhite
Me.comsel(0).Locked = False
Case Is = "删除会员"
Me.qd.Caption = " 删除"
Me.txtselect(0).Locked = False
Me.txtselect(0).BackColor = vbWhite
Me.comsel(0).BackColor = vbWhite
Me.comsel(0).Locked = False
Me.Text1(0).BackColor = &H80000004
Me.Text1(1).BackColor = &H80000004
Me.Text1(2).BackColor = &H80000004
Me.Text1(3).BackColor = &H80000004
Me.Text1(4).BackColor = &H80000004
Case Is = "查询会员"
Me.txtselect(0).Locked = False
Me.txtselect(0).BackColor = vbWhite
Me.comsel(0).BackColor = vbWhite
Me.comsel(0).Locked = False
Me.Text1(0).BackColor = &H80000004
Me.Text1(1).BackColor = &H80000004
Me.Text1(2).BackColor = &H80000004
Me.Text1(3).BackColor = &H80000004
Me.Text1(4).BackColor = &H80000004
Me.Image1(0).Visible = False
Me.Image2(0).Visible = False
Me.qd.Visible = False
End Select
End Sub
Private Sub Label2_Click()
Unload Me '御下窗体
End Sub
Private Sub qd_Click()
On Error Resume Next
Select Case msg
Case Is = "添加新会员"
If Me.Text1(0).Text = "" Or Me.Text1(1).Text = "" Then
MsgBox "请输入会员号或姓名!!!", vbQuestion
Else
Call yn.opendb("select * from 客户 where 客户姓名='" & Me.Text1(1).Text & "'")
If yn.myrec.EOF Then
Call yn.myrec.AddNew ' 添加
yn.myrec.Fields("客户号") = Me.Text1(0).Text
yn.myrec.Fields("客户姓名") = Me.Text1(1).Text
yn.myrec.Fields("电话") = Me.Text1(2).Text
yn.myrec.Fields("OICQ") = Me.Text1(3).Text
yn.myrec.Fields("Email") = Me.Text1(4).Text
Call yn.myrec.Update '更新
Call yn.closedb '关闭
MsgBox "用户注册成功!!!", vbInformation
For i = 0 To 4
Me.Text1(i).Text = ""
Next
Else
MsgBox "此用户已注册!!!", vbInformation
Call yn.closedb
End If
End If
Case Is = "修改会员"
If Me.Text1(0).Text <> "" Then
Call yn.opendb("select * from 客户 where 客户号='" & Me.Text1(0).Text & "'")
If Not yn.myrec.EOF Then
yn.myrec.Fields("客户号") = Me.Text1(0).Text
yn.myrec.Fields("客户姓名") = Me.Text1(1).Text
yn.myrec.Fields("电话") = Me.Text1(2).Text
yn.myrec.Fields("OICQ") = Me.Text1(3).Text
yn.myrec.Fields("Email") = Me.Text1(4).Text
Call yn.myrec.Update
Call yn.closedb
MsgBox "用户修改成功!!!", vbInformation
End If
End If
Case Is = "删除会员"
If Me.Text1(0).Text <> "" Then
Call yn.opendb("select * from 客户 where 客户号='" & Me.Text1(0).Text & "'")
If yn.myrec.EOF Then
MsgBox "没有此用户!!!", vbInformation
Call yn.closedb
Else
Call yn.myrec.Delete
Call yn.myrec.Update
Call yn.closedb
MsgBox "会员删除成功!!!", vbInformation
For i = 0 To 4
Me.Text1(i).Text = ""
Next
End If
End If
End Select
End Sub
Private Sub search_Click(Index As Integer)
For i = 0 To 4
Me.Text1(i).Text = ""
Next
On Error Resume Next
Call yn.opendb("select * from 客户 where " & Me.comsel(0).Text & "='" & Me.txtselect(0).Text & "'")
If yn.myrec.EOF Then
MsgBox "没有此用户!!!", vbInformation
Call yn.closedb
Else
Me.Text1(0).Text = yn.myrec.Fields("客户号")
Me.Text1(1).Text = yn.myrec.Fields("客户姓名")
Me.Text1(2).Text = yn.myrec.Fields("电话")
Me.Text1(3).Text = yn.myrec.Fields("OICQ")
Me.Text1(4).Text = yn.myrec.Fields("Email")
Call yn.closedb
End If
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 0 Or Index = 2 Or Index = 3 Then '如果是TEXT1,TEST2,TEXT3
Select Case KeyAscii
Case Asc("0") To Asc("9") '只允许它们输入数字
Case Else
KeyAscii = 0
MsgBox "请输入数字!!!", vbInformation
End Select
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -