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

📄 do.asp

📁 ASP系统使用说明及程序
💻 ASP
字号:
<!--#include file="YZ_login.asp"-->
<!--#include file="cls_DB.asp"-->
<%

if request("action")="deloption" then
	call deloption() '删除某个选项的函数
elseif request("action")="delvote" then
	call delvote() '删除整个投票项目的函数
else
	mdfid=request("mdfid")
	'读取验证表单数据,添加和修改公用
	ZhuTi=request("ZhuTi")
	x=request("x")
		
	if ZhuTi="" or len(ZhuTi)>20 then
		response.write "<script>alert('主题不能为空且'"_
		&"+'不能超过20个字符!');</script>"
response.write "<script>"_
&" history.back(1);</script>"  
		response.end
	end if
	
	for i=1 to n
		if request("option"&i)="" or len(request("option"&i))>20 then
			response.write "<script>alert('选项内容不能为空且不能超过20个字符!');</script>"
			response.write "<script>history.back(1);</script>"
			response.end
		end if
	next
	
	XuanZe=request("XuanZe")
	KaiShiTime=request("nian")&"-"&_
				request("yue")&"-"&request("ri")
	JieShuTime=request("nian1")&"-"&request("yue1")&"-"&request("ri1")
	ShiFou=request("ShiFou")
	'下面为数据库操作
	openDB
	'如果把添加的设为当前投票项目,则更新已有的投票项目ShiFou值为0
	if ShiFou=1 then
			Conn.Execute("UPDATE titles SET ShiFou=0")
	end if
	'如果没有mdfid值传入,就做添加处理
	if mdfid="" then
		call add()
	else '有mdfid值传入时,做修改处理
		call modify()
	end if	

end if
'删除投票项目处理函数
sub delvote()
	openDB
	conn.Execute("delete from options where Tid = " &request("delid") )
	conn.Execute("delete from titles where ID = " & request("delid") )
	closeDB
	response.Redirect "admin.asp"
end sub
'删除某个选项处理函数
sub deloption()
	openDB
	'在删除选项前,先要更新Counts值
	conn.execute("update titles set Counts=Counts-"&request("delvote")_
	&" where id="&request("mdfid"))
	conn.execute("delete * from options where oid = " &request("deloid"))
	closeDB
	response.Redirect "modify.asp?mdfid="&request("mdfid")
end sub
'修改处理函数
sub modify()
	'更新titles表内的相关数据
	conn.execute("update titles set ZhuTi='"&ZhuTi&"',"&_
	"XuanZe='"&XuanZe&"',KaiShiTime='"&KaiShiTime&"',JieShuTime"&_
	"='"&JieShuTime&"',ShiFou='"&ShiFou&"' where id="&mdfid)
	'更新options表内的选项值
	for i=1 to n
		conn.execute("update options set options"&_
		"='"&request("option"&i)&"' where oid="&request("oid"&i)) 
	next
	'添加新选项
	if request("addoption")<>"" then
		conn.execute("insert into options (tid,options) values"&_
		" ('"&mdfid&"','"&request("addoption")&"')")
	end if
	closeDB
	response.write "<script>alert('修改投票成功');</script>"
	'如果在修改时选了继续添加选项,则在完成处理后仍转到该项目的修改页面
	if request("continue")="yes" then
		response.Redirect "modify.asp?mdfid="&mdfid
	else
		response.write "<script>location.href='admin.asp';</script>"
	end if
end sub
'下面列出添加项目函数
sub add()
	conn.execute("insert into titles(ZhuTi,XuanZe,KaiShiTime,"&_
	"JieShuTime,ShiFou) values ('"&ZhuTi&"','"&XuanZe&"',"&_
	"'"&KaiShiTime&"','"&JieShuTime&"','"&ShiFou&"')")
	sql="select top 1 ID from [titles] order by id desc"
	set rst=Server.CreateObject("ADODB.Recordset")
	rst.open sql,conn,1,1
	id = rst("id")
	rst.Close
		
	for i=1 to x
		Conn.Execute("insert into options (tid,options) values"&_
		"('" & id & "','" & Request("option"&i) & "')")
	next
	CloseDB
	response.write "<script>alert('添加投票成功');</script>"
	response.write "<script>location.href='index.asp';</script>"
end sub

%>

⌨️ 快捷键说明

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