📄 main_czy.frm
字号:
VERSION 5.00
Begin VB.Form main_czy
BorderStyle = 3 'Fixed Dialog
Caption = "系统设置-〖操作员设置〗"
ClientHeight = 1590
ClientLeft = 3525
ClientTop = 3585
ClientWidth = 3990
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1590
ScaleWidth = 3990
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "E:\明日vb编程500例\实用程序10例\客户管理系统\khgl.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 345
Left = 1200
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "ma"
Top = 4800
Visible = 0 'False
Width = 1515
End
Begin VB.Frame Frame1
Height = 1095
Left = 120
TabIndex = 3
Top = 0
Width = 3795
Begin VB.ComboBox Combo1
Height = 300
Left = 1530
Locked = -1 'True
TabIndex = 8
Top = 240
Width = 2055
End
Begin VB.TextBox Text1
Height = 285
IMEMode = 3 'DISABLE
Index = 1
Left = 1515
PasswordChar = "*"
TabIndex = 4
Top = 660
Width = 2055
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "密码 "
Height = 285
Left = 720
TabIndex = 6
Top = 720
Width = 645
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "操作员 "
Height = 330
Left = 675
TabIndex = 5
Top = 330
Width = 870
End
End
Begin VB.CommandButton ComEnd
Caption = "退出"
Height = 375
Left = 3000
TabIndex = 2
Top = 1200
Width = 885
End
Begin VB.CommandButton ComSave
Caption = "保存"
Height = 375
Left = 1080
TabIndex = 1
Top = 1200
Width = 885
End
Begin VB.CommandButton ComAdd
Caption = "添加"
Height = 375
Left = 120
TabIndex = 0
Top = 1200
Width = 885
End
Begin VB.CommandButton ComDelete
Caption = "删除"
Height = 375
Left = 2040
TabIndex = 7
Top = 1200
Width = 885
End
End
Attribute VB_Name = "main_czy"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Dim mydb As Database
Dim myrs1 As Recordset
Private Sub Combo1_Click()
Text1(1).SetFocus
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text1(1).SetFocus
Else
End If
End Sub
Private Sub Form_Load()
frm_main.StatusBar1.Panels(1) = Me.Caption
Data1.DatabaseName = App.Path & "\khgl.mdb"
Data1.RecordSource = "select * from ma "
Data1.Refresh
If Data1.Recordset.RecordCount > 0 Then
Data1.Recordset.MoveFirst
Do While Data1.Recordset.EOF = False
Combo1.AddItem (Data1.Recordset.Fields("操作员"))
Data1.Recordset.MoveNext
Loop
Else
End If
Text1(1).MaxLength = 6
ComSave.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True
frm_main.StatusBar1.Panels(1) = "长春市明日科技有限责任公司"
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
Select Case Index
Case 0
If Index = 0 And KeyCode = vbKeyReturn Then Text1(1).SetFocus
Case 1
If Index = 1 And KeyCode = vbKeyReturn Then ComSave.SetFocus
End Select
End Sub
Private Sub ComAdd_Click()
ComSave.Enabled = True
ComAdd.Enabled = False
Combo1.Locked = False
End Sub
Private Sub ComSave_Click()
Data1.RecordSource = "select * from ma where 操作员='" + Combo1.Text + "'"
Data1.Refresh
If Data1.Recordset.RecordCount > 0 Then
MsgBox "用户名已经存在,注册不成功!", , "信息提示"
Combo1.Text = ""
Combo1.SetFocus
Else
Set mydb = Workspaces(0).OpenDatabase(App.Path & "\khgl.mdb")
Set myrs1 = mydb.OpenRecordset("ma", dbOpenTable)
myrs1.AddNew
If Combo1.Text <> "" Then myrs1.Fields(0) = Combo1.Text
If Text1(1).Text <> "" Then
myrs1.Fields(1) = Text1(1).Text
myrs1.Fields(2) = "0"
myrs1.Fields(3) = "0"
myrs1.Fields(4) = "0"
myrs1.Fields(5) = "0"
myrs1.Fields(6) = "0"
Else
End If
myrs1.Update
myrs1.Close
mydb.Close
Data1.Refresh
ComSave.Enabled = False
ComAdd.Enabled = True
End If
End Sub
Private Sub ComDelete_Click()
Data1.RecordSource = "select * from ma where 操作员='" + Combo1.Text + "'"
Data1.Refresh
If Trim(Combo1.Text) = Name1 Then
MsgBox "不能删除当前操作员!", , "提示信息"
Else
If Data1.Recordset.RecordCount <> 0 Then
Data1.Recordset.Delete
MsgBox "信息删除成功!", , "信息提示"
Else
MsgBox "请选择要删除的操作员名称", , "信息提示"
Combo1.SetFocus
End If
End If
End Sub
Private Sub ComEnd_Click()
frm_main.Enabled = True
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -