Functions facilitate the production of management interface

Source: Internet
Author: User
Tags numeric modify table name
Functions sometimes do the admin interface add Delete Modify repeat labor is troublesome

Try writing a function that contains pagination display add delete Modify

Dim arrheadername,arrfieldname,arrfielddata,arrtdwidth,strtblname,strkeyname,strheadercss,strbodycss, Strtablecss,strbuttomcss,ipagesize,itableborder,impdifymethod
Arrheadername=array ("number", "Starting Address", "End Address", "Country", "place")
Arrfieldname=array ("id", "Onip", "OFFIP", "Addj", "ADDF")
Arrfielddata=array ("Auto", "num", "num", "char", "char")
Arrtdwidth=array ("50", "100", "100", "150", "250")
Strtblname= "IP"
Strkeyname= "id"
Strheadercss= "Headercss"
Strbodycss= "Bodycss"
Strtablecss= "Tablecss"
Strbuttomcss= "Buttomcss"
Ipagesize=20
Itableborder=1
Imodifymethod=7
' Data table (Title array group, field array group, field type array [auto: AutoNumber, num: Numeric, Char: Character (Memo), date, date, time: type], cell width array, table name, heading style, body style, table overall style, bottom style, page, table border, modify requirements [0: No 1: Add 2: Delete 3: Modify 4: Add + Modify 5: Delete + Modify 6: Add + DELETE 7: Add + delete + Modify])
DataGrid Arrheadername,arrfieldname,arrfielddata,arrtdwidth,strtblname,strkeyname,strheadercss,strbodycss, Strtablecss,strbuttomcss,ipagesize,itableborder,imodifymethod

This function completes a page with a paging display add delete modify several fields function in a table

Http://www.musecn.com/new

The functions are as follows:

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
' Define global variables
Dim objconn
' Information filtering (information, type)
function Myrequest (info,itype)
If Itype=0 Then
Myrequest=trim (Replace (Request (info), "'", ""))
Else
If IsNumeric (Request (info)) Then
MYREQUEST=CLNG (Request (info))
Else
Response.Write "Type Error"
Response.End
End If
End If
End Function
' Page header (page title, style address)
Sub Pagestart (STRPAGETITLE,STRPAGECSS)
Response.Write "Response.Write "Response.Write "<meta http-equiv=" "Content-type" "content=" "text/html"; charset=gb2312 "" > "&vbcrlf
Response.Write "<link href=" "&strPageCss&" "rel=" "Stylesheet" "type=" "Text/css" ">" &vbcrlf
Response.Write "<title>" &strPageTitle& "</title>" &vbcrlf
Response.Write "Response.Write "<body>" &vbcrlf
End Sub
' Connection database (database name)
Sub Dbconn (dbname)
Set Objconn=server. CreateObject ("Adodb.connection")
objConn.Open "Driver={microsoft Access Driver (*.mdb)};d bq=" &server. MapPath (dbname)
End Sub
Sub Pagelast ()
Response.Write "</body>" &vbcrlf
Response.Write "End Sub
' Data table (Title array group, field array group, array of field types [Auto: AutoNumber, num: Numeric, char: Character type (memo), date, date, Time: type), cell width array, table name, primary key name, title style, body style, table overall style, Bottom style, page, table border, modify requirements [0: No 1: Add 2: Delete 3: Modify 4: Add + Modify 5: Delete + Modify 6: Add + DELETE 7: Add + delete + Modify])
Sub DataGrid (ARRHEADERNAME,ARRFIELDNAME,ARRFIELDDATA,ARRTDWIDTH,STRTBLNAME,STRKEYNAME,STRHEADERCSS,STRBODYCSS, Strtablecss,strbuttomcss,ipagesize,itableborder,imodifymethod)
Dim objRS
Dim strexec
Dim itmp,itmp2
Dim Ipagecount
Dim ipage
Dim iRecordCount
Dim Ipagestart
Dim ipageend
Dim ilasttenpage
Dim inexttenpage
Set Objrs=server. CreateObject ("Adodb.recordset")
Objrs.open "SELECT COUNT (*) from" &strtblname,objconn,1,1
Irecordcount=objrs (0)
Objrs.close
If irecordcount MoD ipagesize=0 Then
Ipagecount= irecordcount\ipagesize
Else
ipagecount= Irecordcount\ipagesize + 1
End If
Ipage=myrequest ("IPage", 1)
If Ipage<1 then ipage=1
If Ipage>ipagecount then Ipage=ipagecount
If Myrequest ("method", 0) = "Delete" Then
strexec= "Delete from" &strTblName& "where" &strKeyName& "=" &myrequest (strkeyname,1)
objConn.Execute strexec
Response.Redirect "Ipage=" &ipage
End If
If Myrequest ("method", 0) = "Modifypost" Then
strexec= "Update" &strTblName& "set"
For Itmp=0 to UBound (arrheadername)
If Arrfieldname (itmp) <>strkeyname Then
If Arrfielddata (itmp) = "num" Then
Strexec=strexec&arrfieldname (itmp) & "=" &myrequest (Arrfieldname (itmp), 0)
Else
Strexec=strexec&arrfieldname (itmp) & "= '" &myrequest (ARRF



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.