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

📄 infomodify.asp

📁 一篇不错的好论文
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<%@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 = ""
%>
<%
' *** Update Record: set variables

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  MM_editConnection = MM_StudentConn_STRING
  MM_editTable = "StudentInfo"
  MM_editColumn = "StudentNum"
  MM_recordId = "'" + Request.Form("MM_recordId") + "'"
  MM_editRedirectUrl = "InfoQuery2.asp"
  MM_fieldsStr  = "Name|value|Sex|value|Folk|value|place|value|politics|value|Birthday|value|enrollment|value|housemaster|value|TelNum|value|HouseAddress|value|remark|value"
  MM_columnsStr = "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
%>
<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql update statement
  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 " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the update
    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 Request("RedirectUrl")<>"" then
		Response.Redirect(Request("RedirectUrl") & "?StudentNum=" & CLng(Request("MM_recordId"))+1)
	end if
	if Session("strQureyString")<>"" then
	    response.redirect "InfoQuery2.asp?" & Session("strQureyString")
	end if
  End If
End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
if (Request.QueryString("StudentNum") <> "") then Recordset1__MMColParam = Request.QueryString("StudentNum")
%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_StudentConn_STRING
Recordset1.Source = "SELECT * FROM StudentInfo WHERE StudentNum = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<!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()
{
  if(document.form1.Name.value=="")
  {
    alert("你还没有填姓名");
    document.form1.Name.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 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY> 
        <TR> 
              <td width="25%" height=30><img src="images/info.gif" width="16" height="16"><a href="InfoInput.asp">录入学生信息</a></td>
              <td width="25%" height=30 ><img src="images/info.gif" width="16" height="16"><a href="InfoQuery.asp">查询学生信息</a></td>
              <td width="25%" height=30><img src="images/info.gif" width="16" height="16"><a href="InfoModifyDel.asp">修改/删除学生信息</a></td>
              <td height=30 width="25%">&nbsp;</td>
        </TR>
        </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                    <td width="120" valign="top"><br>
                  <br>
                  <br>
              <img src="images/cat008.gif" width="90" height="80"><br>
              <font color="#0066cc"><strong>注:</strong><br>
              <br>
              1、带<font color="#FF0000">*</font>项为必填项<br>
              <br>
              2 、输入信息后可直接按回车键保存录入信息<br>
              <br>
              3 、输入过程中可用Tab键将光标在各输入框中切换</font> </td>
                    <td align="center"><font color="#FF0000" size="4"><b><br>
              学生信息修改</b></font> 
              <% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
              <form Name="form1" onsubmit="return checkform()" action="<%=MM_editAction%>" method="POST">
                <table width="100%" border=0 cellpadding="0" cellspacing=2>
                          <tr> 
                            <td align=right width=80>学号:</td>
                            <td align=left width=426><%=(Recordset1.Fields.Item("StudentNum").Value)%>
                      <%
				if request("Err")<> "" then
					response.Write "&nbsp;&nbsp;&nbsp;&nbsp;<font color='ff0000'>此学号已存在!</font>"
                	response.Write "<input name='RedirectUrl' type='hidden' value='InfoInput.asp'>"
                end if
				%>
                    </td>
                          </tr>
                          <tbody>
                            <tr> 
                              <td align=right width=80>姓名:</td>
                              <td align=left width=426> 
                                <input class=rec_form size=12 Name=Name value="<%=(Recordset1.Fields.Item("Name").Value)%>">
                        <font color="#FF0000">*</font> </td>
                            </tr>
                            <tr> 
                              <td align=right width="80">性别:</td>
                              <td align=left width="426"> 
                                <select Name=Sex>
                                  <option value="男">男</option>
                                  <option value="女">女</option>
                                  <%
While (NOT Recordset1.EOF)
%>

⌨️ 快捷键说明

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