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

📄 shopa_editdisplay.asp

📁 本软件可以实现的功能如下:   用户管理
💻 ASP
字号:
<%option explicit%>
<!-- #include file="shop$db.asp" -->
<!-- #include file="shopa_Tools.asp" -->
<%
ShopCheckAdmin

dim mysql
Dim Fieldcount
Dim Headnames(6)
Dim ProcType
Dim SortType
Dim Sortfield
Dim SortUpDown
Dim Sortupdownnames(2)
Dim Sortupdownvalues(2)
Dim Sortupdowncount
Dim Procnames(3)
dim Procvalues(3)
Dim Fieldnames
Dim Fieldnamecount
Dim DisplayFields
Dim displayFieldCount
Dim DisplayField
Dim Idfield
Dim SelectField
Dim SelectValue
Dim maxfields
Dim i 
Dim item
dim dbtable
Dim scriptresponder
dim fieldname
Dim rstemp
Dim dbc
const cSelect="选择"
AdminPageHeader            ' Admin page headers are different
ShopOpenDatabase   dbc        ' open database
maxfields=6
GetInput                    ' get all form fields
If Request("Delete")<>"" Then
	For each item in Request("DeleteUser")
            DeleteRecord Item
	Next
End if
GenerateDisplayHeader       ' Generate sort button etc 
scriptresponder="shopa_editrecord.asp"
if ucase(dbtable)="PRODUCTS" then
  scriptresponder="shopa_addproduct.asp"
end if
if ucase(dbtable)="SUBCATEGORIES" then
  scriptresponder="shopa_addsubcategory.asp"
end if
ShopopenRecordSet mysql, rstemp, mypagesize, mypage
GenerateTable                ' write the tabe
Call PageNavBar (Mysql)      ' put bottom navigation bar
rsTemp.close                ' close database
ShopCloseDatabase dbc
AdminPageTrailer            ' Write admin trailer 
'
Sub GetTableName
dbtable=request.querystring("table")
if dbtable=""  then
  dbtable=request("table")
end if
Response.write "表名 =" & dbtable & "<br>"
end sub
Sub GetInput
mypage = Request.querystring("page")
'first time we need everything, othertimes sql is set up
sortfield=request("Sortfield")
' See how we are sorting
If Sortfield="" or Sortfield=cSelect then
   sortfield=IdField
end if
SelectValue=request("Selectvalue")
SelectField=request("selectField")
If SelectField=cSelect then
    selectvalue=""
end if
'response.write "sortfield="& sortfield & "<br>"
' see which types processed or unprocessed
SortUpdown=request("SortUpdown")
If SortUpdown=""  then 
   sortupdown="ASC"
end if

if mypage="" then
   GetTableName
   SetFieldNames              ' field names for table
   GetDisplayfields
   mypage=1
   GenerateSQL 
else
   Mysql=Session("sqlquery")
   Fieldnames=session("Fieldnames")
   sortfield=Session("sortfield")
   sortupdown=Session("sortupdown")
   IDfield=Session("IDfield")
   Fieldcount=Session("Fieldcount")   
   dbtable=Session("table")
   DisplayFields=Session("DisplayFields") 
   DisplayFieldCount=Session("DisplayFieldCount")
end if
maxrecs=10
mypagesize=maxrecs
SetUpDown
end sub
'
' SQL is generate by using fields on form

Sub GenerateSQL
dim sqlproc
dim key
MySql = "SELECT * from " & dbtable 
if Selectvalue<> "" then
   key  = SelectValue & "%"
   mySQL = MySQL & " where " & SelectField & " like '" & key  & "'"  
end if 
If sortfield<>"" then
   mysql=mysql & " order by " & sortfield & " " & sortupdown
end if
Session("sqlquery")=MySQL
Session("sortfield")=sortfield
Session("sortupdown")=sortupdown
'response.write "generated sql=" & mysql & "<br>"
End sub
'
Sub GenerateTable()
dim howmanyfields
dim my_link
Dim howmanyrecs
Dim ArrayFields
Dim fieldvalue
Session("Table")=dbtable
Session("Dbname")=dbname
Session("Idfield")=idfield
Session("Fieldcount")=fieldcount
If DisplayFieldcount> 0 then
   howmanyfields=DisplayFieldCount-1
   ArrayFields=DisplayFields
else
  howmanyfields=fieldcount-1
  ArrayFields=Fieldnames 
end if
'DebugWrite "fieldcount = " & fieldcount & "howmany=" & howmanyfields
if howmanyfields > maxfields then
       howmanyfields = maxfields
end if
Response.write "<font size=4><a href=shopa_addgeneral.asp?database=" & dbname & "&table=" & dbtable & ">增加新项目</a></font><br>"
response.write "<br>Page " & mypage & " of " & maxpages & "<br>"
%>
<center>

<form action="shopa_editdisplay.asp?table=<%=dbtable%>" method="post">
<table border="1" cellpadding="0" cellspacing="0" width="100%">
  <tr><td></td>
<% 
'Put Headings On The Table of Field Names
for i=0 to howmanyfields 
   response.write     "<td align=center><b>" & ArrayFields(i) & "</b></td>"
next
Response.write   "<td align=center><b>删除</b></td></tr>"
' Now lets grab all the records
howmanyrecs=0
DO  UNTIL rstemp.eof OR howmanyrecs=maxrecs
   my_link=scriptresponder & "?which=" & rstemp(idfield) & "&idfield=" & idfield & "&table=" & dbtable & "&database=" & dbname 
   response.write "<tr><td align=center><a HREF=" & my_link & ">修改</a></font></td>"
   for i = 0 to howmanyfields
        If IsNull(rstemp(ArrayFields(i))) then
            response.write ("<td>&nbsp;</td>")
        else
           
           response.write("<td BGCOLOR=""#666666"" align=center>" & rstemp(ArrayFields(i)) & "</td>")
        end if
   next
    response.write "<td><center><input type=checkbox name=DeleteUser value=" & rstemp(idfield) & "></center></td></tr>"
    howmanyrecs=howmanyrecs+1
    if howmanyrecs < maxrecs then
          rstemp.movenext
    end if 
loop
response.write("</table></font>")
%>
          <input type="hidden" name="database" value="<%=database%>">
          <input type="hidden" name="table" value="<%=dbtable%>">
          <input type="hidden" name="idfield" value="<%=idfield%>">

        <br><center><input type="submit" name="Delete" value="删除类别"></center></font>
<%
        response.write("</form>")

'
end sub


Sub SetFieldNames
Fieldnamecount=0
dim fSql
dim rs
dim fldname
ReDim Fieldnames(100)
FSQL = "SELECT * FROM " & dbtable
Set rs = dbc.Execute(fSQL)
For each fldName in rs.Fields
    Fieldnames(fieldcount)=fldName.Name
  '  response.write fieldnames(fieldcount) & "<br>"
    fieldcount=fieldcount+1
next
rs.close
Idfield=Fieldnames(0) 
Session("Fieldnames")=Fieldnames
DisplayFields=Fieldnames
Displayfieldcount=fieldcount
Session("DisplayFields")=Displayfields
Session("DisplayFieldCount")=displayfieldCount
End Sub
Sub SetUpDown
Sortupdownnames(0)="升序"
Sortupdownnames(1)="降序"
Sortupdownvalues(0)="ASC"
Sortupdownvalues(1)="DESC"
SortUpDowncount=2
end sub
Sub DeleteRecord(Item)
dim Rowsaffected
dbc.Execute "delete from " & dbtable &  " where " & idfield & "="  & Item, RowsAffected, 1
end sub
Sub GenerateDisplayHeader
%>
<form action="shopa_editdisplay.asp?table=<%=dbtable%>" method="post">
<table border="0"<tr>
    <td align="left">商品类别排序:</td>
<td>
<%
GenerateSelectNV fieldnames,sortfield,"sortfield", fieldcount, CSelect
%>
</td><td align="left">
<%
GenerateSelectV Sortupdownnames,Sortupdownvalues,sortupdown,"sortupdown", sortupdowncount,""
%>
</td>
<tr>
    <td align="left">搜索指定的商品类别:</td>
<td align=left><input type="text" name="SelectValue" size="20"></td>
<td align="left">
<%
GenerateSelectNV Fieldnames,SelectField,"SelectField", fieldcount, cSelect
response.write "</td>"
%>
<tr><td align="left">按指定的字段显示商品类别:</td>
<td align="left">
<%
Displayfield=""
GenerateSelectMult Fieldnames,fieldcount,DisplayFields,DisplayfieldCount,"DisplayFields","All"
%>
<td align=center><input type="submit" name="Sort" value="显示"></center></font>
<br><input type="reset"value="重来"></td></tr>
</table>  
<%
end sub
Sub GetDisplayFields
dim i
Dim displayArray(100)
DisplayFieldCount = Request("DisplayFields").Count
'Debugwrite DisplayfieldCount
if DisplayfieldCount=0 then
   Session("Displayfieldcount")=displayfieldcount
   exit sub
end if
displayField=Request("DisplayFields")
DisplayFields= Split(DisplayField, ", ", -1, 1)
If DisplayFields(0)="All" then
   Displayfieldcount=0
end if
Session("DisplayFields")=DisplayFields
Session("Displayfieldcount")=displayfieldcount
end sub
%>

⌨️ 快捷键说明

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