数据库课程设计 员工信息管理系统

设计结果与分析(可以加页):

1、员工信息查询 (frmEmpInfo2.frm)

图1.9:员工信息查询界面

主要代码如下:

Private Sub Command1_Click() Dim strId As String Dim strName As String Dim strDept As String Dim strTitle As String Dim strDuty As String Dim strEdu As String Dim strSex As String '设置错误陷阱

On Error GoTo ERR_CONN If Trim(MskId) = \ strId = \ Else

strId = \ End If

If Trim(Text2) = \ strName = \ Else

strName = \ End If

If cboDept.ListIndex = 0 Then strDept = \ Else

strDept = \ End If

If cboTitle.ListIndex = 0 Then strTitle = \ Else

strTitle = \ End If

If cboDuty.ListIndex = 0 Then strDuty = \ Else

strDuty = \ End If

If cboEdu.ListIndex = 0 Then strEdu = \ Else

strEdu = \ End If

If cboSex.ListIndex = 0 Then strSex = \ Else

strSex = \ End If

'打开一个数据集 strSql = \a.emp_id,a.emp_name,a.sex,b.edu_name,c.dept_name,d.duty_name,e.title_name from employee a,education b,department c,duty d,title e where a.edu_id=b.edu_id and a.dept_id=c.dept_id and a.duty_id=d.duty_id and a.title_id=e.title_id \& strTitle & \& \

rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly

If rs.EOF Then

Label9 = \找到0条记录\

flxShow.Rows = 1 Else

'填写数据

flxShow.Rows = 1

Do While Not rs.EOF

flxShow.Rows = flxShow.Rows + 1

flxShow.TextMatrix(flxShow.Rows - 1, 0) = rs.Fields(0).Value

For i = 2 To rs.Fields.Count

flxShow.TextMatrix(flxShow.Rows - 1, i) = rs.Fields(i - 1).Value

Next i

rs.MoveNext Loop

Label9 = \找到\条记录\

End If rs.Close Exit Sub

ERR_CONN:

MsgBox \请检查输入的数据是否有效\End Sub

Private Sub Command3_Click() Unload Me End Sub

Private Sub Form_Load()

'性别

cboSex.AddItem \ cboSex.AddItem \男\ cboSex.AddItem \女\ cboSex.ListIndex = 0

'学历

strSql = \ rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly cboEdu.AddItem \

Do While Not rs.EOF

cboEdu.AddItem (rs.Fields(\

cboEdu.ItemData(cboEdu.NewIndex) = rs.Fields(\ rs.MoveNext Loop rs.Close

cboEdu.ListIndex = 0

'部门

strSql = \dept_id,dept_name from department Order By dept_id\ rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly cboDept.AddItem \ Do While Not rs.EOF

cboDept.AddItem (rs.Fields(\ cboDept.ItemData(cboDept.NewIndex) = rs.Fields(\ rs.MoveNext Loop rs.Close

cboDept.ListIndex = 0

'职务

strSql = \ rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly cboDuty.AddItem \ Do While Not rs.EOF

cboDuty.AddItem (rs.Fields(\ cboDuty.ItemData(cboDuty.NewIndex) = rs.Fields(\ rs.MoveNext Loop rs.Close

cboDuty.ListIndex = 0

'职称

strSql = \ rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly cboTitle.AddItem \ Do While Not rs.EOF

cboTitle.AddItem (rs.Fields(\ cboTitle.ItemData(cboTitle.NewIndex) = rs.Fields(\ rs.MoveNext Loop

联系客服:779662525#qq.com(#替换为@)