<!--#include file="base.asp"-->
<%
''' EYCMS 文章分类
''' ==================================================================

	sub adddb()
		dim t0,t1,t2,t3,t4
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.getint(eycms.fpost("t4",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "类别名称不能为空",0:exit sub
		dim data:data=array(array("catename",t0,50),array("catekey",t1,255),array("catedesc",t2,255),array("cateskin",t3,50),array("ordnum",t4,10))
		if eycms.db.dbnew("wx_master_cate",data,"catename='"&t0&"'")=0 then
			eycms.ajaxjson "类别名称已存在，请更换",0
		else
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub editdb()
		dim t0,t1,t2,t3,t4
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.getint(eycms.fpost("t4",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "类别名称不能为空",0:exit sub
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		dim data:data=array(array("catename",t0,50,1),array("catekey",t1,255,1),array("catedesc",t2,255,1),array("cateskin",t3,50,1),array("ordnum",t4,10,0))
		if eycms.db.dbupdate("wx_master_cate","cateid="&id&"",data)=1 then
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub deldb()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		eycms.db.dbupdate "wx_master","cid="&id&"",array(array("cid",0,10,0))
		eycms.db.dbdel "wx_master_cate","cateid="&id
		eycms.echo "1"
	end sub

	sub orderdb()
		dim t0,t1,t2,t3,i
		t0=eycms.enhtml(eycms.fpost("ordnum",0))
		t1=eycms.enhtml(eycms.fpost("cid",0))
		t2=split(t0,", ")
		t3=split(t1,", ")
		if ubound(t2)-ubound(t3)<>0 then eycms.ajaxjson "0&#21442;&#25968;&#38169;&#35823;",0:exit sub
		for i=0 to ubound(t2)
			if eycms.isnum(t2(i)) then
				eycms.db.dbupdate "wx_master_cate","cateid="&t3(i)&"",array(array("ordnum",t2(i),10,0,0))
			end if
		next
		eycms.ajaxjson "保存成功",1
	end sub

	islogin
	checkpagelever 67
	dim act:act=lcase(eycms.fget("act",0))
	dim id:id=eycms.getint(eycms.fget("id",0),0)
	select case act
		case "add":load theme_master_cate_add
		case "adddb":adddb
		case "edit"
			dim rsshow
			set rsshow=eycms.db.exedb("select top 1 * from wx_master_cate where cateid="&id&"")
			if rsshow.eof then
				eycms.echo "参数错误":eycms.die
			end if
			load theme_master_cate_edit
		case "editdb":editdb
		case "del":deldb
		case "order":orderdb
		case else:load theme_master_cate
	end select
	eycms.db.dbclose
%>