📄 browseemployeedialog.frm
字号:
Width = 1815
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 285
Left = 720
TabIndex = 18
Top = 240
Width = 1215
End
Begin VB.Label Label13
AutoSize = -1 'True
Caption = "备注"
Height = 195
Left = 120
TabIndex = 30
Top = 1680
Width = 360
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "启用日期"
Height = 195
Left = 2160
TabIndex = 10
Top = 960
Width = 720
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "职位"
Height = 195
Left = 120
TabIndex = 9
Top = 960
Width = 360
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "部门"
Height = 195
Left = 2160
TabIndex = 8
Top = 600
Width = 360
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "性别"
Height = 195
Left = 120
TabIndex = 7
Top = 600
Width = 360
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "编号"
Height = 195
Left = 2160
TabIndex = 6
Top = 240
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "姓名"
Height = 195
Left = 120
TabIndex = 5
Top = 240
Width = 360
End
End
Begin VB.Frame EmployeeName
Caption = "雇员编号"
Height = 4575
Left = 0
TabIndex = 2
Top = 0
Width = 1215
Begin VB.ListBox List1
Height = 4155
Left = 120
TabIndex = 3
Top = 240
Width = 975
End
End
Begin VB.CommandButton CancelButton
Caption = "取消"
Height = 375
Left = 5040
TabIndex = 1
Top = 4200
Width = 975
End
Begin VB.CommandButton OKButton
Caption = "确认"
Height = 375
Left = 3960
TabIndex = 0
Top = 4200
Width = 975
End
End
Attribute VB_Name = "BrowseEmployeeDialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim MyDB As Database
Dim MyRecord As Recordset
Dim TempStr As String
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub Command1_Click()
If frmLogin.IsAdmin = False Then
MsgBox "一般用户不具备修改权限!"
Exit Sub
End If
If List1.SelCount = 0 Then
MsgBox "请选定一名雇员 !"
Exit Sub
End If
Text1.Enabled = True
Option1.Enabled = True
Option2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
DTPicker1.Enabled = True
Text6.Enabled = True
Command1.Enabled = False
Command2.Enabled = False
End Sub
Private Sub Command2_Click()
TempStr = "DELETE FROM 雇员表 WHERE EmployeeID='" & Text2.Text & "'"
MyDB.Execute TempStr
MsgBox "成功删除雇员 " & Text2.Text & " !"
Text1.Text = ""
Text2.Text = ""
Option1.Value = False
Option2.Value = False
Text3.Text = ""
Text4.Text = ""
DTPicker1.Value = "2006-1-1"
Text6.Text = ""
List1.RemoveItem List1.ListIndex
Command2.Enabled = False
End Sub
Private Sub Data1_Reposition()
If Not (Data1.Recordset.EOF And Data1.Recordset.BOF) Then
Data2.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
Data2.RecordSource = "select * from 客户表 where CustomerID='" & Data1.Recordset("CustomerID") & "'"
Data2.Refresh
Data3.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
Data3.RecordSource = "select * from 产品表 where ProductID='" & Data1.Recordset("ProductID") & "'"
Data3.Refresh
Else
Text8.Text = ""
Text9.Text = ""
End If
End Sub
Private Sub Form_Load()
Text7.DataField = "OrderID"
Text8.DataField = "CompanyTitle"
Text9.DataField = "Product"
Text10.DataField = "OrderDate"
Text11.DataField = "OrderAmount"
Text12.DataField = "DeliveryDate"
Set MyDB = OpenDatabase(VB.App.Path + "\MySampleDB.mdb", False, False)
Set MyRecord = MyDB.OpenRecordset("雇员表")
MyRecord.Index = "PrimaryKey"
Do While Not MyRecord.EOF
List1.AddItem MyRecord.Fields("EmployeeID")
MyRecord.MoveNext
Loop
End Sub
Private Sub Form_Unload(Cancel As Integer)
MyRecord.Close
MyDB.Close
End Sub
Private Sub List1_Click()
Command1.Enabled = True
MyRecord.Index = "PrimaryKey"
MyRecord.Seek "=", List1.Text
If MyRecord.NoMatch Then
MsgBox "没有编号为" + List1.Text + "的人!"
Else
Text1.Text = MyRecord.Fields("Name")
Text2.Text = List1.Text
If MyRecord.Fields("Sex") = True Then Option1.Value = True Else Option2.Value = True
Text3.Text = MyRecord.Fields("Department")
Text4.Text = MyRecord.Fields("Title")
DTPicker1.Value = MyRecord.Fields("HireDate")
If Not IsNull(MyRecord.Fields("Memo")) Then
Text6.Text = MyRecord.Fields("Memo")
Else
Text6.Text = ""
End If
Data1.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
Data1.RecordSource = "select * from 订单表 where EmployeeID='" & List1.Text & "'"
Data1.Refresh
If Not (Data1.Recordset.EOF And Data1.Recordset.BOF) Then
Command2.Enabled = False
Data2.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
Data2.RecordSource = "select * from 客户表 where CustomerID='" & Data1.Recordset("CustomerID") & "'"
Data2.Refresh
Data3.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
Data3.RecordSource = "select * from 产品表 where ProductID='" & Data1.Recordset("ProductID") & "'"
Data3.Refresh
Else
If frmLogin.IsAdmin = True Then Command2.Enabled = True
Text8.Text = ""
Text9.Text = ""
End If
End If
End Sub
Private Sub OKButton_Click()
If Command1.Enabled = True Then
Unload Me
Else
If Text1.Text = "" Then
MsgBox "请输入 姓名 !"
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "请输入 部门 !"
Exit Sub
End If
If Option1.Value = False And Option2.Value = False Then
MsgBox "请输入 性别 !"
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "请输入 职位 !"
Exit Sub
End If
TempStr = "UPDATE 雇员表 SET Name='" & Text1.Text & "',Sex=" & Option1.Value & _
",Department='" & Text3.Text & "',Title='" & Text4.Text & "',HireDate='" _
& DTPicker1.Value & "',Memo='" & Text6.Text & "' WHERE EmployeeID='" & Text2.Text & "'"
MyDB.Execute TempStr
MsgBox "成功修改雇员" & Text2.Text & "!"
Text1.Enabled = False
Option1.Enabled = False
Option2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
DTPicker1.Enabled = False
Text6.Enabled = False
Command1.Enabled = True
Command2.Enabled = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -