<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
else
if request.cookies("sundxshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
end if
end if

dim action,biaotiid
biaotiid=SafeRequest("id",1)
action=FormatSQL(SafeRequest("action",0))
select case action

case "add" 
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权添加文章分类！');history.go(-1);</script>"
response.End
end if
if Not isNumeric(request.form("biaotiTop")) then
conn.close
set conn = nothing
response.Write "<script language=javascript>alert('推荐必须是数字！');history.go(-1);</script>"
response.End
end if
if Not isNumeric(request.form("biaotiNum")) then
conn.close
set conn = nothing
response.Write "<script language=javascript>alert('排序必须是数字！');history.go(-1);</script>"
response.End
end if
if request.form("biaotititle") ="" then
conn.close
set conn = nothing
response.Write "<script language=javascript>alert('请填写名称！');history.go(-1);</script>"
response.End
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from biaoti",conn,1,3
rs.AddNew
rs("biaotititle")=trim(request.form("biaotititle"))
rs("biaotiNum")=int(request.form("biaotiNum"))
rs("biaotiTop")=int(request.form("biaotiTop"))

rs.Update
rs.Close
set rs=nothing
conn.close
set conn = nothing
response.Redirect "adminbiaoti.asp"

case "edit"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权编辑标题栏目！');history.go(-1);</script>"
response.End
end if

if Not isNumeric(request.form("biaotiTop")) then
conn.close
set conn = nothing
response.Write "<script language=javascript>alert('推荐必须是数字！');history.go(-1);</script>"
response.End
end if
if Not isNumeric(request.form("biaotiNum")) then
conn.close
set conn = nothing
response.Write "<script language=javascript>alert('排序必须是数字！');history.go(-1);</script>"
response.End
end if
if request.form("biaotititle") ="" then
conn.close
set conn = nothing
response.Write "<script language=javascript>alert('请填写名称！');history.go(-1);</script>"
response.End
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from biaoti where biaotiid="&biaotiid,conn,1,3
rs("biaotititle")=trim(request.form("biaotititle"))
rs("biaotisNum")=trim(request.form("biaotiNum"))
rs("biaotiTop")=trim(request.form("biaotiTop"))
rs("biaotiaddress")=trim(request.form("biaotiaddress"))
rs.Update
rs.Close
set rs=nothing
conn.close
set conn = nothing
response.Redirect "adminbiaoti.asp"

case "del"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权删除标题栏目！');history.go(-1);</script>"
response.End
end if
conn.execute ("delete from biaoti where biaotiID="&biaotiid)
conn.close
set conn = nothing
response.Redirect "adminbiaoti.asp"
end select
%>
<title>管理文章分类</title>
<script language = "JavaScript">
<!--
function CheckAdd()
{
    if(checkspace(document.AddForm.biaotititle.value)) {
	document.AddForm.biaotititle.focus();
    alert("请输入名称！");
	return false;
  }

  
 
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
	function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}
//-->
</script>
 <table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" BGCOLOR="#39867B">
        <tr> 
          <td align="center" colspan="6"><font color="#FFFFFF">网站标题栏目信息设置</font></td>
        </tr>
        <tr bgcolor="#FFFFFF" align="center"> 
                <td width="20%">标题名称</td>
                <td width="8%">标题排序</td>
                <td width="8%">标题显示</td>
                <td width="10%">查看修改内容</td>
                <td width="40%">链接地址</td>
                <td width="14%">操作</td>
           </tr>
		  
                <%set rs=server.CreateObject("adodb.recordset")
		  rs.Open "select * from biaoti order by biaotiNum",conn,1,1
		  dim follows
		  if rs.EOF and rs.BOF then
		  response.Write "<div align=center><font color=red>还没有标题栏目</font></center>"
		  follows=0
		  else
		  do while not rs.EOF
		  %>
              <tr bgcolor="#FFFFFF" align="center" height="20"> 
               <form name="form1" method="post" action="adminbiaoti.asp?action=edit&id=<%=rs("biaotiid")%>">
                 <td ><input name="biaotititle" type="text" id="biaotititle" value="<%=trim(rs("biaotititle"))%>" size="20" ></td>
                <td ><input name="biaotiNum" type="text" id="biaotiNum" value="<%=int(rs("biaotiNum"))%>" size="4" ></td>
                <td ><select name="biaotiTop" id="biaotiTop">
			    <option value="0" <% if rs("biaotiTop")=0 Then Response.write("Selected") %>>普通</option>
                <option value="1" <% if rs("biaotiTop")=1 Then Response.write("Selected") %>>推荐</option>
              </select></td>
                <td><a href=biaotidetial.asp?id=<%=rs("biaotiid")%>>查看修改内容</a></td>

                <td ><a href=../biaoti.asp?id=<%=rs("biaotiid")%> target="_blank">biaoti.asp?id=<%=trim(rs("biaotiid"))%></a></td>
                 <td><input type="submit" name="Submit" value="修 改"> &nbsp; <a href="adminbiaoti.asp?id=<%=int(rs("biaotiid"))%>&action=del" onClick="return confirm('您确定进行删除操作吗？')"><font color=red>删除</font></a> 
            </td></form>
              </tr>
               <%rs.MoveNext
          loop
          follows=rs.RecordCount
          end if
    rs.Close
    set rs=nothing
         %>
              
            
       
      </table>

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" BGCOLOR="#39867B">
  <tr> 
    <td height="20" BGCOLOR="#39867B" align="center"><font color="#FFFFFF">添加文章分类</font></td>
  </tr>
  <tr> 
    <td bgcolor="#FFFFFF">
	<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
         <tr bgcolor="#FFFFFF" align="center"> 
                <td width="30%">标题名称</td>
                <td width="30%">标题排序</td>
                <td width="30%">标题显示</td>
                <td width="10%">操作</td>
                
           </tr>
        <form name="AddForm" method="post" action="adminbiaoti.asp?action=add">
          <tr align="center" bgcolor="#FFFFFF"> 
             <td ><input name="biaotititle" type="text" id="biaotititle"  size="20" ></td>
              <td ><input name="biaotiNum" type="text" id="biaotiNum"  size="4" value="<%=follows+1%>"></td>
              <td ><select name="biaotiTop" id="biaotiTop">
			  <option value="0" selected>普通</option>
                         <option value="1">推荐</option>
                     </select>
                </td>   
            <td><input type="submit" name="Submit3" value="添 加" onClick="return CheckAdd();"></td>
          </tr>
        </form>
      </table></td>
  </tr>
</table>

<!--#include file="footer.asp"-->