city_submit.asp

来自「ASP程序实现的酒店预定系统」· ASP 代码 · 共 116 行

ASP
116
字号
<!--#include file="../Include/AdoConn.asp"-->
<!--#include FILE="upload.inc"-->
<%
dim sName(18)

'-----------------------------------------------------------------------------
	'添加图片
dim upload,iCount
set upload=new upload_5xSoft ''建立上传对象

for i=1 to 17  '列出所有form数据
   sName(i)=upload.form("textfield" & i)
next
code=upload.form("code")
for each formName in upload.objFile ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
  sName(18)=file.filename
  file.SaveAs Server.mappath("\china\city\cityimages\" & sName(18))   ''保存文件
 end if
 set file=nothing
next
set upload=nothing  ''删除此对象
'-----------------------------------------------------------------------------

	dim tableName	'下面函数的入口参数,表名
	dim KeyWord	'各表主关键字名称
	dim KeyType	'主键类型,自动增加型为"空",字符型为 " ' "
	dim Num		'保存取得的各字段个数
	tableName="xt_td_city"
	KeyWord="城市编码"
	KeyType=""
	Num=18


	set rst=server.CreateObject ("adodb.recordset")
	strsql="select top 1 * from "&tableName
	rst.Open strsql,conn
	N=Num
	if code<>"" then'修改
	for i=1 to N
		strSet=strSet&rst(i).name&"="&"'"& sName(i) &"'"
		if i<>N then 
		strSet=strSet+","
		end if
	next
	strsql="update "&tableName&" set "&strSet&" where "&KeyWord&"="&KeyType&code&KeyType
	conn.execute (strsql)
	info="您已修改成功!"

	else'新增
	
'''''''''''''''''''''检查数据库内是否有此城市"判断中文名"
set rst2=server.CreateObject ("ADODB.recordset")
StrSQL="select 中文城市名 from "&tableName&" where 中文城市名='"& sName(1) &"'"
rst2.Open strsql,conn,3,2
if not rst2.EOF then
%>
<script Language="JavaScript">
<!--
alert("此城市已注册!");
history.back(-1);
// -->
</script>

<%
Response.End 
end if
	rst2.Close
	set rst2=nothing
'''''''''''''''''''''检查结束


	dim strTitle,strValue'记录自动生成form\rst.fields语句的变量
	strTitle=""
	strValue=""
	for i=1 to N
		strTitle=strTitle&rst(i).name
		strValue=strValue&"'"& sName(i) &"'"
		if i<>N then 
		strTitle=strTitle+","
		strValue=strValue+","
		end if
	next
	strsql="insert into "&tableName&"("&strTitle&")values("&strValue&")"
	conn.execute (strsql)
	info="您已注册成功!"
	end if
	rst.Close
	set rst=nothing
response.redirect("city_edit.asp")
%>


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>
<%= code%>
<%for i=0 to 18%>
<%= sName(i)%><br>
<%next%>
<br>
<%=info%>
<br>
<%=strsql%>
</body>

</html>

⌨️ 快捷键说明

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