<!--#include file="conn.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆！');window.location.href='login.asp';</script>"
response.End
else
if session("flag")>1 then
response.Write "<div align=center><font size=80 color=red><b>您没有此项目管理权限！</b></font></div>"
response.End
end if
end if

dim danweiid,danweiorder,danweiname,danweino,i
if request("action")="update" then
    for i=1 to request.form("danweiid").count
	danweiid=replace(request.form("danweiid")(i),"'","")
	danweiorder=replace(request.form("danweiorder")(i),"'","")
	danweiname=replace(request.form("danweiname")(i),"'","")
	if replace(request.form("danweiorder")(i),"'","")="" then
%>
<script language=javascript>
history.back()
alert("请填写单位的显示排序！")
</script>
<%
		Response.End
	end if
	conn.execute("update shop_danwei set danweiorder="&danweiorder&",danweiname='"&danweiname&"' where id="&danweiid)

    next
conn.close
set conn=nothing
response.write "<p align=center><font color=red>单位设置成功!<br>2秒钟后返回上页!</font>"
response.write "<meta http-equiv=""refresh"" content=""2;url=danweimanage.asp"">"
end if


if request("action")="add" then
	danweino=request.form("danweino")
	danweiname=trim(request("danweiname"))
	danweiorder=request.form("danweiorder")
	If danweiname="" Then
		response.write "单位名称不能为空！请<a href=javascript:history.go(-1)>返回重新填写</a>！"
		response.end
	end if
	If danweiorder="" Then
		response.write "排序不能为空！请<a href=javascript:history.go(-1)>返回重新填写</a>！"
		response.end
	end if
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select * From shop_danwei",conn,1,3
rs.addnew
rs("danweiname")=danweiname
rs("danweiorder")=danweiorder
rs.update
rs.close
set rs=nothing

conn.close
set conn=nothing
response.write "<p align=center><font color=red>单位添加成功!<br>2秒钟后返回上页!</font>"
response.write "<meta http-equiv=""refresh"" content=""2;url=danweimanage.asp"">"
end if
%>