home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / addemployee.cfm < prev    next >
Encoding:
ColdFusion Markup Language  |  1998-10-08  |  1.9 KB  |  45 lines

  1. <!--- This is an example of a custom tag used
  2.       to add employees. Employee information is passed
  3.       through the employee structure (the EMPINFO attribute. --->
  4. <cfswitch expression="#ThisTag.ExecutionMode#">
  5.    <cfcase value="start">
  6.       <CFIF StructIsEmpty(attributes.EMPINFO)>
  7.         <CFOUTPUT>Error. No employee data was passed.</cfoutput>
  8.           <CFEXIT METHOD="ExitTag">
  9.         <cfelse>
  10.           <!--- Add the employee --->
  11.           <!--- In UNIX, you must also insert the Emp_ID (Long) --->
  12.            <CFQUERY NAME="AddEmployee" datasource="cfsnippets">
  13.             <CFIF Server.OS.Name EQ "Windows NT">
  14.                INSERT INTO Employees(FirstName, LastName, EMail, Phone, Department)
  15.                VALUES 
  16.                 <CFOUTPUT>
  17.                   (
  18.                     '#StructFind(attributes.EMPINFO, "firstname")#' ,
  19.                     '#StructFind(attributes.EMPINFO, "lastname")#' ,
  20.                     '#StructFind(attributes.EMPINFO, "email")#' ,
  21.                     '#StructFind(attributes.EMPINFO, "phone")#' ,
  22.                     '#StructFind(attributes.EMPINFO, "department")#'
  23.                    )
  24.                 </cfoutput>
  25.             <CFELSE> 
  26.               INSERT INTO Employees(Emp_ID, FirstName, LastName, EMail, Phone, Department)
  27.                VALUES 
  28.                 <CFOUTPUT>
  29.                   (
  30.                     '#StructFind(attributes.EMPINFO, "empid")#' ,
  31.                     '#StructFind(attributes.EMPINFO, "firstname")#' ,
  32.                     '#StructFind(attributes.EMPINFO, "lastname")#' ,
  33.                     '#StructFind(attributes.EMPINFO, "email")#' ,
  34.                     '#StructFind(attributes.EMPINFO, "phone")#' ,
  35.                     '#StructFind(attributes.EMPINFO, "department")#'
  36.                    )
  37.                 </cfoutput> 
  38.             </cfif>
  39.           </cfquery>
  40.         </cfif>
  41.       <CFOUTPUT><HR>Employee Add Complete</cfoutput>
  42.    </cfcase>
  43. </cfswitch>
  44.  
  45.