<!--#include file="head.asp"-->
<!--#include file="subleft.asp"-->
<!--#include virtual="/inc/connhost.asp"-->
<script>document.getElementById('o_2').setAttribute("class", "ed"); document.getElementById("t_2").style.display="";document.getElementById('s_2_5').setAttribute("class", "ed4");</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title><%=webname%>-库存卡密</title>

<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>
<SCRIPT LANGUAGE="JavaScript">
function down(){

	document.getElementById("act").value="down";
	document.getElementById(myform).submit();
    return true;
 
}



function del(){
	if(confirm("确定要删除吗？"))
	{
		document.getElementById("act").value="alldel";
		document.getElementById(myform).submit();
			return true;
	}else{
			return false;
	}
}

</script>
<%


kakuid=request.Cookies("kamiku")

if SafeRequest("act")="shou" then response.Cookies("shangid")=""

if SafeRequestform("act")="down" then
Const stringmodarr = "0123456789"
dim randarr2,strlength
strlength = Len(stringmodarr)
Randomize timer
For i = 1 To 4 
randarr2 = randarr2&Mid(stringmodarr,Int(Rnd * strlength + 1),1)  
Next 
get_timeh=timer()*100
get_timeh=right("00"&get_timeh,2)
get_timeh=replace(get_timeh,".","0")
randarr = Right((year(Now())),2)&Right(("00"&Month(Now())),2)&Right(("00"&Day(Now())),2)&Right(("00"&hour(Now())),2)&Right(("00"&minute(Now())),2)&Right(("00"&second(Now())),2)&get_timeh&randarr2

shangid=SafeRequestform("shangid")

mingcheng=randarr&".txt"


if trim(shangid)<>"" then
	sql="select * from aygood where aygoodid="&shangid&" and aygoodsuoyouid="&request.Cookies("aynameid")&"" 
	rs.open sql,conn,1,1
	if not(rs.bof and rs.eof) then
	gname=trim(rs("aygoodname"))
	
	end if
	rs.close

strOut=gname&CHR(13)&CHR(10)
else
strOut="  "&CHR(13)&CHR(10)
end if



list1=SafeRequestform("list1")
if list1="" then call PopErr("未找到此项目")
	delid=split(list1,",")
	For dianka=0 To Ubound(delid) 
	sql="select * from "&kakuid&" where aykaid="&trim(delid(dianka))&" and aykasuoyou="&clng(request.Cookies("aynameid"))&"" 
	rs.open sql,conn,1,1
	
	if rs.bof and rs.eof then
	call PopErr("未找到此项目")
	else
		if trim(rs("aykapass"))="0" then 
		aykapass=" "
		else
		aykapass=trim(rs("aykapass"))
		end if
		strOut=strOut&trim(rs("ayka"))&"  "&aykapass&CHR(13)&CHR(10)
	end if
	rs.close
	next
	
	strOut=strOut&CHR(13)&CHR(10)&CHR(13)&CHR(10)&webname&CHR(13)&CHR(10)&CHR(13)&CHR(10)&"创建时间 "&now()
	Set fso=Server.CreateObject("Scripting.FileSystemObject")
	set linkw=fso.createtextfile(server.mappath("\updata\kucunka\"&mingcheng),true)
	linkw.writeline strOut
	linkw.close
	response.Redirect hosturl&"index/downkc?url="&mingcheng
	'response.Redirect("feika?page="&page&"")
set linkw=Nothing
set fso=Nothing
end if


act=SafeRequest("act")
cact=SafeRequest("cact")
sql2="aykasuoyou="&request.Cookies("aynameid")&""
link="kucunka?cact=cha"

if cact="cha" or SafeRequestform("cact")="cha" then

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

kahao=trim(SafeRequestform("kahao"))
if kahao<>"" then response.Cookies("kahao")=kahao
if kahao="" then response.Cookies("kahao")=""

if shangid=0 then response.Cookies("shangid")=""

if shangid<>0 then
response.Cookies("shangid")=shangid
sql2="aykasuoyou="&request.Cookies("aynameid")&" and aykagoodid="&shangid&""



'查找是否为代理商品
response.Cookies("sshangid")=""
sql="select aygoodid,aygoodsuoyouid,aygooddlid,aygiska,aygsumid from aygood where aygoodid="&request.Cookies("shangid")&" and aygoodsuoyouid="&request.Cookies("aynameid")&"" 
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
if clng(rs("aygooddlid"))<>0 then 
if clng(rs("aygiska"))=0 then call PopErr("上级代理商禁止查看该商品卡密信息")

	'验证代理关系
	set rsdl=server.CreateObject("adodb.recordset")
	sqldl="select aydluserid,aydlsjuserid,aydlistongguo from aydailishang where aydluserid='"&request.Cookies("aynameid")&"' and aydlsjuserid='"&trim(rs("aygooddlid"))&"'" 
	rsdl.open sqldl,conn,1,1
	if rsdl.bof and rsdl.eof then call PopErr("无权限")
	if clng(rsdl("aydlistongguo"))<>1 then call PopErr("无权限")
	rsdl.close
	
	'总代卡库
	sqldl="select aynameid,kamiku from ayname where aynameid='"&trim(rs("aygooddlid"))&"'" 
	rsdl.open sqldl,conn,1,1
	kakuid=trim(rsdl("kamiku"))
	rsdl.close
	
	'查找上级代理商品ID 
	set rsdg=server.CreateObject("adodb.recordset")
	sqldg="select aygoodid,aygooddlid,aygsumid,aygoodisydl from aygood where aygoodisydl=0 and aygoodsuoyouid="&rs("aygooddlid")&" and aygsumid='"&trim(rs("aygsumid"))&"'" 
	rsdg.open sqldg,conn,1,1
	if rsdg.bof and rsdg.eof then call PopErr("未找到上级代理的商品"&trim(rs("aygoodname"))&"，请重新获取商品")
	if clng(rsdg("aygoodisydl"))=1 then call PopErr("权限不足")
	response.Cookies("sshangid")=rsdg("aygoodid")
	rsdg.close
	
	if shangid<>0 then
	response.Cookies("shangid")=shangid
		if request.Cookies("sshangid")<>"" then
		sql2="aykasuoyou='"&rs("aygooddlid")&"' and aykagoodid='"&request.Cookies("sshangid")&"'"
		end if
	end if
	
end if
end if
rs.close

end if

if kahao<>"" then sql2=sql2&" and ayka like '%"&kahao&"%'"
link="kucunka?cact=cha&shangid="&request.Cookies("shangid")&""
end if



%>
<br>
<DIV id=main2> 
<%call webleft()%>

<%

page=SafeRequest("page")




%>


<DIV id=main_right>
<DIV id=main_right_content>

<H2><SPAN>库存卡密</SPAN></H2>
<DIV class=main4>
<%if request.Cookies("yanzheng")="" then%>
<form action="kucunka" method="post" name="formyz" id="formyz">
<table width="99%" border="0" cellspacing="0" cellpadding="0" class="table_style_a2">
  <tr>
    <td height="35">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="113" height="35" align="center">输入支付密码：</td>
    <td width="665">&nbsp;&nbsp;
      <input name="anquanma" class="inputty" type="password" id="anquanma">
      <input name="catanquan" type="hidden" id="catanquan" value="anquan">
	  <input name="shangid" type="hidden" id="shangid" value="<%=shangid%>">
      &nbsp;&nbsp;<input type="submit" name="Submit2" value=" 确 定 "> <a href="anquan">[设置支付密码]</a></td>
  </tr>
  <tr>
    <td height="35">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
<%end if%>
<%if request.Cookies("yanzheng")<>"" then
if md5("chaku"&request.Cookies("aynameid")&ptjiami)<>request.Cookies("yanzheng") then response.Redirect "/index/exit"
%>
<form action="?cact=cha" method="post" name="chaxun" id="chaxun">
<br>&nbsp;商品分类：

<select name="shangid" id="shangid">
	   <option value="0">全部商品</option>
	  <%
	  nogood="no"
	  set rsf=server.CreateObject("adodb.recordset")
	  sqlf="select * from aykafenlei where aykanamesuoyou="&request.Cookies("aynameid")&" and ayshangjiid=0 order by aykafenleisx asc" 
	  rsf.open sqlf,conn,1,1
	  if not(rsf.bof and rsf.eof) then
	  do while not rsf.eof
	  
	  
						  sql="select * from aygood where aygoodsuoyouid="&request.Cookies("aynameid")&" and aygoodfl="&rsf("aykafenleiid")&" order by aygoodsx asc" 
						  rs.open sql,conn,1,1
						  if not(rs.bof and rs.eof) then 
						  nogood="yes"
							  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%>><%=trim(rsf("aykafenleiname"))%>>><%=rs("aygoodname")%></option>
							  <%	
							  rs.movenext 
							  loop
						  else%>
						  <option value="0"><%=trim(rsf("aykafenleiname"))%>>>暂无商品</option>
						  <%end if
			   		  	  rs.close
	  
	  
	  
			  set rsf2=server.CreateObject("adodb.recordset")
			  sqlf2="select * from aykafenlei where aykanamesuoyou="&request.Cookies("aynameid")&" and ayshangjiid="&rsf("aykafenleiid")&" order by aykafenleisx asc" 
			  rsf2.open sqlf2,conn,1,1
			  if not(rsf2.bof and rsf2.eof) then
			  do while not rsf2.eof
	  
	  
						  sql="select * from aygood where aygoodsuoyouid="&request.Cookies("aynameid")&" and aygoodfl="&rsf2("aykafenleiid")&" order by aygoodsx asc" 
						  rs.open sql,conn,1,1
						  if not(rs.bof and rs.eof) then 
						  nogood="yes"
							  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%>><%=trim(rsf("aykafenleiname"))%>>><%=trim(rsf2("aykafenleiname"))%>>><%=rs("aygoodname")%></option>
							  <%	
							  rs.movenext 
							  loop
						  else%>
						  <option value="0"><%=trim(rsf("aykafenleiname"))%>>><%=trim(rsf2("aykafenleiname"))%>>>暂无商品</option>
						  <%end if
			   		  	  rs.close
					  
			  rsf2.movenext 
	 		  loop	 
			  end if
			  rsf2.close
			  
			  
	  rsf.movenext 
	  loop 
	  end if
	  rsf.close
	  %>
      </select> <%if nogood="no" then call PopErr2("请先添加商品","goodadd")%>
&nbsp;<br><br>
&nbsp;卡号查询：&nbsp;<input name="kahao" type="text" id="kahao" value="<%if trim(request.Cookies("kahao"))<>"" then response.Write server.HTMLEncode(trim(request.Cookies("kahao")))%>" size="35" maxlength="35">
<input type="submit" name="Submit" value=" 查 询 ">
 <span style="color: #CCCCCC">(查看代理商品卡密请选择商品进行查询)</span><br>
 <br>
</form>

  <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_style_a2">

     <form action="?page=<%=page%>" method="post" name="myform" id="myform"> 
       <tr>
        <th class="border_right border_bottom" >&nbsp;</th>
        
        <th height="35" 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>
<%
sql="select * from "&kakuid&" where "&sql2&" and aykayesno=0 order by aykaid desc" 
'response.Write sql
'response.End()
rs.open sql,conn,1,1
rs.pagesize=200
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 height="35" align="center" class="border_right border_bottom"><%
		response.Write "卡号："&trim(rs("ayka"))&"<br>"
		if trim(rs("aykapass"))<>"0"  then
		response.Write "密码："&trim(rs("aykapass"))
		end if
		%></td>
        <td align="center" class="border_right border_bottom"><%
		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 response.Write rsgood("aygoodname"):else:response.Write "商品或已删除":end if
		%></td>
        <td align="center" class="border_right border_bottom"><%=rs("aykadata")%></td>
        <td align="center" class="border_bottom">&nbsp;</td>
	  </tr>
<%		rsgood.close
n=n+1
rs.movenext  '指针向下移动
if n>=rs.pagesize then exit do  
loop
end if
zongshu=rs.RecordCount
rs.close%>
	  

      <tr>
        <td height="35" colspan="5">&nbsp;
          <input name="chkAll1" type="checkbox" id="chkAll1" onClick="this.value=check1(this.form.list1)" value="checkbox"> 
        全选
           
		  <input type="submit" name="Submit2" value=" 下载到本地 " onClick="return down();">

<%call pageye()
%>		<input name="act" type="hidden" id="act" value="alldel" />
<input name="shangid" type="hidden" id="shangid" value="<%=request.Cookies("shangid")%>" /></td>
      </tr></form>
    </table>
<%end if%>
</DIV>
<% response.Cookies("shangid")=""%>

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

	
%>
<br>

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


