⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_city.asp

📁 依蓝旅游网站管理系统Elan2008.SP2
💻 ASP
📖 第 1 页 / 共 3 页
字号:
<%
Option Explicit
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
%>
<!--#Include File="../Conn.asp"-->
<!--#Include File="Admin_CheckPurview.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href='Admin_Style.css' type='text/css' rel='stylesheet'>
<title>城市管理</title>
<script language="javascript" src="../js/Common.js"></script>
<script language="javascript" src="../js/InstallDir.js"></script>
<script language="javascript" src="../js/WordSpell.js"></script>
<script language="javascript" src="../js/City.js"></script>
</head>
<body>
<%
If EL_Admin.Purview <> 1 Then
   If EL_Admin.CheckAdminPurview(26, 3) = False Then
      EL_Admin.ShowPurviewError("对不起!您没有足够的管理权限")
   End If
End If

Dim Search_Keywords, Search_Field
Search_Keywords = EL_Common.ReplaceBadChar(EL_Common.ELRequest("Search_Keywords", 1))
Search_Field = EL_Common.ReplaceBadChar(EL_Common.ELRequest("Search_Field", 1))
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="Border">
  <tr>
    <td align="center" class="top_25"><strong>城市管理</strong></td>
  </tr>
  <tr>
    <td class="td_50">
	管理导航:
	<a href="<%=EL_CurrentScriptName%>">城市管理</a> | 
	<a href="<%=EL_CurrentScriptName%>?Action=Add">添加城市</a></td>
  </tr>
</table>
<br>
<%
Select Case Action
  Case "": Call ManageCity()
  Case "Add": Call AddCity()
  Case "SaveNewCity": Call SaveCity(0)
  Case "Modify": Call ModityCity()
  Case "SaveModify": Call SaveCity(1) 
  Case "Delete": Call SaveCity(2)
  Case "CreateJs": Call CreateJs()
End Select
Call EL_Common.Bottom()
Call ApplicationTerminate()

Function Format2Jstring(ByVal Str)
   If Str = "" Or IsNULL(Str) Then Exit Function
   Format2Jstring = EL_Common.ServerHTMLEncode(Str)
   Format2Jstring = Replace(Format2Jstring, "\", "\\")
   Format2Jstring = Replace(Format2Jstring, """", "\""")
   Format2Jstring = Replace(Format2Jstring, "'", "\'")   
End Function

Sub CreateJs()
  On Error Resume Next
  Dim rsArea, AreaCmd, CityCmd, rsCity, ProvinceCmd, rsProvince, rsCountry, CountryCmd, CountryCount, ProvinceCount, CityCount, AreaCount, i
  Dim JsDir, JsContent, CityContent, ProvinceContent, CountryContent, AreaContent
   
  
  JsDir = InstallDir &"Js/City.js"    
  CityContent = ""
  ProvinceContent = ""
  CountryContent = ""
  AreaContent = ""
  JsContent = ""
  JsContent = JsContent &"function CountryObject(name, spell){"
  JsContent = JsContent &"this.name = name; this.spell = spell;"
  JsContent = JsContent &"}"
  JsContent = JsContent & VBCRLF
  JsContent = JsContent &"function ProvinceObject(name, spell, country){"
  JsContent = JsContent &"this.name = name; this.spell = spell; this.country = country;"
  JsContent = JsContent &"}"
  JsContent = JsContent & VBCRLF
  JsContent = JsContent &"function CityObject(name, spell, province, country){"
  JsContent = JsContent &"this.name = name; this.spell = spell; this.province = province; this.country = country;"
  JsContent = JsContent &"}"
  JsContent = JsContent & VBCRLF
  JsContent = JsContent &"function AreaObject(name, spell, city, province, country){"
  JsContent = JsContent &"this.name = name; this.spell = spell; this.city = city; this.province = province; this.country = country;"
  JsContent = JsContent &"}"
  JsContent = JsContent & VBCRLF
  JsContent = JsContent & "var Country = new Array();"& VBCRLF  
  JsContent = JsContent & "var Province = new Array();"& VBCRLF
  JsContent = JsContent & "var City = new Array();"& VBCRLF
  JsContent = JsContent & "var Area = new Array();"& VBCRLF
  
  '国家
  Call EL_Common.InitCommonCmd(CountryCmd, rsCountry, "EL_City", "Country,CountrySpell", "1=1 Group By Country,CountrySpell Order By CountrySpell")
  rsCountry.Close()
  CountryCount = CountryCmd(0)
  If CountryCount = 0 Then
     Set rsCountry = Nothing
	 Set CountryCmd = Nothing
  Else
     rsCountry.Open()
	 For i = 1 To CountryCount
	    CountryContent = CountryContent &"Country["& (i-1) &"] = new CountryObject("""& Format2Jstring(rsCountry(0)) &""", """& Format2Jstring(rsCountry(1)) &""");"& VBCRLF
		rsCountry.MoveNext
	 Next
	 rsCountry.Close()
	 Set rsCountry = Nothing
	 Set CountryCmd = Nothing
  End If  
  
  '省份
  Call EL_Common.InitCommonCmd(ProvinceCmd, rsProvince, "EL_City", "Province,ProvinceSpell,Country", "1=1 Group By Province,ProvinceSpell,Country Order By ProvinceSpell")
  rsProvince.Close()
  ProvinceCount = ProvinceCmd(0)
  If ProvinceCount = 0 Then
     Set rsProvince = Nothing
	 Set ProvinceCmd = Nothing
  Else
     rsProvince.Open()
	 For i = 1 To ProvinceCount
	    ProvinceContent = ProvinceContent &"Province["& (i-1) &"] = new ProvinceObject("""& Format2Jstring(rsProvince(0)) &""", """& Format2Jstring(rsProvince(1)) &""", """& Format2Jstring(rsProvince(2)) &""");"& VBCRLF
		rsProvince.MoveNext
	 Next
	 rsProvince.Close()
	 Set rsProvince = Nothing
	 Set ProvinceCmd = Nothing
  End If
  
  '城市
  Call EL_Common.InitCommonCmd(CityCmd, rsCity, "EL_City", "City,CitySpell,Province,Country", "1=1 Group By City,CitySpell,Province,Country Order By CitySpell")
  rsCity.Close()
  CityCount = CityCmd(0)
  If CityCount = 0 Then
     Set rsCity = Nothing
	 Set CityCmd = Nothing
  Else
     rsCity.Open()
	 For i = 1 To CityCount
	    CityContent = CityContent &"City["& (i-1) &"] = new CityObject("""& Format2Jstring(rsCity(0)) &""", """& Format2Jstring(rsCity(1)) &""", """& Format2Jstring(rsCity(2)) &""", """& Format2Jstring(rsCity(3)) &""");"& VBCRLF
		rsCity.MoveNext
	 Next
	 rsCity.Close()
	 Set rsCity = Nothing
	 Set CityCmd = Nothing
  End If

  '区域
  
  
  Call EL_Common.InitCommonCmd(AreaCmd, rsArea, "EL_City", "Area,AreaSpell,City,Province,Country", "1=1 Order By AreaSpell")
  rsArea.Close()
  AreaCount = AreaCmd(0)
  If AreaCount = 0 Then
     Set rsArea = Nothing
	 Set AreaCmd = Nothing
  Else
     rsArea.Open()
	 For i = 1 To AreaCount
	    AreaContent = AreaContent &"Area["& (i-1) &"] = new AreaObject("""& Format2Jstring(rsArea(0)) &""", """& Format2Jstring(rsArea(1)) &""", """& Format2Jstring(rsArea(2)) &""", """& Format2Jstring(rsArea(3)) &""", """& Format2Jstring(rsArea(4)) &""");"& VBCRLF
		rsArea.MoveNext
	 Next
	 rsArea.Close()
	 Set rsArea = Nothing
	 Set AreaCmd = Nothing
  End If

  JsContent = JsContent & CountryContent & ProvinceContent & CityContent & AreaContent
  Call EL_Common.CreateFile(JsContent, JsDir, True)
  
  EL_Common.ShowScriptError()
  
  ComeURL = "Admin_City.asp"
  EL_Common.ShowSuccessMsg("生成城市JS文件成功!")
End Sub

Sub SaveCity(UpdateType)
  On Error Resume Next
  Dim SQL, RetMessage
  Dim ID, Country, CountrySpell, Province, ProvinceSpell, City, CitySpell, Area, AreaSpell, ZipCode, AreaCode
  
  ID = EL_Common.ELRequest("ID", 2)
  Country = EL_Common.ELRequest("Country", 3)
  CountrySpell = EL_Common.ELRequest("CountrySpell", 3)
  Province = EL_Common.ELRequest("Province", 3)
  ProvinceSpell = EL_Common.ELRequest("ProvinceSpell", 3)
  City = EL_Common.ELRequest("City", 3)
  CitySpell = EL_Common.ELRequest("CitySpell", 3)
  Area = EL_Common.ELRequest("Area", 3)
  AreaSpell = EL_Common.ELRequest("AreaSpell", 3)
  ZipCode = EL_Common.ELRequest("ZipCode", 3)
  AreaCode = EL_Common.ELRequest("AreaCode", 3)  

  Country = Replace(Country, "$", "")
  CountrySpell = Replace(CountrySpell, "$", "")
  Province = Replace(Province, "$", "")
  ProvinceSpell = Replace(ProvinceSpell, "$", "")
  City = Replace(City, "$", "")
  CitySpell = Replace(CitySpell, "$", "")
  Area = Replace(Area, "$", "")
  AreaSpell = Replace(AreaSpell, "$", "")
  
  Select Case UpdateType
     Case 0: '添加
	    If Conn.Execute("SELECT COUNT(ID) FROM EL_City WHERE Country='"& Country &"' AND CountrySpell='"& CountrySpell &"' AND Province='"& Province &"' AND ProvinceSpell='"& ProvinceSpell &"' AND City='"& City &"' AND CitySpell='"& CitySpell &"' AND Area='"& Area &"' AND AreaSpell='"& AreaSpell &"' AND ZipCode='"& ZipCode &"' AND AreaCode='"& AreaCode &"'")(0)>0 Then
		   EL_Common.ShowErrorMsg("数据库中已存在一条一样的数据!")
		   Exit Sub
		End If
	    SQL = "INSERT INTO EL_City(Country,CountrySpell,Province,ProvinceSpell,City,CitySpell,Area,AreaSpell,ZipCode,AreaCode) VALUES('"& Country &"','"& CountrySpell &"','"& Province &"','"& ProvinceSpell &"','"& City &"','"& CitySpell &"','"& Area &"','"& AreaSpell &"','"& ZipCode &"','"& AreaCode &"')"
		Conn.Execute(SQL)
		RetMessage = "添加城市成功"
		RetMessage = RetMessage &"<p>国&nbsp;&nbsp;&nbsp;&nbsp;家:"& EL_Common.ServerHTMLEncode(Replace(Country, "''", ",")) &"_"& EL_Common.ServerHTMLEncode(Replace(CountrySpell, "''", ",")) &"<br>"
		RetMessage = RetMessage &"省&nbsp;&nbsp;&nbsp;&nbsp;份:"& EL_Common.ServerHTMLEncode(Replace(Province, "''", ",")) &"_"& EL_Common.ServerHTMLEncode(Replace(ProvinceSpell, "''", ",")) &"<br>"
		RetMessage = RetMessage &"城&nbsp;&nbsp;&nbsp;&nbsp;市:"& EL_Common.ServerHTMLEncode(Replace(City, "''", ",")) &"_"& EL_Common.ServerHTMLEncode(Replace(CitySpell, "''", ",")) &"<br>"
		RetMessage = RetMessage &"区&nbsp;&nbsp;&nbsp;&nbsp;域:"& EL_Common.ServerHTMLEncode(Replace(Area, "''", ",")) &"_"& EL_Common.ServerHTMLEncode(Replace(AreaSpell, "''", ",")) &"<br>"
		RetMessage = RetMessage &"邮政编码:"& EL_Common.ServerHTMLEncode(Replace(ZipCode, "''", ",")) &"<br>"
		RetMessage = RetMessage &"区&nbsp;&nbsp;&nbsp;&nbsp;号:"& EL_Common.ServerHTMLEncode(Replace(AreaCode, "''", ",")) &"</p>"
		RetMessage = RetMessage &"【<a href='Admin_City.asp'>城市管理</a>】"
		RetMessage = RetMessage &"【<a href='Admin_City.asp?Action=Modify'>修改信息</a>】"
		RetMessage = RetMessage &"【<a href='Admin_City.asp?Action=CreateJs'>生成JS文件</a>】"
		RetMessage = RetMessage &"【<a href='Admin_City.asp?Action=Add'>继续添加</a>】"
		
	 Case 1: '修改
	    If Conn.Execute("SELECT COUNT(ID) FROM EL_City WHERE Country='"& Country &"' AND CountrySpell='"& CountrySpell &"' AND Province='"& Province &"' AND ProvinceSpell='"& ProvinceSpell &"' AND City='"& City &"' AND CitySpell='"& CitySpell &"' AND Area='"& Area &"' AND AreaSpell='"& AreaSpell &"' AND ZipCode='"& ZipCode &"' AND AreaCode='"& AreaCode &"' AND ID<>"& ID)(0)>0 Then
		   EL_Common.ShowErrorMsg("数据库中已存在一条一样的数据!")
		   Exit Sub
		End If
		
	    Dim rsCity, OldCityName, OldSpellName
		Set rsCity = Server.CreateObject("ADODB.RECORDSET")
		rsCity.Open "SELECT City,CitySpell FROM EL_City WHERE ID="& ID, Conn, 1, 1
		If rsCity.EOF And rsCity.BOF Then
		   EL_Common.ShowErrorMsg("指定城市ID:"& ID &" 不存在")
		   rsCity.Close()
		   Set rsCity = Nothing
		   Exit Sub
		Else
		   OldCityName = Replace(rsCity(0), "'", "''")
		   OldSpellName = Replace(rsCity(1), "'", "''")
		   rsCity.Close()
		   Set rsCity = Nothing
		End If
		
		'更新机票中的城市名称
		Conn.Execute("UPDATE EL_Flight SET Takeoff_City='"& CitySpell &"$"& City &"' WHERE Takeoff_City='"& OldSpellName &"$"& OldCityName &"'")
		Conn.Execute("UPDATE EL_Flight SET Transfer_City='"& CitySpell &"$"& City &"' WHERE Transfer_City='"& OldSpellName &"$"& OldCityName &"'")
		Conn.Execute("UPDATE EL_Flight SET Fall_City='"& CitySpell &"$"& City &"' WHERE Fall_City='"& OldSpellName &"$"& OldCityName &"'")

	    SQL = "UPDATE EL_City SET Country='"& Country &"',CountrySpell='"& CountrySpell &"',Province='"& Province &"',ProvinceSpell='"& ProvinceSpell &"',City='"& City &"',CitySpell='"& CitySpell &"',Area='"& Area &"',AreaSpell='"& AreaSpell &"',ZipCode='"& ZipCode &"',AreaCode='"& AreaCode &"' WHERE ID="& ID
		Conn.Execute(SQL)
			
		RetMessage = "修改城市信息成功"
		RetMessage = RetMessage &"<p>国&nbsp;&nbsp;&nbsp;&nbsp;家:"& EL_Common.ServerHTMLEncode(Replace(Country, "''", ",")) &"_"& EL_Common.ServerHTMLEncode(Replace(CountrySpell, "''", ",")) &"<br>"
		RetMessage = RetMessage &"省&nbsp;&nbsp;&nbsp;&nbsp;份:"& EL_Common.ServerHTMLEncode(Replace(Province, "''", ",")) &"_"& EL_Common.ServerHTMLEncode(Replace(ProvinceSpell, "''", ",")) &"<br>"
		RetMessage = RetMessage &"城&nbsp;&nbsp;&nbsp;&nbsp;市:"& EL_Common.ServerHTMLEncode(Replace(City, "''", ",")) &"_"& EL_Common.ServerHTMLEncode(Replace(CitySpell, "''", ",")) &"<br>"
		RetMessage = RetMessage &"区&nbsp;&nbsp;&nbsp;&nbsp;域:"& EL_Common.ServerHTMLEncode(Replace(Area, "''", ",")) &"_"& EL_Common.ServerHTMLEncode(Replace(AreaSpell, "''", ",")) &"<br>"
		RetMessage = RetMessage &"邮政编码:"& EL_Common.ServerHTMLEncode(Replace(ZipCode, "''", ",")) &"<br>"
		RetMessage = RetMessage &"区&nbsp;&nbsp;&nbsp;&nbsp;号:"& EL_Common.ServerHTMLEncode(Replace(AreaCode, "''", ",")) &"</p>"
		RetMessage = RetMessage &"【<a href='Admin_City.asp'>城市管理</a>】"
		RetMessage = RetMessage &"【<a href='Admin_City.asp?Action=Modify'>修改信息</a>】"
		RetMessage = RetMessage &"【<a href='Admin_City.asp?Action=CreateJs'>生成JS文件</a>】"
		RetMessage = RetMessage &"【<a href='Admin_City.asp?Action=Add'>添加城市</a>】"
		
	 Case 2: '删除

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -