asp导出excel

<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
server.ScriptTimeout=50000
session.Timeout=180
%>
<!--#include file="../../conn/conn.asp"-->
<!--#include file="../psw.asp"-->
<!--#include file="../checkpower.asp"-->
<!--#include file="../../functions/dofunction.asp"-->
<!--#include file="../../functions/showfunction.asp"-->
<%
if session("a_power")="888" and session("a_website")>0 then    content=content&" and website="&session("a_website")&""
'查询条件
username=checkstr(request("username"),2)
userinfo=checkstr(request("userinfo"),2)
ordernum=checkstr(request("ordernum"),2)
lesson_up=checkstr(request("lesson_up"),1)
lesson_id=checkstr(request("lesson_id"),1)
classnum=checkstr(request("classnum"),1)
lessontype=checkstr(request("lessontype"),1)
isinclude=checkstr(request("isinclude"),1)
fromsite=checkstr(request("fromsite"),2)
web_id=checkstr(request("web_id"),2)
alldate=checkstr(request("alldate"),1)
syear=checkstr(request("syear"),1)
smonth=checkstr(request("smonth"),1)
sday=checkstr(request("sday"),1)
eyear=checkstr(request("eyear"),1)
emonth=checkstr(request("emonth"),1)
eday=checkstr(request("eday"),1)
cataid=checkstr(request("cataid"),1)
admin_id=checkstr(request("admin_id"),1)
opentype=checkstr(request("opentype"),1)
paytype=2
discount_type=checkstr(request("discount_type"),1)
content=""
myfilter=" (Privilege_id>0 or (discount_type>0 and Privilege_id=0)) and "
'myfilterlink=" a.Privilege_id>0 or (a.discount_type>0 and a.Privilege_id=0) and "
if username<>"" then content=content&" and student_id=(select top 1 id from edu_userinfo where username='"&username&"')"
if discount_type<>"" and discount_type<>"0" then content=content&" and  discount_type='"&discount_type&"'"

if userinfo<>"" then content=content&" and student_id in (select user_id from edu_userpersonal where name='"&userinfo&"' or tel='"&userinfo&"' or email='"&userinfo&"')"

if ordernum<>"" then content=content&" and order_code='"&ordernum&"'"

if lesson_up>0 and lesson_id=0 then
    content=content&" and ORDER_ID in (select ORDER_ID from HQFS_SELECT_LESSON_DETAIL where lesson_id in (select lesson_id from lessonset where cataid=1 and type=2 and show=1 and isdel=0 and up_id="&lesson_up&"))"
end if

if lesson_id>0 then
    if classnum>0 then
        content=content&" and ORDER_ID in (select ORDER_ID from HQFS_SELECT_LESSON_DETAIL where lesson_id="&lesson_id&" and clasnum="&classnum&")"
    else
        content=content&" and ORDER_ID in (select ORDER_ID from HQFS_SELECT_LESSON_DETAIL where lesson_id="&lesson_id&")"
    end if
end if

if fromsite<>"" then
    if isinclude=1 then
        content=content&" and web_id not in(select COPARTNER_ID from HQFS_COPARTNER_INFO where SHOW_NAME like '%"&fromsite&"%')"
    else
        content=content&" and web_id in(select COPARTNER_ID from HQFS_COPARTNER_INFO where SHOW_NAME like '%"&fromsite&"%')"
    end if
end if

if web_id<>"" then
    if isinclude=1 then
        if checkstr(web_id,1)=1 then
            content=content&" and web_id<>0"
        else
            content=content&" and web_id<>(select COPARTNER_ID from HQFS_COPARTNER_INFO where WEB_NAME='"&web_id&"')"
        end if
    else
        if checkstr(web_id,1)=1 then
            content=content&" and web_id=0"
        else
            content=content&" and web_id=(select COPARTNER_ID from HQFS_COPARTNER_INFO where WEB_NAME='"&web_id&"')"
        end if
    end if
end if

if alldate=1 then content=content&" "
if alldate=0 and syear>0 and smonth>0 and sday>0 and eyear>0 and emonth>0 and eday>0 then

    stime=cdate(syear&"-"&smonth&"-"&sday&" 00:00:00")
    etime=cdate(eyear&"-"&emonth&"-"&eday&" 23:59:59")

    content=content&" and CREATION_DATE>='"&stime&"' and CREATION_DATE<='"&etime&"'"
end if

select case lessontype
    case 1
        content=content&" and order_id in (select order_id from hqfs_select_lesson_detail where discount_id>0 and discount_id in (select id from edu_discount where isprint=1))"
    case else
end select

select case cataid
    case 1
        content=content&" and isbuy=1"
    case 2
        content=content&" and isbuy=0"
end select

if admin_id>0 then content=content&" and created_by="&admin_id-1&""

if opentype=1 then
    content=content&" and created_by=0"
elseif opentype=2 then
    content=content&" and created_by>0"   
end if

if paytype=1 then
    'content=content&" and privilege_id=0"
elseif paytype=2 then
    'content=content&" and ORIGINF_TOTAL_AMOUNT>SELECT_TOTAL_AMOUNT"
    'content=content&" and privilege_id>0"
elseif paytype=3 then
    content=content&" and SELECT_TOTAL_AMOUNT=0"
end if

strSearch="cataid="&cataid&"&lessontype="&lessontype&"&paytype="&paytype&"&opentype="&opentype&"&ordernum="&ordernum&"&username="&username&"&userinfo="&userinfo&"&admin_id="&admin&"&lesson_up="&lesson_up&"&lesson_id="&lesson_id&"&classnum="&classnum&"&fromsite="&fromsite&"&web_id="&web_id&"&isinclude="&isinclude&"&syear="&syear&"&smonth="&smonth&"&sday="&sday&"&eyear="&eyear&"&emonth="&emonth&"&eday="&eday&"&alldate="&alldate&"&discount_type="&discount_type&"&"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
A:link{
    FONT-SIZE: 10pt;
    COLOR: #0000FF;
    TEXT-DECORATION: none;
}
A:visited{
    FONT-SIZE: 10pt;
    COLOR: #0000FF;
    TEXT-DECORATION: none;
}
A:active{
    FONT-SIZE: 10pt;
    text-decoration: none;
}
A:hover{
    COLOR: #ff0000;
    TEXT-DECORATION: underline;
}

body,td{
    font-size:9pt;
    line-height:140%;
}
.STYLE1 {color: #FFFF00}
</style>
</head>
<%
set rs=server.createobject("adodb.recordset")
SQL="select lesson_id,lesson,up_id from lessonset where cataid=1 and type=2 and show=1 and isdel=0 order by up_id,lesson_id"
rs.open sql,conn,3
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
        <%
        count = 0
        do while not rs.eof
        %>
subcat[<%=count%>] = new Array("<%= trim(rs("lesson"))%>","<%= rs("up_id")%>","<%= rs("lesson_id")%>");
        <%
        count = count + 1
        rs.movenext
        loop
        rs.close
        %>
onecount=<%=count%>;
</script>

<script language="JavaScript">
function changelocation(locationid){
    var lesson_id=document.getElementById("lesson_id");
    lesson_id.length = 0;

    var locationid=locationid;
    var i;
    lesson_id.options[lesson_id.length] = new Option("选择课程...", "");
    for (i=0;i < onecount; i++){
        if (subcat[i][1] == locationid){
            lesson_id.options[lesson_id.length] = new Option(subcat[i][0], subcat[i][2]);
        }
    }
}

function CheckAll(form){
    for (var i=0;i<form.elements.length;i++){
        var e = form.elements[i];
        if (e.name != 'chkall')
           e.checked = form.chkall.checked;
    }
}

function check(){
    return(confirm("确定要删除吗?"))
}

function ToPage(){
    window.location=("SPOrderList.asp?<%=strSearch%>page=" + document.getElementById("page").value);
}

function add(){
    window.open ("add.asp","_blank","width=700,height=550,top=100,left=200");
}

function manage(id){
    window.open ("managebook.asp?id="+id,"_blank","width=568,height=350,top=100,left=200,scrollbars=1;");
}

function AddRemark(id){
    window.open ("SetLessonRemark.asp?order_code="+id,"_blank","width=598,height=450,top=100,left=200,scrollbars=1;");
}

function CancelOrder(id){
    window.open ("CancelOrder.asp?order_code="+id,"_blank","width=598,height=450,top=100,left=200,scrollbars=1;");
}

function ShowCancelOrder(id){
    window.open ("ShowCancelOrder.asp?order_code="+id,"_blank","width=598,height=450,top=100,left=200,scrollbars=1;");
}

function ShowOrder(id){
    window.open ("showorder.asp?order_code="+id,"_blank","width=598,height=450,top=100,left=200,scrollbars=1;");
}

function ChangeOrder(id){
    window.open ("changeorder.asp?<%=strSearch%>id="+id,"_blank","width=568,height=350,top=100,left=200,scrollbars=1;");
}

function ShowTR(n){
    var tr=document.getElementById("tr" + n);
    if(tr.style.display==""){tr.style.display="none";}else{tr.style.display="";}
}
function MakeExcel(){
    var objXL;

    try {
        objXL = new ActiveXObject( "Excel.Application" );
    }
    catch(e) {
        alert("Excel对象无法创建!\n\n使用此功能必须在浏览器中设置:Internet选项->安全->将本站加入“受信任的站点”");
        return;
     }
     objXL.Visible = true;

    //新增 //var xlBook =
    var xlBook = objXL.Workbooks.Add;

    //添加工作表
    var xlsheet = xlBook.Worksheets(1);

    var SumRow=(count+1)*2+1;

    //设置单元格宽度
    objXL.Columns(1).ColumnWidth = 10;
    objXL.Columns(2).ColumnWidth = 10;
    objXL.Columns(3).ColumnWidth = 10;
    objXL.Columns(4).ColumnWidth = 10;
    objXL.Columns(5).ColumnWidth = 10;
    objXL.Columns(6).ColumnWidth = 15;
    objXL.Columns(7).ColumnWidth = 10;
    objXL.Columns(8).ColumnWidth = 10;
    objXL.Columns(9).ColumnWidth = 10;
    /*
    objXL.Columns(10).ColumnWidth = 5;
    objXL.Columns(11).ColumnWidth = 15;
    objXL.Columns(12).ColumnWidth = 5;
    objXL.Columns(13).ColumnWidth = 30;
    */
    objXL.Cells(1, 1).Value = "编号";
    objXL.Cells(1, 2).Value = "课程订单号";
    objXL.Cells(1, 3).Value = "订购人";
    objXL.Cells(1, 4).Value = "订单价格";
    objXL.Cells(1, 5).Value = "开课价格";
    objXL.Cells(1, 6).Value = "开课时间";
    objXL.Cells(1, 7).Value = "操作人";
    objXL.Cells(1, 8).Value = "特批类型";
    objXL.Cells(1, 9).Value = "来自网站";
    objXL.Cells(1, 10).Value = "备注";
    /*objXL.Cells(1, 10).Value = "省份";
    objXL.Cells(1, 11).Value = "来自";
    objXL.Cells(1, 12).Value = "是否包含退费班";
    objXL.Cells(1, 13).Value = "课程";*/

    objXL.Selection.HorizontalAlignment = -4108;// ' xlLeft

    objXL.Range("A1:m" + (count+1)).select;

    objXL.Selection.Borders.LineStyle = 1;
    objXL.Selection.Borders.Weight = -4138;
    objXL.Selection.Borders(11).LineStyle = -4142;
    objXL.Selection.Borders(12).LineStyle = -4142;
    objXL.Selection.Interior.ColorIndex = 0;

    objXL.Range("A1:m1").select;
    objXL.Selection.Font.Bold = true;
    objXL.Selection.Interior.ColorIndex = 1;
    objXL.Selection.Interior.Pattern = 1;  //xlSolid
    objXL.Selection.Font.Size=10;
    objXL.Selection.Font.ColorIndex = 2;
    for(i=2;i<=count+1;i++) {
//        var nRow=Math.floor(i/2)-1;
//        if(i % 2 == 0){
            for(j=1;j<=13;j++) {
                xlsheet.Cells(i, j).Value = arrRow[i-2][j-1];
                xlsheet.Cells(i, j).Font.Size=10;        //字体
                xlsheet.Cells(i, j).Font.ColorIndex =1;    //字体颜色,1=黑;2=白;3=红;4=绿;5=蓝;6=黄;7=粉;8=湖蓝
            }
//        }else{
//            xlsheet.Range(xlsheet.Cells(i-1, 1),xlsheet.Cells(i, 1)).MergeCells = true;
//            xlsheet.Range(xlsheet.Cells(i, 2),xlsheet.Cells(i, 9)).MergeCells = true;
//            xlsheet.Cells(i, 2).WrapText = true;
//            xlsheet.Cells(i, 2).RowHeight = arrRow[nRow][10];
//            xlsheet.Cells(i, 2).Font.Size = 10;
//            xlsheet.Cells(i, 2).Font.Name = "宋体";
//            xlsheet.Cells(i, 2).Value = arrRow[nRow][9];
//        }
    }
}
</script>
<script language="javascript" src="../js/ajax.js"></script>
<body>
<!--Session过期时间
<iframe width=0 height=0 src="SessionKeeper.asp">
</iframe>-->
<%if instr(a_Purview,"|查询|")>0 or session("a_power")="999" then%>
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#999999">
  <tr>
    <td height="25" colspan="6" bgcolor="#666699">&nbsp;<font color="#FFFFFF" face="黑体" style="font-size:12pt;line-height:150%;">查询条件</font><span class="STYLE1"></span></td>
  </tr>
  <form name="myform" method="post" action="SPOrderList.asp">
  <!--
    <tr>
      <td width="9%" height="25" align="right" bgcolor="#E2E2E2">订 单 号:</td>
      <td width="31%" bgcolor="#E2E2E2"><input name="ordernum" type="text" id="ordernum" size="15"></td>
      <td width="14%" align="right" bgcolor="#E2E2E2">订 购 人:</td>
      <td width="20%" bgcolor="#E2E2E2"><input name="username" type="text" id="username" size="15"></td>
      <td width="11%" align="right" bgcolor="#E2E2E2">用户信息:</td>
      <td width="15%" bgcolor="#E2E2E2"><input name="userinfo" type="text" id="userinfo" size="15"></td>
    </tr>
    -->
    <%if instr(a_Purview,"|高级查询|")>0 or session("a_power")="999" then%>
    <!--
    <tr>
      <td height="25" align="right" bgcolor="#E2E2E2">订购课程:</td>
      <td height="25" colspan="5" bgcolor="#E2E2E2"><select name="lesson_up" id="lesson_up" onChange="changelocation(this.options[this.selectedIndex].value);">
        <option value="" selected>请选择科目..</option>
        <%
        Set rs = Server.CreateObject("ADODB.Recordset")
        SQL="select * from lessonset where cataid=1 and type=1 and show=1 and isdel=0 order by up_id"
        rs.Open SQL,conn,3
        if not(rs.bof or rs.eof) then
            for i=1 to rs.recordcount
            %>
        <option value="<%=rs("lesson_id")%>" <%if lesson_up=rs("lesson_id") then response.Write "selected"%>><%=rs("lesson")%></option>
        <%
            rs.movenext
            if rs.eof then exit for
            next
        end if
        %>
      </select><select name="lesson_id" id="lesson_id" style="width:380px;">
          <option value="" selected>请选择检索课程..</option>
        </select><select name="classnum" id="classnum">
          <option value="" selected>选择班别..</option>
          <%
        set rs=server.CreateObject("adodb.recordset")
        sql="select * from hqfs_class_type where isdo=1 order by class_type_id asc"
        rs.open sql,conn,3
        if not(rs.bof or rs.eof) then
              for i=1 to rs.recordcount
          %>
          <option value="<%=rs("class_type_id")%>" <%if classnum=rs("class_type_id") then response.Write "selected"%>><%=rs("class_type_name")%></option>
          <%
            rs.movenext
            if rs.eof then exit for
            next
        end if
        %>
        </select></td>
    </tr>
    -->
    <!--
    <tr>
      <td height="25" align="right" bgcolor="#E2E2E2">合作客户:</td>
      <td height="25" colspan="3" bgcolor="#E2E2E2"><input name="fromsite" type="text" id="fromsite1" size="10" value="<%=request("fromsite")%>">
        <select name="web_id" id="web_id" onChange="document.getElementById('fromsite').value='';">
          <option value="" selected>选择合作网站...</option>
          <option value="1" <%if checkstr(web_id,1)=1 then response.Write "selected"%>>www.edu24ol.com</option>
        </select>
        <input name="isinclude" type="checkbox" id="isinclude" value="1" <%if checkstr(request("isinclude"),1)=1 then response.Write "checked"%>>不包含
        <script language="javascript" src="../../js/Link_Site.js"></script>
        <script language="javascript">
        for(i=0;i<SiteCount;i++){
            document.myform.web_id.options[document.myform.web_id.length] = new Option(arrSite[i][1],arrSite[i][2]);
        }
        </script>
        </td>
     <td height="25" align="right" bgcolor="#E2E2E2">选课类型:</td>
      <td height="25" bgcolor="#E2E2E2"><select name="lessontype" id="lessontype">
        <option value="">选择...</option>
        <option value="1">保过班</option>
      </select>
      </td>
    </tr>
    -->
    <!--
    <tr>
      <td height="25" align="right" bgcolor="#E2E2E2">开课类型:</td>
      <td height="25" colspan="3" bgcolor="#E2E2E2"><select name="paytype" id="paytype">
        <option value="">选择...</option>
        <option value="1" <%if paytype=1 then response.Write "selected"%>>正常开课</option>
        <option value="2" <%if paytype=2 then response.Write "selected"%>>特批开课</option>
        <option value="3" <%if paytype=3 then response.Write "selected"%>>免费开课</option>
      </select></td>
      <td height="25" align="right" bgcolor="#E2E2E2">开课方式:</td>
      <td height="25" bgcolor="#E2E2E2"><select name="opentype" id="opentype">
        <option value="">选择...</option>
        <option value="1" <%if opentype=1 then response.Write "selected"%>>自开课</option>
        <option value="2" <%if opentype=2 then response.Write "selected"%>>客服开课</option>
      </select></td>
    </tr>
    -->
    <tr>
      <td height="25" align="right" bgcolor="#E2E2E2">订购日期:</td>
      <td height="25" colspan="3" bgcolor="#E2E2E2"><select name="syear">
            <%for i=2006 to year(now())%>
              <option value="<%=i%>" <%if i=year(now()) then response.Write "selected"%>><%=i&"年"%></option>
            <%next%>
        </select><select name="smonth">
            <%for i=1 to 12%>
              <option value="<%=i%>" <%if i=month(now()) then response.Write "selected"%>><%=i&"月"%></option>
            <%next%>
        </select><select name="sday">
            <%for i=1 to 31%>
              <option value="<%=i%>" <%if i=day(now()) then response.Write "selected"%>><%=i&"日"%></option>
            <%next%>
        </select>
        —
        <select name="eyear">
            <%for i=2006 to year(now())%>
              <option value="<%=i%>" <%if i=year(now()) then response.Write "selected"%>><%=i&"年"%></option>
            <%next%>
        </select><select name="emonth">
            <%for i=1 to 12%>
              <option value="<%=i%>" <%if i=month(now()) then response.Write "selected"%>><%=i&"月"%></option>
            <%next%>
        </select><select name="eday">
            <%for i=1 to 31%>
              <option value="<%=i%>" <%if i=day(now()) then response.Write "selected"%>><%=i&"日"%></option>
            <%next%>
        </select>
        <input name="alldate" type="checkbox" id="alldate" value="1">全部日期 &nbsp;&nbsp;特批类型:
            <select name="discount_type" id="discount_type">
                <option value="" selected>选择...</option>
                  <option value="1">重新开课</option>
                  <option value="2">折扣开课</option>
                  <option value="3">公共账号</option>
                  <option value="4">其他</option>
            </select>
      </td>
        <td height="25" align="left" bgcolor="#E2E2E2" colspan="2">&nbsp;<input type="submit" name="Submit2" value=" 查 询 "></td>
     <!--
      <td height="25" align="right" bgcolor="#E2E2E2">操 作 人:</td>
      <td height="25" bgcolor="#E2E2E2"><label>
        <select name="admin_id" id="admin_id">
          <option value="" selected>选择操作人...</option>
          <%
    set rs=server.CreateObject("adodb.recordset")
    sql="select a.id,a.name,b.up_id from admin a left outer join Edu_Departments b on b.id=a.departmentID where (a.departmentID in (select id from Edu_Departments where up_id=16 or id=16) and a.show=1) or a.id=152 order by b.up_id asc,a.dept asc,a.id asc"
    rs.open sql,conn,3
        do until rs.eof
          %>
          <option value="<%=rs("id")+1%>" <%if admin_id=rs("id") then response.Write "selected"%>><%=rs("name")%></option>
          <%
          rs.movenext
        loop
          %>
        </select>
      </label></td>
      -->
    </tr>
    <%end if%>
  </form>
</table>

<table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<%
end if
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="from1" method="post" action="SPOrderList.asp" onSubmit="return check();">
<input name="cmd" type="hidden" value="del">
  <tr>
    <td><table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#999999">
          <tr>
            <td height="25" colspan="11" bgcolor="#666699">&nbsp;<font face="黑体" style="font-size:12pt;line-height:150%;" color="#FFFFFF">特批课程购买正式订单表</font></td>
          </tr>
          <tr bgcolor="#E2E2E2">
            <td width="7%" height="25" align="center"><b>编号</b></td>
            <td width="13%" align="center" bgcolor="#E2E2E2"><strong>课程订单号</strong></td>
            <td width="12%" height="25" align="center"><strong>订购人</strong></td>
            <td width="7%" align="center"><b><strong>订单<br>
            价格</strong></b></td>
            <td width="7%" align="center"><strong>开课<br>
            价格</strong></td>
            <td width="13%" align="center"><b>开课时间</b></td>
            <td width="10%" align="center"><strong>操作人</strong></td>
            <td width="10%" align="center"><strong>特批类型</strong></td>
            <td width="10%" align="center"><strong>来自网站</strong></td>
            <td width="5%" align="center" title="123"><strong>备注</strong></td>
            <td width="18%" height="25" align="center"><strong>
              <label>
              <input type="button" name="Submit4" value="导出EXCEL文件" style="width:100px;" onClick="MakeExcel();">
              </label>
            </strong> </td>
          </tr>
          <%
ltime=timer
if content<>"" then
    set rs=server.CreateObject("adodb.recordset")
    sql="select count(*) from HQFS_Order where"&myfilter&"Order_ID is not null "&content&""
    'response.Write("535行"&sql)
    rs.open sql,conn,3
    '=================rows为记录总数===============
    rows=rs(0)
    '==============maxrows为每页最大记录数==============
    maxrows=20
    '====================pagecou为共多少页==================       
    pagecou=rows\maxrows
    if rows >(maxrows * pagecou) then pagecou=pagecou+1
    '=================curpage为当前页次============
    if trim(Request("page"))<>"" then curpage=cint(Request("page")) else curpage=1
    spage=maxrows*curpage
    if curpage=pagecou and rows mod maxrows>0 then n=rows mod maxrows else n=maxrows
    ids="0"   
    set rs2=server.CreateObject("adodb.recordset")
    sql="select count(*) as counts  from HQFS_Order where"&myfilter&"Order_ID is not null "&content&""
    rs2.open sql,conn,3
    if rs2("counts")>3000 and rs2("counts")<30000 then
    find2="and a.ORDER_ID in (select top 3000 ORDER_ID from HQFS_Order where"&myfilter&"Order_ID is not null "&content&"  order by ORDER_ID desc)"
    elseif rs2("counts")>30000 then
    find2="and a.ORDER_ID in (select top 10 ORDER_ID from HQFS_Order where"&myfilter&"Order_ID is not null "&content&"  order by ORDER_ID desc)"
    else
    find2="and a.ORDER_ID in (select ORDER_ID from HQFS_Order where"&myfilter&"Order_ID is not null "&content&" )"
    end if
    set rs=server.CreateObject("adodb.recordset")
    sql="select top "& spage &" ORDER_ID from HQFS_Order where"&myfilter&"Order_ID is not null "&content&"  order by ORDER_ID desc"
    'response.Write("999"+sql)
        rs.open sql,conn,3
        if not(rs.bof or rs.eof) then
            rs.Movelast
            for i=1 to n
            if rs.bof or rs.eof then exit for
                ids=ids&","&rs("ORDER_ID")
            rs.MovePrevious
            next
        else
            ids=0
        end if
        find=" and a.ORDER_ID in ("&ids&")"
    set rs=server.CreateObject("adodb.recordset")
    set rs1=server.CreateObject("adodb.recordset")
    sql="select a.*,cast(b.username as varchar(15)) as showname,b.username,cast(c.site_name as varchar(10)) as showsite,c.site_name,d.name as adminname,e.name as updatename from HQFS_Order a"
    sql=sql&" left outer join edu_userinfo b on b.id=a.STUDENT_ID"
    sql=sql&" left outer join HQFS_COPARTNER_INFO c on c.COPARTNER_ID=a.web_id"
    sql=sql&" left outer join admin d on d.id=a.created_by"
    sql=sql&" left outer join admin e on e.id=a.last_updated_by"
    sql1=sql&" where a.Order_ID>0 "&find2&" order by a.ORDER_ID desc"
    'response.Write("584行"&sql)
    'response.Write("585行find2"&find2)
    rs1.open sql1,conn,3
    if not(rs1.bof or rs1.eof) then
    %>
        <script language="javascript">
        var arrRow=new Array();
        var count=0;
        count=<%=rs1.recordcount%>;   
    <%
        for t=1 to rs1.recordcount
            '特批类型
            if rs1("Discount_Type")="0" or rs1("Discount_Type")=NULL or rs1("Discount_Type")="" then
                mydiscounttype=""
            elseif rs1("Discount_Type")="1" then
                mydiscounttype="重新开课"
            elseif rs1("Discount_Type")="2" then
                mydiscounttype="折扣开课"
            elseif rs1("Discount_Type")="3" then
                mydiscounttype="公共账号"
            elseif rs1("Discount_Type")="4" then
                mydiscounttype="其他"
            end if
            '操作人
            if rs1("created_by")>0 or rs1("created_by")=0 and rs1("last_updated_by")>0 and rs1("order_time")>=cdate("2009-1-1 00:00:00") then
                if rs1("created_by")=0 and rs1("last_updated_by")>0 and rs1("order_time")>=cdate("2009-1-1 00:00:00") then
                    operator=rs1("updatename")
                else
                    operator=rs1("adminname")
                end if
            else
                operator="自开课"
            end if
        %>
            arrRow[<%=t-1%>]=new Array("<%=t%>","<%=rs1("order_code")%>","<%=rs1("showname")%>","<%=rs1("ORIGINF_TOTAL_AMOUNT")%>","<%=rs1("SELECT_TOTAL_AMOUNT")%>","<%=rs1("order_time")%>","<%=operator%>","<%=mydiscounttype%>","<%=rs1("site_name")%>","<%=rs1("remark")%>");
        <%
        rs1.MoveNext
        if rs1.EOF then exit for
        next
        'end if
        %>
            </script>
        <%
    end if
    sql=sql&" where a.Order_ID>0 "&find&" order by a.ORDER_ID desc"
    'response.Write(sql)
    rs.open sql,conn,3
    %>
    <%
    if not(rs.bof or rs.eof) then
        for i=1 to rs.recordcount
    %>   

          <tr bgcolor="#FFFFFF" onMouseOver="this.bgColor='#FFF9EC'" onMouseOut="this.bgColor='#FFFFFF'">
            <td align="center"><input name="ids" type="Checkbox" value="<%=rs("order_id")%>"><font color="<%=fcolor%>"><%=maxrows*(curpage-1) + i%></font></td>
            <td height="25" align="center"><a href="javascript:ShowOrder('<%=rs("order_code")%>');"><font color="<%=fcolor%>"><%=rs("order_code")%></font></a></td>
            <td height="25" align="center"><a href="javascript:;" onClick="window.open('showuser.asp?id=<%=rs("STUDENT_ID")%>','_blank','width=580px,height=450px,top=100,left=200,resizable=0,status=0,scrollbars=0')"><font color="<%=fcolor%>"><%=rs("showname")%><%if len(rs("username"))>len(rs("showname")) then response.Write ".."%></font></a></td>
            <td height="25" align="center"><font color="<%=bgcolor%>"><%=rs("ORIGINF_TOTAL_AMOUNT")%></font></td>
            <td height="25" align="center"><font color="<%=bgcolor%>"><%=rs("SELECT_TOTAL_AMOUNT")%></font></td>
            <td height="25" align="center"><font color="<%=bgcolor%>"><%=showtime(rs("order_time"),5)%></font></td>
            <td height="25" align="center" title="<%=rs("last_updated_by")%>"><font color="<%=bgcolor%>"><%
            if rs("created_by")>0 or rs("created_by")=0 and rs("last_updated_by")>0 and rs("order_time")>=cdate("2009-1-1 00:00:00") then
                if rs("created_by")=0 and rs("last_updated_by")>0 and rs("order_time")>=cdate("2009-1-1 00:00:00") then
                    response.Write rs("updatename")
                else
                    response.Write rs("adminname")
                end if
            else
                response.Write "<font color='#FF0000'>自开课</font>"
            end if
            %></font></td>
            <td height="25" align="center"><font color="<%=bgcolor%>"><%
            if rs("Discount_Type")="0" or rs("Discount_Type")=NULL or rs("Discount_Type")="" then
            response.Write("")
            elseif rs("Discount_Type")="1" then
            response.Write("重新开课")
            elseif rs("Discount_Type")="2" then
            response.Write("折扣开课")
            elseif rs("Discount_Type")="3" then
            response.Write("公共开课")
            elseif rs("Discount_Type")="4" then
            response.Write("其他")
            else
            response.Write(rs("Discount_Type"))
            end if
            %></font></td>
            <td align="center" title="<%=rs("site_name")%>"><font color="<%=bgcolor%>">&nbsp;
              </font><font color="<%=bgcolor%>"><%=rs("showsite")%></font><font color="<%=bgcolor%>">
              <%if len(rs("site_name"))>len(rs("showsite")) then response.Write ".."%>
              </font></td>
              <td height="25" align="center" title="<%=rs("remark")%>">
              <font color="<%=bgcolor%>">
              <%
                if len(rs("remark"))>3 then
                response.Write(left(rs("remark"),2)+"..")
                else
                response.Write(rs("remark"))
                end if
              %>
             </font></td>
            <td align="center"><%
            if rs("stoptype")=0 then           
            %>
            <%
            else
            %><input type="button" name="Submit32" value="查看" style="background:#FF9900;width:38px;" onClick="ShowCancelOrder(<%=rs("order_code")%>);"><%
            end if
            %><input type="button" name="but_<%=i%>" id="but_<%=i%>" value="预览" style="width:38px; margin-left:5px;" onClick="ShowAjaxText('<%="but_"& i%>','<%="showpreview.asp?cataid=2&order_id="&rs("order_id")%>','<%="tr"& i%>','<%="text_"& i%>');"></td>
          </tr>
          <tr id="tr<%=i%>" style="display:none;" bgcolor="#FFFFFF">
            <td height="25" colspan="11"><font color="<%=bgcolor%>">
            <label id="text_<%=i%>"><img src="/images/loading.gif" width="32" height="32" align="absmiddle"> 如长时间没有反应请重新点击,数据载入中,请稍等......<br>
            </label>
           </font></td>
          </tr>
          <%
        rs.MoveNext
        if rs.EOF then exit for
        next
    end if
    rs.close
    set rs=nothing
    conn.close
    set conn=nothing

end if
%>
          <tr bgcolor="#FFFFFF" onMouseOver="this.bgColor='#f2f2f2'" onMouseOut="this.bgColor='#FFFFFF'">
            <td height="20" colspan="11" align="center"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E2E2E2">
                <tr>
                  <td height="36" width="155"> <%if instr(a_Purview,"|删除|")>0 or session("a_power")="999" then%> <input type="checkbox" name="chkall" value="on" onClick="CheckAll(this.form)">
                    全部选中
                    <%end if%> </td>
                  <td width="151" align="center">&nbsp;</td>
                  <td align="right" height="36" width="695"> 共<font color="#ff0000"><%=rows%></font>条信息&nbsp;
                    <%if curpage>1 then%>
                    [<a href="SPOrderList.asp?<%=strSearch%>page=1"><font color="red"><u>首页</u></font></a>]
                    [<a href="SPOrderList.asp?<%=strSearch%>page=<%=curpage-1%>"><font color="red"><u>上一页</u></font></a>]
                    <%end if
                    if curpage<pagecou then
                    %>
                    [<a href="SPOrderList.asp?<%=strSearch%>page=<%=curpage+1%>"><font color="red"><u>下一页</u></font></a>]
                    [<a href="SPOrderList.asp?<%=strSearch%>page=<%=pagecou%>"><font color="red"><u>尾页</u></font></a>]
                    <%end if%> &nbsp;&nbsp;&nbsp;&nbsp;去
                    <input name="page" type="text" id="page" size="5" value="<%=curpage%>" style="text-align:center;"><input type="button" name="Submit" value="GO" onClick="ToPage();">页&nbsp;</td>
                </tr>
              </table></td>
          </tr>
        </table>
      </td>
  </tr>
<input name="page" type="hidden" value="<%=curpage%>">
</form>
</table>
<%="获取时间:"&timer-ltime%>
</body>
</html>
<%
    'rs1.close
    'set rs1=nothing
    'rs2.close
    'set rs2=nothing
%>

posted @ 2011-09-21 15:17  十年如一  阅读(374)  评论(0编辑  收藏  举报