📄 modulemain.bas
字号:
Attribute VB_Name = "ModuleMain"
Option Explicit
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Public lCardCount As Long
Public g_GetTimeCount As Long
Public g_AddClass As Long
Public g_Memo As String
Public g_LateTime As Long
Public KQJPWD As String
Public sState As String
Public sCmd As String
Public iFrom As Form
Public con As New Connection
Public UserName As String
Public UserID As Integer
Public isLogin As Boolean
Public IsSystem As Integer
Public rstEmployee As New ADODB.Recordset
Public rstClass As New ADODB.Recordset
Public rstVac As New ADODB.Recordset
Public rstTimeMode As New ADODB.Recordset
Public rstTimePos As New ADODB.Recordset
Public rstMedia As New ADODB.Recordset
Public rstOnClass As New ADODB.Recordset
Public bufOnClass As New ComBuf
Public bufTimePos As New ComBuf
Public bufClass As New ComBuf
Public bufVac As New ComBuf
Public bufEmployee As New ComBuf
Public bufTimeMode As New ComBuf
Public gExit As Boolean
Public Type ClassType
ClassName As String
ClassID As Long
InTime As Integer
OutTime As Integer
End Type
Public Type OnClassType
OnClassID As Long
BeginDate As String
EndDate As String
TimeMode As String
BeginTime As String
EndTime As String
ClassID As Long
End Type
Public Type SetClassType
EmployeeID As Long
CardID As String * 8
BeginDate As String
EndDate As String
TimeMode As Long
BeginTime As Long
EndTime As Long
ClassID As Long
AddClass As Boolean
End Type
Public Type EmployeeType
EmployeeName As String
OnClassID As Long
VacID As Long
EmployeeID As Long
CardID As String * 8
End Type
Public Type InDataType
InDate As String * 8
InCode As String * 8
InTime As String * 4
End Type
Public Type VacType
VacID As Long
BeginDate As String
EndDate As String
TimeMode As String
BeginTime As String
EndTime As String
TimePos As String
End Type
Public Type SetVacType
EmployeeID As Long
BeginDate As String
EndDate As String
TimeMode As String
BeginTime As String
EndTime As String
TimePos As String
End Type
Public Type LeaveType
EmployeeID As Long
BeginDate As String
EndDate As String
TimeMode As String
BeginTime As String
EndTime As String
TimePos As String
End Type
Public Type ClassID
AddClass As Boolean
ClassID As Long
End Type
Public Type tmpClass
AddClass As Boolean
ClassID As Long
bTime As Long
eTime As Long
End Type
Public ClassIDInfo() As ClassID
Public blnClassIDInfo As Boolean
Public tmpClassInfo() As tmpClass
Public blntmpClassInfo As Boolean
Public OnClassInfo() As OnClassType
Public blnOnClassInfo As Boolean
Public ClassInfo() As ClassType
Public blnClassInfo As Boolean
Public SetClassInfo() As SetClassType
Public blnSetClassInfo As Boolean
Public EmployeeInfo() As EmployeeType
Public blnEmployeeInfo As Boolean
Public InDataInfo() As InDataType
Public blnInDataInfo As Boolean
Public VacTypeInfo() As VacType
Public blnVacTypeInfo As Boolean
Public SetVacTypeInfo() As SetVacType
Public blnSetVacTypeInfo As Boolean
Public LeaveTypeInfo() As LeaveType
Public blnLeaveTypeInfo As Boolean
Sub Main()
If App.PrevInstance = True Then
End
End If
App.Title = "考勤管理系统"
If Dir(App.Path & "\Data.mdb") = "" Then
Message "找不到数据文件,请检查!"
End
End If
' Dim strSQL As String
' strSQL = "Driver={SQL Server};Server=127.0.0.1;Uid=sa;Pwd=;Database=KQJ"
' con.Open strSQL
'
' MDI.Show
' FristMain
Login.Show
gExit = False
While Not gExit
DoEvents
Wend
' Dim i As Integer
' For i = 0 To Forms.Count
' Unload Forms(i)
'
' Next
Set bufVac = Nothing
Set bufClass = Nothing
Set bufOnClass = Nothing
Set bufEmployee = Nothing
Set bufTimeMode = Nothing
If rstTimeMode.State = adStateOpen Then
rstTimeMode.Close
End If
If rstEmployee.State = adStateOpen Then
rstEmployee.Close
End If
If rstClass.State = adStateOpen Then
rstClass.Close
End If
Set rstVac = Nothing
Set rstOnClass = Nothing
Set rstEmployee = Nothing
Set rstClass = Nothing
Set rstTimeMode = Nothing
If con.State = adStateOpen Then
con.Close
End If
Set con = Nothing
End
End Sub
Sub FristMain()
rstClass.CursorLocation = adUseClient
rstClass.Open "Select * from class", con, adOpenStatic, adLockBatchOptimistic
bufClass.Headers = "classid,classname[t]"
bufClass.SetBaseCount rstClass.RecordCount
bufClass.DataSource = rstClass
rstOnClass.CursorLocation = adUseClient
rstOnClass.Open "Select * from ClassInfo", con, adOpenStatic, adLockBatchOptimistic
bufOnClass.Headers = "OnClassID,OnClassName[t]"
bufOnClass.SetBaseCount rstOnClass.RecordCount
bufOnClass.DataSource = rstOnClass
rstVac.Open "select VacID, VacName from VacInfo", con, adOpenStatic, adLockBatchOptimistic
bufVac.Headers = "VacID,VacName[t]"
bufVac.SetBaseCount rstVac.RecordCount
bufVac.DataSource = rstVac
rstEmployee.Open "Select * from Employee", con, adOpenStatic, adLockBatchOptimistic
bufEmployee.Headers = "employeeid,Code,name[t],Card"
bufEmployee.SetBaseCount rstEmployee.RecordCount
bufEmployee.DataSource = rstEmployee
rstTimeMode.Open "Select * from TimeMode", con, adOpenStatic, adLockBatchOptimistic
bufTimeMode.Headers = "DataID,TimeMode"
bufTimeMode.SetBaseCount rstTimeMode.RecordCount
bufTimeMode.DataSource = rstTimeMode
'===媒体广告
rstMedia.Open "SELECT * FROM ADCONTROL", con, adOpenStatic, adLockBatchOptimistic
MDI.KQJ.Open
Sleep 300
MDI.KQJ.GetLoginInfo
NAV.ZOrder
End Sub
Public Sub FillInfo(ByVal dBeginTime As Date, ByVal dEndTime As Date)
Dim i As Integer
Dim lCount As Long
Dim tmpRst As New Recordset
Dim strSQL As String
Dim tmps As String
Dim tmps1 As String
Dim iValue As Integer
Dim sBeginTime As String
Dim sEndTime As String
sBeginTime = Format(dBeginTime, "yyyy-mm-dd")
sEndTime = Format(dEndTime, "yyyy-mm-dd")
'=================ClassInfo======================================
ReDim ClassInfo(0)
tmpRst.Open "select a.ClassID,a.ClassName,b.OnDutyTime,b.OffDutyTime from class a " _
& "left outer join class_d b on a.ClassID=b.ClassID", con, adOpenStatic, adLockReadOnly
lCount = tmpRst.RecordCount
If lCount > 0 Then
ReDim ClassInfo(1 To lCount) As ClassType
blnClassInfo = True
tmpRst.MoveFirst
For i = 1 To lCount
ClassInfo(i).ClassName = tmpRst!ClassName
ClassInfo(i).ClassID = tmpRst!ClassID
tmps = tmpRst!OnDutyTime
tmps1 = Split(tmps, ":")(0)
iValue = Val(tmps1)
tmps1 = Split(tmps, ":")(1)
iValue = Val(tmps1) + iValue * 60
ClassInfo(i).InTime = iValue
tmps = tmpRst!OffDutyTime
tmps1 = Split(tmps, ":")(0)
iValue = Val(tmps1)
tmps1 = Split(tmps, ":")(1)
iValue = Val(tmps1) + iValue * 60
ClassInfo(i).OutTime = iValue
tmpRst.MoveNext
Next
End If
'=================OnClassInfo======================================
ReDim OnClassInfo(0)
tmpRst.Close
tmpRst.Open "select * from ClassInfo_D", con, adOpenStatic, adLockReadOnly
lCount = tmpRst.RecordCount
If lCount > 0 Then
ReDim OnClassInfo(1 To lCount) As OnClassType
blnOnClassInfo = True
tmpRst.MoveFirst
For i = 1 To lCount
OnClassInfo(i).OnClassID = tmpRst!OnClassID
OnClassInfo(i).ClassID = tmpRst!ClassID
' OnClassInfo(i).TimeMode = tmpRst!TimeMode
If Trim(tmpRst!TimeMode) = "每天" Then
OnClassInfo(i).TimeMode = 0
ElseIf Trim(tmpRst!TimeMode) = "每周" Then
OnClassInfo(i).TimeMode = 1
ElseIf Trim(tmpRst!TimeMode) = "每月" Then
OnClassInfo(i).TimeMode = 2
End If
OnClassInfo(i).BeginTime = tmpRst!BeginTime
OnClassInfo(i).EndTime = tmpRst!EndTime
tmps = tmpRst!BeginDate
OnClassInfo(i).BeginDate = Val(Mid(tmps, 1, 4)) * 600 + Val(Mid(tmps, 6, 2)) * 50 + Val(Mid(tmps, 9, 2))
tmps = tmpRst!EndDate
OnClassInfo(i).EndDate = Val(Mid(tmps, 1, 4)) * 600 + Val(Mid(tmps, 6, 2)) * 50 + Val(Mid(tmps, 9, 2))
tmpRst.MoveNext
Next
End If
'================EmployeeInfo============================
ReDim EmployeeInfo(0)
tmpRst.Close
Set tmpRst = Nothing
tmpRst.Open "select * from employee order by Card", con, adOpenStatic, adLockReadOnly
lCount = tmpRst.RecordCount
If lCount > 0 Then
ReDim EmployeeInfo(1 To lCount) As EmployeeType
blnEmployeeInfo = True
tmpRst.MoveFirst
For i = 1 To lCount
If IsNull(tmpRst!Name) Then EmployeeInfo(i).EmployeeName = "" Else EmployeeInfo(i).EmployeeName = tmpRst!Name
If IsNull(tmpRst!OnClassID) Then EmployeeInfo(i).OnClassID = 0 Else EmployeeInfo(i).OnClassID = tmpRst!OnClassID
If IsNull(tmpRst!VacID) Then EmployeeInfo(i).VacID = 0 Else EmployeeInfo(i).VacID = tmpRst!VacID
If IsNull(tmpRst!Card) Then EmployeeInfo(i).CardID = "" Else EmployeeInfo(i).CardID = tmpRst!Card
If IsNull(tmpRst!EmployeeID) Then EmployeeInfo(i).EmployeeID = 0 Else EmployeeInfo(i).EmployeeID = tmpRst!EmployeeID
tmpRst.MoveNext
Next
End If
'==============VacInfo=================================
ReDim VacTypeInfo(0)
tmpRst.Close
Set tmpRst = Nothing
tmpRst.Open "select * from VacInfo_D order by VacID,TimePos,TimeMode", con, adOpenStatic, adLockReadOnly
lCount = tmpRst.RecordCount
If lCount > 0 Then
ReDim VacTypeInfo(1 To lCount) As VacType
blnVacTypeInfo = True
tmpRst.MoveFirst
For i = 1 To lCount
VacTypeInfo(i).VacID = tmpRst!VacID
If Trim(tmpRst!TimeMode) = "每天" Then
VacTypeInfo(i).TimeMode = 0
ElseIf Trim(tmpRst!TimeMode) = "每周" Then
VacTypeInfo(i).TimeMode = 1
ElseIf Trim(tmpRst!TimeMode) = "每月" Then
VacTypeInfo(i).TimeMode = 2
End If
If tmpRst!TimePos = "全天" Then
VacTypeInfo(i).TimePos = 0
Else
VacTypeInfo(i).TimePos = Val(Mid(tmpRst!TimePos, 4, Len(tmpRst!TimePos) - 3))
End If
VacTypeInfo(i).BeginDate = tmpRst!BeginDate
VacTypeInfo(i).EndDate = tmpRst!EndDate
VacTypeInfo(i).BeginTime = tmpRst!BeginTime
VacTypeInfo(i).EndTime = tmpRst!EndTime
tmpRst.MoveNext
Next
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -