<!--#include file = "../inc/dbconn.asp"-->
<!--#include file = "CheckLogin.asp"-->
<!--#include file = "../inc/cache.asp"-->
<!--#include file = "../inc/function.asp"-->
<% LOADING_BUFFER_INI %>
<% LOADING_ADMIN_HEAD %>
<% call dbconn %>
<%
Dim tmp_Type:tmp_Type=""
if gqv("do") = "Lock" then
    if not Check_Popedom("H004") then call alertbox("你没有权限操作",2)
    conn.execute("update AD654_Class set Lock=1 where AdClassID="& gqv("ID"))'
elseif gqv("do") = "UnLock" then
    if not Check_Popedom("H004") then call alertbox("你没有权限操作",2)
    conn.execute("update AD654_Class set Lock=0 where AdClassID="& gqv("ID"))'
elseif gqv("do") = "addADClassSave" then
    if not Check_Popedom("H004") then call alertbox("你没有权限操作",2)
	if gfv("AdClassName") = "" then
		call alertbox("[栏目名称(中文名)]不能为空!",2)
	elseif gfv("AdClassNameE") = "" then
		call alertbox("[栏目名称(英文名)]不能为空!",2)
	end if
	dim rs,sql
	set rs = server.createobject (G_654_RS)
	sql = "select * from AD654_Class where AdClassNameE='" & gfv("AdClassNameE") & "'"
	rs.open sql,conn,1,3
	if not rs.eof then		
        rs.update
	    rs.close:set rs = nothing
		call alertbox("抱歉!该分类存在!",2)
	end if	
    dim rsn,nsql
	set rsn = server.createobject(G_654_RS)
	    nsql = "select top 1 * from AD654_Class"
	    rsn.open nsql,conn,1,3
	    rsn.addnew
	    rsn("AdClassName") = gfv("AdClassName")
	    rsn("AdClassNameE") = gfv("AdClassNameE")
		rsn("Lock") = "0" 
	    rsn("AddDate") = now()
        rsn.update
	    rsn.close:set rsn = nothing
	call alertbox("恭喜!添加成功!",2)
elseif gqv("do") = "editSave" then
    dim ID,AdClassName,AdClassNameE
	ID = trim(gfv("ID"))
	AdClassNameE = trim(gfv("AdClassNameE"))
	AdClassName = trim(gfv("AdClassName"))
	if ID = "" or AdClassName = "" or AdClassNameE = "" then
		call alertbox("请完整填写信息!",2)
	end if
	set rs = server.createobject (G_654_RS)
	sql = "select * from AD654_Class where AdClassID=" & ID & ""
	rs.open sql,conn,1,3
	if not rs.eof then
	    rs("AdClassName") = AdClassName
	    rs("AdClassNameE") = AdClassNameE
	    rs("AddDate") = now()
		rs("Lock") = "0" 
		rs.update
		rs.close:set rs = nothing
		call alertbox("恭喜!修改分类成功!请牢记!",2)
	else
		call alertbox("抱歉!填写错误!",2)
	end if
elseif gqv("do") = "del" then
    if not Check_Popedom("H004") then call alertbox("你没有权限操作",2)
	conn.execute("delete * from AD654_Class where ADClassID=" & ChkNum(gqv("id")))
	call alertbox("恭喜!删除分类成功!",2)
end if 
    LINE "<table width=""99%"" border=""0"" align=""center"" cellpadding=""2"" cellspacing=""1"" class=""tbl"" id=tbl>"
    LINE "<tr>"
    LINE "<td align=""center""><B>广告管理界面</B></td>"
    LINE "</tr>"
    LINE "<tr>"
    LINE "<td class=""tbl_head""><a href=""AD_Show.asp?do=UnIsAds"">开启广告</a> | <a href=""AD_Show.asp?do=IsAds"">锁定广告</a> | <a href=""AD_Show.asp?do=AddAds"">添加广告</a> | <a href=""AD_Class.asp"">广告分类</a> | <a href=""AD_Class.asp?do=addADClass"">添加分类</a></td>"
    LINE "</tr>"
    LINE "</table>"
    LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" border=""0"">"
	LINE "<tr>"
	LINE "<td align=""center"" valign=""middle"">"
    LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" class=""tbl"" id=tbl>"
    LINE "<tr height=""30"">"
    LINE "<td width=""5%"" class=""tbl_head"">ID</td>"
	LINE "<td width=""20%"" class=""tbl_head"">分类英文</td>"
	LINE "<td width=""25%"" class=""tbl_head"">分类中文</td>"
    LINE "<td width=""20%"" class=""tbl_head"">添加时间</td>"
    LINE "<td width=""10%"" class=""tbl_head"">是否锁定</td>"
	LINE "<td width=""10%"" class=""tbl_head"">修改</td>"
	LINE "<td width=""10%"" class=""tbl_head"">删除</td>"
    LINE "</tr>"
  	dim ors
	set ors = new cls_vbspage
	set ors.conn = conn
	with ors
		.pagesize = 20
		.pagename = "page"
		.dbtype = "ac"
		.rectype = 0
		.jsurl = "../inc"
		.pkey = "AdClassID"
		.field = "AdClassID,AdClassNameE,AdClassName,AddDate,Lock"
		.table = "AD654_Class"
		.condition = "AdClassID > 0"&tmp_Type
		.orderby = "AdClassID desc"
	end with
	dim ireccount,irs
		ireccount = ors.reccount()
		irs = ors.resultset()
	if ireccount < 1 then
	LINE "<tr>"
	LINE "<td bgcolor=""#ffffff"" align=""center""  height=""30"" colspan=""7""><font color=""red"">暂时没有留言分类!</font></td>"
	LINE "</tr>"
	else
	dim i
	for i = 0 to ubound(irs,2)
    LINE "<tr>"
    LINE "<td bgcolor=""#ffffff"">"&irs(0,i)&"</td>"
	LINE "<td bgcolor=""#ffffff"">"&irs(1,i)&"</td>"
    LINE "<td bgcolor=""#ffffff"">"&irs(2,i)&"</td>"
	LINE "<td bgcolor=""#ffffff"">"&irs(3,i)&"</td>"
    LINE "<td bgcolor=""#ffffff"">"
	if irs(4,i)="0" then
	   Response.write("<a href='?do=Lock&ID="&irs(0,i)&"'><font color=red>关闭</font></a>")
	else
	   Response.write("<a href='?do=UnLock&ID="&irs(0,i)&"'>开启</a>")
	end if
	LINE "</td>"
	LINE "<td bgcolor=""#ffffff""><input name=""submit1"" type=""button"" value=""编辑"" onclick=""window.location.href('?do=editADClass&id=" & irs(0,i) & "');""></td>"
    LINE "<td bgcolor=""#ffffff""><input name=""submit2"" type=""button"" value=""删除"" onclick=""if(confirm('确定要删除此分类?')){window.location.href('?do=del&id=" & irs(0,i) & "');}""></td>"
    LINE "</tr>"
    next
	LINE "<tr>"
	%><td bgcolor="#ffffff" align="right" height="30" colspan="7"><% = ors.showpage() %></td><%
	LINE "</tr>"
	end if
	LINE "</table>"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"%>
<%select case gqv("do")
	case "addADClass"
        if not Check_Popedom("H004") then call alertbox("你没有权限操作",2)
	    Call addADClass
	    Call cursor("#addADClass",0)
	case "editADClass"
        if not Check_Popedom("H004") then call alertbox("你没有权限操作",2)
	    Call editADClass
	    Call cursor("#editADClass",0)
end select%>


<%sub addADClass
	LINE "<a name=""addADClass""></a>"
	LINE "<form name=""form"" action=""?do=addADClassSave"" method=""post"">"
	LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" border=""0"">"
	LINE "<tr>"
	LINE "<td align=""center"" valign=""middle"">"
	LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" class=""tbl"" id=tbl>"
	LINE "<tr>"
	LINE "<td width=""10%"" align=""center"" height=""30"" colspan=""2"" class=""tbl_top0"">添加广告分类</td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td class=""tbl_head"" align=""right"">栏目名称(英文名):</td>"
	LINE "<td bgcolor=""#ffffff"" width=""75%""><input name=""AdClassNameE"" type=""text"" value="""" style=""width:200px;""></td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td class=""tbl_head"" align=""right"">栏目名称(中文名):</td>"
	LINE "<td bgcolor=""#ffffff"" width=""75%""><input name=""AdClassName"" type=""text"" value="""" style=""width:200px;""></td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td align=""right"" bgcolor=""#ffffff""></td>"
	LINE "<td bgcolor=""#ffffff"">"
	LINE "<input name=""submit1"" type=""submit"" value=""添加分类"" onclick=""this.disabled=true;document.form.submit();"">&nbsp;"
	LINE "<input name=""submit2"" type=""reset"" value=""重新填写"">&nbsp;"
	LINE "<input name=""submit3"" type=""button"" value=""返回"" onclick=""window.history.back();"">"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "</form>"
end sub%>

<%sub editADClass
	dim rs,databox
	set rs = conn.execute("select top 1 * from AD654_Class where AdClassID=" & ChkNum(gqv("id")))
	if rs.eof then
		rs.close:set rs = nothing
		call alertbox("抱歉!系统没有找到相关记录!",2)
	else
		databox = rs.getrows()
		rs.close:set rs = nothing
	end if
	LINE "<a name=""editADClass""></a>"
	LINE "<form name=""form"" action=""?do=editSave"" method=""post"">"
	LINE "<input name=""ID"" type=""hidden"" value=""" & ChkNum(gqv("id"))&""">"
	LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" border=""0"">"
	LINE "<tr>"
	LINE "<td align=""center"" valign=""middle"">"
	LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" class=""tbl"" id=tbl>"
	LINE "<tr>"
	LINE "<td width=""10%"" align=""center"" height=""30"" colspan=""2"" class=""tbl_top0"">修改广告分类</td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td class=""tbl_head"" align=""right"">栏目名称(英文名):</td>"
	LINE "<td bgcolor=""#ffffff"" width=""75%""><input name=""ADClassNameE"" type=""text"" value=""" & databox(1,0) & """ style=""width:200px;"">&nbsp;<font color=""red"">必填</font></td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td class=""tbl_head"" align=""right"">栏目名称(中文名):</td>"
	LINE "<td bgcolor=""#ffffff"" width=""75%""><input name=""ADClassName"" type=""text"" value=""" & databox(2,0) & """ style=""width:200px;"">&nbsp;<font color=""red"">必填</font></td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td align=""right"" bgcolor=""#ffffff""></td>"
	LINE "<td bgcolor=""#ffffff"">"
	LINE "<input name=""submit1"" type=""submit"" value=""保存修改"" onclick=""this.disabled=true;document.form.submit();"">&nbsp;"
	LINE "<input name=""submit2"" type=""reset""  value=""重新填写"">&nbsp;"
	LINE "<input name=""submit3"" type=""button"" value=""返回"" onclick=""window.history.back();"">"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "</form>"
	databox = ""
end sub%>
<% LOADING_ADMIN_FOOT %>
