<%@ Language=VBScript%>
<%
Response.Buffer=false
Response.Expires=0
%>
<!-- #include file="../dsn.asp" -->
<!-- #include file="../links.asp" -->
<%
if session("adminusername")="" then
		session("xhy")=1
		Response.Redirect linkwarn
end if
enable=""
id=cint(Request.QueryString("id"))
pid=cint(Request.QueryString("pid"))
yxid=cint(Request.QueryString("yxid"))
delid=cint(Request.QueryString("delid"))
enable=Request.QueryString("enable")
ppid=cint(Request.QueryString("ppid"))
pageno=Request.QueryString("pageno")
htmlname=linklbadmin&"?pid="&pid&"&ppid="&ppid
addhtml=linklbadminedit&"?pid="&pid&"&ppid="&ppid

if pid=0 then 
		tabname="scool"
		classesname="大类"
end if
if pid=1 then 
		tabname="classes"
		classesname="小类"
end if

set cn=Server.CreateObject("ADODB.Connection")
cn.Open mycnstr
set rs1=server.CreateObject("ADODB.Recordset")
set rs2=server.CreateObject("ADODB.Recordset")
if delid<>"" then
	sqltext3="delete from "+tabname+" where id="&delid
	cn.Execute sqltext3
	delid=""
end if

if yxid<>0 then
		sqltext4="select * from "+tabname+" where id="&yxid
		rs1.Open sqltext4,cn,1,2
		if not rs1.EOF then
				if rs1("enable")=1 then
						rs1("enable")=0
					else
						rs1("enable")=1
				end if
				yxid=0
		end if
		rs1.Update 
		rs1.Close 
end if

htmltitle="基本数据管理"
txtname="名称"
%>
<html>
<head>
<title><%=htmltitle%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {font-size: 12px; color: #000000; font-family: 宋体}
td {font-size: 12px; color: #000000; font-family: 宋体;line-height:130%}
.t1 {font:12px 宋体;color=000000} 
.t2 {font:12px 宋体;color:ffffff} 
.t3 {font:12px 宋体;color:336699} 
.t4 {font:12px 宋体;color:ff0000} 
.t5 {font:12px 宋体;color:ff6600} 


.bt1 {font:14px 宋体;color=000000} 
.bt2 {font:12px 宋体;color:ffffff} 
.bt3 {font:14px 宋体;color:336699} 
.bt4 {font:14px 宋体;color:ff0000} 
.bt5 {font:14px 宋体;color:0000ff}
.bt10 {font:14px 宋体;color:0000ff}

.td1 {font-size:12px;background-color:#3388bb;color:#ffffff}
.td2 {font-size:12px;background-color:#ffffff;color:#000000;}

A:link {color: #000077}
A:visited {color: #000077}
A:hover {color: #ff0000}

A.r1:link {text-decoration:none;color:#304556;}
A.r1:visited {text-decoration:none;color:#304556;}
A.r1:hover {text-decoration:underline;color:ff6600;}

A.r2:link {text-decoration:none;color:#ffffff;}
A.r2:visited {text-decoration:none;color:#ffffff;}
A.r2:hover {text-decoration:underline;color:cccc00;}

-->
</style>
</head>
<body topmargin=5>
<table width="100%" align=center>
	<tr>
	<td valign="top" align="left" width="100%">
		<table width="100%" height="20" border="0">
			<tr>
			<td style="font-size:12px;"></td>
			<td><font class="t5">当前位置：类别管理→  <%Response.Write (classesname)%>列表</font>
			</td>
			<td align="right">
			</td>
			</tr>
			</table>
			</td>
			</tr>
			</table>
		<table width="100%" height="20" border="0">
			<tr>
		<%
		'Response.Write sqltext
				sqltext1="select * from "+tabname+" order by id desc"
			rs1.Open sqltext1,cn,1,1
		listcs=30
		rs1.PageSize=listcs
		if pageno="" then 
			pageno=1
		else
			pageno=cint(pageno)	
		end if	
		if rs1.PageCount>0 then rs1.AbsolutePage=pageno%>
				<td class=t1 align="left" width=300>
			<a href="Javascript:window.location.reload()">[刷新列表]</a>
			<a href="<%=addhtml%>">[增加]</a>
		</td>
		<td align="right">
		<%if rs1.PageCount>1 then%>
			[第<b><font color=ff6600><%=pageno%></font></b>页, 共<b><font color=ff6600><%=rs1.PageCount%></font></b>页<b><font color=ff6600><%=rs1.RecordCount%></font></b>条记录		              	
			<%if pageno>1 then%>
				<a class=r href="<%=htmlname%>&pageno=1">首页</a>              
				<a class=r href="<%=htmlname%>&pageno=<%=pageno-1%>">上页</a>              
			<%end if              
			if pageno<rs1.PageCount then%>              
				<a class=r href="<%=htmlname%>&pageno=<%=pageno+1%>">下页</a>              
				<a class=r href="<%=htmlname%>&pageno=<%=rs1.PageCount%>">末页</a>              
			<%end if%>              
		<%end if              
		%>              
		</td></tr>
		</table>
		
		
		<table width="100%" border="0" cellspacing="1" cellpadding="1" style="font-size:14.5px;line-height:100%">
			<tr bgcolor="336699" style="color:#ffffff" align="center">
				<td class=bt2>删除</td>
				<td class=bt2>有效性</td>
				<td class=bt2 width=50>ID号</td>
				<td class=bt2 width=50>序号</td>
				<td class=bt2><%=txtname%></td>
			<%if pid=1 then%>
					<td class=bt2>所属大类</td>
			<%end if%>
			</tr>
		<%
		i=0
		do while not rs1.EOF and i<listcs 
			if (i mod 2)=1 then
				Response.Write("<tr bgcolor=fefefe>")
			else
				Response.Write("<tr bgcolor=efefef>")
			end if	
		%>
		<td width="35" align="center" onclick="Javascript:delrec('<%=rs1("id")%>','<%=trim(rs1("title"))%>')"><img  src="delete.gif"></td>
		<td width="50" align="center"><input type="checkbox" name="yxc" onclick="Javascript:yx('<%=rs1("id")%>')"  <%if rs1("enable")=1 then Response.Write ("checked")%>></td>
					<td width="50" align="center"><%=rs1("id")%></td>
					<td width="50" align="center"><%=rs1("pl")%></td>
					<td align=left><a href="<%=addhtml%>&id=<%=rs1("id")%><%if pid=1 then Response.Write ("&lbpid="&rs1("pid"))%>"><%=rs1("title")%></a>
		  <%if pid=1 then%>			
						<td width="80" align="center">
						     <%sqltext="select title from scool where id="&rs1("pid")
						       rs2.Open sqltext,cn,1,1
						       if not rs2.EOF then%>
										<%Response.Write (trim(rs2("title")))%>
						       <%end if
						       rs2.Close %>
						</td>
		  <%end if%>
			</tr>
			<%rs1.MoveNext 
			i=i+1
			loop%>
					</table>
</body>
</html>
<script language="Javascript">

	function delrec(code,topic)
	{
		if (confirm('您确认要删除“'+topic+'”吗？')==true)
		{
			window.location.href="<%=htmlname%>&delid="+code+""
		return false;
		}
	}
	
	function yx(code)
	{	window.location.href="<%=htmlname%>&yxid="+code+""
	}
	function editimage(keyno,pic)
	{
		var str
		str="upload.asp?" ;
		str=str+"id="+keyno;
		str=str+"&pic="+pic;
		str=str+"&tablename=<%=tabname%>"
	window.open(str,"mywin","toolbar=no,location=no,directories=no,status=no,resizable=no,menubar=no,scrollbars=yes,width=550,height=400,left=120,top=70")		
	}
</script>
