www.pudn.com > renshixitong.rar > frmCheck1.frm
VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmCheck1
BorderStyle = 3 'Fixed Dialog
Caption = "员工考勤"
ClientHeight = 5280
ClientLeft = 48
ClientTop = 336
ClientWidth = 7092
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5280
ScaleWidth = 7092
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin TabDlg.SSTab SSTab1
Height = 4455
Left = 360
TabIndex = 24
Top = 240
Width = 6375
_ExtentX = 11240
_ExtentY = 7853
_Version = 393216
Style = 1
TabHeight = 520
TabCaption(0) = "基本信息"
TabPicture(0) = "frmCheck1.frx":0000
Tab(0).ControlEnabled= -1 'True
Tab(0).Control(0)= "Frame1"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "Frame2"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "Frame5"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).ControlCount= 3
TabCaption(1) = "出勤信息"
TabPicture(1) = "frmCheck1.frx":001C
Tab(1).ControlEnabled= 0 'False
Tab(1).Control(0)= "Frame3"
Tab(1).ControlCount= 1
TabCaption(2) = "其它信息"
TabPicture(2) = "frmCheck1.frx":0038
Tab(2).ControlEnabled= 0 'False
Tab(2).Control(0)= "Frame6"
Tab(2).Control(1)= "Frame4"
Tab(2).ControlCount= 2
Begin VB.Frame Frame6
Caption = "备注"
Height = 1335
Left = -74520
TabIndex = 52
Top = 2520
Width = 5415
Begin VB.TextBox txtItem
Height = 855
Index = 17
Left = 480
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 20
Top = 360
Width = 4575
End
End
Begin VB.Frame Frame5
Caption = "调整工资"
Height = 855
Left = 480
TabIndex = 49
Top = 3240
Width = 5415
Begin VB.TextBox txtItem
Height = 270
Index = 15
Left = 3840
Locked = -1 'True
MaxLength = 8
TabIndex = 7
Top = 360
Width = 1335
End
Begin VB.TextBox txtItem
Height = 270
Index = 14
Left = 1200
Locked = -1 'True
MaxLength = 8
TabIndex = 6
Top = 360
Width = 1335
End
Begin VB.Label Label2
Caption = "扣 考 核:"
Height = 255
Index = 22
Left = 2880
TabIndex = 51
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "加 班 费:"
Height = 255
Index = 21
Left = 240
TabIndex = 50
Top = 360
Width = 975
End
End
Begin VB.Frame Frame4
Caption = "其它"
Height = 1455
Left = -74520
TabIndex = 48
Top = 720
Width = 5415
Begin VB.TextBox txtItem
Height = 855
Index = 16
Left = 360
Locked = -1 'True
MaxLength = 20
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 19
Top = 360
Width = 4695
End
Begin VB.Label Label2
Caption = "备 注:"
Height = 255
Index = 7
Left = 2400
TabIndex = 53
Top = 360
Width = 975
End
End
Begin VB.Frame Frame3
Caption = "实际出勤"
Height = 3495
Left = -74640
TabIndex = 36
Top = 600
Width = 5655
Begin VB.TextBox txtItem
Height = 270
Index = 3
Left = 1320
Locked = -1 'True
MaxLength = 2
TabIndex = 8
Top = 480
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 4
Left = 4080
Locked = -1 'True
MaxLength = 2
TabIndex = 9
Top = 480
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 5
Left = 1320
Locked = -1 'True
MaxLength = 2
TabIndex = 10
Top = 960
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 6
Left = 4080
Locked = -1 'True
MaxLength = 2
TabIndex = 11
Top = 960
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 7
Left = 1320
Locked = -1 'True
MaxLength = 2
TabIndex = 12
Top = 1440
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 8
Left = 4080
Locked = -1 'True
MaxLength = 2
TabIndex = 13
Top = 1440
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 9
Left = 1320
Locked = -1 'True
MaxLength = 2
TabIndex = 14
Top = 1920
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 10
Left = 4080
Locked = -1 'True
MaxLength = 2
TabIndex = 15
Top = 1920
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 11
Left = 1320
Locked = -1 'True
MaxLength = 2
TabIndex = 16
Top = 2400
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 12
Left = 4080
Locked = -1 'True
MaxLength = 2
TabIndex = 17
Top = 2400
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 13
Left = 1560
Locked = -1 'True
MaxLength = 2
TabIndex = 18
Top = 2880
Width = 3735
End
Begin VB.Label Label2
Caption = "出 勤:"
Height = 255
Index = 10
Left = 240
TabIndex = 47
Top = 480
Width = 975
End
Begin VB.Label Label2
Caption = "旷 工:"
Height = 255
Index = 11
Left = 3120
TabIndex = 46
Top = 480
Width = 975
End
Begin VB.Label Label2
Caption = "年 休:"
Height = 255
Index = 12
Left = 240
TabIndex = 45
Top = 960
Width = 975
End
Begin VB.Label Label2
Caption = "请 假:"
Height = 255
Index = 13
Left = 3120
TabIndex = 44
Top = 960
Width = 975
End
Begin VB.Label Label2
Caption = "迟 到:"
Height = 255
Index = 14
Left = 240
TabIndex = 43
Top = 1440
Width = 975
End
Begin VB.Label Label2
Caption = "早 退:"
Height = 255
Index = 15
Left = 3120
TabIndex = 42
Top = 1440
Width = 975
End
Begin VB.Label Label2
Caption = "忘 订 卡:"
Height = 255
Index = 16
Left = 240
TabIndex = 41
Top = 1920
Width = 975
End
Begin VB.Label Label2
Caption = "假日加班:"
Height = 255
Index = 17
Left = 3120
TabIndex = 40
Top = 1920
Width = 975
End
Begin VB.Label Label2
Caption = "其它加班:"
Height = 255
Index = 18
Left = 240
TabIndex = 39
Top = 2400
Width = 975
End
Begin VB.Label Label2
Caption = "补休天数:"
Height = 255
Index = 19
Left = 3120
TabIndex = 38
Top = 2400
Width = 975
End
Begin VB.Label Label2
Caption = "出差工地天数:"
Height = 255
Index = 20
Left = 240
TabIndex = 37
Top = 2880
Width = 1695
End
End
Begin VB.Frame Frame2
Caption = "本月基本信息"
Height = 1335
Left = 480
TabIndex = 28
Top = 1680
Width = 5415
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 4200
Locked = -1 'True
TabIndex = 29
TabStop = 0 'False
Top = 360
Width = 855
End
Begin VB.TextBox txtItem
Height = 270
Index = 1
Left = 1200
MaxLength = 2
TabIndex = 4
Top = 840
Width = 1695
End
Begin VB.TextBox txtItem
Height = 270
Index = 2
Left = 4200
MaxLength = 2
TabIndex = 5
Top = 840
Width = 855
End
Begin VB.ComboBox cboYear
Height = 300
Left = 1200
Style = 2 'Dropdown List
TabIndex = 2
Top = 360
Width = 735
End
Begin VB.ComboBox cboMonth
Height = 300
Left = 2280
Style = 2 'Dropdown List
TabIndex = 3
Top = 360
Width = 615
End
Begin VB.Label Label2
Caption = "考勤年月:"
Height = 255
Index = 2
Left = 240
TabIndex = 35
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "本月天数:"
Height = 255
Index = 3
Left = 3240
TabIndex = 34
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "公休天数:"
Height = 255
Index = 4
Left = 240
TabIndex = 33
Top = 840
Width = 975
End
Begin VB.Label Label2
Caption = "应出勤天数:"
Height = 255
Index = 5
Left = 3120
TabIndex = 32
Top = 840
Width = 1095
End
Begin VB.Label Label2
Caption = "年"
Height = 255
Index = 8
Left = 2040
TabIndex = 31
Top = 360
Width = 255
End
Begin VB.Label Label2
Caption = "月"
Height = 255
Index = 9
Left = 2880
TabIndex = 30
Top = 360
Width = 255
End
End
Begin VB.Frame Frame1
Caption = "员工信息"
Height = 855
Left = 480
TabIndex = 25
Top = 600
Width = 5415
Begin VB.ComboBox cboItem
Height = 288
Index = 0
Left = 960
Style = 2 'Dropdown List
TabIndex = 0
Top = 360
Width = 1695
End
Begin VB.ComboBox cboItem
Height = 288
Index = 1
Left = 3480
Style = 2 'Dropdown List
TabIndex = 1
Top = 360
Width = 1695
End
Begin VB.Label Label2
Caption = "部 门:"
Height = 255
Index = 0
Left = 240
TabIndex = 27
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "姓 名:"
Height = 255
Index = 1
Left = 2760
TabIndex = 26
Top = 360
Width = 975
End
End
End
Begin VB.TextBox txtId
Height = 270
Left = 1320
TabIndex = 23
TabStop = 0 'False
Top = 4920
Visible = 0 'False
Width = 735
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 5040
TabIndex = 22
Top = 4800
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 3480
TabIndex = 21
Top = 4800
Width = 1215
End
End
Attribute VB_Name = "frmCheck1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'是否改动过记录,ture为改过
Dim mblChange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String
Private Sub cboItem_Click(Index As Integer)
Dim sSql As String
Dim MsgText As String
If gintMode = 1 Then
'初始化员工名称和ID
txtSQL = "select ygid,ygname from manrecord where ygdept='" & Trim(cboItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If Index = 0 Then
cboItem(1).Clear
If Not mrc.EOF Then
With cboItem(1)
Do While Not mrc.EOF
.AddItem Trim(mrc!ygname)
mrc.MoveNext
Loop
.ListIndex = 0
End With
cmdSave.Enabled = True
Else
MsgBox "请先建立员工档案!", vbOKOnly + vbExclamation, "警告"
cmdSave.Enabled = False
Exit Sub
End If
ElseIf Index = 1 Then
mrc.MoveFirst
mrc.Move cboItem(1).ListIndex
txtId = Trim(mrc!ygid)
End If
End If
End Sub
Private Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
Private Sub cboMonth_Click()
Dim dateTemp As Date
dateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear), CInt(cboMonth), 1)))
txtItem(0) = Day(dateTemp)
End Sub
Private Sub cboYear_Click()
Dim dateTemp As Date
If Trim(cboMonth & " ") <> "" Then
dateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear), CInt(cboMonth), 1)))
txtItem(0) = Day(dateTemp)
End If
End Sub
Private Sub cmdExit_Click()
If mblChange And gintMode <> 3 And cmdSave.Enabled Then
If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
'保存
Call cmdSave_Click
End If
End If
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim recTemp As Recordset
Dim sSql As String
Dim MsgText As String
For intCount = 0 To 3
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "本月天数"
Case 2
sMeg = "应出勤天数"
Case 3
sMeg = "出勤"
End Select
If intCount <> 1 Then
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
End If
Next intCount
'添加判断是否有相同的ID记录
If gintMode = 1 Then
txtSQL = "select * from checkin where kqid='" & Trim(txtId) & "' and kqdate= '" & Format(cboYear.Text & "-" & cboMonth.Text & "-01", "yyyy-mm-dd") & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在该员工在该月的考勤记录!", vbOKOnly + vbExclamation, "警告"
cboMonth.SetFocus
Exit Sub
End If
mrc.Close
End If
'先删除已有记录
txtSQL = "delete from checkin where kqid='" & Trim(txtId) & "' and kqdate='" & Format(cboYear & "-" & cboMonth & "-01", "yyyy-mm-dd") & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新记录
txtSQL = "select * from checkin"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = Trim(txtId)
mrc.Fields(1) = Trim(cboItem(1))
mrc.Fields(2) = Format(cboYear & "-" & cboMonth & "-01", "yyyy-mm-dd")
For intCount = 0 To 15
mrc.Fields(intCount + 3) = Trim(txtItem(intCount).Text)
Next intCount
For intCount = 16 To 17
mrc.Fields(intCount + 3) = Trim(txtItem(intCount).Text)
Next intCount
mrc.Update
If gintMode = 1 Then
MsgBox "记录添加成功!", vbOKOnly + vbExclamation, "警告"
For intCount = 0 To 17
txtItem(intCount) = ""
Next intCount
mblChange = False
ElseIf gintMode = 2 Then
MsgBox "记录修改成功!", vbOKOnly + vbExclamation, "警告"
Unload Me
frmCheck.ShowTitle
frmCheck.ShowData
frmCheck.ZOrder 0
End If
gintMode = 0
End Sub
Private Sub Form_Load()
Dim intCount As Integer
Dim dateTemp As Date
Dim MsgText As String
cboYear.AddItem Year(Now)
cboYear.AddItem Year(Now) - 1
cboYear.ListIndex = 0
For intCount = 1 To 12
cboMonth.AddItem intCount
Next intCount
cboMonth = Month(Now)
If gintMode = 1 Then
Me.Caption = Me.Caption & "添加"
'初始化部门名称
txtSQL = "select DISTINCT ygdept from manrecord"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If Not mrc.EOF Then
Do While Not mrc.EOF
cboItem(0).AddItem Trim(mrc!ygdept)
mrc.MoveNext
Loop
cboItem(0).ListIndex = 0
Else
MsgBox "请先进行员工档案登记!", vbOKOnly + vbExclamation, "警告"
cmdSave.Enabled = False
Exit Sub
End If
'初始化本月天数
dateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear), CInt(cboMonth), 1)))
txtItem(0) = Day(dateTemp)
mrc.Close
ElseIf gintMode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
cboItem(1).AddItem .Fields(1)
cboItem(1).ListIndex = 0
For intCount = 2 To 19
If Not IsNull(.Fields(intCount)) Then
txtItem(intCount - 2) = .Fields(intCount)
End If
Next intCount
txtId = .Fields(0)
End With
End If
mrc.Close
txtSQL = "select ygdept from manrecord where ygname = '" & Trim(cboItem(1)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
cboItem(0).AddItem Trim(mrc!ygdept)
cboItem(0).ListIndex = 0
mrc.Close
Me.Caption = Me.Caption & "修改"
End If
mblChange = False
End Sub
Private Sub txtItem_Change(Index As Integer)
'有变化设置gblchange
mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
Private Function GetNo() As String
GetNo = Format(Now, "yymmddhhmmss")
Randomize
GetNo = GetNo & Int((99 - 10 + 1) * Rnd + 10)
End Function
Private Sub txtItem_KeyPress(Index As Integer, KeyAscii As Integer)
If Index >= 0 And Index <= 15 Then
'MsgBox KeyCode
'对键入字符进行控制
'txtQuantity(Index).Locked = False
'小数点只允许输入一次
If KeyAscii = 190 Then
If InStr(Trim(txtItem(Index)), ".") = 0 Then
If Len(Trim(txtItem(Index))) > 0 Then
txtItem(Index).Locked = False
Else
txtItem(Index).Locked = True
End If
Else
txtItem(Index).Locked = True
End If
Exit Sub
End If
'非数字不能输入
If KeyAscii > 57 Or KeyAscii < 48 Then
txtItem(Index).Locked = True
Else
txtItem(Index).Locked = False
End If
'允许Backspace
If KeyAscii = 8 Then
txtItem(Index).Locked = False
End If
'Delete键
If KeyAscii = 46 Then
txtItem(Index).Locked = False
End If
End If
End Sub