📄 frmempman.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"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmEmpMan
BorderStyle = 1 'Fixed Single
Caption = "职工管理"
ClientHeight = 5070
ClientLeft = 45
ClientTop = 375
ClientWidth = 7890
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5070
ScaleWidth = 7890
StartUpPosition = 2 '屏幕中心
Begin MSDataListLib.DataCombo dco_DepName
Height = 330
Left = 1920
TabIndex = 7
Top = 360
Width = 1755
_ExtentX = 3096
_ExtentY = 582
_Version = 393216
Text = ""
End
Begin VB.CommandButton Cmd_Modi
Caption = "修改"
Height = 375
Left = 2520
TabIndex = 6
Top = 4440
Width = 1215
End
Begin VB.CommandButton Cmd_Del
Caption = "删除"
Height = 375
Left = 4320
TabIndex = 5
Top = 4440
Width = 1215
End
Begin VB.CommandButton Cmd_Back
Caption = "返回"
Height = 375
Left = 6120
TabIndex = 4
Top = 4440
Width = 1215
End
Begin VB.CommandButton Cmd_Add
Caption = "添加"
Height = 375
Left = 720
TabIndex = 3
Top = 4440
Width = 1215
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 180
Top = 4440
Visible = 0 'False
Width = 1395
_ExtentX = 2461
_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 = "Adodc1"
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 = 3375
Left = 300
TabIndex = 2
Top = 900
Width = 7515
_ExtentX = 13256
_ExtentY = 5953
_Version = 393216
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
Begin MSAdodcLib.Adodc AdoDepName
Height = 375
Left = 4740
Top = 360
Visible = 0 'False
Width = 2535
_ExtentX = 4471
_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 = "AdoDepName"
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 VB.CheckBox Check1
Caption = "全部"
Height = 315
Left = 4020
TabIndex = 1
Top = 360
Width = 855
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 = 315
Left = 660
TabIndex = 0
Top = 420
Width = 1035
End
End
Attribute VB_Name = "frmEmpMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Refresh_Employees()
Dim TmpSource As String
TmpSource = "SELECT EmpId AS 职工编号,EmpName as 职工姓名,Sex AS 性别," _
+ "DepName as 所在部门,ETitle AS 职务 " _
+ "FROM Employees "
If Check1.Value = 0 And Len(Trim(dco_DepName.Text)) <> 0 Then
TmpSource = TmpSource + " Where DepName='" + Trim(dco_DepName.Text) + "' ORDER BY EmpId"
Else
TmpSource = TmpSource + " ORDER BY EmpId"
End If
'设置数据源属性
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = TmpSource
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
'设置列宽度
DataGrid1.Columns(0).Width = 1000
DataGrid1.Columns(1).Width = 1600
DataGrid1.Columns(2).Width = 1000
DataGrid1.Columns(3).Width = 1600
DataGrid1.Columns(4).Width = 1600
End Sub
Private Sub Check1_Click()
If Check1.Value = 1 Then
dco_DepName.Enabled = False
Else
dco_DepName.Enabled = True
End If
Refresh_Employees
End Sub
Private Sub Cmd_Add_Click()
'设置添加信息
frmEmpEdit.Modify = False
frmEmpEdit.txtName = ""
frmEmpEdit.cmb_Sex.ListIndex = 0
frmEmpEdit.dco_DepName.Text = ""
frmEmpEdit.dco_Title.Text = ""
frmEmpEdit.Show 1
Refresh_Employees
End Sub
Private Sub Cmd_Back_Click()
Unload Me
End Sub
Private Sub Cmd_Del_Click()
If Adodc1.Recordset.BOF = True Then
MsgBox "请选择记录"
Exit Sub
End If
'是否存在此员工的销售机会
If MyChance.HaveCustomer(Adodc1.Recordset.Fields(0)) = True Then
MsgBox "销售机会中存在此员工信息,不能删除!"
Exit Sub
End If
'确认删除
If MsgBox("是否确定要删除员工信息", vbYesNo, "请确认") = vbNo Then
Exit Sub
End If
'删除员工信息
Call MyEmp.Delete(Adodc1.Recordset.Fields(0))
MsgBox "删除成功"
Refresh_Employees
End Sub
Private Sub Cmd_Modi_Click()
Dim TmpAreaId As Long
If Adodc1.Recordset.BOF = True Then
MsgBox "请选择记录"
Exit Sub
End If
'员工姓名
frmEmpEdit.OriEmpId = Adodc1.Recordset.Fields(0)
frmEmpEdit.txtName = Trim(Adodc1.Recordset.Fields(1))
'性别
If Trim(Adodc1.Recordset.Fields(2)) = "男" Then
frmEmpEdit.cmb_Sex.ListIndex = 0
Else
frmEmpEdit.cmb_Sex.ListIndex = 1
End If
'部门
frmEmpEdit.dco_DepName.Text = Trim(Adodc1.Recordset.Fields(3))
'职务
frmEmpEdit.dco_Title.Text = Trim(Adodc1.Recordset.Fields(4))
frmEmpEdit.Modify = True
frmEmpEdit.Show 1
'刷新数据
Refresh_Employees
End Sub
Private Sub dco_DepName_Click(Area As Integer)
Refresh_Employees
End Sub
Private Sub Form_Load()
'装入部门名称
AdoDepName.ConnectionString = Conn
AdoDepName.RecordSource = "SELECT Distinct DepName FROM Employees Order By DepName"
AdoDepName.Refresh
Set dco_DepName.RowSource = AdoDepName
dco_DepName.ListField = "DepName"
dco_DepName.BoundColumn = "DepName"
dco_DepName.Enabled = False
Check1.Value = 1
Refresh_Employees
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -