<!--#include file="conn.asp"-->
<!--#include file="inc/cookies_check.asp"-->
<!--#include file="../include/Lebi_md5.asp"-->
<!--#include file="../include/Lebi_Config.asp"-->
<%
'*****************************************
'* 软件名称 乐彼网上开店软件(56770 EShop)
'* 软件开发 http://www.56770.com
'* 版权所有 http://www.56770.com
'* 文件名称 Admin_user_grade.asp
'* 最后更新 2013-03-28 by 56770.kingdge
'*****************************************
admin_flag=",4.3,"
include "lang/"& LangFilePath &"/lang_sys.inc"
include "lang/"& LangFilePath &"/lang_menu.inc"
include "lang/"& LangFilePath &"/lang_user.inc"
CurrentId = 3
CurrentUrl = "admin_user_grade.asp"
LB_Head()
LB_Menu()
id = CheckNum(request("id"),0)
action = request("action")
%>
<div class="tabmenu mainwidth">
      <ul>
        <li <%If action <> "add" And action <> "grade_ico" Then Response.Write("class=""current""") End If%>><a href="admin_user_grade.asp"><span><%=Lang_Menu(107)%></span></a></li>
        <li <%If action = "grade_ico" Then Response.Write("class=""current""") End If%>><a href="?action=grade_ico"><span><%=Lang_Menu(109)%></span></a></li>
		<%If id <> 0 Then%>
        <li <%If action = "add" Then Response.Write("class=""current""") End If%>><a href="?action=add&id=<%=id%>"><span><%=Lang_User(101)%></span></a></li>
		<%Else%>
        <li <%If action = "add" Then Response.Write("class=""current""") End If%>><a href="?action=add"><span><%=Lang_Menu(108)%></span></a></li>
		<%End If%>
      </ul>
</div>
<%
Response.Write("<div class=""tab-mainbody"">")
Response.Write("<div class=""tab-mainbody2"">")
If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
		adminflag()
		response.End
End If
If OutSubmit = 1 Then CheckOutSubmit()
Select Case action
		Case "del" : del()
		Case "add" : add()
		Case "add_ok" : add_ok()
		Case "up" : up()
		Case "down" : down()
		Case "grade_ico" : gradeIco()
		Case "updateGradeIco" :updateGradeIco()
		Case Else
			list()
End Select
Response.Write("</div>")
Response.Write("</div>")
LB_Footer()

Sub updateGradeIco()
        If OnlyRead = 1 Then OnlyReadMessage()
		icoStr=safereplace(request("grade_ico"))
		if icoStr="" then
				response.write"<SCRIPT language=JavaScript>alert('"& Lang_sys(70) &"');javascript:history.go(-1)</SCRIPT>"
				response.end
		end If
		Dim icoArr:icoArr = Split(icoStr,",")
		for i=0 to ubound(icoArr)
			If Trim(icoArr(i))<> "" Then
				sql="update [Lebi_user_grade] set grade_ico = '"&Trim(icoArr(i))&"' where grade_dj="&i+1
				conn.execute(sql)
			End If
		Next
		If Config_Lebi_Eshop(17)="1" Then
				Application.Contents.RemoveAll
		End If
		ManageLog Lang_User(84)
		Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,"?action=grade_ico",0,0,2,1)
End Sub

Sub up()
        If OnlyRead = 1 Then OnlyReadMessage()
		olddj = Clng(request("dj"))
		newdj = olddj - 1
		If olddj > 1 Then
			sql  = "select id,grade_dj from [Lebi_user_grade] where grade_dj = "& olddj
			Set rs=Server.CreateObject("ADODB.RecordSet")
			rs.open sql, conn, 1, 3
			If not rs.eof Then
				conn.execute("update [Lebi_user_grade] set grade_dj = "&olddj&" where grade_dj = " & newdj)
				rs("grade_dj") = newdj
				rs.update
			End If
			rs.close : Set rs = Nothing
		End If
		If Config_Lebi_Eshop(17)="1" Then
				Application.Contents.RemoveAll
		End If
		ManageLog Lang_User(85)
		response.redirect("?")
		response.End
End Sub

Sub down()
        If OnlyRead = 1 Then OnlyReadMessage()
		olddj = Clng(request("dj"))
		newdj = olddj + 1
		If olddj > 0 Then
			sql  = "select id,grade_dj from [Lebi_user_grade] where grade_dj = "& newdj
			Set rs=Server.CreateObject("ADODB.RecordSet")
			rs.open sql, conn, 1, 3
			If not rs.eof Then
				conn.execute("update [Lebi_user_grade] set grade_dj = "&newdj&" where grade_dj = " & olddj)
				rs("grade_dj") = olddj
				rs.update
			End If
			rs.close : Set rs = Nothing
		End If
		If Config_Lebi_Eshop(17)="1" Then
				Application.Contents.RemoveAll
		End If
		ManageLog Lang_User(86)
		response.redirect("?")
		response.End
End Sub

Sub list()
	%>
	<table width="100%" border="0" cellspacing="0" cellpadding="0" id="list" class="classtable">
	<thead>
	<tr>
	<td height="30" align="left" colspan="2" class="classhead">&nbsp;</td>
	<td height="30" align="right" colspan="6" class="classhead">
	<%=QuickMenu("Admin_user_account.asp|"& Lang_Menu(106) &"","Admin_user_grade.asp?action=grade_ico|"& Lang_Menu(109) &"")%>
	</td>
	</tr>
	<tr>
	<!--td class="classtop" height="30" width="5%">选择</td-->
	<td class="classtop" height="30" width="15%"><%=Lang_User(87)%></td>
	<td class="classtop" width="10%"><%=Lang_User(88)%></td>
	<td class="classtop" width="25%"><%=Lang_User(89)%></td>
	<td class="classtop" width="10%"><%=Lang_User(90)%></td>
	<td class="classtop" width="10%"><%=Lang_User(91)%></td>
	<td class="classtop" width="10%"><%=Lang_User(92)%></td>
	<td class="classtop" width="10%"><%=Lang_User(93)%></td>
	<td class="classtop" width="10%"><%=Lang_User(53)%></td>
	</tr>
	</thead>
	<%
	'sql="select id,grade_name,grade_dj,price_qx,price_txt,discount,gw_jifen from [Lebi_user_grade] order by id"
	sql="select id,grade_name,grade_dj,price_qx,price_txt,discount,gw_jifen from [Lebi_user_grade] order by grade_dj"
	Set rs = conn.execute(sql)
	if rs.eof then
			Response.Write("<tr>")
			Response.Write("<td colspan=""8"" height=""50"" align=""center"" class=classrow>"& Lang_User(94) &"</td>")
			Response.Write("</tr>")
	else
	do while not rs.eof
		userCount = conn.execute("select count(id) from [Lebi_user] where user_grade = "&rs("grade_dj")&"")(0)
		If IsNull(userCount) Or userCount = "" Then userCount = 0
		If rs("grade_dj") = 0 Then
			'checkboxstr = "&nbsp;"
			gradenameurl = "#"
			Change_order_up = "&nbsp;&nbsp;&nbsp;&nbsp;"
			Change_order_down = "&nbsp;&nbsp;&nbsp;&nbsp;"
			delstr = "&nbsp;&nbsp;&nbsp;&nbsp;"
		Else
			'checkboxstr = "<input name=""id"" type=""checkbox"" value="""&rs("id")&""" title=""ID:"&rs("id")&""">"
			gradenameurl = "admin_user.asp?user_grade="&rs("grade_dj")&" "
			Change_order_up = "<input type=image name=""up"" title=""↑"" onClick=""location.href='?action=up&dj="&rs("grade_dj")&"';return false;"" src=images/icon_up.gif align=absmiddle>"
			Change_order_down = "<input type=image name=""down"" title=""↓"" onClick=""location.href='?action=down&dj="&rs("grade_dj")&"';return false;"" src=images/icon_down.gif align=absmiddle>"
			delstr = "<a onClick=""return ConfirmDelGrade();"" href=""?action=del&dj="&rs("grade_dj")&"""><img src=""images/icon_del.gif"" width=""16"" height=""16"" title="" "& Lang_sys(15) &" "" border=""0""></a>"
		End If
	%>
	<tr class="classrow">
	<!--td height="30" class="classrow"><%=checkboxstr%><INPUT TYPE="hidden" NAME="l_type"><INPUT TYPE="hidden" NAME="page"></td-->
	<td height="30" class="classrow"><A HREF="<%=gradenameurl%>"><%=rs("grade_name")%></A></td>
	<td class="classrow"><INPUT TYPE="text" NAME="p_order" id="p_order" style="width:15px" value="<%=rs("grade_dj")%>" onkeyup="value=value.replace(/[^\d\.]/g,'');" maxlength=3 readonly class="form">&nbsp;<%=Change_order_up%>&nbsp;<%=Change_order_down%></td>
	<td class="classrow"><%=getPriceQxName(rs("price_qx"))%></td>
	<td class="classrow"><%=rs("price_txt")%></td>
	<td class="classrow"><%=formatnumber2(rs("discount"))%></td>
	<td class="classrow"><%=formatnumber2(rs("gw_jifen"))%></td>
	<td class="classrow"><A HREF="<%=gradenameurl%>"><%=userCount%></a></td>
	<td class="classrow"><a href="?action=add&id=<%=rs("id")%>"><img src="images/icon_edit.gif" width="16" height="16" border="0" title="<%=Lang_sys(51)%>"></a>&nbsp;&nbsp;<%=delstr%></td>
	</tr>
	<%
	rs.movenext
			loop
	end if
	rs.close:set rs=nothing
	%>
	</tbody>
	</table>
	<script>tdshow("list");</script>
	<%
End Sub

Sub gradeIco()
	%>
	<script language="javascript" src="Upfile/js/Upload_Other.js"></script>
	<table width="100%" border="0" cellspacing="0" cellpadding="0" id="list" class="classtable">
	<FORM METHOD="POST" ACTION="?action=updateGradeIco" name="grade">
	<thead>
	<tr>
	<td height="30" colspan="3" class="classhead"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle"></td>
	<td height="30" align="right" class="classhead">
	<%=QuickMenu("admin_user_grade.asp|"& Lang_Menu(107) &"","Admin_user_grade.asp?action=add|"& Lang_Menu(108) &"")%>
	</td>
	</tr>
	<tr>
	<!--td class="classtop" height="30" width="5%" align="center">选择</td-->
	<td class="classtop" height="30" width="15%"><%=Lang_User(87)%></td>
	<td class="classtop" width="10%"><%=Lang_User(95)%></td>
	<td class="classtop" width="15%"><%=Lang_User(96)%></td>
	<td class="classtop" width="60%"><%=Lang_User(97)%></td>
	</tr>
	</thead>
	<%
	'sql="select id,grade_name,grade_dj,price_qx,price_txt,discount,gw_jifen from [Lebi_user_grade] order by id"
	sql="select grade_name,grade_dj,grade_ico from [Lebi_user_grade] where grade_dj <> 0 order by grade_dj"
			Set rs=Server.CreateObject("ADODB.RecordSet")
			rs.open sql, conn, 1, 1
			if rs.eof then
					Response.Write("<tr class=""classrow"">")
					Response.Write("<td colspan=""4"" height=""50"" align=""center"" class=""classrow"">"& Lang_User(94) &"</td>")
					Response.Write("</tr>")
			Else
	Dim i:i=0
	do while not rs.eof
	%>
	<tr class="classrow">
	<td height="30" class="classrow"><%=rs("grade_name")%></td>
	<td class="classrow"><%=rs("grade_dj")%></td>
	<td class="classrow"><IMG SRC="../<%=rs("grade_ico")%>" name="gico" id="gico" BORDER="0" title=""></td>
	<td class="classrow"><input type="text" name="grade_ico" id="grade_ico<%=i%>" size="30" value="<%=rs("grade_ico")%>" class="form">&nbsp;<input type="button" id="Upload_grade_ico<%=i%>" name="Submit" value="<%=Lang_sys(52)%>" onclick="uploadpanel('grade','grade_ico<%=i%>','grade')" class="btn_upload"></td>
	</tr>
	<%
		i = i+1
	rs.movenext
			loop
	%>
	<tfoot>
	<tr>
	<td height="30" class="classfooter" align="left" colspan="4"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle"></td>
	</tr>
	</tfoot>
	<%
	end if
	rs.close:set rs=nothing
	%>
	</tbody>
	</FORM>
	</table>
	<script>tdshow("list");</script>
	<%
End Sub

Sub add_ok()
		If OnlyRead = 1 Then OnlyReadMessage()
		id = CheckNum(request("id"),0)
        grade_name=Safereplace(trim(request("grade_name")))
        grade_dj=CheckNum(request("grade_dj"),0)
        price_qx=Safereplace(trim(request("price_qx")))
		price_qx=","&Replace(price_qx," ","")&","
        price_txt=Safereplace(trim(request("price_txt")))
        discount=CheckNum(request("discount"),0)
        gw_jifen=CheckNum(request("gw_jifen"),0)
        is_jifen_zh=CheckNum(request("is_jifen_zh"),0)
        jifen_zh=Safereplace(trim(request("jifen_zh")))
		is_auto_upgrade=CheckNum(request("is_auto_upgrade"),0)
		upgrade_jifen=CheckNum(request("upgrade_jifen"),0)
		is_del_jifen=CheckNum(request("is_del_jifen"),0)
		is_auto_degrade=CheckNum(request("is_auto_degrade"),0)
		auto_degrade_days=CheckNum(request("auto_degrade_days"),0)
		auto_degrade_cash=CheckNum(request("auto_degrade_cash"),0)
		is_buy=CheckNum(request("is_buy"),0)
		is_fav=CheckNum(request("is_fav"),0)
		is_plsh=CheckNum(request("is_plsh"),0)
		login_jifen=CheckNum(request("login_jifen"),0)
		login_del_jifen=CheckNum(request("login_del_jifen"),0)
		accounts_jifen=CheckNum(request("accounts_jifen"),0)
		accounts_cash=CheckNum(request("accounts_cash"),0)
		is_advance_booking=CheckNum(request("is_advance_booking"),0)
		is_advance=CheckNum(request("is_advance"),0)
		advance_percent=CheckNum(request("advance_percent"),0)
		lowprice=CheckNum(request("lowprice"),0)
		is_auto_accounts=CheckNum(request("is_auto_accounts"),0)
		grade_ico=safereplace(request("grade_ico"))
		If grade_ico="" Then grade_ico = "images/grade/"&grade_dj&".gif"
		If grade_dj = "0" Then is_fav = 0
		fav_qty=CheckNum(request("fav_qty"),0)
		If id <> 0 Then
			set rs=server.CreateObject("adodb.recordset")
			rs.open "select * from [Lebi_user_grade] where id="& id, conn, 1, 3
			If Not rs.eof Then
				For LangT = 1 To TotalLang
						rs("grade_name" & LanguageTxt(LangT))=safereplace(request("grade_name" & LanguageTxt(LangT)))
						rs("price_txt" & LanguageTxt(LangT))=safereplace(request("price_txt" & LanguageTxt(LangT)))
				Next
				rs("grade_dj")=grade_dj
				rs("price_qx")=price_qx
				rs("discount")=discount
				rs("gw_jifen")=gw_jifen
				rs("is_jifen_zh")=is_jifen_zh
				rs("jifen_zh")=jifen_zh
				rs("is_auto_upgrade")=is_auto_upgrade
				rs("upgrade_jifen")=upgrade_jifen
				rs("is_del_jifen")=is_del_jifen
				rs("is_auto_degrade")=is_auto_degrade
				rs("auto_degrade_days")=auto_degrade_days
				rs("auto_degrade_cash")=auto_degrade_cash
				rs("is_buy")=is_buy
				rs("is_fav")=is_fav
				rs("is_plsh")=is_plsh
				rs("login_jifen")=login_jifen
				rs("login_del_jifen")=login_del_jifen
				rs("accounts_jifen")=accounts_jifen
				rs("accounts_cash")=accounts_cash
				rs("is_advance_booking")=is_advance_booking
				rs("is_advance")=is_advance
				rs("advance_percent")=advance_percent
				rs("lowprice")=lowprice
				rs("is_auto_accounts")=is_auto_accounts
				rs("grade_ico")=grade_ico
				rs("fav_qty")=fav_qty
				rs.update
			End If
			rs.close : Set rs = Nothing 
			ManageLog Lang_User(98) &" ["&grade_name&"]"
			If Config_Lebi_Eshop(17)="1" Then
					Application.Contents.RemoveAll
			End If
			Call Up_mes(Lang_sys(48),"·"& Lang_sys(47),0,"?",0,0,2,1)
		Else
			set rs=server.CreateObject("adodb.recordset")
			rs.open "select * from [Lebi_user_grade]", conn, 1, 3
			rs.addnew
				For LangT = 1 To TotalLang
						rs("grade_name" & LanguageTxt(LangT))=safereplace(request("grade_name" & LanguageTxt(LangT)))
						rs("price_txt" & LanguageTxt(LangT))=safereplace(request("price_txt" & LanguageTxt(LangT)))
				Next
				rs("grade_dj")=grade_dj
				rs("price_qx")=price_qx
				rs("discount")=discount
				rs("gw_jifen")=gw_jifen
				rs("is_jifen_zh")=is_jifen_zh
				rs("jifen_zh")=jifen_zh
				rs("is_auto_upgrade")=is_auto_upgrade
				rs("upgrade_jifen")=upgrade_jifen
				rs("is_del_jifen")=is_del_jifen
				rs("is_auto_degrade")=is_auto_degrade
				rs("auto_degrade_days")=auto_degrade_days
				rs("auto_degrade_cash")=auto_degrade_cash
				rs("is_buy")=is_buy
				rs("is_fav")=is_fav
				rs("is_plsh")=is_plsh
				rs("login_jifen")=login_jifen
				rs("login_del_jifen")=login_del_jifen
				rs("accounts_jifen")=accounts_jifen
				rs("accounts_cash")=accounts_cash
				rs("is_advance_booking")=is_advance_booking
				rs("is_advance")=is_advance
				rs("advance_percent")=advance_percent
				rs("lowprice")=lowprice
				rs("is_auto_accounts")=is_auto_accounts
				rs("grade_ico")=grade_ico
				rs("fav_qty")=fav_qty
			rs.update
			rs.close : Set rs = Nothing 
			If savepricetype = 0 Then	
				Set rs = conn.execute("select id,sprice from [lebi_product]")
				Do While Not rs.eof
					conn.execute("insert into [Lebi_product_price] (product_id,grade_id,price)values("&rs(0)&","&grade_dj&","&FormatNumber2(rs(1)*discount)&")")
				rs.movenext 
				Loop
				rs.close : Set rs = Nothing 
			ElseIf savepricetype = 1 Then 
				Set rs = conn.execute("select p.id,s.price from [lebi_product] as p,[Lebi_product_price] as s where p.id = s.product_id and s.grade_id = "&grade_dj - 1&"")
				Do While Not rs.eof
					conn.execute("insert into [Lebi_product_price] (product_id,grade_id,price)values("&rs(0)&","&grade_dj&","&rs(1)&")")
				rs.movenext 
				Loop
				rs.close : Set rs = Nothing 
			End If 
			If Config_Lebi_Eshop(17)="1" Then
					Application.Contents.RemoveAll
			End If
			ManageLog Lang_User(99) &" ["&grade_name&"]"
			Call Up_mes(Lang_sys(45),"·"& Lang_sys(44),0,"?",0,0,2,1)
		End If
End Sub

Sub add()
		id = CheckNum(request("id"),0)
		If id <> 0 Then
			sql = "select * from [Lebi_user_grade] where id = "& id
			set Rs = conn.execute(Sql)
			If not rs.eof Then
				grade_name = rs("grade_name")
				grade_dj = rs("grade_dj")
				price_qx = rs("price_qx")
				price_txt = rs("price_txt")
				discount = rs("discount")
				gw_jifen = rs("gw_jifen")
				is_jifen_zh = rs("is_jifen_zh")
				jifen_zh = rs("jifen_zh")
				is_auto_upgrade = rs("is_auto_upgrade")
				upgrade_jifen = rs("upgrade_jifen")
				is_del_jifen = rs("is_del_jifen")
				is_auto_degrade = rs("is_auto_degrade")
				auto_degrade_days = rs("auto_degrade_days")
				auto_degrade_cash = rs("auto_degrade_cash")
				is_buy = rs("is_buy")
				is_fav = rs("is_fav")
				is_plsh = rs("is_plsh")
				login_jifen = rs("login_jifen")
				login_del_jifen = rs("login_del_jifen")
				accounts_jifen = rs("accounts_jifen")
				accounts_cash = rs("accounts_cash")
				is_advance_booking = rs("is_advance_booking")
				is_advance = rs("is_advance")
				advance_percent = rs("advance_percent")
				lowprice = rs("lowprice")
				is_auto_accounts = rs("is_auto_accounts")
				grade_ico = rs("grade_ico")
				fav_qty = rs("fav_qty")
			End If
			rs.close:set rs=nothing
		Else
			upgrade_jifen = "200"
			grade_dj = 1
			price_qx = ""
			discount = "0.9"
			gw_jifen = "1.00"
			is_jifen_zh = 0
			jifen_zh = "0.1"
			is_auto_upgrade = 0
			is_del_jifen = 1
			is_auto_degrade = 0
			auto_degrade_days = 180
			auto_degrade_cash = 2000
			is_buy = 1
			is_fav = 1
			is_plsh = 1
			login_jifen = 0
			login_del_jifen = 0
			accounts_jifen = 300
			accounts_cash = 300
			is_advance_booking = 0
			is_advance = 0
			advance_percent = 0.2
			lowprice = 0
			is_auto_accounts = 0
			fav_qty = 20
			set Rs = conn.execute("select Max(grade_dj) from [Lebi_user_grade] ")
			If not rs.eof Then grade_dj = rs(0)+1 End If
			rs.close:Set rs = Nothing
		End If
		If Trim(grade_ico) = "" Or IsNull(grade_ico) Then grade_ico = "pic/grade/level"&grade_dj&".gif"
%>
		<script language="javascript">
		function CheckForm()
		{
			if (CheckEmpty('grade_name<%= LanguageTxt(1) %>')){ShowMessage('grade_name<%= LanguageTxt(1) %>','<%=Lang_User(152)%>');return false;}
			if (CheckEmpty('price_txt<%= LanguageTxt(1) %>')){ShowMessage('price_txt<%= LanguageTxt(1) %>','<%=Lang_User(153)%>');return false;}
		}
		</script>
		<script language="javascript" src="Upfile/js/Upload_Other.js"></script>
       <table width="100%" border="0" cellspacing="0" cellpadding="0" class="classtable">
            <form name="grade" method="post" action="?action=add_ok&id=<%=id%>" onSubmit="return CheckForm();">
            <tr>
              <td class="classhead" height="30" align="left">
                <input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle"></td>
				<td align="right" class="classhead">
				<%=QuickMenu("?action=grade_ico|"& Lang_Menu(109) &"","|")%>
				</td>
           </tr>
            <tr>
              <td class="classtop" colspan="2" height="30">
			  <%
			  If id <> 0 Then
				response.write Lang_User(101)
			  Else
				response.write Lang_User(100)
			  End If
			  %></td>
           </tr>
<tr>
<td class="classbg" colspan="2">
<ul id="tablist">
   <%For LangT = 1 To TotalLang%>
   <li<%If LangT = 1 Then response.write(" class=""selected""") End If%>><a rel="tcontent<%= LangT %>" style="CURSOR:hand;"><%= LanguageName(LangT) %></a></li>
   <%Next%>
</ul>
<div id="tabcontentcontainer">
<%
For LangT = 1 To TotalLang
If id <> 0 Then
		sql = "select grade_name"& LanguageTxt(LangT)&",price_txt"& LanguageTxt(LangT)&" from [Lebi_user_grade] where id = "& id
		set Rs = conn.execute(Sql)
		If not rs.eof Then
				grade_name = rs(0)
				price_txt = rs(1)
		End If
		rs.close:set rs=Nothing
End If
%>
   <div id="tcontent<%= LangT %>" class="tabcontent">
   <table cellspacing="0" cellpadding="4" width="100%" border="0" id="add_<%= LangT %>">
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_User(102)%></td>
<td class="classrow">
<input type="text" name="grade_name<%= LanguageTxt(LangT) %>" id="grade_name<%= LanguageTxt(LangT) %>" class="form" value="<%=grade_name%>"> <span id="mes_grade_name<%= LanguageTxt(LangT) %>"></span></td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(103)%></td>
<td class="classrow"><input type="text" name="price_txt<%= LanguageTxt(LangT) %>" id="price_txt<%= LanguageTxt(LangT) %>" class="form" value="<%=price_txt%>"> <span id="mes_price_txt<%= LanguageTxt(LangT) %>"></span></td>
</tr>
	</table>
	</div>
	<script>tdshow("add_<%= LangT %>");</script>
<%Next%>
</div>
<script>showtabcontent("tablist")</script>
<ul id="tablistmain">
   <li class="selected"><a rel=""><%=Lang_sys(66)%></a></li>
</ul>
<div id="tabcontentcontainer">
<table cellspacing="0" cellpadding="4" width="100%" border="0" id="add_other">
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_User(32)%></td>
<td class="classrow"><input type="text" name="grade_dj" class="form"  value="<%=grade_dj%>" size="5" readonly/></td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(104)%></td>
<td class="classrow">
<input type="text" name="discount" class="form" value="<%=formatnumber2(discount)%>" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');"></td>
</tr>
<%If id = 0 Then%>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(163)%></td>
<td class="classrow">
<input type="radio" name="savepricetype" value="0" checked><%=Lang_User(164)%>
<input type="radio" name="savepricetype" value="1"><%=Lang_User(165)%></td>
</tr>
<%End If%>
<tr class="classrow">
  <td height="30" class="classrow"><%=Lang_User(105)%></td>
  <td class="classrow"><%=getPriceQx(grade_dj,price_qx)%></td>
</tr>
<tr class="classrow">
  <td height="30" class="classrow"><%=Lang_User(106)%></td>
  <td class="classrow"><input type="text" id="grade_ico" name="grade_ico" size="20" value="<%=grade_ico%>" class="form">&nbsp;<input type="button" id="Upload_grade_ico" name="Submit" value="<%=Lang_sys(52)%>" onclick="uploadpanel('grade','grade_ico','grade')" class="btn_upload"></td>
</tr>
<tr class="classrow">
  <td height="30" class="classrow"><%=Lang_User(107)%></td>
  <td class="classrow"><%=Lang_User(108)%>  <input type="text" name="gw_jifen" size="5" value="<%=formatnumber2(gw_jifen)%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');"></td>
</tr>
<tr class="classrow">
  <td height="30" class="classrow"><%=Lang_User(109)%></td>
  <td class="classrow"><input type="radio" value="1" <%if is_jifen_zh=1 then Response.Write"checked"%> name="is_jifen_zh"> <%=Lang_User(111)%>
<input type="radio" value="0" <%if is_jifen_zh=0 then Response.Write "checked"%> name="is_jifen_zh"> <%=Lang_User(112)%>
&nbsp;&nbsp;<%=Lang_User(110)%> <input type="text" name="jifen_zh" size="5" value="<%=formatnumber2(jifen_zh)%>" class="form"></td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(113)%></td>
<td class="classrow"><input type="radio" value="1" <%if is_auto_upgrade=1 then Response.Write"checked"%> name="is_auto_upgrade"> <%=Lang_User(111)%>
<input type="radio" value="0" <%if is_auto_upgrade=0 then Response.Write "checked"%> name="is_auto_upgrade"> <%=Lang_User(112)%>
&nbsp;&nbsp;<%=Lang_User(114)%> <input type="text" name="upgrade_jifen" size="5" value="<%=upgrade_jifen%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');">
<select name="is_del_jifen">
  <option value="0" <%If is_del_jifen=0 Then response.write "selected"%>><%=Lang_User(115)%></option>
  <option value="1" <%If is_del_jifen=1 Then response.write "selected"%>><%=Lang_User(116)%></option>
</select>
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(117)%></td>
<td class="classrow"><input type="radio" value="1" <%if is_auto_degrade=1 then Response.Write"checked"%> name="is_auto_degrade"> <%=Lang_User(111)%>
<input type="radio" value="0" <%if is_auto_degrade=0 then Response.Write "checked"%> name="is_auto_degrade"> <%=Lang_User(112)%>
&nbsp;&nbsp;
<%=Lang_User(118)%><input type="text" name="auto_degrade_days" size="5" value="<%=auto_degrade_days%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');" />
<%=Lang_User(119)%><input type="text" name="auto_degrade_cash" size="5" value="<%=auto_degrade_cash%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');"></td>
</tr>
<!--  -->
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(120)%></td>
<td class="classrow"><input type="radio" value="1" <%if is_buy=1 then Response.Write"checked"%> name="is_buy"> <%=Lang_User(111)%>
<input type="radio" value="0" <%if is_buy=0 then Response.Write "checked"%> name="is_buy"> <%=Lang_User(112)%>
&nbsp;&nbsp;</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(121)%></td>
<td class="classrow"><input type="radio" value="1" <%if is_fav=1 And grade_dj<>0 then Response.Write"checked"%> name="is_fav"> <%=Lang_User(111)%>
<input type="radio" value="0" <%if is_fav=0 Or grade_dj = 0 then Response.Write "checked"%> name="is_fav"> <%=Lang_User(112)%>
&nbsp;&nbsp;</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(122)%></td>
<td class="classrow"><input type="text" name="fav_qty" size="5" value="<%=fav_qty%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');"></td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(123)%></td>
<td class="classrow"><input type="radio" value="1" <%if is_plsh=1 then Response.Write"checked"%> name="is_plsh"> <%=Lang_User(111)%>
<input type="radio" value="0" <%if is_plsh=0 then Response.Write "checked"%> name="is_plsh"> <%=Lang_User(112)%>&nbsp;&nbsp;<IMG SRC="images/help.gif" BORDER="0" align="absmiddle" onmouseover="showhintinfo(this,0,0,'','<%=Lang_User(124)%>','50','up');" onmouseout="hidehintinfo();" />
&nbsp;&nbsp;</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(125)%></td>
<td class="classrow"><%=Lang_User(126)%><input type="text" name="login_jifen" size="5" value="<%=login_jifen%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');">&nbsp;&nbsp;<%=Lang_User(127)%><input type="text" name="login_del_jifen" size="5" value="<%=login_del_jifen%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');"> <IMG SRC="images/help.gif" BORDER="0" align="absmiddle" onmouseover="showhintinfo(this,0,0,'','<%=Lang_User(128)%>','50','up');" onmouseout="hidehintinfo();" /></td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(33)%></td>
<td class="classrow"><%=Lang_User(129)%><input type="text" name="accounts_jifen" size="5" value="<%=accounts_jifen%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');">&nbsp;&nbsp;<%=Lang_User(130)%><input type="text" name="accounts_cash" size="5" value="<%=accounts_cash%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');">
<select name="is_auto_accounts">
	<option value="0" <%If is_auto_accounts=0 Then response.write "selected"%>><%=Lang_User(131)%></option>
	<option value="1" <%If is_auto_accounts=1 Then response.write "selected"%>><%=Lang_User(132)%></option>
</select>
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_User(133)%></td>
<td class="classrow"><input type="radio" value="1" <%if is_advance_booking=1 then Response.Write"checked"%> name="is_advance_booking"> <%=Lang_User(111)%>
<input type="radio" value="0" <%if is_advance_booking=0 then Response.Write "checked"%> name="is_advance_booking"> <%=Lang_User(112)%>
<select name="is_advance">
  <option value="0" <%If is_advance=0 Then response.write "selected"%>><%=Lang_User(134)%></option>
  <option value="1" <%If is_advance=1 Then response.write "selected"%>><%=Lang_User(135)%></option>
</select>&nbsp;&nbsp;<%=Lang_User(137)%><input type="text" name="advance_percent" class="form"  value="<%=formatnumber2(advance_percent)%>" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');">
</td>
</tr>
<tr class="classrow">
  <td height="30" class="classrow"><%=Lang_User(136)%></td>
  <td class="classrow"><%=Lang_User(138)%><input type="text" name="lowprice" size="5" value="<%=formatnumber2(lowprice)%>" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');"></td>
</tr>
</table>
</div>
<script>tdshow("add_other");</script>
</td>
</tr>
<tr>
<td colspan="2" align="left" height="30" class="classfooter">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle"></td>
</tr>
</form>
</table>
<%
end Sub

Sub del
		If OnlyRead = 1 Then OnlyReadMessage()
		dj = CheckNum(request("dj"),0)
		if dj = 0 then
				response.write"<SCRIPT language=JavaScript>alert('"& Lang_sys(41) &"');javascript:history.go(-1)</SCRIPT>"
				response.end
		end If
		yxdj = false
		sql = "select id,grade_dj from [Lebi_user_grade] where grade_dj = "&dj&" and grade_dj <> 0"
		set rs=server.createobject("ADODB.Recordset")
		rs.open sql, conn, 1, 3
		if Not rs.eof Then
			conn.execute "delete from [Lebi_product_price] where grade_id = "&dj	'删除产品价格表中记录
			conn.execute "update [Lebi_product_price] set grade_id = grade_id-1 where grade_id > "&dj&""
			conn.execute "update [Lebi_user] set user_grade = user_grade-1 where user_grade >= "&dj&""
			rs.delete
			yxdj = true
		End If
		rs.close : Set rs = Nothing
		If yxdj Then
			conn.execute "update [Lebi_user_grade] set grade_dj = grade_dj-1 where grade_dj > "&dj&""
			set rs=server.createobject("ADODB.Recordset")
			sql="select id,price_qx from [Lebi_user_grade]"	'更新现有会员组查看价格权限
			rs.open sql, conn, 1, 3
			If Not rs.eof Then
					Do While Not rs.eof
						rs("price_qx") = getNewQx(dj,rs("price_qx"))
						'rs("price_qx") = Replace(rs("price_qx"),","&dj&",",",")
						rs.update
						rs.movenext
					Loop
			End If
			rs.close:Set rs=Nothing
		End If
		ManageLog Lang_User(139) &" ["&dj&"]"
		If Config_Lebi_Eshop(17)="1" Then
				Application.Contents.RemoveAll
		End If
		Call Up_mes(Lang_sys(43),"·"& Lang_sys(42),0,"?",0,0,2,1)
End Sub

Function getPriceQx(id,qxstr)
		sql="select grade_dj,price_txt from [Lebi_user_grade] where grade_dj <> 0 order by grade_dj"
		set rs_p = conn.execute(sql)
			do while not rs_p.eof
				qxid = rs_p("grade_dj") : pricetxt = rs_p("price_txt")
				getPriceQx = getPriceQx&"<INPUT TYPE=""checkbox"" NAME=""price_qx"" value="""&qxid&""" "
				If InStr(qxstr,","&qxid&",") > 0 Then getPriceQx = getPriceQx&" checked "
				If Clng(qxid)=Clng(id) Then getPriceQx = getPriceQx&" checked disabled "
				getPriceQx = getPriceQx & " >"&pricetxt&"&nbsp;"
				If Clng(qxid)=Clng(id) Then getPriceQx = getPriceQx&" <INPUT TYPE=""hidden"" value="""&qxid&""" NAME=""price_qx""> "
				rs_p.movenext
			Loop
		rs_p.close:Set rs_p = Nothing
End Function

Function getNewQx(dj,qxstr)'从现有权限字符串中去除已删除权限
		getNewQx = ""
		qxArr = Split(qxstr,",")
		for j=0 to ubound(qxArr)
			qx = qxArr(j)
			If Trim(qx)<> "" And IsNumeric(qx) Then
				If Clng(qx) <> Clng(dj) Then
					If Clng(qx) > Clng(dj) Then
						getNewQx = getNewQx &","& Clng(qx)-1
					Else
						getNewQx = getNewQx &","& Clng(qx)
					End If
				End If
			End If
		Next
		getNewQx = getNewQx & ","
End Function

Function getPriceQxName(qxid)
		If Len(qxid) > 2 then
			qxid = Mid(qxid,2,Len(qxid)-2)
			If Left(qxid,1)="," Then qxid = "999"& qxid
			sql="select price_txt from [Lebi_user_grade] where grade_dj in ("&qxid&") order by grade_dj"
			set rs_p = conn.execute(sql)
				do while not rs_p.eof
					If getPriceQxName = "" Then
						getPriceQxName = rs_p("price_txt")
					Else
						getPriceQxName = getPriceQxName & "," & rs_p("price_txt")
					End If
					rs_p.movenext
				Loop
			rs_p.close:Set rs_p = Nothing
		Else
			getPriceQxName = "无"
		End If
End Function
%>
<SCRIPT LANGUAGE="JavaScript">
<!--
function ConfirmDelGrade()
{
    if(confirm("<%=Lang_sys(64)%>\n<%=Lang_User(140)%>"))
        return true;
    else
        return false;
}
function setImg(i,ipath)
{
	document.getElementsByName('gico')[i].src= "../"+ipath;
}
//-->
</SCRIPT>