<!--#include file="../conn.asp"-->
<!--#include file="inc/admin_config.asp"-->
<%
If Cint(AdminGroup(4))=1   or Cint(Request.Cookies("IsSuper"))=1 then
else
Response.Redirect("Default.asp")
Response.End()
End If

%>
<!--#include file="inc/top.asp"-->
<table border="0" align="center" cellpadding="0" cellspacing="1" class="tablecolor">
  <tr> 
    <td height="25" align="center" class="banner"><a href="news_Sort.asp">栏目管理</a></td>
    <td width="20%" align="center" class="banner"><a href="?action=add">添加栏目</a></td>
  </tr>
</table>
<%
select case request("action")
case "add"
call add()
case "saveedit"
call saveedit()
'推荐删除等操作
case "saveOperation"
call saveOperation()
case else
call normal()
end select
sub normal()
dim strFileName,listid
listid=request("listid")
strFileName="news_Sort.asp?listid=" & listid
pageno=20
dim rs,p_i
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from wd_news_Sort order by wt_grade asc,  wt_id desc",conn,1,1
rscount=rs.recordcount
%>
<table border="0" align="center" cellpadding="0" cellspacing="1" class="tablecolor">
  <%
   if  rscount<1 then
  %>
  <tr>
    <td height="25" colspan="9" align="center" class="tablebody">目前还没有大类！</td>
  </tr>
  <%
else
%>
  <tr>
    <td width="50" height="25" align="center" class="tablebody">编号</td>
    <td width="50" height="25" align="center" class="tablebody">排序</td>
    <td align="center" class="tablebody">栏目名称</td>
    <td align="center" class="tablebody">修改</td>
     <td align="center" class="tablebody">操作</td>
 </tr> <form name="form1" method="post" action="?action=saveOperation" onSubmit="return checkf(form1)">
  <%
call showsql(pageno)
rs.move(rsno)
for p_i=1 to loopno
%>
  <tr bgcolor="#ffffff"  onMouseOver="this.style.background='#E7EFFF'; " onmouseout ="this.style.background='#ffffff'; " >
    <td height="25" align="center" ><%=rs("wt_id")%></td>
    <td height="25" align="center" ><%=rs("wt_grade")%></td>
    <td align="center" ><%=rs("wt_title")%> </td>
     <td align="center" ><a href="?action=add&id=<%=rs("wt_id")%>">修改</a></td>
    <td align="center" ><input name="id" type="checkbox" id="id" value="<%=rs("wt_id")%>"></td>
  </tr>
  <%
  rs.movenext
  next
  %><tr>
    <td height="25" colspan="9" align="right"  class="tablebody"><INPUT onclick=CheckAll(this.form) type=checkbox value=on name=chkall>
      &nbsp;全选
        <input name="Submit" type="submit" id="Submit" value="删除" onClick="SetSubmitImgId('realdel');">
        &nbsp;</td>
  </tr>
  <tr>
    <td colspan="9" align="right"  class="tablebody"><%call showpage(strFileName,rscount,pageno,false,true,"个类别")%></td>
  </tr>
  <% end if%>
  </form>
</table>
<%
end sub
sub add()
dim title,id,grade 
dim wt_description,wt_Keywords,wt_fileName,wt_ChannelDir
id=request("id")
if id<>"" then
	if not isnumeric(id) then
		response.Write("<script>alert('参数错误！');history.back(-1)</script>")
		response.End()
	end if
	dim rs
	set rs=conn.execute("select * from wd_news_Sort where  wt_id="&clng(id))
	if rs.bof and rs.eof then
		response.Write("<script>alert('参数错误！');history.back(-1)</script>")
		response.End()
	end if
		title=rs("wt_title")
		grade=rs("wt_grade")
		wt_description=rs("wt_description")
		wt_Keywords=trim(rs("wt_Keywords"))
	rs.close
	set rs=nothing
end if
%>
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tablecolor">
  <tr>
    <td height="25" align="center" class="tablebody" colspan="2"><%if title="" then 
	response.Write("栏目添加") 
	else
	response.Write("栏目修改") end if%></td>
  </tr>
  <form name="form1" method="post" action="?action=saveedit">
    <tr >
      <td width="120"  align="center" class="tablebody">栏目名称：</td>
      <td class="tablebody"><input name="title" type="text" id="adminname" value="<%=title%>" maxlength="20"></td>
    </tr>
    <tr >
      <td align="center" class="tablebody">栏目排序：</td>
      <td class="tablebody"> 
        <input onKeyDown="onlyNum();" style="ime-mode:Disabled" value="<%=grade%>" name="grade" size="5">
        只允许输入数字，数字越小排列越靠前.</td>
    </tr>
    <tr >
      <td align="center" class="tablebody">关键字：</td>
      <td class="tablebody"><input name="wt_Keywords" type="text" id="wt_Keywords" value="<%=wt_Keywords%>" maxlength="255" size="70"> * 目录关键字</td>
    </tr>
    <tr >
      <td align="center" class="tablebody">简单描述：</td>
      <td class="tablebody"><textarea name="wt_description" cols="60" rows="6"><%=wt_description%></textarea></td>
    </tr>
    <tr>
      <td class="tablebody">　</td>
      <td class="tablebody"><input type="hidden" name="id" value="<%=id%>">
        <input type="submit" name="Submit" value="提交">
        <input type="reset" name="Submit2" value="重写"></td>
    </tr>
  </form>
</table>
<% end sub
sub saveedit()
dim id,title,grade
dim wt_description,wt_Keywords,wt_fileName,wt_ChannelDir
dim wt_fileUrl
id=request("id")
title=checkStr(request.Form("title"))
grade=checkStr(request.Form("grade"))
wt_description=checkStr(request.Form("wt_description"))
wt_Keywords=checkStr(request.Form("wt_Keywords"))
'response.End()
if title="" then
response.Write("<script>alert('栏目名称不能为空！');history.back(-1)</script>")
response.End()
end if
if wt_Keywords="" then
response.Write("<script>alert('关键词不能为空！');history.back(-1)</script>")
response.End()
end if
if grade="" then
grade=99
end if
if id="" then
'//判断栏目是否存在
dim rs
set rs=conn.execute("select wt_id,wt_title from wd_news_Sort where wt_title='"&title&"'")
if not rs.eof then
response.Write("<script>if(confirm('该栏目已存在，是否删除该栏目数据？')!=0) window.location='news_Sort.asp?action=delall&listid="&rs("wt_id")&"';else history.back(-1)</script>")
response.end()
end if
rs.close
set rs=nothing
conn.execute("insert into wd_news_Sort (wt_title,wt_grade,wt_description,wt_Keywords) values('"&title&"',"&grade&",'"&wt_description&"','"&wt_Keywords&"')")
response.Write("<script>alert('添加成功！');location='news_Sort.asp'</script>")
response.End()
else
conn.execute("update wd_news_Sort set wt_title='"&title&"',wt_grade="&grade&",wt_description='"&wt_description&"',wt_Keywords='"&wt_Keywords&"'  where wt_id="&clng(id))
response.Write("<script>alert('修改成功！');history.back(2)</script>")
response.End()
end if
end sub
sub saveOperation()
dim id,sql
id=request.form("id")
if id="" then
response.Write("<script>alert('参数错误！');history.back(-1)</script>")
response.End()
end if
select case request("submit")
case "删除"
sql="delete from wd_news_Sort where wt_id="
case else
response.Write("<script>alert('参数错误！');history.back(-1)</script>")
response.End()
end select
for each id in request.Form("id")
conn.execute(sql&id)
next
dim ip
ip=Request.ServerVariables("HTTP_REFERER")
response.Write("<script>alert('操作成功！');location='"&ip&"'</script>")
response.End()
end sub
%>
<%CloseConn%><!--#include file="inc/end.asp"-->
