📄 infoinput.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 = ""
strStudentNum=CStr(Request("StudentNum"))
%>
<%
' *** Redirect if StudnetNum exists
If (strStudentNum <> "") Then
MM_dupKeyRedirect="InfoModify.asp"
MM_rsKeyConnection=MM_StudentConn_STRING
MM_dupKeyUsernameValue = strStudentNum
MM_dupKeySQL="SELECT StudentNum FROM StudentInfo 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
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "StudentNum=" & MM_dupKeyUsernameValue & "&Err=True"
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) <> "") Then
MM_editConnection = MM_StudentConn_STRING
MM_editTable = "StudentInfo"
strStudentNum = Request.Form("StudentNum")
strStudentNum = strStudentNum + 1
MM_editRedirectUrl = "InfoInput.asp?StudentNum=" & strStudentNum
MM_fieldsStr = "StudentNum|value|Name|value|Sex|value|Folk|value|place|value|politics|value|Birthday|value|enrollment|value|housemaster|value|TelNum|value|HouseAddress|value|remark|value"
MM_columnsStr = "StudentNum|',none,''|Name|',none,''|Sex|',none,''|Folk|',none,''|place|',none,''|politics|',none,''|Birthday|',none,NULL|enrollment|',none,NULL|housemaster|',none,''|TelNum|',none,''|HouseAddress|',none,''|remark|',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
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
%>
<!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 checkform()
{
var strStudentNum
strStudentNum=document.form1.StudentNum.value
if(strStudentNum=="")
{
alert("你还没有填学号!");
document.form1.StudentNum.focus();
return false;
}
if(isNaN(strStudentNum))
{
alert("学号必须由数字组成!");
document.form1.StudentNum.focus();
return false;
}
if(strStudentNum.length<8)
{
alert("学号位数不足8位!");
document.form1.StudentNum.focus();
return false;
}
if(strStudentNum<19980000||strStudentNum>20080000)
{
alert("学号超出范围!请不要乱输学号,否则会给以后的管理造成麻烦。");
document.form1.StudentNum.focus();
return false;
}
if(document.form1.Name.value=="")
{
alert("你还没有填姓名!");
document.form1.Name.focus();
return false;
}
}
function SetEnrollment()
{
var strStudentNum;
strStudentNum=document.form1.StudentNum.value;
if(strStudentNum>=4)
{
document.form1.enrollment.value=strStudentNum.substring(0,4)+"-9-1";
}
}
</script>
<link href="home.css" rel="stylesheet" type="text/css">
</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> </TD>
<TD>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
<tr>
<td height=30><img src="images/info.gif" width="16" height="16"><a href="InfoInput.asp">录入学生信息</a></td>
<td height=30 ><img src="images/info.gif" width="16" height="16"><a href="InfoQuery.asp">查询学生信息</a></td>
<td height=30><img src="images/info.gif" width="16" height="16"><a href="InfoModifyDel.asp">修改/删除学生信息</a></td>
<td height=30 width="14%"> </td>
</tr>
</table>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -