Advertisement
Guest User

Untitled

a guest
Nov 13th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 12.23 KB | None | 0 0
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <!--#include file="Connections/ColourShade.asp" -->
  3. <!--#include file="Connections/adovbs.inc" -->
  4. <%
  5.  
  6. Dim GradeFindAll__COLOUR_SHADE_RECORD_ID
  7. GradeFindAll__COLOUR_SHADE_RECORD_ID = "0"
  8. if(Request("NO_RUNTIME_VALUE") <> "") then GradeFindAll__COLOUR_SHADE_RECORD_ID = Request("NO_RUNTIME_VALUE")
  9.  
  10. %>
  11. <%
  12.  
  13. set GradeFindAll = Server.CreateObject("ADODB.Command")
  14. GradeFindAll.ActiveConnection = MM_ColourShade_STRING
  15. GradeFindAll.CommandText = "dbo.GRADE_FIND_ALL"
  16. GradeFindAll.Parameters.Append GradeFindAll.CreateParameter("@RETURN_VALUE", 3, 4)
  17. GradeFindAll.Parameters.Append GradeFindAll.CreateParameter("@COLOUR_SHADE_RECORD_ID", 3, 1,4,GradeFindAll__COLOUR_SHADE_RECORD_ID)
  18. GradeFindAll.CommandType = 4
  19. GradeFindAll.CommandTimeout = 0
  20. GradeFindAll.Prepared = true
  21. set Grades = GradeFindAll.Execute
  22. Grades_numRows = 0
  23.  
  24. %>
  25. <%
  26. If Request("MACHINENAME") <> "" Then
  27.     Session("MACHINENAME") = Request("MACHINENAME")
  28. ElseIf Session("MACHINENAME") = "" Then
  29.     Response.Redirect("index.asp")
  30. End If
  31. Session("GRADEID") = ""
  32. Session("GRADEDESCRIPTION") = ""
  33. Session("STANDARDDESCRIPTION") = ""
  34. Session("ORDER") = ""
  35. Session("DATEFROM") = ""
  36. Session("DATETO") = ""
  37. %>
  38. <html>
  39. <head>
  40. <title>Colour and Shade Database</title>
  41. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  42. <link href="basic.css" rel="stylesheet" type="text/css">
  43. <script language="JavaScript" type="text/JavaScript">
  44. <!--
  45. function FDK_StripChars(theFilter,theString)
  46. {
  47.     var strOut,i,curChar
  48.  
  49.     strOut = ""
  50.     for (i=0;i < theString.length; i++)
  51.     {      
  52.         curChar = theString.charAt(i)
  53.         if (theFilter.indexOf(curChar) < 0) // if it's not in the filter, send it thru
  54.             strOut += curChar      
  55.     }  
  56.     return strOut
  57. }
  58.  
  59. function FDK_AddToValidateArray(FormName,FormElement,Validation,SetFocus)
  60. {
  61.     var TheRoot=eval("document."+FormName);
  62.  
  63.     if (!TheRoot.ValidateForm)
  64.     {
  65.         TheRoot.ValidateForm = true;
  66.         eval(FormName+"NameArray = new Array()")
  67.         eval(FormName+"ValidationArray = new Array()")
  68.         eval(FormName+"FocusArray = new Array()")
  69.     }
  70.     var ArrayIndex = eval(FormName+"NameArray.length");
  71.     eval(FormName+"NameArray[ArrayIndex] = FormElement");
  72.     eval(FormName+"ValidationArray[ArrayIndex] = Validation");
  73.     eval(FormName+"FocusArray[ArrayIndex] = SetFocus");
  74.  
  75. }
  76.  
  77. function FDK_ValidateDate(FormElement,Required,MinDate,MaxDate,Format,ErrorMsg)
  78. {
  79.     var msg = "";
  80.     var theString = DateCheck(FormElement.value);
  81.     var dateVar = new Date(theString);
  82.     var peavd = ErrorMsg;
  83.     var d = dateVar;
  84.  
  85.     var fullYear = d.getYear();
  86.     if (fullYear <= 10) fullYear += 2000;
  87.     if (fullYear <= 200) fullYear += 1900;
  88.     d.setYear(fullYear)
  89.     dateVar.setYear(fullYear)
  90.  
  91.  
  92.     var theLen = FDK_StripChars(" ",theString).length
  93.     if (theLen == 0)
  94.     {
  95.         if (!Required) return "";
  96.         else return peavd;
  97.     }
  98.  
  99.     if (isNaN(dateVar.valueOf()) || (dateVar.valueOf() == 0))
  100.         return peavd;
  101.  
  102.     // Check for correct range.
  103.     if (MinDate != "")
  104.     {
  105.         var Today = new Date(MinDate);
  106.         if (dateVar <= Today)
  107.           return peavd;
  108.     }
  109.     if (MaxDate != "")
  110.     {
  111.         var Today = new Date(MaxDate);
  112.         if (dateVar >= Today)
  113.         return peavd;
  114.     }
  115.  
  116.     // We have a valid date. Reformat it and write it back to the control
  117.     var style = Format;
  118.  
  119.     if (style == "2") {
  120.       var date_string = (d.getMonth()+1) + "/" + d.getDate() + "/" + fullYear;
  121.       }
  122.       else if (style == "3") {
  123.       var date_string = (d.getMonth()+1) + "-" + d.getDate() + "-" + fullYear;
  124.       }
  125.       else if (style == "4") {
  126.       var date_string = d.getDate() + "/" + (d.getMonth()+1) + "/" + fullYear;
  127.       }
  128.       else if (style == "5") {
  129.       var date_string = getMonthName(d) + " " + d.getDate() + ", " + fullYear;
  130.       }
  131.       else if (style == "6") {
  132.       var date_string = getDayName(d) + " " + getMonthName(d) + " " + d.getDate() + ", " + fullYear;
  133.       }
  134.       else if (style == "7") {
  135.       var date_string = d.toLocaleString();
  136.       }
  137.       else if (style == "1") {
  138.       var date_string = theString;
  139.       }
  140.       else {
  141.       var date_string = d.toGMTString();
  142.   }
  143.  
  144.     FormElement.value=date_string;
  145.  
  146.     return msg;
  147. }
  148.  
  149. function FDK_AddDateValidation(FormName,FormElementName,Required,StartDate,EndDate,Format,SetFocus,ErrorMsg)  {
  150.   var ValString = "FDK_ValidateDate("+FormElementName+","+Required+","+StartDate+","+EndDate+","+Format+","+ErrorMsg+")"
  151.   FDK_AddToValidateArray(FormName,eval(FormElementName),ValString,SetFocus)
  152. }
  153.  
  154. function FDK_Validate(FormName, stopOnFailure, AutoSubmit, ErrorHeader)
  155. {
  156.  var theFormName = FormName;
  157.  var theElementName = "";
  158.  if (theFormName.indexOf(".")>=0)  
  159.  {
  160.    theElementName = theFormName.substring(theFormName.indexOf(".")+1)
  161.    theFormName = theFormName.substring(0,theFormName.indexOf("."))
  162.  }
  163.  var ValidationCheck = eval("document."+theFormName+".ValidateForm")
  164.  if (ValidationCheck)  
  165.  {
  166.   var theNameArray = eval(theFormName+"NameArray")
  167.   var theValidationArray = eval(theFormName+"ValidationArray")
  168.   var theFocusArray = eval(theFormName+"FocusArray")
  169.   var ErrorMsg = "";
  170.   var FocusSet = false;
  171.   var i
  172.   var msg
  173.    
  174.  
  175.         // Go through the Validate Array that may or may not exist
  176.         // and call the Validate function for all elements that have one.
  177.   if (String(theNameArray)!="undefined")
  178.   {
  179.    for (i = 0; i < theNameArray.length; i ++)
  180.    {
  181.     msg="";
  182.     if (theNameArray[i].name == theElementName || theElementName == "")
  183.     {
  184.       msg = eval(theValidationArray[i]);
  185.     }
  186.     if (msg != "")
  187.     {
  188.      ErrorMsg += "\n"+msg;                  
  189.      if (stopOnFailure == "1")
  190.      {
  191.        if (theFocusArray[i] && !FocusSet)  
  192.       {
  193.        FocusSet=true;
  194.        theNameArray[i].focus();
  195.       }
  196.       alert(ErrorHeader+ErrorMsg);
  197.       document.MM_returnValue = false;
  198.       break;
  199.      }
  200.      else  
  201.      {
  202.       if (theFocusArray[i] && !FocusSet)  
  203.       {
  204.        FocusSet=true;
  205.        theNameArray[i].focus();
  206.       }
  207.      }
  208.     }
  209.    }
  210.   }
  211.   if (ErrorMsg!="" && stopOnFailure != "1")
  212.   {
  213.    alert(ErrorHeader+ErrorMsg);
  214.   }
  215.   document.MM_returnValue = (ErrorMsg=="");
  216.   if (document.MM_returnValue && AutoSubmit)  
  217.   {
  218.    eval("document."+FormName+".submit()")
  219.   }
  220.  }
  221. }
  222.  
  223. function DateCheck(dateString) {
  224.     var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  225.    
  226.     // Check to see whether the date entered is in the 'xx/xx/xx' format
  227.     // Spilt into an array on the '/' and check for a resulting array
  228.     // length of 3 items. If it's not in the 'xx/xx/xx' format then check
  229.     // whether Javascript can parse the field as a date. If it can then
  230.     // just return the field value untouched.
  231.     var dateArray = dateString.split("/");
  232.     if (dateArray.length != 3) {
  233.         var dateVar = new Date(dateString);
  234.         if (isNaN(dateVar.valueOf()) || (dateVar.valueOf() == 0))
  235.             return "";
  236.         else
  237.             return dateString;
  238.     }
  239.    
  240.     // If it's in the 'xx/xx/xx' format then assume it means 'dd/mm/yy'
  241.     // and assign the array items to variables matching the day,
  242.     // month and year accordingly.
  243.     // Note: parsing a 2 digit year as an integer will remove any leading
  244.     // zero and effectively when re-converted to a string below, it will
  245.     // have a string length of one character.
  246.     var dayBit, monthBit, yearBit;
  247.     dayBit = parseInt(dateArray[0], 10);
  248.     monthBit = parseInt(dateArray[1], 10);
  249.     yearBit = parseInt(dateArray[2], 10);
  250.  
  251.     // If the year was 2 digits, make it 4.
  252.     // There will be no records will be prior to 2000.
  253.     var strYearBit = new String(yearBit);
  254.     if (strYearBit.length == 2)
  255.         yearBit = parseInt("20" + strYearBit, 10);
  256.     if (strYearBit.length == 1)
  257.         yearBit = parseInt("200" + strYearBit, 10);
  258.  
  259.     // Check for invalid month.
  260.     if (monthBit > 12 || monthBit == 0)
  261.         return "";
  262.  
  263.     // Check for invalid number of days with respect to the chosen month.
  264.     if (monthBit == 2)
  265.     {
  266.         // Leap years are divisible by 4, except years also divisible by 100 which aren't leap years.
  267.         daysInFebruary = yearBit % 4 == 0 && (yearBit % 100 != 0 || yearBit % 400 == 0) ? 29 : 28;
  268.         if (dayBit < 1 || dayBit > daysInFebruary)
  269.             return "";
  270.     }
  271.     else if (monthBit == 4 || monthBit == 6 || monthBit == 9 || monthBit == 11)
  272.     {
  273.         if (dayBit < 1 || dayBit > 30)
  274.             return "";
  275.     }
  276.     else if (dayBit < 1 || dayBit > 31)
  277.             return "";
  278.  
  279.     // Return the 'monthname d, yyyy'. Otherwise JavaScript will
  280.     // attempt to interpret it as an American format.
  281.     return monthNames[monthBit - 1] + " " + dayBit + ", " + yearBit;
  282. }
  283. //-->
  284. </script>
  285. </head>
  286.  
  287. <body onLoad="FDK_AddDateValidation('form1','document.form1.DATEFROM',true,'\'\'','\'\'','\'1\'',true,'\'Dated between : Please enter a valid date in the \\\'from\\\' field\'');FDK_AddDateValidation('form1','document.form1.DATETO',true,'\'\'','\'\'','\'1\'',true,'\'Dated between : Please enter a valid date in the \\\'to\\\' field\'')">
  288. <table align="center" cellpadding="0" cellspacing="0" class="layout">
  289.   <tr>
  290.     <td class="layoutToolbar">
  291.       <table border="0" cellspacing="0" cellpadding="0">
  292.         <tr>
  293.           <!--#include file="toolbarCells.asp" -->
  294.  
  295.         </tr>
  296.       </table></td>
  297.     <td align="right" class="layoutLogo"><img src="images/arjoLogo.jpg"></td>
  298.   </tr>
  299.   <tr>
  300.     <td colspan="2" class="layoutPageHeading">Search for records on <%= Session("MACHINENAME") %></td>
  301.   </tr>
  302.   <tr>
  303.     <td colspan="2" class="layoutContent">
  304.  
  305. <form action="results.asp" method="get" name="form1" onSubmit="FDK_Validate('form1',true,false,'The Form Could Not Be Submitted\n\n');return document.MM_returnValue">
  306.         <table class="tableCenterWidth" align="center">
  307.           <tr>
  308.             <td width="20%" class="normalFont9BlueBold">Standard</td>
  309.             <td width="10%"> <select name="GRADEID" id="select4">
  310.                 <option value="0"></option>
  311.                 <%
  312. While (NOT Grades.EOF)
  313. %>
  314.                 <option value="<%=(Grades.Fields.Item("GRADE_ID").Value)%>"><%=(Grades.Fields.Item("STANDARD").Value)%></option>
  315.                 <%
  316.   Grades.MoveNext()
  317. Wend
  318. If (Grades.CursorType > 0) Then
  319.   Grades.MoveFirst
  320. Else
  321.   Grades.Requery
  322. End If
  323. %>
  324.               </select>
  325.             </td>
  326.             <td width="10%" align="center" class="normalFont9BlueBold">Or</td>
  327.             <td width="20%" class="normalFont9BlueBold">Standard contains</td>
  328.             <td width="25%"> <input name="STANDARDDESCRIPTION" type="text" id="STANDARDDESCRIPTION" size="8" maxlength="8">
  329.             </td>
  330.             <td width="15%" align="right"> <input type="submit" name="Submit" value="Search"></td>
  331.           </tr>
  332.           <tr>
  333.             <td class="normalFont9BlueBold">&nbsp;</td>
  334.             <td colspan="5">&nbsp;</td>
  335.           </tr>
  336.           <tr>
  337.             <td class="normalFont9BlueBold">Grade contains</td>
  338.             <td colspan="5"> <input name="GRADEDESCRIPTION" type="text" id="GRADEDESCRIPTION5" size="30">
  339.             </td>
  340.           </tr>
  341.           <tr>
  342.             <td class="normalFont9BlueBold">&nbsp;</td>
  343.             <td colspan="5">&nbsp;</td>
  344.           </tr>
  345.           <tr>
  346.             <td class="normalFont9BlueBold">Dated between</td>
  347.             <td><input name="DATEFROM" type="text" id="DATEFROM" value="<%= DateAdd("yyyy", -10, Date()) %>" size="10" maxlength="20"></td>
  348.             <td align="center" class="normalFont9BlueBold">And</td>
  349.             <td colspan="3"><input name="DATETO" type="text" id="DATETO" value="<%= Date() %>" size="10" maxlength="20"></td>
  350.           </tr>
  351.           <tr>
  352.             <td class="normalFont9BlueBold">&nbsp;</td>
  353.             <td colspan="5">&nbsp;</td>
  354.           </tr>
  355.           <tr>
  356.             <td class="normalFont9BlueBold">Order by</td>
  357.             <td colspan="5"><table>
  358.                 <tr>
  359.                   <td class="normalFont9BlueBold"> <label>
  360.                     <input name="ORDER" type="radio" value="2" checked>
  361.                     Standard, Date</label></td>
  362.                   <td class="normalFont9BlueBold"> <label>
  363.                     <input type="radio" name="ORDER" value="1">
  364.                     Running Order</label></td>
  365.                 </tr>
  366.               </table></td>
  367.           </tr>
  368.           <tr>
  369.             <td colspan="6" align="right">&nbsp; </td>
  370.           </tr>
  371.         </table>
  372.       </form>
  373.    
  374.     </td>
  375.   </tr>
  376. </table>
  377. </body>
  378. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement