<!--#include file="conn.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆!');window.location.href='login.asp';</script>"
response.End
else
if session("flag")>1 then
response.Write "<div align=center><font size=80 color=red><b>您没有此项目管理权限!</b></font></div>"
response.End
end if
end if
action=request.querystring("action")
filename=request.form("filename")
if action="add" then
if right(filename,4)<>".xls" then
response.write "<script language=JavaScript>" & chr(13) & "alert('输入的文件格式不正确!')</script>"
response.write"javascript:history.go(-1)</SCRIPT>"
end if
'获取导出参数
dim strLine,responsestr,strf,strlirui,strj,strdanjia
strLine=""
strf=""
strlirui=""
strj=""
strdanjia=""
dim bianhao,dalei,xiaolei,bookname,lirui,chengjiaocount,jinjia,chushoujia,qipiname,qipi,model,didian,addtime,fhsj,bookcontent
if request.form("bianhao")=1 then
strLine=strLine&"编号"&chr(9)
strf="ProdId,"
end if
strLine=strLine&"商品大类"&chr(9)
strf=strf&"anclassid,"
strLine=strLine&"商品小类"&chr(9)
strf=strf&"nclassid,"
if request.form("bookname")=1 then
strLine=strLine&"商品名称"&chr(9)
strf=strf&"bookname,"
end if
if request.form("lirui")=1 then
strLine=strLine&"利润"&chr(9)
strf=strf&"lirui,"
strlirui="lirui"
end if
if request.form("chengjiaocount")=1 then
strLine=strLine&"销售量"&chr(9)
strf=strf&"chengjiaocount,"
end if
if request.form("jinjia")=1 then
strLine=strLine&"进价"&chr(9)
strf=strf&"jinjia,"
end if
if request.form("chushoujia")=1 then
strLine=strLine&"出售价"&chr(9)
strf=strf&"danjia,"
strdanjia="danjia"
end if
if request.form("qipiname")=1 then
strLine=strLine&"起批单位"&chr(9)
strf=strf&"bookchuban,"
end if
if request.form("qipi")=1 then
strLine=strLine&"起批量"&chr(9)
strf=strf&"qipi,"
end if
if request.form("model")=1 then
strLine=strLine&"商品颜色"&chr(9)
strf=strf&"model,"
end if
if request.form("didian")=1 then
strLine=strLine&"供货商"&chr(9)
strf=strf&"didian,"
end if
if request.form("addtime")=1 then
strLine=strLine&"入库时间"&chr(9)
end if
strf=strf&"adddate,"
if request.form("fhsj")=1 then
strLine=strLine&"出售时间"&chr(9)
strf=strf&"fhsj"
strj="fhsj"
end if
if strLine="" or strLine="adddate," then
response.write "<script language=JavaScript>" & chr(13) & "alert('参数为能为空!')</script>"
response.write"javascript:history.go(-1)</SCRIPT>"
end if
if request.form("lirui")=1 then
if request.form("chushoujia")<>1 or request.form("jinjia")<>1 then
response.write "<script language=JavaScript>" & chr(13) & "alert('如果您选中了利润刚请选择进价和出售价')</script>"
response.write"javascript:history.go(-1)</SCRIPT>"
end if
end if
'获取导出参数结束
day1="#"&trim(Request.Form("month1"))&"-"&trim(Request.Form("day1"))&"-"&trim(Request.Form("year1"))&"#"
day2="#"&trim(Request.Form("month2"))&"-"&trim(Request.Form("day2"))&"-"&trim(Request.Form("year2"))&"#"
set rs=server.createobject("adodb.recordset")
if right(strf,1)="," then
strf=left(strf,len(strf)-1)
end if
xiaolei=request.form("xiaolei")
'筛选类别
if xiaolei<>"xxx" then
sqlsst= "select "&strf&" from shop_books where (datediff('d',adddate,"&day2&")>=0) and (datediff('d',"&day1&",adddate)>=0) and nclassid="&xiaolei&" order by adddate"
else
sqlsst= "select "&strf&" from shop_books where (datediff('d',adddate,"&day2&")>=0) and (datediff('d',"&day1&",adddate)>=0) order by adddate"
end if
rs.open sqlsst,conn,1,1
'导出到EXcel表开始
Set fs = server.CreateObject("scripting.filesystemobject")
'--假设你想让生成的EXCEL文件做如下的存放
filename = Server.MapPath(filename)
'--如果原来的EXCEL文件存在的话删除它
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'--创建EXCEL文件
set myfile = fs.CreateTextFile(filename,true)
'--将表的列名先写入EXCEL
myfile.writeline strLine
dim strxv,strtime
Do while Not rs.EOF
strLine=""
if strdanjia<>"" or strj<>"" or strlirui<>"" then
set fft=server.createobject("adodb.recordset")
sqlfft="select actionid,bookid,dingdan,danjia,fhsj from shop_action where bookid="&rs("bookid")&""
fft.open sqlfft,conn,1,1
strdanjiav=fft("danjia")
strtime=fft("fhsj")
fft.close
set fft=nothing
end if
for each x in rs.Fields
str2=split(strf,",")
for i=0 to ubound(str2)
if str2(i)="danjia" then
rs.fields(x).value=strxv
end if
if str2(i)="lirui" then
rs.fields(x).value=rs("chengjiaocount")*(strdanjiav - rs("jinjia"))
end if
if str2(i)="danjia" then
rs.fields(x).value=strdanjiav
end if
if str2(i)="fhsj" then
rs.fields(x).value=strtime
end if
if str2(i)="anclassid" then
set fft=server.createobject("adodb.recordset")
sqlfft="select anclassid,anclass from shop_anclass where anclassid="&rs("anclassid")&""
fft.open sqlfft,conn,1,1
if not fft.eof then
rs.fields(x).value=111
end if
fft.close
set fft=nothing
end if
if str2(i)="nclassid" then
set fft=server.createobject("adodb.recordset")
sqlfft="select nclassid,nclass from shop_nclass where nclassid="&rs("nclassid")&""
fft.open sqlfft,conn,1,1
if not fft.eof then
rs.fields(x).value=222
end if
fft.close
set fft=nothing
end if
next
response.write "<script language=JavaScript>" & chr(13) & "alert('导出数据成功!')</script>"
end if
%>
<script language=JavaScript>
<%dim i,j
set rs_s=server.createobject("adodb.recordset")
rs_s.open "select * from shop_anclass order by anclassid",conn,1,1
%>
var selects=[];
selects['xxx']=new Array(new Option('选择小类','xxx'));
<%
for i=1 to rs_s.recordcount
%>
selects['<%=rs_s("anclassid")%>']=new Array(
<%
set rs_s1=server.createobject("adodb.recordset")
rs_s1.open "select * from shop_nclass where anclassid="&rs_s("anclassid")&" order by nclass",conn,1,1
if rs_s1.recordcount>0 then
for j=1 to rs_s1.recordcount
if j=rs_s1.recordcount then
%>
new Option('<%=trim(rs_s1("nclass"))%>','<%=trim(rs_s1("nclass"))%>'));
<% else
%>
new Option('<%=trim(rs_s1("nclass"))%>','<%=trim(rs_s1("nclassid"))%>'),
<%
end if
rs_s1.movenext
next
else
%>
new Option('','0'));
<%
end if
rs_s1.close
set rs_s1=nothing
rs_s.movenext
next
rs_s.close
set rs_s=nothing
%>
function chsel(){
with (document.form1){
if(dalei.value) {
xiaolei.options.length=0;
for(var i=0;i<selects[dalei.value].length;i++){
xiaolei.add(selects[dalei.value][i]);
}
}
}
}
</script>