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

id=request("id")
ids=request("ids")
ids=replace(ids," ","")
n_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
	    set rs_t=conn.execute("select customer_reg_name from jins_customer_list where customer_id in ("&ids&") and customer_reg_name<>'guest' ")
		do while not rs_t.eof 
		    n_ids=n_ids&"'"&rs_t("customer_reg_name")&"',"
		rs_t.movenext
		loop
		set rs_t=nothing
		
		if n_ids<>"" then 
			n_ids=left(n_ids,len(n_ids)-1)
			conn.execute("delete from jins_customer_order_list where customer_name in ("&n_ids&") ")
			conn.execute("delete from jins_customer_count_list where customer_name in ("&n_ids&") ")
			conn.execute("delete from jins_customer_consume_list where customer_name in ("&n_ids&") ")
			conn.execute("delete from jins_customer_wishlist_list where customer_name in ("&n_ids&") ")
		end if

		conn.execute("delete from jins_customer_list where customer_id in ("&ids&") and customer_reg_name<>'guest' ")
		
		MySys.error.info="删除用户成功！"
		MySys.error.location="back"
		MySys.error.suc()
	end if
	
case "edit"

	sql="select * from jins_customer_list  where customer_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("customer_open")="" or rs("customer_reg_admin")="" then
		MySys.error.info="请完整填写相关项目！"
		MySys.error.location="back"
		MySys.error.err()
	end if
		
	'/////////////////////////////////////////////
	
	MySys.error.info="用户资料编辑成功！"
	
	
	rs("sort_id")=int(request.form("sort_id"))
	rs("customer_open")=int(request.form("customer_open"))
	rs("customer_reg_admin")=int(request.form("customer_reg_admin"))
	'rs("customer_reg_name")=request.form("customer_reg_name")
	rs("customer_reg_email")=request.form("customer_reg_email")
	rs("customer_reg_password_verify_question")=request.form("customer_reg_Password_verify_question")
	if request.form("customer_reg_Password_verify_answer")<>"" then rs("customer_reg_password_verify_answer")=MySys.functions.EncodeMd5(request.form("customer_reg_Password_verify_answer"),16)
	'rs("customer_reg_Password")=request.form("customer_reg_Password")
	rs("customer_reg_realname")=request.form("customer_reg_realname")
	rs("customer_reg_sex")=int(request.form("customer_reg_sex"))
	rs("customer_reg_addtime")=request.form("customer_reg_addtime")
	rs("customer_reg_address")=request.form("customer_reg_address")
	rs("customer_reg_postcode")=request.form("customer_reg_postcode")
	rs("customer_reg_telnumber")=request.form("customer_reg_telnumber")
	rs("customer_reg_qqnumber")=request.form("customer_reg_qqnumber")
	rs("customer_reg_property")=request.form("customer_reg_property")
	rs("customer_reg_age")=int(request.form("customer_reg_age"))
	'rs("customer_login_time")=int(request.form("customer_login_time"))
	'rs("customer_login_date_last")=request.form("customer_login_date_last")
	'rs("customer_login_ip_last")=request.form("customer_login_ip_last")
	rs("customer_login_ip_lock")=int(request.form("customer_login_ip_lock"))
	'rs("customer_login_ip_locked")=request.form("customer_login_ip_locked")

	rs.update
	
	if instr(1,rs("customer_reg_name"),"?_")>0 and request.form("customer_reg_admin")=1 then
	
		conn.execute("update jins_customer_list set sort_id="&rs("sort_id")&" where customer_reg_name='"&replace(rs("customer_reg_name"),"?_","")&"' ")
		conn.execute("delete from jins_customer_list where customer_id="&rs("customer_id")&" ")

	end if
	
	rs.close
	MySys.error.location="back"
	MySys.error.suc()

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