人事工资管理系统(ER图+数据流程图+系统功能模块结构图+源代码) 第6页
人事工资管理系统
6、系统源代码
Public fMainForm As frmmain
Public gintMode As Integer
Public flagEdit As Boolean
Public username As String
Sub Main()
Dim fLogin As New frmlogin
fLogin.Show vbModal
If Not fLogin.OK Then
End
End If
Unload fLogin
Set fMainForm = New frmmain
fMainForm.Show
End Sub
Public Function ExecuteSQL(ByVal SQL _
As String, MsgString As String) _
As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim sTokens() As String
On Error GoTo ExecuteSQL_Error
sTokens = Split(SQL)
Set cnn = New ADODB.Connection
cnn.Open ConnectString
If InStr("INSERT,DELETE,UPDATE", _
UCase$(sTokens(0))) Then
cnn.Execute SQL
MsgString = sTokens(0) & _
" query successful"
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(SQL), cnn, _
adOpenKeyset, _
adLockOptimistic
Set ExecuteSQL = rst
MsgString = "查询到" & rst.RecordCount & _
" 条记录 "
End If
ExecuteSQL_Exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function
ExecuteSQL_Error:
MsgString = "查询错误: " & _
Err.Description
Resume ExecuteSQL_Exit
End Function
Public Function ConnectString() As String
ConnectString = "FileDSN=renshi.dsn"
End Function
员工基本信息模块代码:
Option Explicit
沈 阳 大 学
课程设计说明书 NO.22
Dim mblchange As Boolean
Public txtSQL As String
Public msgtext As String
Dim mrc As ADODB.Recordset
Private Sub cmdcancle_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim intCount As Integer
Dim txtSQL As String
Dim MsgString As String
Dim sMeg As String
Dim i As Integer
For intCount = 0 To 1
If Trim(Text1(intCount) & "") = "" Then
Select Case intCount
Case 0
sMeg = "工号"
Case 1
sMeg = "姓名"
End Select
sMeg = sMeg & "不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text1(intCount).SetFocus
Exit Sub
End If
Next intCount
If Trim(Text1(3) & "") = "" Then
MsgBox "出生日期不能为空", vbOKOnly + vbExclamation, "警告"
End If
If Trim(Text1(3) & "") <> "" Then
If Not IsDate(Text1(3)) Then
MsgBox "出生日期应为(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
Text1(3).SetFocus
Exit Sub
Else
Text1(3) = Format(Text1(3), "yyyy-mm-dd")
End If
End If
If Trim(Text1(2) & "") = "" Then
MsgBox "年龄不能为空", vbOKOnly + vbExclamation, "警告"
沈 阳 大 学
课程设计说明书 NO.23
Exit Sub
End If
If gintMode = 1 Then
txtSQL = "select * from dangan where ygid='" & Trim(Text1(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.EOF = False Then
MsgBox "有重复记录", vbOKOnly + vbExclamation, "警告"
Text1(0).SetFocus
End If
mrc.Close
txtSQL = "delete * from dangan where ygid='" & Trim(Text1(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
txtSQL = "select * from dangan"
Set mrc = ExecuteSQL(txtSQL, msgtext)
mrc.AddNew
For intCount = 0 To 1
mrc.Fields(intCount) = Trim(Text1(intCount))
Next intCount
For intCount = 2 To 5
mrc.Fields(intCount) = Trim(Text1(intCount))
Next intCount
For intCount = 6 To 10
mrc.Fields(intCount) = Trim(Text1(intCount))
Next intCount
mrc.Fields(11) = Trim(Combo1.Text)
mrc.Update
If gintMode = 1 Then
MsgBox "添加记录成功", vbOKOnly, "提示"
For i = 0 To 10
Text1(i).Text = ""
Next i
frmyuangong.Show
frmyuangong.ZOrder 0
frmmanrecord.ShowTitle
frmmanrecord.ShowData
frmmanrecord.ZOrder 1
End If
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim rectemp As Recordset
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页