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

📄 madd.asp

📁 具有计划、任务、通告、公文、员工档案、等网络办公功能
💻 ASP
字号:
<%dim ThisKey
ThisKey = "$"
%>
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel=stylesheet href="main.css" type="text/css">
</head>
<BR><BR><BR>
<%
ID=trim(request("ID"))
if ID="" then ID=0
ClassID=trim(request("ClassID"))
if ClassID="" then ClassID=0

dim strTitle,strFilePath,strbody
If request("cmdAdd")<>"" then

	strTitle=replace(trim(request("Title")),"'","''")
	strBody=replace(rtrim(request("Body")),"'","''")
	strFilePath=replace(trim(request("FilePath")),"'","''")
	
	if strTitle<>"" and isnumeric(strPrice) then
		AddNews()

	else
		response.write "数据输入有错误!标题不能为空并且价格必须为数值型!<a href=# onclick=""javascript:history.back(-1)"">[返回]</a>"
		response.end
	end if
end if

If request("cmdUpdate")<>"" and ID<>0 then
	strTitle=replace(trim(request("Title")),"'","''")
	strBody=replace(rtrim(request("Body")),"'","''")
	strFilePath=replace(trim(request("FilePath")),"'","''")
	if strTitle<>"" then
		UpdateNews(ID)
		alertinfo="修改成功!"
	else
		response.write "数据输入有错误!标题不能为空!<a href=# onclick=""javascript:history.back(-1)"">[返回]</a>"
		response.end
	end if
end if

if ID<>0 then
	GetData(ID)
end if
%>

<body <%if alertinfo<>"" then response.write " onload=""alert('" & alertinfo & "')"""%>>

<form method="POST" action="mAdd.asp" name="StarsForm">
<div align="center">
<table border=0 cellpadding=3 cellspacing=1 width="80%" bgcolor=#336699>

	<tr bgcolor=#FFFFFF>
		<td>类&nbsp;&nbsp;别:</td>
		<td>
		<select name="ClassID">
		<option value=1>音乐
		<option value=2 <%if ClassID=2 then response.write " selected"%>>视频
		</select>
		</td>
	</tr>
	
	<tr bgcolor=#FFFFFF>
		<td>标  题:</td>
		<td><input name="Title" value="<%=strTitle%>" class="input" size="40" maxlength=100> <font color=red>*</font></td>
	</tr>
	<tr bgcolor=#FFFFFF>
		<td>文件名:</td><td><input name="FilePath" value="<%=strFilePath%>" class="input" size="40" maxlength=100> <font color=red>*</font></td>
	</tr>

	<tr bgcolor=#FFFFFF>
		<td>简单描述:</td><td>
		<textarea rows=5 cols=50 name="body"><%=strbody%></textarea></td>
	</tr>
		
	<tr bgcolor=#FFFFFF>
	<td colspan=2 align="center">
		<%if ID=0 then%>
		  <input name="cmdAdd" type="submit" value="添加" onclick="return CheckData();">
		<%else%>
		  <input name="cmdUpdate" type="submit" value="修改" onclick="return CheckData();">
		<%end if%>
		<input name="cmdback" type="button" value="返回" onclick="history.back(-1);">
		</td>
	</tr>
</table>
</div>
<input type="Hidden" name="ID" VALUE="<%=ID%>">
</form>
<BR><BR>
</body>
</html>
<!--#include file="conn_close.asp"-->
<script language=javascript>
function CheckData()
{	
	if(jtrim(document.StarsForm.ClassID.value)=="0")
	{
		alert("请选择类别。")
		return false;
	}
	if(jtrim(document.StarsForm.Title.value)=="")
	{
		alert("请输入名称。")
		document.StarsForm.Title.focus();
		return false;
	}
			
	return true;
}
</script>
<script language=javascript src="../inc/jtrim.js"></script>
<%

Sub GetData(ID)
if isnumeric(ID) and ID<>0 then
Set conn=Server.CreateObject("ADODB.Connection")
DBPath1=server.mappath("../access.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath1

	Set oRs=Server.CreateObject("ADODB.Recordset")
	strSql="Select * from tblVideo where ID="& ID
	oRs.open strSql,Conn,1,1
	if not oRs.eof then
		strTitle=trim(oRs("Title"))
		strbody=trim(oRs("body"))
		ClassID=trim(oRs("ClassID"))
		strFilePath=trim(oRs("FilePath"))
	end if
	oRs.close
	set oRs=nothing
end if
End Sub

Sub AddNews()
Set conn=Server.CreateObject("ADODB.Connection")
DBPath1=server.mappath("../access.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath1
	sql=" INSERT INTO tblVideo (ClassID,Title, FilePath, Body) VALUES(" & ClassID & _
		",'"& strTitle & _
		"','" & strFilePath & _
		"','"& strbody & _
		"');"
		Conn.execute (sql)
		response.redirect ("manageVideo.asp")
End Sub

Sub UpdateNews(ID)
Set conn=Server.CreateObject("ADODB.Connection")
DBPath1=server.mappath("../access.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath1

	Conn.execute ("Update tblVideo set ClassID="& ClassID &",Title='"& strTitle &"',body='"& strbody &"',FilePath='"&strFilePath&"' where ID="&ID)
	response.redirect ("manageVideo.asp")
End Sub

%>

⌨️ 快捷键说明

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