\系统登录\
X = MsgBox(\你不是管理员,将以普通用户登陆\
End If If X = 2 Then
txtUserName.SetFocus txtUserName.Text = \txtPassword.Text = \
Now & \
Else
'添加操作员登陆时间
strSql = \用户,登录时间) values('\
Set objRs = ExecuteSQL(strSql, strMsg) Unload Me MDIForm1.Show
End If
End If End If
End If End If
Logontimes = Logontimes + 1 '登陆次数 Exit Sub Dealerror:
msg = \程序执行出错,错误信息如下:\ ShowError msg End Sub
Dim objRs As Recordset Dim i As Integer
Dim Logontimes As Integer Private Sub Comcancle_Click()
n = MsgBox(\你选择了退出系统登陆,退出将不能启动管理系统!\& vbCrLf & \是否真的退出?\vbYesNo, \系统验证\If n = vbYes Then Unload Me End If End Sub
21
图4-2 工资管理系统主窗体
4.3、员工基本档案信息的实现
员工基本档案信息管理,在窗体中完成员工基本信息的录入工作。根据提示在该窗体中输入相应的信息,最后单击“保存”按钮,进行信息的保存。如图4-3所示
图4-3 员工基本档案信息录入窗口
22
相应部分代码如下:
'添加员工基本信息
Private Sub cmdOK_Click() Dim rs As ADODB.Recordset Dim strSql As String Dim strMsg As String Dim tmpPath As String Dim iStm As ADODB.Stream
'如果是修改(保存照片--删除原记录--保存记录) If blnChange = True Then '如果不要删除
If blnDelPhoto = False Then
strSql = \工号='\
Set rs = ExecuteSQL(strSql, strMsg) '保存到文件
tmpPath = App.path & \
If Not IsNull(rs.Fields(\照片\ Set iStm = New ADODB.Stream With iStm
.Mode = adModeReadWrite .Type = adTypeBinary .Open
.Write rs.Fields(\照片\ .SaveToFile tmpPath Else
blnDel = False End If rs.Close End If '删除记录
strSql = \工号='\
blnDel = True strFileName = tmpPath
'pic.Picture = LoadPicture(tmpPath) iStm.Close
End With
23
Set rs = ExecuteSQL(strSql, strMsg) Else
strSql = \工号='\ Set rs = ExecuteSQL(strSql, strMsg) If rs.EOF = False Then
MsgBox \已有相同的工号,无法添加到数据库!\警告\ TextFocus txtGH Exit Sub End If rs.Close End If
strSql = \ Set rs = ExecuteSQL(strSql, strMsg) rs.AddNew
rs.Fields(\工号\ rs.Fields(\姓名\ If cboPayStyle.Text = \ Else End If
If cboHealthy.Text = \ Else End If
If cboSex.Text = \ Else End If
If cboEmployeeStyle.Text = \
rs.Fields(\职工类型\rs.Fields(\性别\rs.Fields(\性别\
rs.Fields(\健康状况\rs.Fields(\健康状况\
rs.Fields(\工资类别\rs.Fields(\工资类别\
24
Else End If
If cboPart.Text = \ Else End If
If cboDuty.Text = \ Else End If
If cboCulture.Text = \ Else
If cboNation.Text = \
rs.Fields(\民族\rs.Fields(\民族\
Else End If '数字型
If txtMoney.Text = \ Else End If
If cboSpec.Text = \ Else
rs.Fields(\所学专业\rs.Fields(\所学专业\rs.Fields(\薪金\rs.Fields(\薪金\
rs.Fields(\文化程度\
End If
rs.Fields(\文化程度\rs.Fields(\职务\rs.Fields(\职务\rs.Fields(\部门\rs.Fields(\部门\
rs.Fields(\职工类型\
25