?? savescore.asp
字號:
<%option explicit%>
<%session.CodePage="936"%>
<!--#include file="Conn.asp"-->
<!--#include file="include/md5.asp"-->
<!--#include file="include/ReplaceHtml.asp"-->
<!--#include file="include/PublicFunction.asp"-->
<!--#include file="include/TeacherSession.asp"-->
<% call checkouterurl()
'強制瀏覽器重新訪問服務(wù)器下載頁面
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
<html>
<head>
<title>保存分?jǐn)?shù) </title>
<meta HTTP-EQUIV="Content-Type" Content="text-html; charset=gb2312">
</head>
<body bgcolor="white">
<%
Dim SqlNumber,ii,DoInsertSql,iii,TotalElementNum
SqlNumber=request.Form("StudentRsNum")
'為了防止數(shù)據(jù)提交失敗,必須保證表單中的每一項的數(shù)值都不為空,此處逐個校驗表單中的每一個元素
TotalElementNum=(SqlNumber*2)+6 '此處的6代表是表單中除了分?jǐn)?shù)元素之外,其余元素的數(shù)目
For iii=1 to TotalElementNum-2
IF request.Form(iii)="" then
Response.Write("<script>alert('數(shù)據(jù)不完整,無法保存,請您輸入完成之后,再保存!');window.close(); </script>")
Response.End()
'******If Err Then Err.Clear
'****** response.Write request.Form'TotalElementNum-1
'****** Response.End()
exit for
End IF
NEXT
'*******************************************************
' 下面這段代碼決定 如何處理當(dāng)前表單提交過來的數(shù)據(jù),
'根據(jù)term_id, department_id, teacher_id,class_id,subject_id這幾個字段,
'使用count(*)篩選出符合這幾個字段的記錄的條數(shù),如果記錄數(shù)等于0,說明
'當(dāng)前班級本學(xué)期的這門課程的成績還沒有添加,那么此時則執(zhí)行添加數(shù)據(jù)的操作;
'如果記錄數(shù)大于0,說明 當(dāng)前班級本學(xué)期的這門課程的成績已經(jīng)添加過了,那么
'此時訪問者提交數(shù)據(jù)的目的是修改數(shù)據(jù),則應(yīng)執(zhí)行修改操作。
Dim Add_or_Edit,Add_or_Edit_Sql,CurrentScoreNum
Add_or_Edit_Sql="select count(*) from [score] where [term_id]='"&request.Form("term_id")&"' and [department_id]='"&request.Form("department_id")&"' and [teacher_id]='"&request.Form("teacher_id")&"' and [class_id]='"&request.Form("class_id")&"' and [subject_id]='"&request.Form("subject_id")&"'"
Set Add_or_Edit=Initialize_Conn.execute(Add_or_Edit_Sql)
CurrentScoreNum=Add_or_Edit(0): Add_or_Edit.close: Set Add_or_Edit=nothing
IF CurrentScoreNum=0 Then
Call DoSaveScore()
else
Call DoEditScore()
End If
'***************************************************
'下面是數(shù)據(jù)入庫代碼,此處使用For循環(huán)依次向數(shù)據(jù)庫中插入分?jǐn)?shù)
Sub DoSaveScore()
For ii=0 to SqlNumber-1
DoInsertSql="Insert into score(subject_id,sore,student_id,Term_id,teacher_id,department_id,HaveBeenAdd,class_id) values("&request.Form("subject_id")&","&request.Form("Score_"&ii)&","&request.Form("StuID_"&ii)&","&request.Form("term_id")&","&request.Form("teacher_id")&","&request.Form("department_id")&",1,"&request.Form("class_id")&")"
Initialize_Conn.execute(DoInsertSql)
NEXT
Response.Write "<script>alert('恭喜!分?jǐn)?shù)保存成功,按確定返回。');window.close();</script>"
End Sub
'***************************************************
'下面是數(shù)據(jù)修改代碼,此處使用For循環(huán)依次向數(shù)據(jù)庫中修改分?jǐn)?shù)
Sub DoEditScore()
Dim DoEditSql,iiii
For iiii=0 to SqlNumber-1
DoEditSql="Update [score] Set sore='"&request.Form("Score_"&iiii)&"' where [term_id]='"&request.Form("term_id")&"' and [department_id]='"&request.Form("department_id")&"' and [teacher_id]='"&request.Form("teacher_id")&"' and [class_id]='"&request.Form("class_id")&"' and [subject_id]='"&request.Form("subject_id")&"' and [student_id]='"&request.Form("StuID_"&iiii)&"'"
Initialize_Conn.execute(DoEditSql)
'Response.Write(DoEditSql&"<br>")
NEXT
Response.Write "<script>alert('恭喜,分?jǐn)?shù)編輯保存成功,按確定返回。');window.close();</script>"
End Sub
'response.Write request.Form()&"<br>"
'response.Write request.Form("submit")
%>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -