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

<%
dim id
dim ids
dim grade
dim s

id=request("id")
ids=request("ids")
ids=replace(ids," ","")

if not MySys.check.isInteger(id) and request("action")<>"delete" and  request("action")<>"add" then
MySys.error.info="请选择您要操作的项目！"
MySys.error.location="back"
MySys.error.err()
end if

set s = MySys.temp.search
select case request("action")
case "delete"

	dim i
	if ids="" then
		MySys.error.info="请选择你要删除的公共标签！"
		MySys.error.location="back"
		MySys.error.err()
	end if

	ids=split(ids,",")
	
	for i=0 to ubound(ids)
	
		s.sort_ids=""
		s.Sort_search "jins_template_label_sort",ids(i) ,""
		if s.sort_ids="" then s.sort_ids=","
		s.sort_ids=right(s.sort_ids,len(s.sort_ids)-1)
		conn.execute("delete from jins_template_label_sort where sort_id in ("&s.sort_ids&") ")
		
	next
	
	set s=nothing

	MySys.error.info="删除公共标签成功！"
	MySys.error.location="back"
	MySys.error.suc()
	
case "add"
	sql="select * from jins_template_label_sort "
	rs.open sql,conn,1,3
	
	if request("sort_up")<>0 and conn.execute("select sort_id from jins_template_label_sort where sort_id="&request("sort_up")&" ").eof then
		MySys.error.info="您加入的公共标签的上级分类不存在！"
		MySys.error.location="back"
		MySys.error.err()
	end if
	
	if request.form("sort_name")="" or request.form("sort_type")="" then
		MySys.error.info="请完整填写相关项目！"
		MySys.error.location="back"
		MySys.error.err()
	end if
	
	if request.form("sort_type")-1=0 and  request.form("sort_source")="" then
		MySys.error.info="您选择的是过程型的标签，请在源码一栏中填写过程代码！"
		MySys.error.location="back"
		MySys.error.err()
	end if
	
	rs.addnew
	rs("sort_description")=replace(request("sort_description"),"""","&quot;")	
	rs("sort_content")=request("sort_content")
	rs("sort_up")=request("sort_up")
	rs("sort_num")=0	
	rs("sort_name")=request("sort_name")	
	rs("sort_type")=request("sort_type")	
	rs("sort_addtime")=request("sort_addtime")	
	rs("label_link")=int(request("label_link"))
	if request("sort_source")=""  then rs("sort_source")=request("sort_name") else rs("sort_source")=request("sort_source")
	rs.update
	rs.close
    MySys.error.info="公共标签添加成功！"
	MySys.error.location="admin/admin_template_label_sort.asp?id="&request("sort_up")
	MySys.error.suc()

case "edit"
	    
	sql="select * from jins_template_label_sort where sort_id="&id&""
	rs.open sql,conn,1,3
	
	'/////////////////////////////////////////////检测
	
	if rs.eof then
		MySys.error.info="您选择的项目不存在！"
		MySys.error.location="back"
		MySys.error.err()
	end if
	
	if request.form("sort_name")="" or request.form("sort_type")="" then
		MySys.error.info="请完整填写相关项目！"
		MySys.error.location="back"
		MySys.error.err()
	end if
		
	if request.form("sort_type")-1=0 and  request.form("sort_source")="" then
		MySys.error.info="您选择的是过程型的标签，请在源码一栏中填写过程代码！"
		MySys.error.location="back"
		MySys.error.err()
	end if
	
	'/////////////////////////////////////////////
	
	rs("sort_description")=replace(request("sort_description"),"""","&quot;")	
	rs("sort_content")=request("sort_content")
	rs("sort_up")=request("sort_up")
	rs("sort_num")=0	
	rs("sort_name")=replace(request("sort_name"),"""","&quot;")	
	rs("sort_type")=request("sort_type")	
	rs("sort_addtime")=request("sort_addtime")	
	rs("label_link")=int(request("label_link"))
	if request("sort_source")="" then rs("sort_source")=request("sort_name") else rs("sort_source")=request("sort_source")
	rs.update
	rs.close
    MySys.error.info="公共标签编辑成功！"
	MySys.error.location="admin/admin_template_label_sort.asp?id="&request("sort_up")
	MySys.error.suc()

	
end select
%>
<!--#include file="admin_end.asp"-->
