<%@ language = VBScript %> AS/400 Customer List Active Server Page <% '----------------------------------------------------------------- 'define constants, set intial values for Sort options '----------------------------------------------------------------- const Space3 = "   " const sortNone = 0 'first time flag const sortCus = 1 'sort by Customer number const sortName = 2 'sort by Contact name const sortCity = 3 'sort by City const sortState = 4 'sort by State const sortZip = 5 'sort by Zip Code const sortBal = 6 'sort by Balance Dur const chkChecked = "checked" 'Radio checked chkCus = vbNullString 'option checked placeholder - Customer number chkName = vbNullString 'option checked placeholder - Name chkCity = vbNullString 'option checked placeholder - City chkState = vbNullString 'option checked placeholder - State chkZip = vbNullString 'option checked placeholder - Zip chkBal = vbNullString 'option checked placeholder - Balance Due '----------------------------------------------------------------- 'determine which Sort Option is selected, format variables '----------------------------------------------------------------- SortOption = CInt(Request("optSort")) 'get requested sort selection select case SortOption case sortCus hdgSort = "Sort by Customer Number" chkCus = chkChecked OrderBy = "CUSNUM" case sortName hdgSort = "Sort by Contact Name" chkName = chkChecked OrderBy = "LSTNAM" case sortCity hdgSort = "Sort by City" chkCity = chkChecked OrderBy = "CITY" case sortState hdgSort = "Sort by State" chkState = chkChecked OrderBy = "STATE" case sortZip hdgSort = "Sort by Zip Code" chkZip = chkChecked OrderBy = "ZIPCOD" case sortBal hdgSort = "Sort by Balance Due" chkBal = chkChecked OrderBy = "BALDUE DESC" end select %>

Customer Listing

<%= hdgSort & Space3 & Date & Space3 & Time%>


Enter User ID, Password, choose a Sort option, click Sort button <%= "
Enter User ID:  
" %> <%= "
Enter Password: 
" %> <%= Space3 %> Highlight Balance Due greater than: ">

<% '-------------------------------------------------------------- 'format table headers for Customer table '-------------------------------------------------------------- const thBTD = "" thRow = thBTD & "Row" & thETD & vbCrLf thCustomer = thBTD & "Customer" & thETD & vbCrLF thContact = thBTD & "Contact" & thETD & vbCrLF thCity = thBTD & "City" & thETD & vbCrLf thState = thBTD & "State" & thETD & vbCrLf thZip = thBTD & "Zip" & thETD & vbCrLf thBal = thBTD & "Bal. Due" & thETD & vbCrLf thSort = thBTD & "Sort:" & thETD '-------------------------------------------------------------- 'format Option Buttons for sort selection in table header 'chkXXX is used to select "checked" option for an Option Button '-------------------------------------------------------------- const RADIO = " <%= thRow %> <%= thCustomer %> <%= thContact %> <%= thCity %> <%= thState %> <%= thZip %> <%= thBal %> <%= thSort %> <%= optSortCus %> <%= optSortName %> <%= optSortCity %> <%= optSortState %> <%= optSortZip %> <%= optSortBal %> <% '----------------------------------------------------------------------- 'If Sort Option specified, get/format/display data '----------------------------------------------------------------------- if (SortOption <> sortNone) then '-------------------------------------------------------------- 'open Connection to AS/400, get Result Set '-------------------------------------------------------------- Connect = "DSN=QCUSTCDT;UID=" Connect = Connect & Request("UserID") Connect = Connect & ";PWD=" Connect = Connect & Request("Password") Connect = Connect & ";" SQL = "SELECT * FROM QCUSTCDT ORDER BY " & OrderBy Set cnAS400 = Server.CreateObject("ADODB.Connection") cnAS400.Open Connect Set rsCustomers = cnAS400.Execute(SQL) '-------------------------------------------------------------- 'define Table Data attributes, values '-------------------------------------------------------------- tdBTD = "" tdETDR = "" '-------------------------------------------------------------- 'Read customer result set, write table data rows '-------------------------------------------------------------- do while not rsCustomers.eof tdCount = tdCount + 1 %> <%= vbCrLf %> <%= "" %> <%= tdBTD & tdCount & tdETD & vbCrLf %> <%= tdBTD & rsCustomers("CUSNUM") & tdETD & vbCrLf %> <%= tdBTD & trim(rsCustomers("LSTNAM")) & ", " & trim(rsCustomers("INIT")) & tdETD & vbCrLF %> <%= tdBTD & rsCustomers("CITY") & tdETD & vbCrLf %> <%= tdBTD & rsCustomers("STATE") & tdETD & vbCrLf %> <%= tdBTD & rsCustomers("ZIPCOD") & tdETD & vbCrLf %> <% '-------------------------------------------------------------- 'Highlight Balance Due if over the specified limit '------------------------------------------------------------- Balance = CCur(rsCustomers("BALDUE")) OverBal = 0 if Request("OverBalance") <> "" then OverBal = CCur(Request("OverBalance")) end if if (OverBal <> 0) and (Balance > OverBal) then %> <%= tdBTDR & FormatCurrency(Balance) & tdEDTR %> <% else %> <%= tdBTD & FormatCurrency(Balance) & tdEDT %> <% end if %> <% rsCustomers.MoveNext Loop end if %>
" const thETD = "
" tdBTDR = "" tdETD = "