📄 targetmanage2.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 = "TargetScore"
MM_editRedirectUrl = "TargetManage2.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
EditType="Insert"
for intTemp = LBound(arrStudentNum) to UBound(arrStudentNum) '对每一条记录进行插入或更新操作
Call CheckExist(Cstr(arrStudentNum(intTemp)))
if 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)=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 EditType="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"))
Call CheckExist(strStudentNum)
if 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 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 CheckExist(tmpStudentNum)
'通过判断学号是否存在来检查是否已录入任何一科成绩
MM_rsKeyConnection=MM_StudentConn_STRING
MM_dupKeyUsernameValue = tmpStudentNum
MM_dupKeySQL="SELECT Top 1 * FROM " & MM_editTable & " WHERE StudentNum='" & MM_dupKeyUsernameValue & "'"
MM_adodbRecordset="ADODB.Recordset"
set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
MM_rsKey.ActiveConnection=MM_rsKeyConnection
MM_rsKey.Source=MM_dupKeySQL
MM_rsKey.CursorType=0
MM_rsKey.CursorLocation=2
MM_rsKey.LockType=3
MM_rsKey.Open
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' 如果已录入任何一科成绩,则进行更新记录操作
EditType="Update"
Else '否则进行插入记录操作
EditType="Insert"
End If
MM_rsKey.Close
End Sub
%>
<%
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,Recordset3__MMColParam
Dim strStudentNum, strName, strGrade, strClass
strStudentNum= Request("StudentNum")
strGrade=Request("Grade")
strClass=request("ClassSelect")
Session("txtStudentNum")=strStudentNum
Session("txtGrade")=strGrade
Session("txtClass")=strClass
if Request.Form("chkbox")<>"" then Session("strQureyString")=Request.Form
if (strStudentNum <> "") then
Recordset1__MMColParam =left(strStudentNum,6)
Recordset3__MMColParam =left(strStudentNum,6)
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 len(strStudentNum)<4 then strStudentNum=strStudentNum & string(4-len(strStudentNum),"0")
if NewMonth<9 then
strGrade=NewYear-left(strStudentNum,4)-1
else
strGrade=NewYear-left(strStudentNum,4)
end if
if len(strStudentNum)>=5 then
strClass=mid(strStudentNum,5,2)
else
strClass=""
end if
if Len(strClass)=1 then
strClass="0" & strClass
end if
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -