asp搜索问题,大侠帮忙看看
帮忙看看代码怎么回事,现在按名称可以正常搜索,但是按单位无法搜索,单位字段Users_Danwei,数字型字段,这是个考试系统,原来的系统只有按名称搜索,现在我加了一个单位字段,但是单位这个说什么也搜索不了,各位高手帮忙看看,asp新手,这是这个页面的代码<!--#Include File="Include.asp"--><%
'==========================================
'文 件 名:Admin/Users.asp
'文件用途:考生管理
'==========================================
Call CheckAdminType("0",Admin_Type)
Dim Paper
Dim Users_LoginName,Users_LoginPass,Users_Name,Users_Danwei
Types=Clng(Request.QueryString("Type"))
Select Case Types
Case 1
Call UsersList() '考生列表
Case 2
Call UsersAddForm() '添加考生表单
Case 3
Call UsersAddDo() '执行添加考生
Case 4
Call UsersEditForm() '修改考生表单
Case 5
Call UsersEditDo() '执行修改考生
Case 6
Call UsersDelDo() '执行删除考生
Case 7
Call ImportDo() '执行考生导入
Case Else
Call FKFun.ShowErr("未发现功能项!",1)
End Select
'==========================================
'函 数 名:UsersList()
'作 用:考生列表
'==========================================
Sub UsersList()
Dim Paper_Name
Paper=Request.QueryString("Paper")
If Paper<>"" Then
Paper=Clng(Paper)
Sqlstr="Select Paper_Id,Paper_Name From [Paper] Where Paper_Id=" & Paper
Else
Sqlstr="Select Top 1 Paper_Id,Paper_Name From [Paper] Order By Paper_Id Desc"
End If
Rs.Open Sqlstr,Conn,1,1
If Not Rs.Eof Then
Paper=Rs("Paper_Id")
Paper_Name=Rs("Paper_Name")
Else
Rs.Close
Call FKFun.ShowErr("<div id='rightNav'><ul><li><a href='Paper.asp?Type=1' target='get' div='mainRight'>考试项目管理</a></li></ul></div><div id='searchLine' class='font_bold'>未找到考试项目</div>",2)
End If
Rs.Close
PageNow=Request.QueryString("Page")
If PageNow<>"" Then
PageNow=Clng(PageNow)
Else
PageNow=1
End If
Users_Name=FKFun.HTMLEncode(Trim(Request.QueryString("Users_Name")))
Session("NowPage")=FkFun.GetNowUrl()
%>
<div id="rightNav">
<ul>
<li><a href="Users.asp?Type=2&Paper=<%=Paper%>" target="dialog" width="400">添加考生</a></li>
<li><a href="javascript:void(0);" onclick="ajax_get('mainRight','<%=Session("NowPage")%>');">刷新</a></li>
</ul>
</div>
<div id="searchLine" class="font_bold">
<p>“<%=Paper_Name%>”考生管理
<select name="Paper" id="Paper" class="input" onchange="ajax_get('mainRight','Users.asp?Type=1&Paper='+$(this).val());">
<%
Sqlstr="Select Paper_Id,Paper_Name From [Paper] Order By Paper_Id Desc"
Rs.Open Sqlstr,Conn,1,1
If Not Rs.Eof Then
While Not Rs.Eof
%>
<option value="<%=Rs("Paper_Id")%>"<%=FkFun.BeSelect(Paper,Rs("Paper_Id"))%>><%=Rs("Paper_Name")%></option>
<%
Rs.MoveNext
Wend
End If
Rs.Close
%>
</select></p>
<p> 考生用户名/姓名:
<input type="text" class="input" name="UsersName" value="<%=Users_Name%>" id="UsersName" />
<select name="UsersDanwei" class="input" id="UsersDanwei">
<option>所有单位</option>
<option value="1"<%=FKFun.BeSelect(Users_Danwei,1)%>>人大</option>
<option value="2"<%=FKFun.BeSelect(Users_Danwei,2)%>>政协</option>
<option value="3"<%=FKFun.BeSelect(Users_Danwei,3)%>>法院</option>
</select>
<input type="button" value="搜 索" onClick="ajax_get('mainRight','Users.asp?Type=1&Paper=<%=Paper%>&Users_Name='+escape($('#UsersName').val())+'&Users_Danwei='+escape($('#UsersDanwei').val()));" class="button" /></p>
</div>
<table width="100%" bordercolor="#CCCCCC" border="1" cellspacing="0" cellpadding="0">
<form name="AddFile" id="AddFile" onsubmit="return false;">
<tr>
<td height="30" colspan="7" style="padding-bottom:5px;">
考生名单导入 <input name="XlsFile" value="" type="hidden" id="XlsFile" />
<iframe frameborder="0" width="290" height="30" scrolling="No" id="XlsFiles" name="XlsFiles" src="Upfile.asp?Form=AddFile&Input=XlsFile"></iframe>
<input type="button" value="导 入" class="button" onclick="if($('#XlsFile').val()!=''){ajax_get('mainRight','Users.asp?Type=7&Paper=<%=Paper%>&XlsFile='+$('#XlsFile').val());}else{alert('请先点浏览选择文件,再点上传,上传导入文件!');}" /> <a href="users.xls" target="_blank">下载导入格式</a>
</td>
</tr>
</form>
<tr>
<th align="center">序号</th>
<th align="center">登录名</th>
<th align="center">姓名</th>
<th align="center">单位</th>
<th align="center">是否考试</th>
<th align="center">考试成绩</th>
<th align="center">操作</th>
</tr>
<%
Call FKDB.PaperDB_Open(Paper)
Sqlstr="Select Users_Id,Users_LoginName,Users_Name,Users_Danwei,Users_Ip,Users_AllFraction From [Users] Where 1=1"
If Users_Name<>"" Then
Sqlstr=Sqlstr&" And (Users_Name Like '%%"&Users_Name&"%%' Or Users_LoginName Like '%%"&Users_Name&"%%')"
End If
If Users_Danwei<>"" Then
Sqlstr=Sqlstr&" And Users_Danwei="&Users_Danwei&""
End If
Sqlstr=Sqlstr&" Order By Users_Id Asc"
Rs.Open Sqlstr,PaperConn,1,1
If Not Rs.Eof Then
i=1+(PageNow-1)*PageSizes
Rs.PageSize=PageSizes
If PageNow>Rs.PageCount Or PageNow<=0 Then
PageNow=1
End If
PageCounts=Rs.PageCount
Rs.AbsolutePage=PageNow
PageRecordCount=Rs.RecordCount
j=1
While (Not Rs.Eof) And j<PageSizes+1
If Rs("Users_Ip")<>"" Then
Temp="<span style='color:#0C0'>已考</span>"
Else
Temp="<span style='color:#F00'>未考</span>"
End If
%>
<tr>
<td height="20" align="center"><%=i%></td>
<td align="center"><%=Rs("Users_LoginName")%></td>
<td align="center"><%=Rs("Users_Name")%></td>
<td align="center"><%=FKFun.GetDanweiTypeName(Rs("Users_Danwei"))%></td>
<td align="center"><%=Temp%></td>
<td align="center"><%=Rs("Users_AllFraction")%></td>
<td align="center"><a href="Users.asp?Type=4&Paper=<%=Paper%>&Id=<%=Rs("Users_Id")%>" target="dialog" width="300">修改</a> <a href="Users.asp?Type=6&Paper=<%=Paper%>&Id=<%=Rs("Users_Id")%>" target="delete" confirmStr="您确认要删除“<%=Rs("Users_Name")%>[<%=Rs("Users_LoginName")%>]”?此操作不可逆!" refreshUrl="<%=Session("NowPage")%>" showStr="考生删除成功!">删除</a></td>
</tr>
<%
Rs.MoveNext
i=i+1
j=j+1
Wend
Else
%>
<tr>
<td height="25" colspan="7" align="center">暂无记录</td>
</tr>
<%
End If
Rs.Close
%>
<tr>
<td height="30" colspan="7"> <%Call FKFun.ShowPageCode("Users.asp?Type=1&Users_Name="&Server.URLEncode(Users_Name)&"&Paper="&Paper&"&Page=",PageNow,PageRecordCount,PageSizes,PageCounts)%></td>
</tr>
</table>
<div id="rightBottom">
</div>
<%
End Sub
'==========================================
'函 数 名:UsersAddForm()
'作 用:添加考生表单
'==========================================
Sub UsersAddForm()
Paper=Clng(Request.QueryString("Paper"))
%>
<form id="UsersAdd" name="UsersAdd" method="post" target="ajax" action="Users.asp?Type=3" showStr="新考生添加成功!" refreshUrl="Users.asp?Type=1&Paper=<%=Paper%>" boxClose="1">
<div id="title">添加新考生</div>
<div id="box">
<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="24%" height="30" align="right">登录名:</td>
<td width="76%"> <input name="Users_LoginName" type="text" class="input" id="Users_LoginName" /><span class="help" title="<p>考生登录使用,建议用英文、数字,不可重复,请输入1-50个字符(两个字符为一个汉字)。</p>"></span></td>
</tr>
<tr>
<td height="30" align="right">密码:</td>
<td> <input name="Users_LoginPass" type="text" class="input" id="Users_LoginPass" /><span class="help" title="<p>姓名,请输入1-50个字符。</p>"></span></td>
</tr>
<tr>
<td height="30" align="right">姓名:</td>
<td> <input name="Users_Name" type="text" class="input" id="Users_Name" /><span class="help" title="<p>密码,请输入1-50个字符。</p>"></span></td>
</tr>
<tr>
<td height="30" align="right">单位:</td>
<td>
<select name="Users_Danwei" id="Users_Danwei">
<option selected="selected">选择单位</option>
<option value="1">人大</option>
<option value="2">政协</option>
<option value="3">法院</option>
</select>
</td>
</tr>
</table>
</div>
<div id="bottom">
<input type="hidden" name="Paper" value="<%=Paper%>" />
<input type="submit" class="button" name="Enter" id="Enter" value="添 加" />
<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub
'==============================
'函 数 名:UsersAddDo
'作 用:执行添加考生
'==============================
Sub UsersAddDo()
Paper=Trim(Request.Form("Paper"))
Users_LoginName=FKFun.HTMLEncode(Trim(Request.Form("Users_LoginName")))
Users_LoginPass=FKFun.HTMLEncode(Trim(Request.Form("Users_LoginPass")))
Users_Name=FKFun.HTMLEncode(Trim(Request.Form("Users_Name")))
Users_Danwei=FKFun.HTMLEncode(Trim(Request.Form("Users_Danwei")))
Call FKFun.JsonString(Users_LoginName,1,50,0,"请输入登录名!","登录名不能大于50个字符!")
Call FKFun.JsonString(Users_LoginPass,1,50,0,"请输入登录密码!","登录密码不能大于50个字符!")
Call FKFun.JsonString(Users_Name,1,50,0,"请输入姓名!","姓名不能大于50个字符!")
Call FKFun.JsonNum(Users_Danwei, "请选择单位!")
Call FKFun.JsonNum(Paper,"考试项目编号获取失败!")
Call FKDB.PaperDB_Open(Paper)
Sqlstr="Select Users_Id,Users_LoginName,Users_LoginPass,Users_Name,Users_Danwei From [Users] Where Users_LoginName='"&Users_LoginName&"'"
Rs.Open Sqlstr,PaperConn,1,3
If Rs.Eof Then
Application.Lock()
Rs.AddNew()
Rs("Users_LoginName")=Users_LoginName
Rs("Users_LoginPass")=Users_LoginPass
Rs("Users_Name")=Users_Name
Rs("Users_danwei")=Users_Danwei
Rs.Update()
Application.UnLock()
Call FKFun.JsonSuccess()
Else
Rs.Close
Call FKDB.PaperDB_Close()
Call FKFun.JsonError("该登录名已经被占用!")
End If
Rs.Close
Call FKDB.PaperDB_Close()
End Sub
'==========================================
'函 数 名:UsersEditForm()
'作 用:修改考生表单
'==========================================
Sub UsersEditForm()
Paper=Clng(Request.QueryString("Paper"))
Id=Clng(Request.QueryString("Id"))
Call FKDB.PaperDB_Open(Paper)
Sqlstr="Select Users_LoginName,Users_LoginPass,Users_Name,Users_Danwei From [Users] Where Users_Id=" & Id
Rs.Open Sqlstr,PaperConn,1,1
If Not Rs.Eof Then
Users_LoginName=Rs("Users_LoginName")
Users_LoginPass=Rs("Users_LoginPass")
Users_Name=Rs("Users_Name")
Users_Danwei=Rs("Users_Danwei")
Else
Rs.Close
Call FKFun.ShowErr("考生不存在,请按键盘的ESC键退出!",2)
End If
Rs.Close
Call FKDB.PaperDB_Close()
%>
<form id="UsersEdit" name="UsersEdit" method="post" target="ajax" action="Users.asp?Type=5" showStr="考生修改成功!" refreshUrl="<%=Session("NowPage")%>" boxClose="1">
<div id="title">修改考生</div>
<div id="box">
<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="24%" height="30" align="right">登录名:</td>
<td width="76%"> <%=Users_LoginName%></td>
</tr>
<tr>
<td height="30" align="right">密码:</td>
<td> <input name="Users_LoginPass" type="text" class="input" id="Users_LoginPass" value="<%=Users_LoginPass%>" /><span class="help" title="<p>姓名,请输入1-50个字符。</p>"></span></td>
</tr>
<tr>
<td height="30" align="right">姓名:</td>
<td> <input name="Users_Name" type="text" class="input" id="Users_Name" value="<%=Users_Name%>" /><span class="help" title="<p>密码,请输入1-50个字符。</p>"></span></td>
</tr>
<tr>
<td height="30" align="right">单位:</td>
<td> <select name="Users_Danwei" class="input" id="Users_Danwei">
<option value="1"<%=FKFun.BeSelect(Users_Danwei,1)%>>人大</option>
<option value="2"<%=FKFun.BeSelect(Users_Danwei,2)%>>政协</option>
<option value="3"<%=FKFun.BeSelect(Users_Danwei,3)%>>法院</option>
</select></td>
</tr>
</table>
</div>
<div id="bottom">
<input type="hidden" name="Id" value="<%=Id%>" />
<input type="hidden" name="Paper" value="<%=Paper%>" />
<input type="submit" class="button" name="Enter" id="Enter" value="修 改" />
<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub
'==============================
'函 数 名:UsersEditDo
'作 用:执行修改考生
'==============================
Sub UsersEditDo()
Paper=Trim(Request.Form("Paper"))
Id=Trim(Request.Form("Id"))
Users_LoginPass=FKFun.HTMLEncode(Trim(Request.Form("Users_LoginPass")))
Users_Name=FKFun.HTMLEncode(Trim(Request.Form("Users_Name")))
Users_Danwei=FKFun.HTMLEncode(Trim(Request.Form("Users_Danwei")))
Call FKFun.JsonString(Users_LoginPass,1,50,0,"请输入登录密码!","登录密码不能大于50个字符!")
Call FKFun.JsonString(Users_Name,1,50,0,"请输入姓名!","姓名不能大于50个字符!")
Call FKFun.JsonNum(Users_Danwei,"请选择单位!")
Call FKFun.JsonNum(Id,"考生编号获取失败!")
Call FKFun.JsonNum(Paper,"考试项目编号获取失败!")
Call FKDB.PaperDB_Open(Paper)
Sqlstr="Select Users_Id,Users_LoginPass,Users_Name,Users_Danwei From [Users] Where Users_Id=" & Id
Rs.Open Sqlstr,PaperConn,1,3
If Not Rs.Eof Then
Application.Lock()
Rs("Users_LoginPass")=Users_LoginPass
Rs("Users_Name")=Users_Name
Rs("Users_Danwei")=Users_Danwei
Rs.Update()
Application.UnLock()
Call FKFun.JsonSuccess()
Else
Rs.Close
Call FKDB.PaperDB_Close()
Call FKFun.JsonError("要修改的考生不存在!")
End If
Rs.Close
Call FKDB.PaperDB_Close()
End Sub
'==============================
'函 数 名:UsersDelDo
'作 用:执行删除考生
'==============================
Sub UsersDelDo()
Id=Trim(Request.QueryString("Id"))
Paper=Request.QueryString("Paper")
Call FKFun.ShowNum(Paper,"考试项目未找到!")
Call FKFun.ShowNum(Id,"系统参数错误,请刷新页面!")
Call FKDB.PaperDB_Open(Paper)
Sqlstr="Select Users_Id From [Users] Where Users_Id=" & Id
Rs.Open Sqlstr,PaperConn,1,3
If Not Rs.Eof Then
Application.Lock()
Rs.Delete()
Application.UnLock()
Response.Write("ok")
Else
Response.Write("考生不存在!")
End If
Rs.Close
Call FKDB.PaperDB_Close()
End Sub
'==============================
'函 数 名:ImportDo
'作 用:执行考生导入
'==============================
Sub ImportDo()
On Error Resume Next
Dim Rs2,XlsFile,Conn3
Paper=Request.QueryString("Paper")
If Paper<>"" Then
Paper=Clng(Paper)
Else
Response.Write("<div style=""margin:30px;""><a href=""javascript:void(0);"" onclick=""ajax_get('mainRight','"&Session("NowPage")&"');"">考试项目编号获取失败</a></div>")
Response.End()
End If
XlsFile=Trim(Request.QueryString("XlsFile"))
If XlsFile="" Then
Response.Write("<div style=""margin:30px;""><a href=""javascript:void(0);"" onclick=""ajax_get('mainRight','"&Session("NowPage")&"');"">请先上传导入文件</a></div>")
Response.End()
End If
Response.Write("<div style=""margin:30px;line-height:22px;"">")
Response.Write("导入过程开始<br />")
Response.Flush()
Response.Clear()
Set Rs2=Server.Createobject("Adodb.RecordSet")
Call FKDB.PaperDB_Open(Paper)
Set Conn3=CreateObject("ADODB.Connection")
Conn3.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended properties=Excel 8.0;Data Source="&Server.MapPath(XlsFile)
Sqlstr="Select * From [考生$]"
Rs.Open Sqlstr,Conn3,1,3
If Err Then
Response.Write("<span style=""color:red;"">未找到表名为“考生”的Excel工作表!如下图所示:</span><br /><img src=""Images/xls_users.jpg"" /><br />")
Response.Write("<a href=""javascript:void(0);"" onclick=""ajax_get('mainRight','"&Session("NowPage")&"');"">返回考生列表</a></div>")
Err.Clear
Response.End()
End If
Application.Lock()
While Not Rs.Eof
If Trim(Rs(0))<>"" And Trim(Rs(1))<>"" And Trim(Rs(2))<>"" Then
Sqlstr="Select Users_Id,Users_LoginName,Users_Name,Users_LoginPass,Users_Danwei From [Users] Where Users_LoginName='"&FKFun.HTMLEncode(Rs(0))&"'"
Rs2.Open Sqlstr,PaperConn,1,3
If Rs2.Eof Then
Rs2.AddNew()
Rs2("Users_LoginName")=FKFun.HTMLEncode(Rs(0))
Rs2("Users_Name")=FKFun.HTMLEncode(Rs(1))
Rs2("Users_LoginPass")=FKFun.HTMLEncode(Rs(2))
Rs2("Users_Danwei")=FKFun.HTMLEncode(Rs(3))
Rs2.Update()
Response.Write("<span style=""color:green;"">“"&FKFun.HTMLEncode(Rs(0))&"”帐号成功导入!</span><br />")
Response.Flush()
Response.Clear()
Else
Response.Write("<span style=""color:red;"">“"&FKFun.HTMLEncode(Rs(0))&"”帐号已经存在!</span><br />")
Response.Flush()
Response.Clear()
End If
Rs2.Close
End If
Rs.MoveNext
Wend
Application.UnLock()
Rs.Close
Set Rs2=Nothing
Conn3.Close
Set Conn3=Nothing
Call FKDB.PaperDB_Close()
Response.Write("导入过程完成<br />")
Response.Write("<a href=""javascript:void(0);"" onclick=""ajax_get('mainRight','"&Session("NowPage")&"');"">返回考生列表</a></div>")
End Sub
Call FKFun.PageEnd()
%>