<!--#include file="admin_start.asp"-->
<%
dim id
dim ids
dim grade

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

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

select case request("action")
case "delete"
	if ids="" then
		MySys.error.info="请选择你要删除的用户类型！"
		MySys.error.location="back"
		MySys.error.err()
	else

		rs.open "select sort_name from jins_customer_sort  where sort_id="&ids&" and sort_name<>'guest' ",conn,1,3
	    if not rs.eof then
			conn.execute("delete from jins_object_list where object_print='temp_detail_goods_detailinfo_price' and  object_name='"&rs("sort_name")&"' ")
			if MySys.check.dbnameSearch("jins_goods_list","goods_price_"&rs("sort_name")) then conn.execute("ALTER TABLE jins_goods_list drop COLUMN goods_price_"&rs("sort_name")&" ")
			'if MySys.check.dbnameSearch("jins_goods_list","price_"&rs("sort_name")) then conn.execute("ALTER TABLE jins_goods_price drop COLUMN price_"&rs("sort_name")&" ")
			if MySys.check.dbnameSearch("jins_goods_price","price_"&rs("sort_name")) then conn.execute("ALTER TABLE jins_goods_price drop COLUMN price_"&rs("sort_name")&" ")
			rs.close
			conn.execute("delete from jins_customer_sort where sort_id ="&ids&" ")
			conn.execute("delete from jins_customer_list where sort_id ="&ids&" ")
		end if

		MySys.error.info="删除用户类型成功！"
		MySys.error.location="back"
		MySys.error.suc()
	end if
	
case else

	if request("action")="add" then
	    sql="select * from jins_customer_sort "
	else
	    sql="select * from jins_customer_sort  where sort_id="&id&""
	end if
	
	rs.open sql,conn,1,3
	
	'/////////////////////////////////////////////检测
	
	if request("action")="edit" and rs.eof then
		MySys.error.info="您选择的项目不存在！"
		MySys.error.location="back"
		MySys.error.err()
	end if
	
	if request("sort_description")="" or request.form("sort_update_admin")="" or request.form("sort_open")="" or request.form("sort_grade")="" or request.form("sort_count")="" or (request("action")="add" and request.form("sort_name")="") then
		MySys.error.info="请完整填写相关项目！"
		MySys.error.location="back"
		MySys.error.err()
	end if
		
	'/////////////////////////////////////////////
	if request("action")="add" then
		conn.execute("ALTER TABLE jins_goods_list ADD goods_price_"&trim(request.form("sort_name"))&" money ")
		conn.execute("ALTER TABLE jins_goods_price ADD price_"&trim(request.form("sort_name"))&" money  ")
	    MySys.error.info="用户类型加入成功！"
	    rs.addnew
		rs("sort_reg_property")=""	
		rs("sort_reg_now")=0	
		rs("sort_limit_reg")=0	
		rs("sort_limit_day")=0	
		rs("sort_up")=0	
		rs("sort_num")=0	
	    rs("sort_name")=request.form("sort_name")	
	else
	    MySys.error.info="用户类型编辑成功！"
	end if
	
	rs("sort_description")=request.form("sort_description")	
	rs("sort_grade")=request.form("sort_grade")	
	rs("sort_open")=int(request.form("sort_open"))	
	rs("sort_reg_pact")=request.form("sort_reg_pact")	
	if request.form("sort_limit_customers")<>"" then  rs("sort_limit_customers")=int(request.form("sort_limit_customers"))
	if request.form("sort_limit_ip")<>"" then  rs("sort_limit_ip")=int(request.form("sort_limit_ip"))	
	rs("sort_mail_topic")=request.form("sort_mail_topic")	
	rs("sort_mail_content")=request.form("sort_mail_content")	
	rs("sort_mail_open")=int(request.form("sort_mail_open"))	
	if request.form("sort_exchangetocount")<>"" then  rs("sort_exchangetocount")=int(request.form("sort_exchangetocount"))	
	if request.form("sort_count")<>"" then  rs("sort_count")=int(request.form("sort_count"))	
	if request.form("sort_update_admin")<>"" then  rs("sort_update_admin")=int(request.form("sort_update_admin"))	
	rs("sort_premium_deliverfee")=request.form("sort_premium_deliverfee")
	rs("sort_premium_price")=request.form("sort_premium_price")

	rs.update
	rs.close
	
	if request("action")="add" then
		rs.open "select * from jins_object_list ",conn,1,3
		rs.addnew
		'rs("object_show")=	
		'rs("object_id")=	
		rs("object_up")=232
		rs("object_num")=request.form("sort_grade")
		rs("object_print")="temp_detail_goods_detailinfo_price"
		rs("object_num_temp")=request.form("sort_grade")
		rs("object_customer_grade")=">=|"&request.form("sort_grade")&"|0"
		rs("object_description")=request.form("sort_description")	
		rs("object_style_default")=	1
		rs("object_qu")=-1
		rs("object_class")="object"
		rs("object_name")=request.form("sort_name")
		rs("object_argument")=request.form("sort_grade")
		rs("object_open_temp")=	1
		rs("object_open")=	1
		'rs("object_template")="	
		rs("object_ads")=	0
		rs("object_insert")= 0
		rs.update
		rs.close
	end if

	MySys.error.location="admin/admin_user_customer_sort.asp"
	MySys.error.suc()

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