productlist.asp

来自「Activity——活动管理模块 Analyse——分析模块 Client—」· ASP 代码 · 共 260 行

ASP
260
字号
<!--#include file="../conn.asp"-->
<!--#include file="../IsUser.asp"-->
<!--#include file="../Pub_Fun.asp"-->
<%
''删除记录
if request("act")="del" then
	For Each item in request.form
		if Left(item, 8) = "ckdelete" then
			conn.execute("delete from Product where ProductID="&Cint(request(item)))
		end if
	Next
end if

	 '获得传递参数
	 ListPageSize = request("PageSelect")
	 ''默认为每页显示15条记录
	 if ListPageSize = "" then
	 	ListPageSize = 15
	 end if
	 ListPageSize = Cint(ListPageSize)	 

	 SelectPage = request("SelPage")
	 ''默认当前页面为第一页
	 if SelectPage = "" then
	 	SelectPage = 1
	 end if
	 SelectPage = Cint(SelectPage)
	 
''获得查询的字段	 
	 SearchOption =request("S_SearchOption")
	 if SearchOption = "" then
	    SearchOption = 0
	 end if
	 SearchOption = Cint(SearchOption)
	 
''获得查询的关系
	 SearchRelation = request("S_Relation")
	 if SearchRelation = "" then
	 	SearchRelation = "包含"
	 end if
	 
''查询条件中关键字符的处理 
	 SearchText = request("T_SearchText")
	 SqlSearchText = replace(SearchText,"'","''")
	 SqlSearchText = replace(SearchText,"[","[[]")
	 SqlSearchText = replace(SearchText,"]","[]]")
	 SqlSearchText = replace(SearchText,"%","[%]")
	 SqlSearchText = replace(SearchText,"_","[_]")

%>
<%
	 '读取数据库数据
	 Dim Sqlstr
	 	Sqlstr = "select * from Product where 1=1 "
	 	if SearchText <> "" then
             select case SearchOption
			     case 0
				    if SearchRelation = "包含" then
				       sqlstr=sqlstr&"and  ProductName like '%"&SqlSearchText&"%'"
					else
					    sqlstr=sqlstr&"and  ProductName  not like '%"&SqlSearchText&"%'"
					end if
				 case 1
				    if SearchRelation = "包含" then
				       sqlstr=sqlstr&" and ProductSupplyID in (select clientid from client where clientname like '%"& SqlSearchText&"%' )"
					else
					    sqlstr=sqlstr&"and  ProductSupplyID in (select clientid from client where clientname not like '%"& SqlSearchText&"%' )"
					end if
			     case 2
				    if SearchRelation = "包含" then
				       sqlstr=sqlstr&"and  ProductInfo like '%"&SqlSearchText&"%'"
					else
					    sqlstr=sqlstr&"and  ProductInfo  not like '%"&SqlSearchText&"%'"
					end if
			end select			
		end if
		
	sqlstr=sqlstr&" order by ProductID desc"
	 set  rs=server.createobject("adodb.recordset")
	 rs.open Sqlstr,conn,3  '
%>


<!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 http-equiv=Pragma content=no-cache>
<META content="MSHTML 6.00.2715.400" name=GENERATOR>
<style type="text/css">
<!--
.style1 {color: #FF6600}
-->
</style>

</HEAD>

<LINK href="../css.css" rel=stylesheet>
<BODY><BR>
<form action="Productlist.asp" method="post" name="Productfm">
<input type="hidden" name="act">
  <TABLE  width="751" border=0 align=center cellPadding=0 cellSpacing=0>
    <TBODY> 
    <TR> 
        <TD  height="24" valign="top"    bgcolor="#566CDB" ><img src="../images/DispStation_H.gif" width="11" height="24">产品相关信息查看</TD>
      <TD colspan="3" align="right" valign="middle" bgcolor="#DDDDDD" >快速查询:
        <select name="S_SearchOption" class="text60" >
		<option value="0" <%if SearchOption = 0 then%>selected<% end if %>>产品名称</option>
		<option value="1" <%if SearchOption = 1 then%>selected<% end if %>>供应商名称</option>
		<option value="2" <%if SearchOption = 2 then%>selected<% end if %>>产品信息</option> 		
        </select>
          &nbsp;&nbsp; <select name="S_Relation" class="text40" id="S_Relation">
            <option value="包含" <%if SearchRelation = "包含" then%>selected<% end if %>>包含</option>
            <option value="不包含" <%if SearchRelation = "不包含" then%>selected<% end if %>>不包含</option>
          </select>
          &nbsp;&nbsp; 
          <input name="T_SearchText" type="text"  size="15" maxlength="50" value="<%=SearchText%>">

<input name="SearchButton" type="submit" class="button_all"  value="查询">
      <input name="NewProduct" onClick="javascript:location.href='Product.asp'" type="button" class="button_all" id="NewClient" value="新建">
      <input name="DeleteButton" type="button" class="button_all" id="DeleteClient" value="删除">
      <input name="BackButton" onClick="javascript:location.href='../menu.asp'" type="button" class="button_all" id="BackButton" value="返回">
</TD>
      </TR>
	 </TBODY>
</TABLE>
<TABLE  width="751" border=0 align=center cellPadding=0 cellSpacing=0>
  <TBODY> 
    <TR>
      <TD height="5%"  valign="top"  style="border: #99ccff 1px solid " bgcolor="#6699FF">&nbsp;</TD>
      <TD width="30%" align="center" valign="middle" style="border: #99ccff 1px solid " bgcolor="#6699FF">产品名称</TD>
	  <TD width="30%" align="center" valign="middle" style="border: #99ccff 1px solid " bgcolor="#6699FF">供应商名称</TD>
      <TD  align="center" valign="middle" style="border: #99ccff 1px solid " bgcolor="#6699FF">产品介绍</TD>
    </TR>
	<%  
		'显示处理		
		TotalPages = 1
		TotalRecords = 0
		TotalFlag = 0
		if not(rs.bof or rs.eof) then
			TotalRecords = rs.recordcount
				if ListPageSize = 0 then
					ListPageSize = TotalRecords
					TotalFlag = 1
				end if
			rs.pagesize = ListPageSize
			TotalPages = rs.pagecount
				if SelectPage > TotalPages then
				 	SelectPage = 1
				end if
			rs.absolutepage = SelectPage                  
			for i = 1 to ListPageSize 
				if not(rs.bof or rs.eof) then
	%>
	 <TR>
      <TD height="25"  align="center" valign="middle"  style="border: #99ccff 1px solid " ><input type="checkbox" name="ckdelete<%=i%>" value="<%=rs("ProductID")%>"></TD>
      <TD  align="center" valign="middle" style="border: #99ccff 1px solid " ><div align="left"><a href="product.asp?act=edit&id=<%=trim(rs("ProductID"))%>"><%=rs("ProductName")%></a></div></TD>
	  <TD align="center" valign="middle" style="border: #99ccff 1px solid " ><div align="left"><%=showclientname(trim(rs("ProductSupplyID")))%></div></TD>
      <TD  align="center" valign="middle" style="border: #99ccff 1px solid " ><div align="left"><%=rs("ProductInfo")%></div></TD>

    </TR>
	<%
				rs.movenext
				end if
			next
		end if
	%>

    <TR valign="middle">
      <TD height="30" colspan="4" >
	  <table width="100%">
	 <tr><td width="2%"></td>
	 <td  align="left">
	  <select name="PageSelect">
	    <%
			'生成下拉列表
			for i= 1 to 20
		%>
		<option <%if ListPageSize = i*5 then%>selected<%end if%> value="<%=i*5%>">每页显示<%=i*5%>条</option>
		<%
			next
		%>
		<option <%if TotalFlag = 1 then%>selected<%end if%> value="0">..全部显示..</option>
      </select>
	 </td>
	 <td align="right">	   
	  <%if SelectPage<>1 then%><a href="#" name="FirstPage">首页</a> <a href="#" name="PrePage">上一页</a><%else%>首页 上一页<%end if%> <%if SelectPage<>TotalPages then%><a href="#" name="NextPage"> 下一页</a> <a href="#" name="LastPage">末页</a><%else%> 下一页 末页<%end if%>&nbsp;&nbsp; 当前页数:<%=SelectPage%> 总共页数:<%=TotalPages%> 记录总数:<%=TotalRecords%>
      <input name="SelPage" type="hidden"  value="<%=SelectPage%>">
	  <input name="TotalPage" type="hidden"  value="<%=TotalPages%>">
        </td></tr>
	  </table>
	  </TD>
	  </TR>
	  
   <tr bgColor=#99ccff >
      <td height="10" colspan="4"></td>

    </tr>
    </TBODY> 
</TABLE>
</form>
</BODY></HTML>
	  <!--查询响应函数-->
	   <SCRIPT FOR="SearchButton" EVENT="onClick" LANGUAGE="VBScript">
			Dim TheForm
			Set TheForm = Document.forms("Productfm")
			TheForm.SelPage.value = 1
			TheForm.submit()
	   </SCRIPT>	   

	  <!--下拉列表响应函数-->
	   <SCRIPT FOR="PageSelect" EVENT="onChange" LANGUAGE="VBScript">
			Dim TheForm
			Set TheForm = Document.forms("Productfm")
			TheForm.SelPage.value = 1
			TheForm.submit()
	   </SCRIPT>

	  <!--删除响应函数-->
	   <SCRIPT FOR="DeleteButton" EVENT="onClick" LANGUAGE="VBScript">
			Dim TheForm
			Set TheForm = Document.forms("Productfm")
				MyVar = MsgBox ("你确认要删除选中的产品资料么?",52, "确认删除")
				if MyVar = 6 then
				   TheForm.act.value="del"
					TheForm.submit()
				end if
	   </SCRIPT>

	  <!--首页响应函数-->
	   <SCRIPT FOR="FirstPage" EVENT="onClick" LANGUAGE="VBScript">
			Dim TheForm
			Set TheForm = Document.forms("Productfm")
			TheForm.SelPage.value = 1
			TheForm.submit()
	   </SCRIPT>
	  
	  <!--下一页页响应函数-->
	   <SCRIPT FOR="NextPage" EVENT="onClick" LANGUAGE="VBScript">
			Dim TheForm
			Set TheForm = Document.forms("Productfm")
			TheForm.SelPage.value = TheForm.SelPage.value + 1
			TheForm.submit()
	   </SCRIPT>
	  
	  <!--上一页响应函数-->
	   <SCRIPT FOR="PrePage" EVENT="onClick" LANGUAGE="VBScript">
			Dim TheForm
			Set TheForm = Document.forms("Productfm")
			TheForm.SelPage.value = TheForm.SelPage.value - 1
			TheForm.submit()
	   </SCRIPT>
	  
	  <!--末页响应函数-->
	   <SCRIPT FOR="LastPage" EVENT="onClick" LANGUAGE="VBScript">
			Dim TheForm
			Set TheForm = Document.forms("Productfm")
			TheForm.SelPage.value = TheForm.TotalPage.value
			TheForm.submit()
	   </SCRIPT>

⌨️ 快捷键说明

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