<!--#include virtual="/show/userhead.asp"-->
<!--#include file="subleft.asp"-->
<script>document.getElementById('o_2').setAttribute("class", "ed"); document.getElementById("t_2").style.display="";document.getElementById('s_2_6').setAttribute("class", "ed4");</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title><%=webname%>-卖出卡密(代理)</title> 
<%
set rsdl=server.CreateObject("adodb.recordset")
%>

<SCRIPT LANGUAGE="JavaScript">
var checkflag1 = "false";
function check1(field) {
if (checkflag1 == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag1 = "true";
return "false"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag1 = "false";
return "true"; }
}

function unselectall1()
{
    if(document.myform.chkAll1.checked){
	document.myform.chkAll1.checked = document.myform.chkAll1.checked&0;
	checkflag1 = "false";
    } 	
}
</script>
<br>
<DIV id=main2> 
<%call webleft()%>
<%
call chkyanzhengold("feikadaili")

act=SafeRequest("act")
cact=SafeRequest("cact")
link="feikadaili?ct="
aygismka=1
if SafeRequest("act")="shou" then response.Cookies("shangid")=""
if SafeRequest("act")="shou" then response.Cookies("aykatel")=""

if cact="cha" then


if SafeRequestform("shangid")<>""then
shangid=SafeRequestform("shangid")
elseif SafeRequest("shangid")<>""then
shangid=SafeRequest("shangid")
end if

if SafeRequestform("aykatel")<>"" then
aykatel=SafeRequestform("aykatel")
elseif SafeRequest("aykatel")<>"" then
aykatel=SafeRequest("aykatel")
end if
'if shangid=0 and session("shangid")="" then call PopErr("请选择商品名称")

'if shangid=0 then session("shangid")=""
if aykatel<>"" then
response.Cookies("aykatel")=aykatel
sql2=sql2&" and aykatel='"&aykatel&"'"
else
response.Cookies("aykatel")=""
end if

if shangid<>0 then
response.Cookies("shangid")=shangid
'session("sshangid")=""
sql="select aygoodid,aygoodsuoyouid,aygsumid,aygismka,aygooddlid,aysjgid from aygood where aygoodid="&request.Cookies("shangid")&" and aygoodsuoyouid="&request.Cookies("aynameid")&"" 
rs.open sql,conn,1,1
if rs.bof and rs.eof then call PopErr("未找到代理产品，或权限不足")
if clng(rs("aygismka"))=0 then call PopErr("上级代理商禁止查看该商品卖出卡密信息")
aygooddlid=rs("aygooddlid")  '上级代理ID
sshangid=rs("aysjgid")       '上级商品ID

	rsdl.open "select aygoodid from aygood where aygoodid="&rs("aysjgid")&"" ,conn,1,1
	if rsdl.bof and rsdl.eof then call PopErr("未找到代理产品，或权限不足ERR2")
	rsdl.close
	
rs.close

rs.open "select aynameid,kamiku from ayname where aynameid="&clng(aygooddlid)&"" ,conn,1,1
kamiku=trim(rs("kamiku"))
rs.close

sql2=sql2&" and aykagoodid='"&sshangid&"'"
end if


link="feikadaili?cact=cha&shangid="&request.Cookies("shangid")&"&aykatel="&request.Cookies("aykatel")&""
end if


page=SafeRequest("page")


if act="down" then
Function RndNumber(Min,Max) 
Randomize 
RndNumber=Int((Max - Min + 1) * Rnd() + Min) 
End Function 
suiji=year(now())&Month(now())&day(now())&hour(now())&minute(now())&second(now())
mingcheng=suiji&RndNumber(1000,9999)&".txt"
strOut="商品名称    卡密信息     商品价格      购卡时间       联系方式"&CHR(13)

list1=SafeRequestform("list1")
if list1="" then call PopErr("未找到此项目")
	delid=split(list1,",")

	For dianka=0 To Ubound(delid) 
	'response.Write delid(dianka)
	sql="select * from "&request.Cookies("kamiku")&" where aykaid="&trim(delid(dianka))&" and aydailiid="&clng(request.Cookies("aynameid"))&"" 
	rs.open sql,conn,1,1
	if rs.bof and rs.eof then
	call PopErr("未找到此项目")
	else
		set rsgood=server.CreateObject("adodb.recordset")
		sqlgood="select * from aygood where aygoodid="&clng(rs("aykagoodid"))&"" 
		rsgood.open sqlgood,conn,1,1
		if not(rsgood.bof and rsgood.eof) then
		goodname=trim(rsgood("aygoodname"))
		goodjiage=Formatnumber(rsgood("ayjiage"),2,true,-1,0)&"元"
		else
		goodname="商品或已删除"
		goodjiage="商品或已删除"
		end if
	if trim(rs("aykapass"))="0" then 
	aykapass=" "
	else
	aykapass=trim(rs("aykapass"))
	end if
	strOut=strOut&goodname&"   "&trim(rs("ayka"))&" "&aykapass&"  "&goodjiage&"  "&rs("aykakai")&"  "&trim(rs("aykatel"))&CHR(13)
	rsgood.close
	rs.close
	end if
	next
	
	strOut=strOut&CHR(13)&CHR(13)&webname&CHR(13)&"创建时间 "&now()
	Set fso=Server.CreateObject("Scripting.FileSystemObject")
	set linkw=fso.createtextfile(server.mappath("\upka\"&mingcheng),true)
	linkw.writeline strOut
	linkw.close
	response.Redirect weburl&"show/downfeika.asp?url="&mingcheng
	'response.Redirect("feika?page="&page&"")
set linkw=Nothing
set fso=Nothing
end if
%>
<DIV id=main_right>
<DIV id=main_right_content>

<H2><SPAN>卖出卡密(代理)</SPAN></H2>
<DIV class=main3>
	  <%
	  
	  sql="select * from aygood where aygoodsuoyouid="&request.Cookies("aynameid")&" and aygooddlid<>0 and isptdx=0 order by aygoodsx asc" 
	  rs.open sql,conn,1,1
	  if rs.bof and rs.eof then 
	  call PopErr2("未查询到代理商品","feika")
	  else
	  %>
<form action="?cact=cha" method="post" name="chaxun" id="chaxun">
&nbsp;商品分类：
<select name="shangid" id="shangid">
	   <option value="0">请选择商品</option>
	  <%do while not rs.eof%>
	  <option value="<%=rs("aygoodid")%>" 
	  <%if request.Cookies("shangid")<>"" then
	  if clng(request.Cookies("shangid"))=clng(rs("aygoodid")) then response.Write("selected")
	  end if%>><%=rs("aygoodname")%></option>
	  <%
	  rs.movenext 
	  loop
	  rs.close
	  end if
	  'session("shangid")=""
	  %>
      </select>
&nbsp;
联系方式：
<input name="aykatel" type="text" id="aykatel" value="<%if trim(request.Cookies("aykatel"))<>"" then response.Write server.HTMLEncode(trim(request.Cookies("aykatel")))%>" size="20" maxlength="15">
<input type="submit" name="Submit" value=" 查 询 ">
<a href="feika">[我的产品卖出卡密]</a>
<br><br>
</form>
  <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_style_a1">
     <form action="?act=down" method="post" name="myform" target="_blank" id="myform"> 
       <tr>
        <th class="border_right border_bottom" >&nbsp;</th>
        <th align="center" class="border_right border_bottom" >商品名称
        <th align="center" class="border_right border_bottom">卡密信息
        <th align="center" class="border_right border_bottom">商品价格
        <th align="center" class="border_right border_bottom">购卡时间
        <th align="center" class="border_bottom">联系方式        </tr>
<%
if kamiku<>"" then


if SafeRequest("act")="shou" then
sql="select top 500 * from "&kamiku&" where aydailiid="&request.Cookies("aynameid")&" and aykayesno=1 order by aykakai desc" 
else
sql="select top 500 * from "&kamiku&" where aydailiid="&request.Cookies("aynameid")&" and aykayesno=1"&sql2&"  order by aykakai desc" 
end if

rs.open sql,conn,1,1
rs.pagesize=50
pagecount=rs.pagecount 
if request("page")="" then 
page=1
else
page=int(request("page")) 
end if
if page<=0 then page=1 
if request("page")="" then page=1

if not(rs.bof and rs.eof) then
rs.absolutepage=page
do while not rs.eof%>

	  <tr onmouseover=this.bgColor='#D2FFFF' onmouseout=this.bgColor='#ffffff'>
        <td align="center" class="border_right border_bottom"><input name="list1" type="checkbox" id="list1" value="<%=rs("aykaid")%>" onClick="unselectall1()"></td>
        <td align="center" class="border_right border_bottom">
		<%
		set rsgood=server.CreateObject("adodb.recordset")
		sqlgood="select aygoodid,aygsumid from aygood where aygoodid="&clng(rs("aykagoodid"))&"" 
		rsgood.open sqlgood,conn,1,1
		if not(rsgood.bof and rsgood.eof) then
			set rsbg=server.CreateObject("adodb.recordset")
			sqlbg="select aygoodname,aygoodid,aygsumid,ayjiage,aygismka from aygood where aygsumid='"&trim(rsgood("aygsumid"))&"' and aygoodsuoyouid="&request.Cookies("aynameid")&"" 
			rsbg.open sqlbg,conn,1,1
			if not(rsbg.bof and rsbg.eof) then
			response.Write rsbg("aygoodname")
			else
			response.Write("商品或已删除")
			end if
		else
		response.Write("商品或已删除")
		end if
		rsgood.close
		%>		</td>
        <td align="center" class="border_right border_bottom">
		<%

		if cint(rsbg("aygismka"))=0 then
			response.Write "卡号："&left(trim(rs("ayka")),len(trim(rs("ayka")))-6)&"******<br>"
			if trim(rs("aykapass"))<>"0"  then
			response.Write "密码："&left(trim(rs("aykapass")),len(trim(rs("aykapass")))-6)&"******<br>"
			end if
		else
			response.Write "卡号："&trim(rs("ayka"))&"<br>"
			if trim(rs("aykapass"))<>"0"  then
			response.Write "密码："&trim(rs("aykapass"))
			end if
		end if
		%></td>
        <td align="center" class="border_right border_bottom">
		<%if not(rsbg.bof and rsbg.eof) then
		response.Write Formatnumber(rsbg("ayjiage"),2,true,-1,0)&"元"
		else
		response.Write("商品或已删除")
		end if%>		</td>
        <td align="center" class="border_right border_bottom"><%=rs("aykakai")%></td>
        <td align="center" class="border_bottom">
		<%if trim(rs("aykatel"))<>"0" then 
		response.Write trim(rs("aykatel"))
		else
		response.Write "-"
		end if%></td>
        </tr>
<%		rsbg.close
n=n+1
rs.movenext  '指针向下移动
if n>=rs.pagesize then exit do  
loop
end if
zongshu=rs.RecordCount
rs.close

else%>
<span style="color:#009900">[###请选择相应商品进行查询###]</span><br><br>
<%end if %>
	  

      <tr>
        <td colspan="6">&nbsp;<input name="chkAll1" type="checkbox" id="chkAll1" onClick="this.value=check1(this.form.list1)" value="checkbox"> 
        全选
         <!--<input type="submit" name="Submit" value="下载到本地"> -->

<%call pageye()%>
		</td>
      </tr></form>
    </table>
</DIV>
<% 
response.Cookies("shangid")=""
response.Cookies("aykatel")=""
%>

</DIV></DIV>
<DIV class=clear></DIV></DIV>
</DIV>

<br>

	<!--#include virtual="/show/foot.asp"-->


