📄 userupdate.asp
字号:
<!--#INCLUDE FILE="../database/conn.asp"-->
<%
Response.Write "<form name=form1>"
Dim Method,oRs
Method = Request.QueryString("method")
sub useroper() '防止非法用户
select case session("admin_name")
case "sa"
exit sub
case "admin"
exit sub
case else
%>
<script language="javascript">
alert("你无权访问案例查询模块!")
history.back();
</script>
<%
end select
end sub
Select case Method
case "add"
Add(conn)
case "edit"
Edit(conn)
case "Delete"
Delete(conn)
case "Query"
call Query(conn,Method)
case "check"
check(conn)
case "uncheck"
uncheck(conn)
case "xiugaiPwd"
xiugaiPwd(conn)
End Select
Sub Add(conn)
dim student_no,st_name,xibie,zhuanye,banji,tel,jianshu,Ifadmission, errmsg
student_no=Trim(request.form("student_no")) '用户ID
st_name=Trim(Request.Form("st_name"))
xibie=Trim(request.Form("xibie"))
zhuanye=Trim(request.Form("zhuanye"))
banji= Trim(request.Form("banji"))
tel=Trim(Request.Form("tel"))
Ifadmission="0"
jianshu=Request.Form("jianshu") '以上为传递数据到变量。
errmsg = ""
if student_no="" then errmsg= "帐号不能为空 "
if st_name="" then errmsg=errmsg & "姓名不能为空 "
if xibie="" then errmsg=errmsg & "请选择系别类型! "
if tel="" then errmsg=errmsg & "联系电话不能为空 "
if zhuanye="" then errmsg=errmsg & "专业不能为空 "
if banji="" then errmsg=errmsg & "班级不能为空! "
if jianshu="" then errmsg=errmsg & "简述不能为空! "
if errmsg<>"" then
Response.Write errmsg %>
<script language="javascript">
alert("<%=errmsg%>")
history.back();
</script>
<% else
Set rs = Server.CreateObject("ADODB.RECORDSET")
sql="select * from student where student_no='" &student_no&"'"
rs.open sql,conn,3,3
if not Rs.eof then
%>
<table width=620 height="171" align=left>
<tr>
<td colspan="2" height="38"><%="用户帐号重复,请返回!!"%> </td>
</tr>
<tr>
<td colspan="2" height="52"> </td>
</tr>
<tr>
<td width="193" align=right>
<input type=button value="返回" name=cmdback onclick="history.back()">
</td>
</tr>
</table>
<%
exit sub
CleanUp(oRs)
else
rs.AddNew
rs("student_no")=Trim(student_no)
rs("st_name")=Trim(st_name)
rs("xibie")=Trim(xibie)
rs("zhuanye")=Trim(zhuanye)
rs("banji")=Trim(banji)
rs("tel")=Trim(tel )
rs("Ifadmission")=trim(Ifadmission)
rs("jianshu")=Trim(jianshu)
rs.Update
rs.Close
conn.Close
set conn=nothing
set rs=nothing %>
<table>
<tr>
<td>添加完成,请点击<A href=useradd.asp>返回</A></td>
</table>
<%
'Response.Redirect "useradd.asp"
end if
end if
End Sub
'////////////////////////////////////////////////////////////////////////////////////
%>
<%
Sub Edit(conn)
dim student_no,st_name,xibie,zhuanye,banji,tel,jianshu
dim EditSql
id=request.Form("id")
student_no="'"& trim(Request.Form("student_no"))&"'"
st_name="'"& trim(Request.Form("st_name"))&"'"
xibie="'"& trim(Request.Form("xibie"))&"'"
zhuanye="'"& trim(Request.Form("zhuanye"))&"'"
banji="'"& trim(Request.Form("banji"))&"'"
tel="'"& trim(Request.Form("tel"))&"'"
jianshu="'"& trim(Request.Form("jianshu"))&"'"
set rs=server.CreateObject("adodb.recordset")
sql="select * from student where id="&id
rs.open sql,conn,1,3
if not Rs.eof then
conn.execute( "update student set student_no="&student_no&",st_name="&st_name&",zhuanye="&zhuanye&",xibie="&xibie&",tel="_
&tel&",banji="&banji&",jianshu="&jianshu &" where id="&id )
if error>0 then
response.Write("数据出错,或者没有填写完整")
else
response.Write("数据编辑完毕请点击<A href=../student/student_info.asp>返回</A>")
End if
response.Write("数据编辑完毕请点击<A href=../student/student_info.asp>返回</A>")
end if
' conn.nothing
Response.Redirect "../student/student_info.asp"
End Sub
'////////////////////////////////////////////////////////////////////////////////////
Sub xiugaiPwd(conn)
Dim id,password,password1,password2
id= Request.Form("id")
password=request.form("password")
password1=request.form("password1")
password2=request.form("password2")
if password1<>password2 then %>
<table>
<tr>
<td>
<script language="javascript">
alert("密码和密码确认不一致,请返回!")
history.back();
</script>
</td>
</table>
<%
exit sub
end if
sql="select password from userlist where password= '"&password &"'"
sql =sql &" and id=" &id
rs.open sql,conn,3,3
if not Rs.eof then
conn.execute "update userlist set password='" &password1 &"' where id="& id
%>
<table>
<tr>
<td>密码修改完毕,请点击<A href=../xiugaiPwd.asp>返回</A></td>
</table>
<%else%>
<table>
<tr>
<td>
<script language="javascript">
alert("旧密码不正确,你不能更改密码,请返回!")
history.back();
</script>
</td>
</table>
<%end if
rs.close
conn.close
End Sub
'////////////////////////////////////////////////////////////////////////////////////
Sub check(conn)
Dim plusDevicplat,i,checksql
for each id in Request.Form("mid")
if Session("admin_name")="sa" and Session("Ifadmission")="1" then
checksql="update student set ifadmission='1' where id='" &id&"'"
conn.execute(checksql)
end if
next%>
<table>
<tr>
<td>数据审批完毕,请点击<A href=../student/student_info.asp>返回</A></td>
</table>
<%
conn.close
End Sub
'////////////////////////////////////////////////////////////////////////////////////
Sub uncheck(conn)
Dim plusDevicplat,i,unchecksql,id
for each id in Request.Form("mid")
if Session("admin.name")="sa" then
unchecksql="update student set ifadmission='0' where id='" &id&"'"
conn.execute(unchecksql)
end if
next%>
<table>
<tr>
<td>数据未批准完毕,请点击<A href=../student/student_info.asp>返回</A></td>
</table>
<%
conn.close
End Sub
'////////////////////////////////////////////////////////////////////////////////////
Sub Delete(conn)
Dim plusDevicplat,i,delsql
for each id in Request.Form("mid") '循环删除每一个
delsql="delete from student where id='" &id&"'"
conn.execute(delsql)
next%>
<table>
<tr>
<td>数据删除成功,请点击<A href=../student/student_info.asp>返回</A></td>
</table>
<%
conn.close
End Sub%>
</form>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -