b1nary0mega
8/19/2015 - 4:15 PM

Evaluation PDF Score Generation using Database Table instead of hard coding

Evaluation PDF Score Generation using Database Table instead of hard coding

<!--- CODE TO PULL EVAL RATING DESCRIPTION USING DATABASE --->
<cftry>
  <cfquery name="GetScoreDescription"datasource="#application.datasrc_mss#" dbtype="#application.dbtype_mss#" >
  SELECT DESCRIPTION, 
         MIN_SCORE, 
         MAX_SCORE, 
         INIT,
         AUTORATE 
  FROM EVAL_OVRLLRTNG 
  WHERE MIN_SCORE <= <cfoutput>#variables.OVRLLRTNG#</cfoutput>
  AND MAX_SCORE >= <cfoutput>#variables.OVRLLRTNG#</cfoutput>
  </cfquery>
  <cfif GetScoreDescription.RecordCound EQ 0 
    OR GetScoreDescription.RecordCound GT 1>
    <cfabort showerror="There was an error determining the evaluation rating. Please contact the programmer." />
  <cfelse>
    <cfset AutoRate = #GetScoreDescription.AUTORATE#>
    <cfset AutoRateDsply = #GetScoreDescription.DESCRIPTION#>
  </cfif>
  <!--- in the case that the query blew up (OVRLLRTNG may not have been defined yet) --->
  <cfcatch>
      <cfset AutoRate = 0>
      <cfset AutoRateDsply = "">
  </cfcatch>
</cftry>