28,390
社区成员
发帖
与我相关
我的任务
分享
<%
dbconn.BeginTrans'开始一个事务
'删除该教师在任教课程表teach中所有记录
strSql="delete from teach where tid="&nCurrId
dbConn.execute strSql
'删除教师记录
strSql="delete from teacher where tid="&nCurrId
dbConn.execute strSql
if dbconn.errors.count=0 then
dbconn.CommitTrans'无错执行事务
else
dbconn.RollbackTrans'有错回滚
end if
%>
%
function closeit(o)
if IsObject(o)'如果实参是一个对象
if o.state<>0 then o.close'如果没关闭,先关闭
set o=nothing '再释放
end if
end function
%〉
<%
closeit(rs): closeit(conn)
%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../conn/conn.asp"-->
<%
dim nMode,nCurrId,nCurrType,strPass,strSql,strTitle
nMode=Request("Mode")
nMode=Cint(nMode)
nCurrId=Request("CurrId")
if nCurrTid=0 then nCurrTid="null"
strTitle=Request("Title")
strPass=Request("Pass")
nCurrType=Request("CurrType")
select case Trim(Request("btSubmit"))
case "保存":
if IsNumeric(nCurrId) then '修改保存
strSql="Update teacher set zid="&nCurrType&",tname='"&strTitle&"',pass='"&strPass&"' where tid="&nCurrId
dbConn.execute strSql
'更新该教师任教课程表teach
strSql="delete from teach where tid="&nCurrId
dbConn.execute strSql
'下面这个for循环什么意思?想实现什么?[teach]表只有两个字段吗?
for each id in Request("SelectedCourseId")
'strSql="insert into teach values("&nCurrId&","&id&")"
strSql="insert into teach(字段1,字段2) values("&nCurrId&","&id&")"
dbConn.Execute strSql
next
strSql="Select Max(tid) as MaxId from teacher where tid <"&nCurrId&" and zid="&nCurrType ' 取下一条记录(由大到小排序)
rs.open strSql,dbConn '取下一条记录id
if IsNumeric(rs("MaxId")) then
strSql="edit.asp?Mode=10&CurrId="&rs("MaxId")
Response.Redirect strSql '修改确认返回到编辑窗口
else
Response.Write " <p align=center>已到最后一条记录! </p>"
end if
else '添加保存
strSql="Insert into teacher(zid,tname,pass) values("&nCurrType&",'"&strTitle&"','"&strPass&"')"
dbConn.execute strSql
strSql="select max(tid) as MaxId from teacher where zid="&nCurrType
rs.open strSql,dbConn
nCurrId=rs("MaxId")
'疑问同上
'添加该教师任教课程表teach
for each id in Request("SelectedCourseId")
strSql="insert into teach values("&nCurrId&","&id&")"
dbConn.Execute strSql
next
strSql="edit.asp?Mode=11&CurrId="&nCurrId
Response.Redirect strSql '添加确认返回到编辑窗口
end if
Response.End
case "添加" '[添加]按钮
Response.Redirect "edit.asp?Mode=1&CurrType="&nCurrType
case "删除":
'删除该教师在任教课程表teach中所有记录
strSql="delete from teach where tid="&nCurrId
dbConn.execute strSql
'删除教师记录
strSql="delete from teacher where tid="&nCurrId
dbConn.execute strSql
strSql="Select Max(tid) as MaxId from teacher where tid <"&nCurrId&" and zid="&nCurrType '取下一条记录(由大到小排序)
rs.open strSql,dbConn '取下一条记录id
if IsNumeric(rs("MaxId")) then
strSql="edit.asp?Mode=12&CurrId="&rs("MaxId")
Response.Redirect strSql '删除确认返回到编辑窗口
else
Response.Write " <p align=center>已到最后一条记录! </p>"
Response.End
end if
case "首记录":
strSql="select min(tid) as MaxId from teacher where zid="&nCurrType '记录按由大到小排序
case "前记录":
strSql="select min(tid) as MaxId from teacher where tid>"&nCurrId&" and zid="&nCurrType
case "后记录":
strSql="Select max(tid) as MaxId from teacher where tid <"&nCurrId&" and zid="&nCurrType
'取下一条记录(由大到小排序)
case "末记录":
strSql="select max(tid) as MaxId from teacher where zid="&nCurrType
end select
rs.open strSql,dbConn '取下一条记录id
if IsNumeric(rs("MaxId")) then '移动记录
strSql="edit.asp?Mode=0&CurrId="&rs("MaxId")
Response.Redirect strSql '返回到编辑窗口 显示相应记录信息
else
Response.Write " <p align=center>已到最后一条记录! </p>"
end if
%>