Private Sub cmdOK_Click()
Dim rstData As ADODB.Recordset
Dim resultm As String
Dim i As Integer
If OptCheck.Value = True Then
strFlag = "1"
Else
If Me.OptOver.Value = True Then
strFlag = "2"
Else
strFlag = "3"
End If
End If
Select Case strFlag
Case "1"
txtsql = "select RecordYear as ¿¼ÇÚÄê·Ý,RecordMonth as ¿¼ÇÚÔ·Ý,EmpName as Ö°Ô±ÐÕÃû,"
txtsql = txtsql + " DepName as ËùÔÚ²¿ÃÅ,DaysPresiMonth as µ±ÔÂÈ«ÇÚÌìÊý, "
txtsql = txtsql + " AbsentDays as δ³öÇÚÌìÊý, LateDays as ³Ùµ½ÌìÊý,"
txtsql = txtsql + " LeaveEarlyDays as ÔçÍËÌìÊý,Hours as Àۼƹ¤×÷Сʱ "
txtsql = txtsql + " from tbWorkRecord,(tbEmployee left join tbDep on tbEmployee.DepId=tbDep.DepId) "
txtsql = txtsql + " where tbEmployee.EmpId=tbWorkRecord.EmpId "
Case "2"
txtsql = "select RecordYear as ¿¼ÇÚÄê·Ý,RecordMonth as ¿¼ÇÚÔ·Ý,EmpName as Ö°Ô±ÐÕÃû,"
txtsql = txtsql + " DepName as ËùÔÚ²¿ÃÅ,OverKindName as ¼Ó°àÀàÐÍ, "
txtsql = txtsql + " Hours as ¼Ó°à¹¤×÷Сʱ "
txtsql = txtsql + " from tbOverRecord,(tbEmployee left join tbDep on tbEmployee.DepId=tbDep.DepId),tbOverKind "
txtsql = txtsql + " where tbEmployee.EmpId=tbOverRecord.EmpId "
txtsql = txtsql + " and tbOverKind.OverKindId=tbOverRecord.OverKindId "
Case "3"
txtsql = "select RecordYear as ¿¼ÇÚÄê·Ý,RecordMonth as ¿¼ÇÚÔ·Ý,EmpName as Ö°Ô±ÐÕÃû,"
txtsql = txtsql + " DepName as ËùÔÚ²¿ÃÅ,LeaveKindName as Çë¼ÙÀàÐÍ, "
txtsql = txtsql + " LeaveDays as Çë¼ÙÀÛ¼ÆÌìÊý "
txtsql = txtsql + " from tbLeaveRecord,(tbEmployee left join tbDep on tbEmployee.DepId=tbDep.DepId),tbLeaveKind "
txtsql = txtsql + " where tbEmployee.EmpId=tbLeaveRecord.EmpId "
txtsql = txtsql + " and tbLeaveKind.LeaveKindId=tbLeaveRecord.LeaveKindId "
End Select
If cboYear.Text <> "" Then
txtsql = txtsql + " and RecordYear = '" + cboYear.Text + "'"
End If
If cboMonth.Text <> "" Then
txtsql = txtsql + " and RecordMonth = '" + cboMonth.Text + "'"
End If
If cboDep.Text <> "" Then
Call getcboDepId
If Mid(strDepId, 3, 4) = "0000" Then
txtsql = txtsql + " and substring(DepId,1,2) = '" + Mid(strDepId, 1, 2) + "'"
Else
If Mid(strDepId, 5, 2) = "00" Then
txtsql = txtsql + " and substring(DepId,1,4) = '" + Mid(strDepId, 1, 4) + "'"
Else
txtsql = txtsql + " and DepId = '" + strDepId + "'"
End If
End If
End If
txtsql = txtsql + " order by RecordYear,RecordMonth"
'¼ìË÷ÐèÒªµÄÐÅÏ¢
result = ExecuteSQL(txtsql, rstData, False)
If rstData.RecordCount <> 0 Then
With MSFStatic
.WordWrap = True
.Rows = 2
.Cols = rstData.Fields.Count + 1
Select Case strFlag
Case 1
.CellAlignment = 4
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "¿¼ÇÚÄê·Ý"
.TextMatrix(0, 2) = "¿¼ÇÚÔ·Ý"
.TextMatrix(0, 3) = "Ö°Ô±ÐÕÃû"
.TextMatrix(0, 4) = "ËùÔÚ²¿ÃÅ"
.TextMatrix(0, 5) = "µ±ÔÂÈ«ÇÚÌìÊý"
.TextMatrix(0, 6) = "δ³öÇÚÌìÊý"
.TextMatrix(0, 7) = "³Ùµ½ÌìÊý "
.TextMatrix(0, 8) = "ÔçÍËÌìÊý "
.TextMatrix(0, 9) = "Àۼƹ¤×÷Сʱ "
i = 0
Do While Not rstData.EOF
.Rows = .Rows + 1
i = i + 1
.CellAlignment = 4
.TextMatrix(.Rows - 2, 0) = CStr(i)
.TextMatrix(.Rows - 2, 1) = _
IIf(IsNull(rstData.Fields(0)), "0", rstData.Fields(0))
.TextMatrix(.Rows - 2, 2) = IIf(IsNull(rstData.Fields(1)), "0", rstData.Fields(1))
.TextMatrix(.Rows - 2, 3) = IIf(IsNull(rstData.Fields(2)), "0", rstData.Fields(2))
.TextMatrix(.Rows - 2, 4) = IIf(IsNull(rstData.Fields(3)), "0", rstData.Fields(3))
.TextMatrix(.Rows - 2, 5) = IIf(IsNull(rstData.Fields(4)), "0", rstData.Fields(4))
.TextMatrix(.Rows - 2, 6) = IIf(IsNull(rstData.Fields(5)), "0", rstData.Fields(5))
.TextMatrix(.Rows - 2, 7) = IIf(IsNull(rstData.Fields(6)), "0", rstData.Fields(6))
.TextMatrix(.Rows - 2, 8) = IIf(IsNull(rstData.Fields(7)), "0", rstData.Fields(7))
.TextMatrix(.Rows - 2, 9) = IIf(IsNull(rstData.Fields(8)), "0", rstData.Fields(8))
rstData.MoveNext
Loop
Case 2
.CellAlignment = 4
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "¿¼ÇÚÄê·Ý"
.TextMatrix(0, 2) = "¿¼ÇÚÔ·Ý"
.TextMatrix(0, 3) = "Ö°Ô±ÐÕÃû"
.TextMatrix(0, 4) = "ËùÔÚ²¿ÃÅ"
.TextMatrix(0, 5) = "¼Ó°àÀàÐÍ"
.TextMatrix(0, 6) = "¼Ó°à¹¤×÷Сʱ"
i = 0
Do While Not rstData.EOF
.Rows = .Rows + 1
i = i + 1
.CellAlignment = 4
.TextMatrix(.Rows - 2, 0) = CStr(i)
.TextMatrix(.Rows - 2, 1) = IIf(IsNull(rstData.Fields(0)), "0", rstData.Fields(0))
.TextMatrix(.Rows - 2, 2) = IIf(IsNull(rstData.Fields(1)), "0", rstData.Fields(1))
.TextMatrix(.Rows - 2, 3) = IIf(IsNull(rstData.Fields(2)), "0", rstData.Fields(2))
.TextMatrix(.Rows - 2, 4) = IIf(IsNull(rstData.Fields(3)), "0", rstData.Fields(3))
.TextMatrix(.Rows - 2, 5) = IIf(IsNull(rstData.Fields(4)), "0", rstData.Fields(4))
.TextMatrix(.Rows - 2, 6) = IIf(IsNull(rstData.Fields(5)), "0", rstData.Fields(5))
rstData.MoveNext
Loop
Case 3
.CellAlignment = 4
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "¿¼ÇÚÄê·Ý"
.TextMatrix(0, 2) = "¿¼ÇÚÔ·Ý"
.TextMatrix(0, 3) = "Ö°Ô±ÐÕÃû"
.TextMatrix(0, 4) = "ËùÔÚ²¿ÃÅ"
.TextMatrix(0, 5) = "Çë¼ÙÀàÐÍ"
.TextMatrix(0, 6) = "Çë¼ÙÀÛ¼ÆÌìÊý "
i = 0
Do While Not rstData.EOF
.Rows = .Rows + 1
i = i + 1
.CellAlignment = 4
.TextMatrix(.Rows - 2, 0) = CStr(i)
.TextMatrix(.Rows - 2, 1) = IIf(IsNull(rstData.Fields(0)), "0", rstData.Fields(0))
.TextMatrix(.Rows - 2, 2) = IIf(IsNull(rstData.Fields(1)), "0", rstData.Fields(1))
.TextMatrix(.Rows - 2, 3) = IIf(IsNull(rstData.Fields(2)), "0", rstData.Fields(2))
.TextMatrix(.Rows - 2, 4) = IIf(IsNull(rstData.Fields(3)), "0", rstData.Fields(3))
.TextMatrix(.Rows - 2, 5) = IIf(IsNull(rstData.Fields(4)), "0", rstData.Fields(4))
.TextMatrix(.Rows - 2, 6) = IIf(IsNull(rstData.Fields(5)), "0", rstData.Fields(5))
rstData.MoveNext
Loop
End Select
cmdPrint.Enabled = True
End With
Else
MsgBox "»¹Ã»ÓÐÊý¾Ý£¡", vbOKOnly + vbExclamation, "¾¯¸æ"
End If
End Sub
Dim rstData As ADODB.Recordset
Dim resultm As String
Dim i As Integer
If OptCheck.Value = True Then
strFlag = "1"
Else
If Me.OptOver.Value = True Then
strFlag = "2"
Else
strFlag = "3"
End If
End If
Select Case strFlag
Case "1"
txtsql = "select RecordYear as ¿¼ÇÚÄê·Ý,RecordMonth as ¿¼ÇÚÔ·Ý,EmpName as Ö°Ô±ÐÕÃû,"
txtsql = txtsql + " DepName as ËùÔÚ²¿ÃÅ,DaysPresiMonth as µ±ÔÂÈ«ÇÚÌìÊý, "
txtsql = txtsql + " AbsentDays as δ³öÇÚÌìÊý, LateDays as ³Ùµ½ÌìÊý,"
txtsql = txtsql + " LeaveEarlyDays as ÔçÍËÌìÊý,Hours as Àۼƹ¤×÷Сʱ "
txtsql = txtsql + " from tbWorkRecord,(tbEmployee left join tbDep on tbEmployee.DepId=tbDep.DepId) "
txtsql = txtsql + " where tbEmployee.EmpId=tbWorkRecord.EmpId "
Case "2"
txtsql = "select RecordYear as ¿¼ÇÚÄê·Ý,RecordMonth as ¿¼ÇÚÔ·Ý,EmpName as Ö°Ô±ÐÕÃû,"
txtsql = txtsql + " DepName as ËùÔÚ²¿ÃÅ,OverKindName as ¼Ó°àÀàÐÍ, "
txtsql = txtsql + " Hours as ¼Ó°à¹¤×÷Сʱ "
txtsql = txtsql + " from tbOverRecord,(tbEmployee left join tbDep on tbEmployee.DepId=tbDep.DepId),tbOverKind "
txtsql = txtsql + " where tbEmployee.EmpId=tbOverRecord.EmpId "
txtsql = txtsql + " and tbOverKind.OverKindId=tbOverRecord.OverKindId "
Case "3"
txtsql = "select RecordYear as ¿¼ÇÚÄê·Ý,RecordMonth as ¿¼ÇÚÔ·Ý,EmpName as Ö°Ô±ÐÕÃû,"
txtsql = txtsql + " DepName as ËùÔÚ²¿ÃÅ,LeaveKindName as Çë¼ÙÀàÐÍ, "
txtsql = txtsql + " LeaveDays as Çë¼ÙÀÛ¼ÆÌìÊý "
txtsql = txtsql + " from tbLeaveRecord,(tbEmployee left join tbDep on tbEmployee.DepId=tbDep.DepId),tbLeaveKind "
txtsql = txtsql + " where tbEmployee.EmpId=tbLeaveRecord.EmpId "
txtsql = txtsql + " and tbLeaveKind.LeaveKindId=tbLeaveRecord.LeaveKindId "
End Select
If cboYear.Text <> "" Then
txtsql = txtsql + " and RecordYear = '" + cboYear.Text + "'"
End If
If cboMonth.Text <> "" Then
txtsql = txtsql + " and RecordMonth = '" + cboMonth.Text + "'"
End If
If cboDep.Text <> "" Then
Call getcboDepId
If Mid(strDepId, 3, 4) = "0000" Then
txtsql = txtsql + " and substring(DepId,1,2) = '" + Mid(strDepId, 1, 2) + "'"
Else
If Mid(strDepId, 5, 2) = "00" Then
txtsql = txtsql + " and substring(DepId,1,4) = '" + Mid(strDepId, 1, 4) + "'"
Else
txtsql = txtsql + " and DepId = '" + strDepId + "'"
End If
End If
End If
txtsql = txtsql + " order by RecordYear,RecordMonth"
'¼ìË÷ÐèÒªµÄÐÅÏ¢
result = ExecuteSQL(txtsql, rstData, False)
If rstData.RecordCount <> 0 Then
With MSFStatic
.WordWrap = True
.Rows = 2
.Cols = rstData.Fields.Count + 1
Select Case strFlag
Case 1
.CellAlignment = 4
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "¿¼ÇÚÄê·Ý"
.TextMatrix(0, 2) = "¿¼ÇÚÔ·Ý"
.TextMatrix(0, 3) = "Ö°Ô±ÐÕÃû"
.TextMatrix(0, 4) = "ËùÔÚ²¿ÃÅ"
.TextMatrix(0, 5) = "µ±ÔÂÈ«ÇÚÌìÊý"
.TextMatrix(0, 6) = "δ³öÇÚÌìÊý"
.TextMatrix(0, 7) = "³Ùµ½ÌìÊý "
.TextMatrix(0, 8) = "ÔçÍËÌìÊý "
.TextMatrix(0, 9) = "Àۼƹ¤×÷Сʱ "
i = 0
Do While Not rstData.EOF
.Rows = .Rows + 1
i = i + 1
.CellAlignment = 4
.TextMatrix(.Rows - 2, 0) = CStr(i)
.TextMatrix(.Rows - 2, 1) = _
IIf(IsNull(rstData.Fields(0)), "0", rstData.Fields(0))
.TextMatrix(.Rows - 2, 2) = IIf(IsNull(rstData.Fields(1)), "0", rstData.Fields(1))
.TextMatrix(.Rows - 2, 3) = IIf(IsNull(rstData.Fields(2)), "0", rstData.Fields(2))
.TextMatrix(.Rows - 2, 4) = IIf(IsNull(rstData.Fields(3)), "0", rstData.Fields(3))
.TextMatrix(.Rows - 2, 5) = IIf(IsNull(rstData.Fields(4)), "0", rstData.Fields(4))
.TextMatrix(.Rows - 2, 6) = IIf(IsNull(rstData.Fields(5)), "0", rstData.Fields(5))
.TextMatrix(.Rows - 2, 7) = IIf(IsNull(rstData.Fields(6)), "0", rstData.Fields(6))
.TextMatrix(.Rows - 2, 8) = IIf(IsNull(rstData.Fields(7)), "0", rstData.Fields(7))
.TextMatrix(.Rows - 2, 9) = IIf(IsNull(rstData.Fields(8)), "0", rstData.Fields(8))
rstData.MoveNext
Loop
Case 2
.CellAlignment = 4
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "¿¼ÇÚÄê·Ý"
.TextMatrix(0, 2) = "¿¼ÇÚÔ·Ý"
.TextMatrix(0, 3) = "Ö°Ô±ÐÕÃû"
.TextMatrix(0, 4) = "ËùÔÚ²¿ÃÅ"
.TextMatrix(0, 5) = "¼Ó°àÀàÐÍ"
.TextMatrix(0, 6) = "¼Ó°à¹¤×÷Сʱ"
i = 0
Do While Not rstData.EOF
.Rows = .Rows + 1
i = i + 1
.CellAlignment = 4
.TextMatrix(.Rows - 2, 0) = CStr(i)
.TextMatrix(.Rows - 2, 1) = IIf(IsNull(rstData.Fields(0)), "0", rstData.Fields(0))
.TextMatrix(.Rows - 2, 2) = IIf(IsNull(rstData.Fields(1)), "0", rstData.Fields(1))
.TextMatrix(.Rows - 2, 3) = IIf(IsNull(rstData.Fields(2)), "0", rstData.Fields(2))
.TextMatrix(.Rows - 2, 4) = IIf(IsNull(rstData.Fields(3)), "0", rstData.Fields(3))
.TextMatrix(.Rows - 2, 5) = IIf(IsNull(rstData.Fields(4)), "0", rstData.Fields(4))
.TextMatrix(.Rows - 2, 6) = IIf(IsNull(rstData.Fields(5)), "0", rstData.Fields(5))
rstData.MoveNext
Loop
Case 3
.CellAlignment = 4
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "¿¼ÇÚÄê·Ý"
.TextMatrix(0, 2) = "¿¼ÇÚÔ·Ý"
.TextMatrix(0, 3) = "Ö°Ô±ÐÕÃû"
.TextMatrix(0, 4) = "ËùÔÚ²¿ÃÅ"
.TextMatrix(0, 5) = "Çë¼ÙÀàÐÍ"
.TextMatrix(0, 6) = "Çë¼ÙÀÛ¼ÆÌìÊý "
i = 0
Do While Not rstData.EOF
.Rows = .Rows + 1
i = i + 1
.CellAlignment = 4
.TextMatrix(.Rows - 2, 0) = CStr(i)
.TextMatrix(.Rows - 2, 1) = IIf(IsNull(rstData.Fields(0)), "0", rstData.Fields(0))
.TextMatrix(.Rows - 2, 2) = IIf(IsNull(rstData.Fields(1)), "0", rstData.Fields(1))
.TextMatrix(.Rows - 2, 3) = IIf(IsNull(rstData.Fields(2)), "0", rstData.Fields(2))
.TextMatrix(.Rows - 2, 4) = IIf(IsNull(rstData.Fields(3)), "0", rstData.Fields(3))
.TextMatrix(.Rows - 2, 5) = IIf(IsNull(rstData.Fields(4)), "0", rstData.Fields(4))
.TextMatrix(.Rows - 2, 6) = IIf(IsNull(rstData.Fields(5)), "0", rstData.Fields(5))
rstData.MoveNext
Loop
End Select
cmdPrint.Enabled = True
End With
Else
MsgBox "»¹Ã»ÓÐÊý¾Ý£¡", vbOKOnly + vbExclamation, "¾¯¸æ"
End If
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货