📄 frmemployeetable.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmEmployeeTable
BorderStyle = 3 'Fixed Dialog
Caption = "员工信息表"
ClientHeight = 7260
ClientLeft = 45
ClientTop = 435
ClientWidth = 7785
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 7260
ScaleWidth = 7785
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text7
Height = 375
Left = 1800
TabIndex = 21
Top = 5880
Width = 1575
End
Begin VB.Frame Frame2
Caption = "删除用户"
Height = 1455
Left = 240
TabIndex = 2
Top = 5760
Width = 7095
Begin VB.CommandButton Command8
Caption = "返回"
Height = 375
Left = 3840
TabIndex = 19
Top = 960
Width = 1215
End
Begin VB.CommandButton Command7
Caption = "删除"
Height = 375
Left = 1560
TabIndex = 18
Top = 960
Width = 1215
End
Begin VB.Label Label8
Caption = "用户编号:"
Height = 255
Left = 600
TabIndex = 20
Top = 360
Width = 975
End
End
Begin VB.Frame Frame1
Caption = "添加用户"
Height = 2655
Left = 240
TabIndex = 1
Top = 3000
Width = 7215
Begin VB.CommandButton Command6
Caption = "返回"
Height = 375
Left = 3840
TabIndex = 17
Top = 2160
Width = 1215
End
Begin VB.CommandButton Command5
Caption = "添加"
Height = 375
Left = 1560
TabIndex = 16
Top = 2160
Width = 1215
End
Begin VB.TextBox Text6
Height = 375
Left = 1200
TabIndex = 15
Top = 1680
Width = 3735
End
Begin VB.TextBox Text5
Height = 375
Left = 4680
TabIndex = 13
Top = 1200
Width = 1815
End
Begin VB.TextBox Text4
Height = 375
Left = 1200
TabIndex = 11
Top = 1200
Width = 1575
End
Begin VB.TextBox Text3
Height = 375
Left = 1200
TabIndex = 8
Top = 720
Width = 1575
End
Begin VB.TextBox Text2
Height = 375
Left = 4680
TabIndex = 6
Top = 240
Width = 1815
End
Begin VB.TextBox Text1
Height = 375
Left = 1200
TabIndex = 4
Top = 240
Width = 1575
End
Begin VB.Label Label6
Caption = "员工地址:"
Height = 255
Left = 240
TabIndex = 14
Top = 1800
Width = 975
End
Begin VB.Label Label5
Caption = "员工电话:"
Height = 255
Left = 3240
TabIndex = 12
Top = 1320
Width = 975
End
Begin VB.Label Label4
Caption = "确认密码:"
Height = 255
Left = 240
TabIndex = 10
Top = 1320
Width = 975
End
Begin VB.Label Label7
Caption = "密码长度为3~8位"
Height = 255
Left = 3120
TabIndex = 9
Top = 840
Width = 1455
End
Begin VB.Label Label3
Caption = "员工密码:"
Height = 255
Left = 240
TabIndex = 7
Top = 840
Width = 975
End
Begin VB.Label Label2
Caption = "员工姓名:"
Height = 255
Left = 3600
TabIndex = 5
Top = 360
Width = 975
End
Begin VB.Label Label1
Caption = "员工编号:"
Height = 255
Left = 240
TabIndex = 3
Top = 360
Width = 975
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 1920
Top = 2520
Width = 3495
_ExtentX = 6165
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 2175
Left = 240
TabIndex = 0
Top = 240
Width = 7095
_ExtentX = 12515
_ExtentY = 3836
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmEmployeeTable"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim strempl As String
Dim rs_empl As New ADODB.Recordset
Private Sub Command1_Click()
Adodc1.Recordset.MoveFirst
End Sub
Private Sub Command2_Click()
If Adodc1.Recordset.EOF = True Then
MsgBox "已是末记录!", vbOKOnly + vbInformation, "注意"
Adodc1.Recordset.MoveLast
Else
Adodc1.Recordset.MoveNext
End If
End Sub
Private Sub Command3_Click()
If Adodc1.Recordset.BOF = True Then
MsgBox "已是首记录!", vbOKOnly + vbInformation, "注意"
Adodc1.Recordset.MoveFirst
Else
Adodc1.Recordset.MovePrevious
End If
End Sub
Private Sub Command4_Click()
Adodc1.Recordset.MoveLast
End Sub
Private Sub Command5_Click()
If Text1.Text = "" Then
MsgBox "请输入用户名!", vbOKOnly + vbInformation, "提示"
Text1.SetFocus
Exit Sub
ElseIf Text2.Text = "" Then
MsgBox "请输入用户编号!", vbOKOnly + vbInformation, "提示"
Text2.SetFocus
Exit Sub
ElseIf Text3.Text = "" Then
MsgBox "请输入密码!", vbOKOnly + vbInformation, "提示"
Text3.SetFocus
Exit Sub
ElseIf Text4.Text = "" Then
MsgBox "请输入确认密码!", vbOKOnly + vbInformation, "提示"
Text4.SetFocus
Exit Sub
ElseIf Text5.Text = "" Then
MsgBox "请输入联系电话!", vbOKOnly + vbInformation, "提示"
Text5.SetFocus
Exit Sub
ElseIf Text6.Text = "" Then
MsgBox "请输入联系地址!", vbOKOnly + vbInformation, "提示"
Text6.SetFocus
Exit Sub
End If
If Len(Text3.Text) < 3 Or Len(Text3.Text) > 8 Then
MsgBox "密码长度不符合要求!", vbOKOnly + vbInformation, "提示"
Text3.Text = ""
Text3.SetFocus
Exit Sub
End If
If Text3.Text <> Text4.Text Then
MsgBox "两次输入的密码不一致!", vbOKOnly + vbInformation, "注意"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
Exit Sub
End If
strempl = "select * from employee where 员工编号='" & Text1.Text & "'"
rs_empl.Open strempl, cnn, adOpenKeyset, adLockOptimistic
If rs_empl.EOF = True Then
rs_empl.AddNew
rs_empl.Fields("员工编号") = Text1.Text
rs_empl.Fields("员工姓名") = Text2.Text
rs_empl.Fields("员工密码") = Text3.Text
rs_empl.Fields("员工电话") = Text5.Text
rs_empl.Fields("员工地址") = Text6.Text
rs_empl.Update
rs_empl.Close
Else
MsgBox "该用户编号已存在,请重新输入!", vbOKOnly + vbInformation, "注意"
rs_empl.Close
Exit Sub
End If
MsgBox "添加用户成功!", vbOKOnly + vbInformation, ""
strempl = "select * from employee"
rs_empl.Open strempl, cnn, adOpenKeyset, adLockOptimistic
Adodc1.RecordSource = strempl
Adodc1.Refresh
DataGrid1.ReBind
DataGrid1.Refresh
rs_empl.Close
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
Private Sub Command6_Click()
Unload Me
End Sub
Private Sub Command7_Click()
If Text7.Text = "" Then
MsgBox "请输入要删除的用户编号!", vbOKOnly + vbInformation, ""
Text7.SetFocus
Exit Sub
End If
If Text7.Text = "0001" Then
MsgBox "不能删除管理员帐户", vbOKOnly + vbInformation, "注意"
Text7.Text = ""
Text7.SetFocus
Exit Sub
End If
If MsgBox("真的要删除该用户?", vbYesNo + vbQuestion, "") = vbNo Then
Exit Sub
End If
strempl = "select * from employee where 员工编号='" & Text7.Text & "'"
rs_empl.Open strempl, cnn, adOpenKeyset, adLockOptimistic
If rs_empl.EOF = True Then
MsgBox "该用户编号不存在,请重新输入!", vbOKOnly + vbInformation, ""
Exit Sub
rs_empl.Close
Else
rs_empl.Delete
rs_empl.Update
rs_empl.Close
End If
strempl = "select * from employee "
rs_empl.Open strempl, cnn, adOpenKeyset, adLockOptimistic
Adodc1.RecordSource = strempl
Adodc1.Refresh
DataGrid1.ReBind
rs_empl.Close
Text7.Text = ""
End Sub
Private Sub Command8_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim str As String
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\sellsystem.mdb;"
Adodc1.ConnectionString = str
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from employee"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -