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

📄 major_result_query.asp

📁 ASP程序实现的科技期刊系统
💻 ASP
字号:
<!--#include file="../include/AdoConn.asp"-->
<%
	table_name=Request.QueryString("tablename")'表名
'	dim strconn       '连接串
'	dim objconn        'connection对象
'	dim objrec         'recordset对象
'	dim strsql         'sql语句
'	dim table_name     '数据表名
	
	set objres=server.CreateObject ("adodb.recordset")
	objres.CursorType =3
	objres.CursorLocation =3
	objres.LockType =2
	strsql="select * from "+table_name
   
    
if Request.QueryString("submit")="submit" then    '提交而来
	strsql=strsql+" where "+ Request.Form("radio1")
	objres.Open strsql,strconn
	actionstr=Request.QueryString("aspname")+"?"+objres.Fields(0).Name +"="+objres.Fields(0).Value 
	if objres.Fields.Count >1 then
		for i=1 to objres.Fields.Count -1
			actionstr=actionstr+"&"+objres.Fields(i).Name +"="+objres.Fields(i).Value 
		next
	end if
'	Response.Redirect  actionstr 
session("objres.fields(0).name")=objres.Fields(0).Value 
end if
	
	 objres.Open strsql,strconn
 
 '接收数据
 selectname1=Request.Form("selectname1")    '列名1
 selectname2=Request.Form("selectname2")    '列名2
 selectrel1=Request.Form("selectrel1")      '关系1
 selectrel2=Request.Form("selectrel2")      '关系2
 textfield1=Request.Form("textfield1")      '输入1
 textfield2=Request.Form("textfield2")      '输入2
 radio=Request.Form("radiobutton")          '两个条件之间的关系
 
	function selrel(intrel)       '将索引值转化为对应运算符
		select case intrel
			case "0"
			selrel=" = "		
			case "1"
			selrel=" <> "
			case "2"
			selrel=" > "
			case "3"
			selrel=" < "
			case "4"
			selrel=" <= "
			case "5"
			selrel=" >= "
			case else 
			selrel=" like "
		end select
	end function
	 
	item0type=cint(objres.Fields.Item(cint(selectname1)).Type )'处理主键的不同数据类型
	function type0()
		select case item0type
			case 3
			type0=""
			case 135
			type0="#"
			case 200
			type0="'"
			case else
		end select
	end function
    
	
	dim where1       'where语句第一部分
	dim where2       'where语句第二部分
	
	if not textfield1=""then         '处理第一个查询条件
		select case cint(objres.Fields.Item(cint(selectname1)).Type )
			case 3        'int类型
			where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+textfield1
			case 135     'datetime类型
			where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+"#"+textfield1+"#"
			case 200     'VC类型
				select case selectrel1
					case "6"        '包含
					where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+"'%"+textfield1+"%'"
					case "7"         '类似
					where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+"'"+textfield1+"%'"
					case else        '其它
					where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+"'"+textfield1+"'"
				end select
			case else      '其他类型,不作处理
		end select
	end if
	
	if not textfield2=""then         '处理第二个查询条件
		select case cint(objres.Fields.Item(cint(selectname2)).Type )
			case 3        'int类型
			where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+textfield2
			case 135     'datetime类型
			where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+"#"+textfield2+"#"
			case 200     'VC类型
				select case selectrel2
					case "6"        '包含
					where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+"'%"+textfield2+"%'"
					case "7"         '类似
					where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+"'"+textfield2+"%'"
					case else        '其它
					where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+"'"+textfield2+"'"
				end select
			case else      '其他类型,不作处理
		end select
	end if
	
								'处理sql语句
	if not where1="" then
		if not where2="" then '两个条件都填写了,考虑两个条件之间的逻辑关系
			if  radio="andrel" then strsql="select * from "+table_name+" where "+where1 +" and "+where2 else  strsql="select * from "+table_name+" where "+where1 +" or "+where2
			else
			strsql="select * from "+table_name+" where "+where1
		end if 
		else
		if not where2="" then 
			strsql="select * from "+table_name+" where "+where2
			else
			strsql="select * from "+table_name
		end if
	end if
	
	objres.Close 
	objres.Open  strsql,strconn
	reccount=objres.RecordCount '记录条数
	itemcount=2 '烈数
		redim arrayitemname(itemcount-1)'以数组形式记录列名
		arrayitemname(0)="专业编码"
		arrayitemname(1)="专业名称"

'	itemcount=objres.Fields.Count '烈数
	if reccount>0 then	'以数组形式处理记录
		redim arrayrecord (reccount-1,itemcount-1)
		for i=0 to reccount-1
			for j=0 to itemcount-1
				arrayrecord(i,j)=objres(arrayitemname(j)).Value 
			next
			objres.MoveNext 
		next

'		redim arrayitemname(itemcount-1)'以数组形式记录列名
'		for j=0 to itemcount-1
'				arrayitemname(j)=objres.Fields(j).name
'		next
	end if
   
  
%>
<%
dim Pname
Pname=Request.QueryString("Pname")
%>
<script language="vbscript">
function back()
history.back 
end function
</script>
<script language=javascript> 
function updateparent(textfield,objLength){ 
if (objLength==1)//只有一项
{opener.document.forms(0).<%=Pname%>.value=textfield.value }
if (objLength==0)//有多项
{
	for(i=0;i<textfield.length;i++)
		{
		if (textfield(i).checked) opener.document.form1.<%=Pname%>.value=textfield(i).value 
		}
}
window.close()
} 
//end hiding 
</script> 
<html>
<head>
<title>查询结果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/CssLib/Cssbutton.css">
<STYLE type=text/css>A {
	TEXT-DECORATION: none
}
    TD {FONT-SIZE: 9pt}
</STYLE>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="_result_Query.asp?submit=submit&tablename=<%=table_name%>&aspname=<%=Request.QueryString("aspname")%>">
  <div align="center">
    <table style="font-size:9pt" width="300" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td width="75" height="20" valign="bottom"> 
          <div align="center"><img src="../../public/images/find_2.gif" width="75" height="25" border="0"onclick="back()"></div>
        </td>
        <td width="75" height="20" valign="bottom"><img src="../../public/images/find_3.gif" width="75" height="25"></td>
        <td width="150" height="20">&nbsp;</td>
      </tr>
      <tr> 
        <td colspan="3" bgcolor="#6699FF"></td>
      </tr>
    </table>
    <table width="300" border="1" cellspacing="0" cellpadding="0" bordercolor="#6699FF">
      <tr> 
        <td height="130"> 
          <%if reccount >0 then   '查到了符合要求的记录%>
          <font color="#0066CC"><br>
          您的查询结果如下:</font>
          <input type="button" value="确定" id=button1 name=button1 onClick="javascript:<%if reccount=1 then %>updateparent(code,1) <%else%> updateparent(code,0)<%end if%>" class="button">
          <table width="250" border="0" cellspacing="0" cellpadding="0" align="center" height="30">
            <tr> 
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <%for i=0 to itemcount-1 %>
              <td><%=arrayitemname(i)%></td>
              <%next%>
            </tr>
            </table>
            
          <table width="250" border="0" cellspacing="0" cellpadding="0" align="center">
            <tr> 
              <td height="151" valign="top"> 
         <% if reccount>5 then     '超过5条记录时滚动显示%>
            <MARQUEE direction=down height=150 width=200 scrollAmount=1 scrollDelay=100   align="center">
            <% end if%>
			
                <table width="250" border="0" cellspacing="0" cellpadding="0" align="center" >

                  <%  i=0' 第一行%>
                  <tr> 
                    <td>&nbsp;</td>
                    <td> 
                      <input type="radio" id="radio1" name="code" checked  value="<% Response.write arrayrecord(i,0)%>">
                    </td>
                    <%for j=0 to itemcount-1 %>
                    <td><%=arrayrecord(i,j)%></td>
                    <%next%>
                  </tr>
                  <% if reccount>1 then     '第二行以后
            for i=1 to  reccount -1%>
                  <tr> 
                    <td>&nbsp;</td>
                    <td> 
                      <input type="radio" id="radio1" name="code" value="<% Response.write arrayrecord(i,0)%>">
                    </td>
                    <%for j=0 to itemcount-1 '显示一行%>
                    <td><%=arrayrecord(i,j)%></td>
                    <%next%>
                  </tr>
                  <% next 
            end if%>
                </table>
           </MARQUEE>
              </td>
            </tr>
          </table>
          <br>
          <%else     '无符合要求的记录%>
            
          <p><font color="#0066CC"> <br>
            对不起,没有符合您的查询要求的记录</font> </p>
          <table width="250" border="0" cellspacing="0" cellpadding="0" align="center" height="70" bgcolor="#FFF8F4">
            <tr> 
              <td>&nbsp;</td>
            </tr>
          </table>
          <% end if%>
        </td>
      </tr>
      
    </table>
  </div>
</form>
<div align="center"><br>
</div>
</body>
</html>

⌨️ 快捷键说明

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