📄 scoreinput2.asp
字号:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/StudentConn.asp" -->
<!--#include file="CheckLogin.asp"-->
<%
MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
MM_abortEdit = false
MM_editQuery = ""
%>
<%
If (Trim(Request.Form("InputScore")) <> "" and Trim(Request.Form("StudentNum")) <> "") Then
MM_editConnection = MM_StudentConn_STRING
MM_editTable = session("txtSheetName")
MM_editRedirectUrl = "scoreinput2.asp?" & session("strQureyString")
MM_editQuery=""
if Instr(Request.Form("StudentNum"),",")>0 then '需要对多条记录进行操作
arrStudentNum = Split(Replace(Request.Form("StudentNum")," ",""),",")
arrEditType = Split(Replace(Request.Form("EditType")," ",""),",")
arrSubject = Split(Replace(Request.Form("Subject"),"|value",""),"|")
dim arrScore()
Redim arrScore(UBound(arrSubject)+1)
for intTemp = LBound(arrSubject) to UBound(arrSubject)
arrScore(intTemp)=Replace(Replace(Request.Form(arrSubject(intTemp))," ",""),",","|")
next
for intTemp = LBound(arrStudentNum) to UBound(arrStudentNum) '对每一条记录进行插入或更新操作
if arrEditType(intTemp)="Insert" then '插入记录
MM_fieldsStr = "StudentNum|value|" & Request.Form("Subject")
MM_columnsStr = "StudentNum|',none,''|" & Replace(Request.Form("Subject"),"value","none,none,NULL")
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
MM_fields(1)=arrStudentNum(intTemp)
For j = 2 To UBound(MM_fields) Step 2
arrTemp=Split(arrScore((j-2)/2),"|")
MM_fields(j+1) = arrTemp(intTemp) & ""
if MM_Fields(j+1)="" then MM_Fields(j+1)="0"
Next
InsertRecord
end if
if arrEditType(intTemp)="Update" then '更新记录
MM_recordId = "'" & arrStudentNum(intTemp) & "'"
MM_fieldsStr = Request.Form("Subject")
MM_columnsStr = Replace(Request.Form("Subject"),"value","',none,''")
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
For j = LBound(MM_fields) To UBound(MM_fields) Step 2
arrTemp=Split(arrScore(j/2),"|")
MM_fields(j+1) = arrTemp(intTemp) & ""
if MM_Fields(j+1)="" then MM_Fields(j+1)="0"
Next
UpdateRecord
end if
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
next
else '只有一条记录时
strStudentNum = Trim(Request.Form("StudentNum"))
if Trim(Request.Form("EditType"))="Insert" then '插入记录
MM_fieldsStr = "StudentNum|value|" & request.Form("Subject")
MM_columnsStr = "StudentNum|',none,''|" & replace(request.Form("Subject"),"value","none,none,NULL")
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
MM_fields(1)=strStudentNum
For intTemp = 2 To UBound(MM_fields) Step 2
MM_fields(intTemp+1) = CStr(Request.Form(MM_fields(intTemp)))
if MM_Fields(intTemp+1)="" then MM_Fields(intTemp+1)="0"
Next
InsertRecord
end if
if Trim(Request.Form("EditType"))="Update" then '更新记录
MM_recordId = "'" & strStudentNum & "'"
MM_fieldsStr = Request.Form("Subject")
MM_columnsStr = Replace(Request.Form("Subject"),"value","',none,''")
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
For intTemp = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(intTemp+1) = CStr(Request.Form(MM_fields(intTemp)))
if MM_Fields(intTemp+1)="" then MM_Fields(intTemp+1)="0"
Next
UpdateRecord
end if
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
end if
Response.Redirect(MM_editRedirectUrl)
end if
%>
<%
Sub InsertRecord()
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),",")
Delim = MM_typeArray(0)
If (Delim = "none") Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none") Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none") Then EmptyVal = ""
If (FormVal = "") Then
FormVal = EmptyVal
Else
If (AltVal <> "") Then
FormVal = AltVal
ElseIf (Delim = "'") Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''") & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
End Sub
%>
<%
Sub UpdateRecord()
MM_editQuery = "update " & MM_editTable & " set "
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),",")
Delim = MM_typeArray(0)
If (Delim = "none") Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none") Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none") Then EmptyVal = ""
If (FormVal = "") Then
FormVal = EmptyVal
Else
If (AltVal <> "") Then
FormVal = AltVal
ElseIf (Delim = "'") Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''") & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
Next
MM_editQuery = MM_editQuery & " where StudentNum = " & MM_recordId
End Sub
%>
<%
Dim Recordset1__MMColParam,Recordset2__MMColParam,Recordset3__MMColParam
Dim strSheetName, strStudentNum, strName, strGrade, strClass
strSheetName = Request("SheetName")
Recordset2__MMColParam = Request("SheetName")
strStudentNum= Request("StudentNum")
strGrade=Request("Grade")
strClass=request("ClassSelect")
if Request.QueryString<>"" then Session("strQureyString")=Request.QueryString
if Request.Form<>"" then Session("strQureyString")=Request.Form
if (strStudentNum <> "") then
Recordset1__MMColParam =strStudentNum
Recordset3__MMColParam =strStudentNum
else
If len(Year(Now()))<=2 Then
NewYear="20" & Year(Now())
Else
NewYear=Year(Now())
End If
If len(Month(Now()))<=1 Then
NewMonth="0" & Month(Now())
Else
NewMonth=Month(Now())
End If
if NewMonth<9 then
strStudentNum=NewYear-strGrade-1
else
strStudentNum=NewYear-strGrade
end if
if strClass="All" then strClass=""
if Len(strClass)=1 then
strClass="0" & strClass
end if
strStudentNum=strStudentNum & strClass
Recordset1__MMColParam =strStudentNum
Recordset3__MMColParam =strStudentNum
end if
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_StudentConn_STRING
Recordset1.Source = "SELECT StudentNum, Name FROM StudentInfo WHERE StudentNum like '%" & Recordset1__MMColParam & "%' ORDER BY StudentNum"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_StudentConn_STRING
Recordset2.Source = "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" + Replace(Recordset2__MMColParam, "'", "''") + "'"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 3
Recordset2.Open()
Recordset2_numRows = 0
set Recordset3 = Server.CreateObject("ADODB.Recordset")
Recordset3.ActiveConnection = MM_StudentConn_STRING
Recordset3.Source = "SELECT * FROM " & strSheetName & " WHERE StudentNum like '%" & Recordset3__MMColParam & "%' ORDER BY StudentNum"
Recordset3.CursorType = 0
Recordset3.CursorLocation = 2
Recordset3.LockType = 3
Recordset3.Open()
Recordset3_numRows = 0
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset3_numRows = Recordset3_numRows + Repeat1__numRows
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -