home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / rds.cab / addrbook.asp1 < prev    next >
Text File  |  1997-08-14  |  6KB  |  227 lines

  1. <HTML>
  2. <HEAD>
  3. <TITLE>Corporate Address Book</TITLE>
  4. </HEAD>
  5.  
  6. <!--
  7.     Purpose:    To provide a company directory search service for Web users.
  8.     Written By:    Microsoft Data Access Group, Microsoft Corp.
  9.     Date:        May, 1997
  10. -->
  11.  
  12. <BODY BACKGROUND="Arcadia.gif" LANGUAGE="VBScript" onload="Load">
  13. <tr>
  14.     <td align="center" width="40%">
  15.         <table border="2" cellpadding="7" cellspacing="7">
  16.             <tr>
  17.                 <td width="100%"><font color="#160B5A"><font
  18.                 size="4"><strong>Arcadia Bay Corporate Phone Directory</strong></font></font></td>
  19.             </tr>
  20.         </table>
  21.         </td>
  22. </tr>
  23.  
  24. <hr>
  25. <h2><font color = "#160B5A">Search Parameters</h2>
  26. <h5><font color = "#160B5A">Please enter one or more search patterns and press FIND to search.</h5>
  27.  
  28. <FONT COLOR = "#160B5A"><B>
  29.  
  30. <PRE> First Name     <INPUT NAME=SFirst SIZE=30> </PRE>
  31.  
  32. <PRE> Last Name      <INPUT NAME=SLast  SIZE=30> </PRE>
  33.  
  34. <PRE> Title          <INPUT NAME=STitle SIZE=30> </PRE>
  35.  
  36. <PRE> E-mail Alias   <INPUT NAME=SEmail SIZE=30> </PRE>
  37.  
  38. <!-- 
  39.     Command button options:
  40.     -----------------------
  41.     Find        Submit a search request to the database.
  42.     Clear        Clear the QBE fields (labor saving function only).
  43.     Update Profile    Send updated "address profile" back to the database.
  44.     Cancel Changes    Undo all changes since the last Update Profile.
  45. -->
  46.  
  47. <INPUT TYPE=BUTTON NAME="Find"         VALUE="Find">
  48. <INPUT TYPE=BUTTON NAME="Clear"     VALUE="Clear">
  49. <INPUT TYPE=BUTTON NAME="Update"     VALUE="Update Profile">
  50. <INPUT TYPE=BUTTON NAME="Cancel"     VALUE="Cancel Changes">
  51.  
  52. <hr>
  53. <h2><font color = "#400040">Search Results</h2>
  54. </B>
  55. <br>
  56.  
  57. <!-- 
  58.     This Sheridan DataGrid control (SGrid) are initialized to
  59.     allow changes to the data - these changes will be saved
  60.     to the database when the Update Profile button is pressed. 
  61. -->
  62.  
  63. <Object CLASSID="clsid:AC05DC80-7DF1-11d0-839E-00A024A94B3A"
  64.     CODEBASE="http://<%=Request.ServerVariables("SERVER_NAME")%>/MSADC/Samples/ssdatb32.cab"
  65.     ID=GRID1 
  66.         datasrc=#SControl 
  67.         HEIGHT=125 
  68.         WIDTH=495>
  69.     <PARAM NAME="AllowAddNew"   VALUE="TRUE">
  70.     <PARAM NAME="AllowDelete"   VALUE="TRUE">
  71.     <PARAM NAME="AllowUpdate"   VALUE="TRUE">
  72.     <PARAM NAME="BackColor"     VALUE="-2147483643">
  73.     <PARAM NAME="BackColorOdd"  VALUE="-2147483643">
  74.     <PARAM NAME="ForeColorEven" VALUE="0">
  75. </OBJECT>
  76.  
  77. <br>
  78. <br>
  79. <INPUT TYPE=BUTTON NAME="First"     VALUE="First">
  80. <INPUT TYPE=BUTTON NAME="Prev"         VALUE="Previous">
  81. <INPUT TYPE=BUTTON NAME="Next"        VALUE="Next">
  82. <INPUT TYPE=BUTTON NAME="Last"        VALUE="Last">
  83. <hr>
  84.  
  85.  
  86. <!-- Non-visual controls - AdvancedDataControl -->
  87.  
  88. <OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
  89.     ID=SControl
  90.     WIDTH=1 HEIGHT=1>
  91.     <PARAM NAME="SERVER" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
  92.     <PARAM NAME="CONNECT" VALUE="dsn=ADCDemo;UID=ADCDemo;PWD=ADCDemo;">
  93. </OBJECT>
  94.  
  95.  
  96. <!-- VBS scripting for composing queries, updating profiles, and retrieving search results. -->
  97.  
  98. <SCRIPT LANGUAGE="VBScript">
  99. '---- enum Values ----
  100. Const adcExecSync = 1
  101. Const adcExecAsync = 2
  102.  
  103. '---- enum Values ----
  104. Const adcFetchUpFront = 1
  105. Const adcFetchBackground = 2
  106. Const adcFetchAsync = 3
  107.  
  108. Dim myQuery
  109.  
  110. SUB Load
  111.     'Chnage the asynchronous options such that execution is synchronous
  112.     'and Fetching can occur in the background
  113.     SControl.ExecuteOptions = adcExecSync
  114.     SControl.FetchOptions = adcFetchBackground
  115.     
  116.     Grid1.CAPTION = "Arcadia Bay Corporate Phone Directory"
  117.  
  118.     'Initialize data grid with column names only.
  119.     SControl.SQL = "Select FirstName, LastName, Title, Email, Building, Room, Phone from Employee where 2 < 1"
  120.     SControl.Refresh
  121.  
  122. END SUB
  123.  
  124. 'Implement "Clear" button - clears all of the QBE fields in preparation for a new "Find."
  125.  
  126. SUB Clear_OnClick
  127.     SFirst.Value=""
  128.     SLast.Value=""
  129.     STitle.Value=""
  130.     SEmail.Value=""
  131. END SUB
  132.  
  133.  
  134. 'Implement "Find" button - composes a dynamic SQL query to be processed by the database and returns matching records to be bound to the SGrid object.
  135.  
  136. SUB Find_OnClick
  137.  
  138.     myQuery = "Select FirstName, LastName, Title, Type, Email, ManagerEmail, Building, Room, Phone from Employee"
  139.  
  140.     'Check QBE fields and compose a dynamic SQL query.
  141.  
  142.     IF (SFirst.Value <> "") THEN
  143.         myQuery = myQuery + " where FirstName like '" + SFirst.Value + "%'"
  144.     END IF
  145.  
  146.     IF (SLast.Value <> "") THEN
  147.         myQuery = myQuery + " where LastName like '" + SLast.Value + "%'"
  148.     END IF
  149.  
  150.     IF (STitle.Value <> "") THEN
  151.         myQuery = myQuery + " where Title like '" + STitle.Value + "%'"
  152.     END IF
  153.  
  154.     IF (SEmail.Value <> "") THEN
  155.         myQuery = myQuery + " where Email like '" + SEmail.Value + "%'"
  156.     END IF
  157.  
  158.     'Set the new query and then refresh the SControl so that the new results are displayed.
  159.  
  160.     SControl.SQL = myQuery
  161.     SControl.Refresh
  162.  
  163.     'Optional command specific to the Sheridan Grid to ensure display of the correct data
  164.     Grid1.Rebind
  165.     
  166. END SUB
  167.  
  168. 'Navigation subroutines - based on currency changes to AdvancedDataControl (SControl).
  169.  
  170. 'Move to the first record in the bound recordset.
  171.  
  172. SUB First_OnClick
  173.       SControl.Recordset.MoveFirst
  174. END SUB
  175.  
  176. 'Move to the next record from the current position in the bound recordset.
  177.  
  178. SUB Next_OnClick
  179.     On Error Resume Next
  180.     SControl.Recordset.MoveNext
  181.     IF ERR.Number <> 0 THEN
  182.         SControl.Recordset.MoveLast  'If already at end of recordset stay at end.
  183.     END IF
  184. END SUB
  185.  
  186. 'Move to the previous record from the current position in the bound recordset.
  187.  
  188. SUB Prev_OnClick
  189.     On Error Resume Next
  190.     SControl.Recordset.MovePrevious
  191.     IF ERR.Number <> 0 THEN
  192.         SControl.Recordset.MoveFirst  'If already at start of recordset stay at top.
  193.     END IF
  194. END SUB
  195.  
  196. 'Move to the last record in the bound recordset.
  197.  
  198. SUB Last_OnClick
  199.       SControl.Recordset.MoveLast
  200. END SUB
  201.  
  202. 'Submits edits made and pull a clean copy of the new data.
  203.  
  204. SUB Update_OnClick
  205.       SControl.SubmitChanges
  206.     SControl.Refresh        ' A Refresh is not required in ADC 1.5 after a SubmitChanges, but it ensures fresh data.
  207.  
  208.     'Optional command specific to the Sheridan Grid to ensure display of the correct data
  209.     Grid1.Rebind
  210. END SUB
  211.  
  212. 'Cancel edits and restores original values.
  213.  
  214. SUB Cancel_OnClick
  215.       SControl.CancelUpdate
  216.  
  217.     'Optional command specific to the Sheridan Grid to ensure display of the correct data
  218.     Grid1.Rebind
  219. END SUB
  220.  
  221. </SCRIPT>
  222.  
  223. <BR>
  224. <font color = "#400040">This site powered by the Microsoft Data Access Components. </font>
  225. </BODY>
  226. </HTML>
  227.