qiqi163 2016-12-27 06:32 采纳率: 0%
浏览 1084

求请大虾帮我看下感谢,是不是分页循环取数做错了,无法显示多天数据,感觉只取一个人第一条数据

设计思想从用户表取出用户到考勤表对应人员循环取数据出报表。
目前考勤日报表没有问题,可以显示当天数据,但想要显示多天数据报表时候,发现一问题,无法显示每个人多天的数据。 比如程序里我修改成显示所有人大于8号的数据,想显示结果是每个人从8号到现在的数据都列出来,可是感觉每个循环都只取了第一条数据一样,只显示当天的记录无法显示出几天的数据出来。如图:只能显示一天的数据。
![图片说明](https://img-ask.csdn.net/upload/201612/27/1482820799_899969.jpg)图片说明

  • 写回答

1条回答 默认 最新

  • qiqi163 2016-12-27 06:33
    关注

    <%

    dim username,date1,strAday,date2,date3,strPday,strtest
    dim deptlst,namelst
    dim strmnu
    strMnu="index.asp?mnu=searchday"
    username=Trim(Session("username"))
    if Request.form("txtdate")="" then
    date1=formatdatetime(now(),2)

    else
    date1=Request.form("txtdate")
    end if
    date2=split(date1,"-")
    date3=date2(0)&"/"&date2(1)&"/"&date2(2)
    'Response.Write date3
    redim deptlst(0)
    redim namelst(0)

    if Request.Form("sel_dept")<>"" then
    loaddept Request.Form("sel_dept")
    loadname Request.Form("sel_dept")
    'Response.Write(Request.Form("sel_dept"))
    else
    loaddept ""
    end if

    '载入部门列表
    sub loaddept(seldept)
    dim rs_user

    set rs_user=cn_user.execute("select * from dept order by dept_ID")
    if rs_user.eof then 
        deptlst(0)="<option value=''></option>"
        rs_user.close
        set rs_user=nothing
        exit sub
    end if
    do until rs_user.eof
        redim Preserve deptlst(UBound(deptlst)+1)
        if rs_user("Dept_name")=seldept then
            deptlst(UBound(deptlst))="<option value='" &  rs_user("Dept_name") & "' selected='selected'>" &  rs_user("Dept_name") & "</option>"
        else
            deptlst(UBound(deptlst))="<option value='" &  rs_user("Dept_name") & "'>" &  rs_user("Dept_name") & "</option>"
        end if
        rs_user.movenext
    loop
    set rs_user=nothing
    

    end sub

    sub loadname(deptname)
    dim rs_user

    if deptname="" then
        namelst(0)="<option value=''></option>"
        exit sub
    end if
    set rs_user=cn_user.execute("select * from userinfo where dept='" & deptname & "' order by U_ID")
    if rs_user.eof then 
        namelst(0)="<option value=''></option>"
        rs_user.close
        set rs_user=nothing
        exit sub
    end if
    do until rs_user.eof
        redim Preserve namelst(UBound(namelst)+1)
        namelst(UBound(namelst))="<option value='" &  rs_user("U_ID") & "'>" &  rs_user("T_name") & "</option>"
        rs_user.movenext
    loop
    set rs_user=nothing
    

    end sub

    '查询数据库各个资料库是否存在申请,并判断出查询结果
    function goSearch(strUID,theDate)
    '各种状态显示文字
    dim strGout
    dim strXJ,strZG,strCC,strWC,strYC,strDP
    strXJ="休假中"
    strZG="正常"
    strCC="出差中"
    strWC="外出中"
    strDP="待批"
    strYC="异常"
    strtest="ok"
    if getCustom(theDate,strArea) =1 then
    subdate=""
    strstatus=strXJ
    strH_datetxt=""
    strH_count=""
    strH_whys="法定假日"
    'viewresult
    exit function
    elseif getCustom(theDate,strArea) =2 then
    subdate=""
    strstatus=strXJ
    strH_datetxt=""
    strH_count=""
    strH_whys="公休日"
    'viewresult
    exit function
    end if
    '判断是否为出差
    strGout=getGout(thedate,strUID)
    if IsArray(strGout) then
    subdate=strGout(0)
    strstatus=strCC
    strH_datetxt=strGout(0)
    strH_count=""
    strH_whys=strGout(1)
    exit function
    end if
    '判断是否存在申请
    strGout=getHolyday(thedate,strUID)
    if IsArray(strGout) then
    subdate=strGout(2)
    if strGout(5)="未批准" then
    strstatus=strDP
    else
    if strGout(0)="外出" then
    strstatus=strWC
    else
    strstatus=strXJ
    end if
    end if
    strH_datetxt=strGout(3)
    strH_count=strGout(1)
    strH_whys=strGout(4)
    ' if ISNULL(strPday) then
    ' strstatus=strYC
    ' end if

                            'strAday=strGout(1)
            exit function
        'elseif ISNULL(strPday) or ISNULL(straday) then
        'strstatus=strYC
        else
    
            subdate=""
            strstatus=strZG
            strH_datetxt=""
            strH_count=""
            strH_whys=""
    
            exit function
    
        end if
    

    end function
    '查询系统中是否存在此用户,如有,则分配姓名,区域值给全局变量
    function getUser(strUID)
    dim rs_user
    set rs_user=cn_user.execute("select * from userinfo where U_ID='" & strUID & "'")

    if not rs_user.eof then
        strTName=rs_user("T_name")
        getUser=strTName
        strArea=rs_user("U_area")
    
    else
        getUser=""
    end if
    set rs_user=nothing
    

    end function

    '查询打卡记录
    'function getkq (date1)
    'dim rs_kq
    'set rs_kq=cn.execute("select * from kq where day=#" & date1 & "# and name='叶芸'")
    'if not rs_kq.eof then
    ' strAday=rs_kq("a_day")
    'getkq=strAday
    ' else
    ' getkq=""
    ' end if

    ' set rs_kq=nothing

    'end function

    '查询是否法定假日
    function getCustom(thedate,strArea)
    dim rs
    set rs=cn.execute("select * from customholyday where c_date=#" & thedate & "# and c_area='" & strArea & "'")
    if not rs.eof then
    getCustom=1
    else
    if weekday(thedate)=1 or weekday(thedate)=7 then
    getCustom=2
    else
    getCustom=0
    end if
    end if
    set rs=nothing

    end function

    '查询是否有出差通知
    function getGout(thedate,strUID)
    dim rs
    set rs=cn.execute("select * from gout where U_ID='" & strUID & "' and staday<=#" & thedate & "# and endday>=#" & thedate & "# ")
    if not rs.eof then
    dim strGet(1)
    strGet(0)=rs("staday") & " " & rs("selsta") & "-----" & rs("endday") & " " & rs("selend")
    strGet(1)=rs("G_body")
    getgout=strGet
    else
    getgout=0
    end if
    set rs=nothing

    end function

    function getHolyday(thedate,strUID)
    dim rs,strSql
    strSql="select * from H_all where U_ID='" & strUID & "' and M_date=#" & thedate & "# "
    set rs=cn.execute(strSql)
    if not rs.eof then
    dim strGet(6)
    strGet(0)=rs("h_type") '申请类型
    if rs("H_count")<1 then
    strGet(1)=formatnumber(rs("H_count"),1,-1) '申请天数
    else
    strGet(1)=rs("H_count")
    end if
    strGet(2)=rs("sub_date") '申请日期
    strGet(3)=rs("h_datetxt") '时间段
    strGet(4)=rs("h_whys") '内容
    strGet(5)=rs("h_status")
    'strGet(6)=rs("r_name") '批准状态
    getHolyday=strGet
    else
    getHolyday=""
    end if
    set rs=nothing
    'Response.Write strTName
    'Dim nameArr,i
    'nameArr = Array(strTName)
    'For I = Lbound(nameArr)+1 to Ubound(nameArr)
    'Response.Write nameArr(i)
    ' Next
    'strTName=strTName+"1"

    end function

    %>

    <!-- .search_title { font-family: "宋体"; font-size: 9pt; } .search {font-size: 12pt; color: #0000CC; font-weight: bold; } .searchdo { font-family: "宋体"; font-size: 9pt; } .STYLE1 {color: #FF0000} -->

    日期

    部门
      姓名

    <%

    if request.Querystring("dept")<>"" then
    viewresult "select * from userinfo where dept='" & request.Form("sel_dept") & "'" ,Request.Form("txtDate")
    elseif request.Querystring("UID")<>"" then
    viewresult "select * from userinfo where U_ID='" & request.Form("sel_UID") & "'" ,Request.Form("txtDate")
    end if

    dim theDate,strTName,theDay,strUID,strAll,subdate,strstatus,strH_count,strH_whys,strH_datetxt,strArea
    sub viewresult(strSql,theDate)

    %>










    <%
    dim strLink,strSqlDept,strlinkDept
    dim rs,lngPagesize,strPages,iPage,strPage,lngPage
    set rs=Server.CreateObject("ADODB.Recordset")
    'Response.Write(strSql)
    rs.open strSql,cn_user,3
    
    
       dim strnew,the2Date,x
       strnew=split(thedate,"-")
       'for x=0 to Ubound(strnew)
    

    ' if cint(strnew(x))<10 then
    ' strnew(x)="0"&strnew(x)
    ' end if
    ' next
    ' the2Date=strnew(0)&"-"&strnew(1)&"-"&strnew(2)
    strnew(2)=cstr(cint(strnew(2))+1)
    the2Date=strnew(0)&"-"&strnew(1)&"-"&strnew(2)

    '=====================att===1============================
    dim att,rs_att,strSql2
    Set att= Server.CreateObject("ADODB.Connection")
    strCn="Provider=sqloledb;Network Library=DBMSSOCN;Data Source=10.16.217.222;Initial Catalog=zksys;User Id=sa;Password=csclszhk147159;"
    att.open strCn
    set rs_att=Server.CreateObject("ADODB.Recordset")
    'strSql2="select * from view_getatt_users where Name='"&rs("T_name")&"' and Date>'"&theDate&"' and Date<'"&the2Date&"' order by Date"
    strSql2="select * from view_getatt_users where Name='"&rs("T_name")&"' and CONVERT(varchar(10) , Date, 120 )='"&theDate&"' order by Date"
    'strSql2="select * from view_getatt_users where Name='于君' and CONVERT(varchar(10) , Date, 120 )='2010-08-06'"
    rs_att.open strSql2,att,3
    
    
    if rs.eof=false then
        '分页显示
        rs.Pagesize=200
        strPage =trim(Request.QueryString("iPage"))
        strLinkDept="dept=" & Request.Form("sel_dept")
        strmnu=strmnu & "&" & strLinkDept
        strLink="<a href='#' onclick=""pgdn('" & strMnu & "&iPage="
        if strPage<>"" then lngPage=cint(strPage) else lngPage=1
        If lngPage > rs.PageCount Then lngPage = rs.PageCount 
        If lngPage<> 1 Then
            strPages=strPages & strLink & (lngPage-1) & "')"">" & "上一页</A>  "
        End If
    
        for iPage=1 to rs.pagecount
            if iPage<>lngPage then
                strPages=strPages & strLink & iPage & "')"">" & iPage & "</a>    "
            else
                strPages=strPages & "<font color='#C0C0C0'>" & iPage & "    </font>"
            end if
        next
        If lngPage<> rs.PageCount Then 
            strPages=strPages &  strLink & (lngPage+1) & "')"">"  & "下一页</A>" 
        End If 
        strPages=strPages &  "(" & lngPage & "/" & rs.PageCount & ")"    
        '循环显示每条记录 
        rs.AbsolutePage = lngPage '把页码赋给absolutepage属性从而知当前页的首条记录号 
    end if
    
    
    
    
    
    dim strTR,I
    if not rs.eof then 
    For iPage = 1 To rs.PageSize
        I=I+1
        'strLink="<a href='index.asp?mnu=edituser&opt=edit&id=" & Server.URLEncode(rs("ID")) & "'>" 
    

    ' strID=rs("ID")
    goSearch rs("U_ID"),theDate
    ' strU_ID=rs("U_id")
    strTName= rs("T_name")

    dim mystr,aa
    mystr=replace(strH_datetxt,"
    ","")
    'if strH_datetxt<>"" then
    'mystr=strH_datetxt
    'mystr=split(strH_datetxt,"
    ")
    'for i=0 to ubound(mystr)

    'next
    'aa=mystr(i)
    'else
    'aa=""
    'end if

        dim rs1,strSql1 
    strSql1=("select * from kq where day1=#"&date3&"#  and name='"&strTName&"'")
    set rs1=cn.execute(strSql1)
    if not rs1.eof then
    strAday=rs1("aday")
    strPday=rs1("Pday")
    else
    strAday=""
    strPday=""
    end if
    if strAday="" then 
    strAday="无打卡"
    end if
    if strPday="" then 
    strPday="无打卡"
    end if
    if isnull(strAday) then 
    strAday="无打卡"
    end if
    if isnull(strPday) then 
    strPday="无打卡"
    end if
    set rs1=nothing
    
    'Response.Write strSql1
    
             '& "</a>"
            'Response.Write(strTName&"1")
    
    
    
    
    
    
    
    
    
    
    
            subdate=theDate
    

    ' strUsertype=strLink & trim(rs("U_type")) & ""
    ' strDept=trim(rs("dept"))
    ' strjob=trim(rs("job"))
    ' strAuth=getUserNameT(rs("Auth1"))
    ' strAuth2=getUserNameT(rs("Auth2"))
    ' strEmail=trim(rs("email"))
    ' if Len(strEmail)>20 then
    ' strEmail=left(strEmail,17) & "..."
    ' end if
    ' strEmail=strLink & strEmail & ""
    ' strEdit=strLink & "More."
    dim strhcount
    ' if ccur(strH_count)< 1 then
    ' strHcount="0" & cstr(strH_count)
    ' else
    ' strHcount=cstr(strH_count)
    ' end if
    ' Response.write typename(strH_count) & cstr((strH_count))
    if I mod 2 =0 then
    strTR="onmouseover=""this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='" & LINEACTCOLOR & "';""" & _
    "onmouseout=""this.style.backgroundColor=this.oldcolor;"" style=""background-color:"& LINECOLOR2 & ";height:22px;"""
    else
    strTR="onmouseover=""this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='" & LINEACTCOLOR & "';""" & _
    "onmouseout=""this.style.backgroundColor=this.oldcolor;"" style=""background-color:"& LINECOLOR1 & ";height:22px;"""
    end if
    %>

    >







    <%
    rs.movenext
    If rs.EOF Then Exit For
    next
    rs.close
    set rs=nothing
    rs_att.close
    set rs_att=nothing
    else
    %>



    <%end if%>

    姓名
    日期
    状态
    时间段
    天数
    打卡情况
    <%=strTname%>
    <%=subdate%>



    <% if strH_datetxt="" or isnull(strH_datetxt) then%>
    <%if strAday="无打卡" or strPday="无打卡" then%>
    异常
    <%else%>
    <%=strstatus%>
    <% end if %>
    <%else%>
    <%=strstatus%>
    <% end if %>


    <%=mystr%>

    <%=strH_count%>
    <%' if isnull(strAday) then%><%'else%><%=strAday%><%' end if %>
    <%' if isnull(strPday) then%><%'else%><%=strPday%><%' end if %>
    没有找到用户
    function submit1() { // if(checkdate()) // { document.form1.action="index.asp?mnu=searchdo1"; document.form1.submit(); // } } function checkdate() { var timeValue=document.form1.txtdate.value var inputdate=new Date(Date.parse(timeValue.replace(/-/g, "/"))); var today = new Date(); inputdate.setDate(inputdate.getDate()+1); if (inputdate>today) { return true; } else { alert("输入日期已过期!"); return false; timeValue.focus(); } } function submit2() { // document.form1.action="index.asp?mnu=searchday"; // document.form1.submit(); document.form1.action="index.asp?mnu=searchday&dept="+document.form1.sel_dept.value; document.form1.submit(); } function submit3() { document.form1.action="index.asp?mnu=searchday&UID="+document.form1.sel_UID.value; document.form1.submit(); } function pgdn(strmnu) { document.form1.action=strmnu; document.form1.submit(); }
    评论

报告相同问题?

悬赏问题

  • ¥50 comsol稳态求解器 找不到解,奇异矩阵有1个空方程返回的解不收敛。没有返回所有参数步长;pid控制
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功