pageLen = 99 'กำหนดจำนวนแต่ละหน้าที่ต้องการแสดงกี่ Reccord
pageNo = request.QueryString("pageNo")
if pageNo="" then pageNo = 1
IF Trim(Request.QueryString("WorkID")) <> "" Then
strCondition = " and a.WorkID = "&Trim(Request.QueryString("WorkID")) &" "
End IF
strConditionSearch = " and Month(StartDate) >= "&Request.QueryString("FromMM")&" and Year(StartDate) >= "&Request.QueryString("FromYY")&" and Month(StartDate) <= "&Request.QueryString("ToMM")&" and Year(StartDate) <= "&Request.QueryString("ToYY")&" "
strStatusID = " and StatusID IN ("&Request.QueryString("StatusID") &") "
strSectionID = " and SectionID = ("&Request.QueryString("SectionID")&" ) "
Sql ="SELECT * FROM Work where 1=1 "&strCondition&" "&strStatusID&" "&strConditionSearch&" and OfficerID IN (Select OfficerID from Officer where DivisionID = "&RsAdmin.Fields("DivisionID").Value&" "&strSectionID&" ) order by StartDate asc"
Set RS =Server.CreateObject("ADODB.Recordset")
RS.open Sql,Conn,1,3
if NOT Rs.EOF Then
Nrecord=RS.recordcount
rs.pageSize = pageLen
totalPage = rs.PageCount
rs.absolutePage = pageNo
recNo=1
'*** แสดงข้อมูลทุก Record ที่อยู่ในช่วง Page ***'
Do While Not RS.EOF and recNo <= pageLen
k = k +1
%> [/color] <tr bgcolor="#CCFF99">
<td width="20" height="38" align="center" valign="middle" bgcolor="#FFFFFF"><div align="center"><img src="images/bit2.gif" width="11" height="11"></div></td>
<td width="231" align="left" valign="middle" bgcolor="#FFFFFF"><div align="left"><a href="officer_check_work-00mg.asp?WorkID=<%=Rs.Fields("WorkID").Value%>"style="text-decoration:none;"><%=Rs.Fields("WorkName").Value%></a></div></td>
<td align="left" valign="middle" bgcolor="#FFFFFF"><div align="center"><%=Rs.Fields("StartDate").Value%></div></td>
<%
Sql1 ="SELECT * FROM History WHERE (WorkID = " & Rs.Fields("WorkID").Value & ") ORDER BY HistoryID DESC"
set Rs1=conn.Execute(Sql1)
%>
<td align="left" valign="middle" bgcolor="#FFFFFF"><div align="center"><%=Rs1.Fields("LastDay").Value%></div></td>
<td align="left" valign="middle" bgcolor="#FFFFFF"><div align="center">-</div></td>
<td align="left" valign="middle" bgcolor="#FFFFFF"><div align="center">-</div></td>
<td valign="middle" bgcolor="#FFFFFF"><div align="center"><%=Rs1.Fields("LastDay").Value - Rs.Fields("StartDate").Value%><br>
</div></td>
<td bgcolor="#FFFFFF"><div align="center">-</div></td>
<td bgcolor="#FFFFFF"><div align="center">
<%
Dim i
'*** เลือกสถานะ ผู้จัดการ ***'
Sql2_0 ="Select * From WorkTeam where WorkID="&Rs.Fields("WorkID").Value&" and TeamID = 0"
Set Rs2_0 = Conn.Execute(Sql2_0)
IF NOT Rs2_0.EOF Then
Response.write(" ผู้จัดการ<BR>")
End IF
Sql2 ="Select * From Team a,WorkTeam b,Section c where 1=1 and a.SectionID = c.SectionID and a.TeamID=b.TeamID and b.WorkID = "&Rs.Fields("WorkID").Value&" order by a.TeamID asc"
Set Rs2 = Conn.Execute(Sql2)
IF NOT Rs2.EOF Then
Rs2.MoveFirst
While NOT Rs2.EOF
i = i + 1
SqlStatus ="Select * From WorkTeam where WorkID="&Rs.Fields("WorkID").Value&" and TeamID = "&Rs2.Fields("TeamID").Value&" "
Set RsStatus = Conn.Execute(SqlStatus)
%>
<%=Rs2.Fields("TeamName").Value%>
<%
Rs2.MoveNext
Wend
End IF
%>
</div></td>
</tr>
<%
' วนลูปแสดงข้อมูล
recNo=recNo+1
RS.MoveNext
Loop
rs.close
end if
%>