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

📄 subjectmanage.asp

📁 一篇不错的好论文
💻 ASP
字号:
<%@LANGUAGE="VBSCRIPT"%> 
<!--#include file="Connections/StudentConn.asp" -->
<!--#include file="CheckLogin.asp"-->
<%
' *** Edit Operations: declare variables

MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) <> "") Then

  MM_editConnection = MM_StudentConn_STRING
  MM_editTable = "Subject"
  MM_editRedirectUrl = "SubjectManage.asp"
  MM_fieldsStr  = "Subject|value"
  MM_columnsStr = "SubjectName|',none,''"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")

  ' set the form values
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
  Next

Dim rsTarget
Dim rsTarget_numRows
Set rsTarget = Server.CreateObject("ADODB.Recordset")
rsTarget.ActiveConnection = MM_StudentConn_STRING
rsTarget.Source = "SELECT * FROM TargetScore"
rsTarget.CursorType = 0
rsTarget.CursorLocation = 2
rsTarget.LockType = 1
rsTarget.Open()
rsTarget_numRows = 0
InsertFlag=True
for k=0 to rsTarget.fields.count-1
	if rsTarget.fields.item(k).name=CStr(Request.Form("Subject")) then InsertFlag=False
next
rsTarget.Close()
if InsertFlag=True then
	' *** 向TargetScore表中添加字段
	strSubject = CStr(Request.Form("Subject")) & " SINGLE"
	MM_AppendFieldConnection = MM_StudentConn_STRING
	MM_AppendFieldQuery = "ALTER TABLE TargetScore ADD COLUMN " & strSubject
	Set MM_AppendFieldCmd = Server.CreateObject("ADODB.Command")
	MM_AppendFieldCmd.ActiveConnection = MM_AppendFieldConnection
    MM_AppendFieldCmd.CommandText = MM_AppendFieldQuery
	MM_AppendFieldCmd.Execute
    MM_AppendFieldCmd.ActiveConnection.Close
end if

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
%>
<%
' *** Delete Record: declare variables

if (CStr(Request("MM_delete")) = "form2") Then

  MM_editConnection = MM_StudentConn_STRING
  MM_editTable = "Subject"
  MM_editColumn = "ID"
  MM_recordId = "" + Request.Form("Subject") + ""
  MM_editRedirectUrl = "SubjectManage.asp"

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If
  
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

If (CStr(Request("MM_insert")) <> "") Then

  ' create the sql insert statement
  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 & ")"

  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
<%
' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) <> "") Then

  ' create the sql delete statement
  MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the delete
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>

<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_StudentConn_STRING
Recordset1.Source = "SELECT * FROM Subject ORDER BY ID ASC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>

<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index

Repeat2__numRows = -1
Repeat2__index = 0
Recordset2_numRows = Recordset2_numRows + Repeat2__numRows
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>考试管理</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2600.0" Name=GENERATOR>
<link href="home.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
function checktest(){
if(document.form1.Subject.value=="")
  {
   alert("考试科目名不能为空!");
   document.form1.TestName.focus();
   return false;
   }
}
</script>
</HEAD>
<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0>
<!--#include file="Top.asp"-->
<TABLE cellSpacing=0 cellPadding=0 width=750 align=center border=0>
  <TBODY> 
  <TR> 
      <TD vAlign=top width=46 background=images/p_left_2.gif></TD>
      <TD width="20" align="center" valign="top">&nbsp;</TD>
      <TD> 
        <table border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="150" height="30"><img src="images/friendsite.GIF" width="19" height="19"><a href="TestManage.asp">考试管理</a></td>
            <td width="150" height="30"><img src="images/friendsite.GIF" width="19" height="19"><a href="SubjectManage.asp">考试科目管理</a></td>
          </tr>
        </table>
        <br>
        <strong><font size="4">考试科目管理</font></strong><br>
        <form Name="form1" onsubmit="return checktest()" method="POST" action="<%=MM_editAction%>">
          <font color="#FF0000"><b><font color="#339999">添加新考试科目:</font> 
          <input name="Subject" type="text" id="Subject" size="10">
          <input type="submit" name="Submit2" value="添加">
          <input type="hidden" name="MM_insert" value="form1">
          </b></font> 
        </form>
      <% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
        <form name="form2" method="POST" action="<%=MM_editAction%>">
          <font color="#FF0000"><b><font color="#339999">删除已有的考试科目:</font></b></font> 
          <select name="Subject" id="Subject">
            <%
intTemp = 0
While (NOT Recordset1.EOF)
intTemp=intTemp+1
%>
            <option value="<%=(Recordset1.Fields.Item("ID").Value)%>" selected><%=(Recordset1.Fields.Item("SubjectName").Value)%></option>
            <%
  Recordset1.MoveNext()
Wend
If (Recordset1.CursorType > 0) Then
  Recordset1.MoveFirst
Else
  Recordset1.Requery
End If
%>
          </select>
          <% if intTemp>7 then %>
		  <input name="Submit" type="submit" id="Submit" value="删除">
          <input type="hidden" name="MM_delete" value="form2">
		  <% end if %>
        </form>
        <br>
        <% End If ' end Not Recordset1.EOF Or NOT Recordset1.BOF %>
      <% If Recordset1.EOF And Recordset1.BOF Then %>
      <p align="center"><br>
        <br>
          找不到任何考试科目,请添加考试科目!<br>
        <br>
      </p>
      <% End If ' end Recordset1.EOF And Recordset1.BOF %>
    </TD>
  </TR>
  </TBODY> 
</TABLE>
<!--#include file="CopyRight.asp"-->
</BODY>
</HTML>
<%
Recordset1.Close()
%>

⌨️ 快捷键说明

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