displaying previously entered multiple fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bonneylake
    Contributor
    • Aug 2008
    • 769

    Hey Acoder,

    When i did that it now does not display serial at all unless click add button an then the count is messed up here is what i got on serialpartsdisp lay.cfm. But i am wondering did i need to change cticketpage2edi t.cfm to cflop instead of serialpartsdisp lay.cfm?

    here is what i got on serialpartsdisp lay.cfm

    Code:
    <!---IF HAVE ANY BLANKS IN ANY FIELDS THIS MAKES IT SO THE FIELD WILL SHOW UP--->
    
    <!--- Shows what was previously entered for Model No, Product Type, and Type of Hardware Failure  --->
    <cfloop query="serial">
    <div id="dynamic#count#Input"> 
    <table class="zpExpandedTable" id="modeltable"> 
    <th class="sectiontitletick" colspan="7">
    Serial Information #count# </th>
    <tr>
    <td id="paddingformultitop">Model No:&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </td>
    <td>
    <select name="modelno_#count#">
    <option value="">Make A Selection</option>
    <cfloop query="models">
    <option value="#model#"<cfif #model# is #model_no#>selected</cfif>>#model#</option>
    </cfloop> 
    </select></td>
    <td>
    &nbsp;&nbsp;&nbsp;&nbsp;Product Type:
    </td>
    <td>
    <select name="producttype_#count#">
    <option value="" selected>No Choice</option>
    <cfloop query="getProdType">
    <option value="#pk_productType#"<cfif #pk_productType# is #product_type#>selected</cfif>>#pk_productType#</option> 
    </cfloop>
    </select>
    </td>
    <td class="red">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type Of Hardware Failure*:
    </td>
    <td>
    
    <select name="hardwarefailure_#count#">
    <option value="" selected>Make A Selection</option>
    <cfloop query="getHardwareFail">
    <option value="#pk_hardwareFailure#"<cfif #pk_hardwareFailure# is #type_hardware_failure#>selected</cfif>>#pk_hardwareFailure#</option>
    </cfloop>
    </select>
    </td>
    </tr>
    <table>
     
    <!--- Shows what was previously entered for Serial Number and Software/Hardware  --->
    <table class="zpExpandedTable" id="modeltable">
    <tr>
    <td id="paddingformultitop">
    Serial Number:&nbsp;&nbsp;
    <input type="text" name="serialnum_#count#" value="#pka_serialNo#">
    &nbsp;&nbsp;&nbsp;&nbsp;Software/Hardware:&nbsp;&nbsp;
    <select name="softhardware_#count#">
    <option value="" selected>No Choice</option>
    <cfloop query="getSoftHard">
    <option value="#pk_softwareHardware#"<cfif #pk_softwareHardware# is #software_hardware#>selected</cfif>>#pk_softwareHardware#</option>
    </cfloop>
    </select>
    
    </td>
    </tr>
    </table>
    
    <!--- Shows what was previously entered for Description ---> 
    
     <cfquery name="getnotes" dbtype="query" >
    SELECT *
    FROM notes
    WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#" 
    cfsqltype="cf_sql_char" maxLength="20">
    </cfquery>
    <cfloop query="getnotes">
    
    <input type="hidden" name="pk_num_#count#" id="pk_num" value="" /></cfloop>
    <!---<div style="width: 150px; height: 150px; overflow-y: scroll; scrollbar-arrow-color:blue; 
    scrollbar-face-color: #e7e7e7; scrollbar-3dlight-color: #a0a0a0; scrollbar-darkshadow-color:#888888;">--->
    <table class="zpExpandedTable" id="resoltable" cellpadding="3" cellspacing="0">
    <tr><td id="paddingformutli">
    Previously Submitted Descriptions:</td><td id="paddingformutli">
    <div id="descriptionbox" style="HEIGHT:100px; WIDTH:500px; OVERFLOW:auto;" >
    <cfloop query="getnotes">
    Added By: #fk_addedBy# <br/>
    Dated Added: #DateFormat(date_stamp,'mm/dd/yyyy')#<br/><br/>
    #description#
    <div id="line"></div>
    </cfloop></div></td>
    
    </tr>
    </table>
    <table class="zpExpandedTable" id="resoltable" cellpadding="3" cellspacing="0">
    <tr>
    <!---<input type="hidden" name="thedescriptoin_#count#" id="thedescriptoin" value="#description#" />--->
    <td id="paddingformutli">
    Description:&nbsp;&nbsp;
    </td>
    <td class="descriptionmoveinmulti">
    
    ( You may enter up to 1000 characters. )
    <br>
    <textarea maxlength='1000' onkeyup='return descriptionmaxlength(this)' onkeydown='return descriptionmaxlength(this)'rows='4' cols='60' name="thedescription_#count#"></textarea>
    
    </td>
    </tr>
    </table>
    <!---Shows what was previously entered for Resolution ---> 
    
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td id="paddingformutli">
    Resolution:&nbsp;&nbsp;
    </td>
    <td class="resolutionmoveinmulti">
    ( You may enter up to 1500 characters. )
    <br>
    <textarea  maxlength="1500" onkeyup="return resolutionismaxlength(this)" onkeydown="return resolutionismaxlength(this)" rows="4" cols="60" name="resolution_#count#">#resolution#</textarea>
    </td>
    </tr>
    </table>
     
    <!--- Shows what was previously entered for Resolution Date, Current Date (for resolution date) and resolution vertified as effective by  --->
    
    <table class="zpExpandedTable" id="resoldatetab" cellpadding="1" cellspacing="0">
    <tr>
    <td id="paddingformultitop">
    Resolution Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;
    </td>
    <td>
    <input type="text" name="resdate_#count#" value="#DateFormat(resolution_date,'mm/dd/yyyy')#">&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;
    <input type="checkbox" name="currentdateresol_#count#" 
    onClick="resdate_#count#.value=fill_date()">
    </td>
    <td>
    Resolution Verified as effective by:&nbsp;&nbsp;
    </td>
    <td>
    <select name="resvertified_#count#">
    <option value="" selected>Make A Selection</option>
    <cfloop query="gettech">
    <option value="#fname# #lname#"<cfif "#fname# #lname#" is #resolution_verified_by#>
    selected</cfif>>#fname# #lname#</option>
    </cfloop>
    </select>
    </td>
    </tr>
    </table>
    <!--- Shows what was previously entered for Vertification Date, Current Date (for vertification date)   --->
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td id="paddingformultitop">
    Verification Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;
    </td>
    <td class="vertificationmoveinmulti">
    <input type="text" name="vertifidate_#count#" value="#DateFormat(verification_date,'mm/dd/yyyy')#">&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;
    <input type="checkbox" name="currentdatevert_#count#" 
    onClick="vertifidate_#count#.value=fill_date()">
    
    </td>
    </tr>
    </table>
     
    <!--- Shows what was previously entered for Dept/Vendor Responsibility  --->
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td class="red" id="paddingformultitop">
    Dept/Vendor Responsibility*:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <select name="deptvendor_#count#">
    <option value="" selected>Make A Selection</option>
    <cfloop query="getDeptVendor">
    <option value="#pk_deptVendor#"<cfif #pk_deptVendor# is #dept_responsibility#>selected</cfif>>#pk_deptVendor#</option>
    </cfloop>
    </select>
    </td>
    </tr>
    </table>
    <input type="hidden" name="serialcount" id="serialcount" value="#count#">
    
    
    
    <!--- Adds Delete to every ticket  --->
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td>
    <input type="button" class="removeticket" value="Remove Serial #count#" onClick="removeElement('dynamic#count#Input')">
    </td>
    </tr>
    <tr>
    <td>
    <input type="button" class="addticket" value="Add Parts" onClick="addpartInput('dynamic#count#Input')">
    </td>
    </tr>
    </table>
    
    
    <!---Shows what was previously entered into parts table--->
    <!---dbtype="query"--->
    
    
    <cfquery name="getparts" dbtype="query" >
    SELECT *
    FROM parts
    WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#" 
    cfsqltype="cf_sql_char" maxLength="20">
    </cfquery>
    <cfset count1 = 0>
    <!---<cfif serial.recordcount is 0>--->
    <!---<cfloop query="getparts">
    <cfset count1 = count1 + 1>--->
    
    
    
    <!---The template is where most of the parts section is held--->
    <!---<cfinclude template="partsdisplay.cfm">--->
    <!---<cfset count1 = 0>--->
    <cfloop query="getparts">
    <cfset count1 = count1 + 1>
    <cfset hc_partNo = #hc_partNo#>
    <cfset part_returned = #part_returned#>
    <cfset defective = #defective#>
    <cfset rma_number = #rma_number#>
    <cfinclude template="partsdisplay.cfm">
       </cfloop>
       <cfif serial.recordcount is 0 and getparts.recordcount is 0>
     <cfset count1 = 1>
    <cfset hc_partNo = "">
    <cfset part_returned = "">
    <cfset defective = ""> 
    <cfset rma_number = "">
      <cfinclude template="partsdisplay.cfm">
     </cfif>
     
    
    <input type="hidden" name="partscount#count#" id="partscount#count#" value="#count1#"/>
    <!---</cfloop>
    --->
    
    </div>
    <!---this one makes it so you can add a part to a previously submitted serial--->
    
    <input type="hidden" name="partcounter#count#" id="partcounter#count#" value="#count1#" />
    </cfloop>
    here is what i got on cticketpage2edi t.cfm

    Code:
      <div id="dynamicInput"> 
         <!--- All Ticket Information Appears Here--->
    
    <!---If there is a serial it will show it (parts table works the same way). parts is in serialpartsdisplay.cfm--->
    <cfset count = 0>
     <cfoutput query="serial">
     <cfset count = count + 1>
     <cfset model_no = #model_no#>
     <cfset product_type = #product_type#>
     <cfset type_hardware_failure = #type_hardware_failure#>
      <cfset pka_serialNo = #pka_serialNo#>
     <cfset software_hardware = #software_hardware#>
      <cfset resolution = #resolution#>
     <cfset resolution_date = #resolution_date#>
     <cfset resolution_verified_by = #resolution_verified_by#>
      <cfset verification_date = #verification_date#>
     <cfset dept_responsibility = #dept_responsibility#>
     <cfinclude template="serialpartsdisplay.cfm">
       </cfoutput>
    
    <!---  If fields in the serial was not added it shows the blank field/ or it will show the whole table if no serial was submitted (parts table works the same way). parts is in serialpartsdisplay.cfm--->
     <cfif serial.recordcount is 0>
     <cfset count = 1>
     <cfset model_no = "">
     <cfset product_type = "">
     <cfset type_hardware_failure = "">
     <cfset pka_serialNo = "">
     <cfset software_hardware = "">
     <cfset resolution = "">
     <cfset resolution_date = "">
     <cfset resolution_verified_by = "">
     <cfset verification_date = "">
     <cfset dept_responsibility = "">
       <cfoutput><cfinclude template="serialpartsdisplay.cfm"></cfoutput>
     </cfif>
    
    
    
    
    <input type="hidden" value="<cfoutput>#count#</cfoutput>" name="theValue" id="theValue" />
    </div>
    
         <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
    Thank you,
    Rach

    Comment

    • bonneylake
      Contributor
      • Aug 2008
      • 769

      Hey Acoder,

      I really can't figure it out. I know it has to do with a cfloop or cfoutput in the wrong place but not sure where. But here is what i got in full on every page

      on cticketpage2edi t.cfm.
      Code:
          <div id="dynamicInput"> 
           <!--- All Ticket Information Appears Here--->
      
      <!---If there is a serial it will show it (parts table works the same way). parts is in serialpartsdisplay.cfm--->
      <cfset count = 0>
       <cfloop query="serial">
       <cfset count = count + 1>
       <cfset model_no = #model_no#>
       <cfset product_type = #product_type#>
       <cfset type_hardware_failure = #type_hardware_failure#>
        <cfset pka_serialNo = #pka_serialNo#>
       <cfset software_hardware = #software_hardware#>
        <cfset resolution = #resolution#>
       <cfset resolution_date = #resolution_date#>
       <cfset resolution_verified_by = #resolution_verified_by#>
        <cfset verification_date = #verification_date#>
       <cfset dept_responsibility = #dept_responsibility#>
       <cfinclude template="serialpartsdisplay.cfm">
         </cfloop>
      
      <!---  If fields in the serial was not added it shows the blank field/ or it will show the whole table if no serial was submitted (parts table works the same way). parts is in serialpartsdisplay.cfm--->
       <cfif serial.recordcount is 0>
       <cfset count = 1>
       <cfset model_no = "">
       <cfset product_type = "">
       <cfset type_hardware_failure = "">
       <cfset pka_serialNo = "">
       <cfset software_hardware = "">
       <cfset resolution = "">
       <cfset resolution_date = "">
       <cfset resolution_verified_by = "">
       <cfset verification_date = "">
       <cfset dept_responsibility = "">
         <cfoutput><cfinclude template="serialpartsdisplay.cfm"></cfoutput>
       </cfif>
      
      <input type="hidden" value="<cfoutput>#count#</cfoutput>" name="theValue" id="theValue" />
      </div>
      
           <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >





      serialpartsdisp lay.cfm-
      Code:
      <cfoutput>
      
      the serials display here
      
      <cfquery name="getparts" dbtype="query" >
      SELECT *
      FROM parts
      WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#" 
      cfsqltype="cf_sql_char" maxLength="20">
      </cfquery>
      <cfset count1 = 0>
      <!---<cfif serial.recordcount is 0>--->
      <!---<cfloop query="getparts">
      <cfset count1 = count1 + 1>--->
      
      
      
      <!---The template is where most of the parts section is held--->
      <!---<cfinclude template="partsdisplay.cfm">--->
      <!---<cfset count1 = 0>--->
      <cfloop query="getparts">
      <cfset count1 = count1 + 1>
      <cfset hc_partNo = #hc_partNo#>
      <cfset part_returned = #part_returned#>
      <cfset defective = #defective#>
      <cfset rma_number = #rma_number#>
      <cfinclude template="partsdisplay.cfm">
         </cfloop>
         <cfif serial.recordcount is 0 and getparts.recordcount is 0>
       <cfset count1 = 1>
      <cfset hc_partNo = "">
      <cfset part_returned = "">
      <cfset defective = ""> 
      <cfset rma_number = "">
      <cfinclude template="partsdisplay.cfm">
       </cfif>
       
      
      <input type="hidden" name="partscount#count#" id="partscount#count#" value="#count1#"/>
      
      serials close here
      
      
      </cfoutput>
      partsdisplay.cf m
      Code:
      <div id="part#count1#Name#count#">
      
      <input type="hidden" name="pkpartID_#count1#_#count#" id="pkpartID" value="#pk_partID#" />
      <!---<cfset partliststr = "">
      <cfloop from="1" to="#count1#" index="pl">
      <cfset partliststr = partliststr & #pl# & ",">
      </cfloop>
      
      <input type="hidden" name="part2count#count#" id="part2count#count#" value="#partliststr#">
      <input type="hidden" name="partscount#count#" id="partscount#count#" value="#count1#">--->
      
      <!---THIS IS THE PARTS SECTION--->
      
      
      
      <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
      <th class="sectiontitle" colspan="7">Parts Information #count1# Serial Information #count#</th>
      <tr>
      <td class='indent' id='formfieldpadding'>HC P/N:&nbsp;&nbsp;&nbsp;<input type='text' name="hcpn_#count1#_#count#" style="margin:0px" value="#hc_partNo#"></td>
      <td>
      Parts been returned*
      <input type="checkbox" name="partsreturn_#count1#_#count#" value="#part_returned#"<cfif #part_returned# eq "1">checked=yes</cfif>/>
      </td>
      <td>
      <td class="indent">Defective<input type="checkbox" name="defective_#count1#_#count#" value="#defective#"<cfif #defective# eq "1">checked=yes</cfif>/></td>
      </td>
      </tr>
      </table>
      <!---<input type="hidden" name="partscount#count#" id="partscount#count#" value="#count#">--->
      
      
      <!--- Shows what was previously entered for RMA Data Only  --->
      <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
      <tr>
      <td id="paddingformultitop">
      RMA Data Only:&nbsp;&nbsp;&nbsp;&nbsp;
      </td>
      <td class="rmanmoveinmulti">
      ( You may enter up to 1000 characters. )
      <br/>
      
      <textarea maxlength="1000" onkeyup="return rmaismaxlength(this)" onkeydown="return rmaismaxlength(this)" rows="4" cols="60" name="rma_#count1#_#count#" >#rma_number#</textarea></td>
      </tr>
      </table>
      
      
      <!--- Adds Delete to every ticket  --->
      <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
      <tr>
      <td>
      
      <input type="button" class="removeticket" value="Remove Parts #count1#" 
      onclick="removetheElement('part#count1#Name#count#',#count#,#count#)">
      </td>
      </td>
      </tr>
      </table>
      
      </div>
      Thank you,
      Rach

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        If you look carefully, you'll notice that you have cfoutput within cfoutput. On the edit page, you've put cfoutput tags around serialpartsdisp lay include, then within serialpartsdisp lay you have the whole content in cfoutput. What I would suggest for an easy solution here is that you remove the cfoutput tags in serialpartsdisp lay and change the cfloop query in the edit page to a cfoutput one.

        Comment

        • bonneylake
          Contributor
          • Aug 2008
          • 769

          Hey Acoder,

          I tried that but it didn't work. All it does is the same problem i am having with parts which it displays #count# instead of the number an it does it for all fields an it does it with or without a serial filled out. The only way i been able to display serials is by having cfoutput in serialpartsdisp lay.cfm. Here is what i tried

          on cticketpage2edi t.cfm

          Code:
          <div id="dynamicInput"> 
               <!--- All Ticket Information Appears Here--->
          
          <!---If there is a serial it will show it (parts table works the same way). parts is in serialpartsdisplay.cfm--->
          <cfset count = 0>
           <cfoutput query="serial">
           <cfset count = count + 1>
           <cfset model_no = #model_no#>
           <cfset product_type = #product_type#>
           <cfset type_hardware_failure = #type_hardware_failure#>
            <cfset pka_serialNo = #pka_serialNo#>
           <cfset software_hardware = #software_hardware#>
            <cfset resolution = #resolution#>
           <cfset resolution_date = #resolution_date#>
           <cfset resolution_verified_by = #resolution_verified_by#>
            <cfset verification_date = #verification_date#>
           <cfset dept_responsibility = #dept_responsibility#>
           <cfinclude template="serialpartsdisplay.cfm">
             </cfoutput>
          
          <!---  If fields in the serial was not added it shows the blank field/ or it will show the whole table if no serial was submitted (parts table works the same way). parts is in serialpartsdisplay.cfm--->
           <cfif serial.recordcount is 0>
           <cfset count = 1>
           <cfset model_no = "">
           <cfset product_type = "">
           <cfset type_hardware_failure = "">
           <cfset pka_serialNo = "">
           <cfset software_hardware = "">
           <cfset resolution = "">
           <cfset resolution_date = "">
           <cfset resolution_verified_by = "">
           <cfset verification_date = "">
           <cfset dept_responsibility = "">
             <cfoutput><cfinclude template="serialpartsdisplay.cfm"></cfoutput>
           </cfif>
          
          
          
          
          <input type="hidden" value="<cfoutput>#count#</cfoutput>" name="theValue" id="theValue" />
          </div>
          
               <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
          serialpartsdisp lay.cfm
          Code:
          <!---IF HAVE ANY BLANKS IN ANY FIELDS THIS MAKES IT SO THE FIELD WILL SHOW UP--->
          
          <!--- Shows what was previously entered for Model No, Product Type, and Type of Hardware Failure  --->
          
          <div id="dynamic#count#Input"> 
          <table class="zpExpandedTable" id="modeltable"> 
          <th class="sectiontitletick" colspan="7">
          Serial Information #count# </th>
          <tr>
          <td id="paddingformultitop">Model No:&nbsp;&nbsp;&nbsp;&nbsp;</td>
          </td>
          <td>
          <select name="modelno_#count#">
          <option value="">Make A Selection</option>
          <cfloop query="models">
          <option value="#model#"<cfif #model# is #model_no#>selected</cfif>>#model#</option>
          </cfloop> 
          </select></td>
          <td>
          &nbsp;&nbsp;&nbsp;&nbsp;Product Type:
          </td>
          <td>
          <select name="producttype_#count#">
          <option value="" selected>No Choice</option>
          <cfloop query="getProdType">
          <option value="#pk_productType#"<cfif #pk_productType# is #product_type#>selected</cfif>>#pk_productType#</option> 
          </cfloop>
          </select>
          </td>
          <td class="red">
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type Of Hardware Failure*:
          </td>
          <td>
          
          <select name="hardwarefailure_#count#">
          <option value="" selected>Make A Selection</option>
          <cfloop query="getHardwareFail">
          <option value="#pk_hardwareFailure#"<cfif #pk_hardwareFailure# is #type_hardware_failure#>selected</cfif>>#pk_hardwareFailure#</option>
          </cfloop>
          </select>
          </td>
          </tr>
          <table>
           
          <!--- Shows what was previously entered for Serial Number and Software/Hardware  --->
          <table class="zpExpandedTable" id="modeltable">
          <tr>
          <td id="paddingformultitop">
          Serial Number:&nbsp;&nbsp;
          <input type="text" name="serialnum_#count#" value="#pka_serialNo#">
          &nbsp;&nbsp;&nbsp;&nbsp;Software/Hardware:&nbsp;&nbsp;
          <select name="softhardware_#count#">
          <option value="" selected>No Choice</option>
          <cfloop query="getSoftHard">
          <option value="#pk_softwareHardware#"<cfif #pk_softwareHardware# is #software_hardware#>selected</cfif>>#pk_softwareHardware#</option>
          </cfloop>
          </select>
          
          </td>
          </tr>
          </table>
          
          <!--- Shows what was previously entered for Description ---> 
          
           <cfquery name="getnotes" dbtype="query" >
          SELECT *
          FROM notes
          WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#" 
          cfsqltype="cf_sql_char" maxLength="20">
          </cfquery>
          <cfloop query="getnotes">
          
          <input type="hidden" name="pk_num_#count#" id="pk_num" value="" /></cfloop>
          <!---<div style="width: 150px; height: 150px; overflow-y: scroll; scrollbar-arrow-color:blue; 
          scrollbar-face-color: #e7e7e7; scrollbar-3dlight-color: #a0a0a0; scrollbar-darkshadow-color:#888888;">--->
          <table class="zpExpandedTable" id="resoltable" cellpadding="3" cellspacing="0">
          <tr><td id="paddingformutli">
          Previously Submitted Descriptions:</td><td id="paddingformutli">
          <div id="descriptionbox" style="HEIGHT:100px; WIDTH:500px; OVERFLOW:auto;" >
          <cfloop query="getnotes">
          Added By: #fk_addedBy# <br/>
          Dated Added: #DateFormat(date_stamp,'mm/dd/yyyy')#<br/><br/>
          #description#
          <div id="line"></div>
          </cfloop></div></td>
          
          </tr>
          </table>
          <table class="zpExpandedTable" id="resoltable" cellpadding="3" cellspacing="0">
          <tr>
          <!---<input type="hidden" name="thedescriptoin_#count#" id="thedescriptoin" value="#description#" />--->
          <td id="paddingformutli">
          Description:&nbsp;&nbsp;
          </td>
          <td class="descriptionmoveinmulti">
          
          ( You may enter up to 1000 characters. )
          <br>
          <textarea maxlength='1000' onkeyup='return descriptionmaxlength(this)' onkeydown='return descriptionmaxlength(this)'rows='4' cols='60' name="thedescription_#count#"></textarea>
          
          </td>
          </tr>
          </table>
          <!---Shows what was previously entered for Resolution ---> 
          
          <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
          <tr>
          <td id="paddingformutli">
          Resolution:&nbsp;&nbsp;
          </td>
          <td class="resolutionmoveinmulti">
          ( You may enter up to 1500 characters. )
          <br>
          <textarea  maxlength="1500" onkeyup="return resolutionismaxlength(this)" onkeydown="return resolutionismaxlength(this)" rows="4" cols="60" name="resolution_#count#">#resolution#</textarea>
          </td>
          </tr>
          </table>
           
          <!--- Shows what was previously entered for Resolution Date, Current Date (for resolution date) and resolution vertified as effective by  --->
          
          <table class="zpExpandedTable" id="resoldatetab" cellpadding="1" cellspacing="0">
          <tr>
          <td id="paddingformultitop">
          Resolution Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;
          </td>
          <td>
          <input type="text" name="resdate_#count#" value="#DateFormat(resolution_date,'mm/dd/yyyy')#">&nbsp;&nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;
          <input type="checkbox" name="currentdateresol_#count#" 
          onClick="resdate_#count#.value=fill_date()">
          </td>
          <td>
          Resolution Verified as effective by:&nbsp;&nbsp;
          </td>
          <td>
          <select name="resvertified_#count#">
          <option value="" selected>Make A Selection</option>
          <cfloop query="gettech">
          <option value="#fname# #lname#"<cfif "#fname# #lname#" is #resolution_verified_by#>
          selected</cfif>>#fname# #lname#</option>
          </cfloop>
          </select>
          </td>
          </tr>
          </table>
          <!--- Shows what was previously entered for Vertification Date, Current Date (for vertification date)   --->
          <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
          <tr>
          <td id="paddingformultitop">
          Verification Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;
          </td>
          <td class="vertificationmoveinmulti">
          <input type="text" name="vertifidate_#count#" value="#DateFormat(verification_date,'mm/dd/yyyy')#">&nbsp;&nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;
          <input type="checkbox" name="currentdatevert_#count#" 
          onClick="vertifidate_#count#.value=fill_date()">
          
          </td>
          </tr>
          </table>
           
          <!--- Shows what was previously entered for Dept/Vendor Responsibility  --->
          <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
          <tr>
          <td class="red" id="paddingformultitop">
          Dept/Vendor Responsibility*:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <select name="deptvendor_#count#">
          <option value="" selected>Make A Selection</option>
          <cfloop query="getDeptVendor">
          <option value="#pk_deptVendor#"<cfif #pk_deptVendor# is #dept_responsibility#>selected</cfif>>#pk_deptVendor#</option>
          </cfloop>
          </select>
          </td>
          </tr>
          </table>
          <input type="hidden" name="serialcount" id="serialcount" value="#count#">
          
          
          
          <!--- Adds Delete to every ticket  --->
          <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
          <tr>
          <td>
          <input type="button" class="removeticket" value="Remove Serial #count#" onClick="removeElement('dynamic#count#Input')">
          </td>
          </tr>
          <tr>
          <td>
          <input type="button" class="addticket" value="Add Parts" onClick="addpartInput('dynamic#count#Input')">
          </td>
          </tr>
          </table>
          
          
          <!---Shows what was previously entered into parts table--->
          <!---dbtype="query"--->
          
          
          <cfquery name="getparts" dbtype="query" >
          SELECT *
          FROM parts
          WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#" 
          cfsqltype="cf_sql_char" maxLength="20">
          </cfquery>
          <cfset count1 = 0>
          <!---<cfif serial.recordcount is 0>--->
          <!---<cfloop query="getparts">
          <cfset count1 = count1 + 1>--->
          
          
          
          <!---The template is where most of the parts section is held--->
          <!---<cfinclude template="partsdisplay.cfm">--->
          
          <cfset count1 = 0>
          <cfloop query="getparts">
          <cfset count1 = count1 + 1>
          <cfset hc_partNo = #hc_partNo#>
          <cfset part_returned = #part_returned#>
          <cfset defective = #defective#>
          <cfset rma_number = #rma_number#>
          <cfinclude template="partsdisplay.cfm">
             </cfloop>
          
          <cfif serial.recordcount is 0 and getparts.recordcount is 0>
           <cfset count1 = 1>
          <cfset hc_partNo = "">
          <cfset part_returned = "">
          <cfset defective = ""> 
          <cfset rma_number = "">
          <cfoutput><cfinclude template="partsdisplay.cfm"></cfoutput>
           </cfif>
          
           
          
          <input type="hidden" name="partscount#count#" id="partscount#count#" value="#count1#"/>
          <!---</cfloop>
          --->
          
          </div>
          <!---this one makes it so you can add a part to a previously submitted serial--->
          
          <input type="hidden" name="partcounter#count#" id="partcounter#count#" value="#count1#" />

          Thank you,
          Rach

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            Yes, you're right, it won't work that way.

            <cfinclude> won't output variables if the cfoutput is outside. So ignore my previous advice and add cfoutput inside both templates. You can remove it from the edit page unless there's some variables on that page.

            Comment

            • bonneylake
              Contributor
              • Aug 2008
              • 769

              Hey Acoder,

              So would it be like this for the cticketpage2edi t.cfm page?

              Code:
                  <div id="dynamicInput"> 
                   <!--- All Ticket Information Appears Here--->
              
              <!---If there is a serial it will show it (parts table works the same way). parts is in serialpartsdisplay.cfm--->
              <cfset count = 0>
               <cfloop query="serial"> <cfset count = count + 1>
               <cfset model_no = #model_no#>
               <cfset product_type = #product_type#>
               <cfset type_hardware_failure = #type_hardware_failure#>
                <cfset pka_serialNo = #pka_serialNo#>
               <cfset software_hardware = #software_hardware#>
                <cfset resolution = #resolution#>
               <cfset resolution_date = #resolution_date#>
               <cfset resolution_verified_by = #resolution_verified_by#>
                <cfset verification_date = #verification_date#>
               <cfset dept_responsibility = #dept_responsibility#>
               <cfinclude template="serialpartsdisplay.cfm">
                 </cfloop>
              
              <!---  If fields in the serial was not added it shows the blank field/ or it will show the whole table if no serial was submitted (parts table works the same way). parts is in serialpartsdisplay.cfm--->
               <cfif serial.recordcount is 0>
               <cfset count = 1>
               <cfset model_no = "">
               <cfset product_type = "">
               <cfset type_hardware_failure = "">
               <cfset pka_serialNo = "">
               <cfset software_hardware = "">
               <cfset resolution = "">
               <cfset resolution_date = "">
               <cfset resolution_verified_by = "">
               <cfset verification_date = "">
               <cfset dept_responsibility = "">
                 <cfinclude template="serialpartsdisplay.cfm">
               </cfif>
              
              
              
              
              <input type="hidden" value="<cfoutput>#count#</cfoutput>" name="theValue" id="theValue" />
              </div>
              
                   <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
              an then on serialpartsdisp lay.cfm would this work

              Code:
              <cfoutput>
              around all serials
              
              <cfquery name="getparts" dbtype="query" >
              SELECT *
              FROM parts
              WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#" 
              cfsqltype="cf_sql_char" maxLength="20">
              </cfquery>
              <cfset count1 = 0>
              <!---<cfif serial.recordcount is 0>--->
              <!---<cfloop query="getparts">
              <cfset count1 = count1 + 1>--->
              
              
              
              <!---The template is where most of the parts section is held--->
              <!---<cfinclude template="partsdisplay.cfm">--->
              
              <cfset count1 = 0>
              <cfloop query="getparts">
              <cfset count1 = count1 + 1>
              <cfset hc_partNo = #hc_partNo#>
              <cfset part_returned = #part_returned#>
              <cfset defective = #defective#>
              <cfset rma_number = #rma_number#>
              <cfinclude template="partsdisplay.cfm">
                 </cfloop>
              
              <cfif serial.recordcount is 0 and getparts.recordcount is 0>
               <cfset count1 = 1>
              <cfset hc_partNo = "">
              <cfset part_returned = "">
              <cfset defective = ""> 
              <cfset rma_number = "">
              <cfinclude template="partsdisplay.cfm">
               </cfif>
              </cfoutput>
              an then on partsdisplay.cf m all i did was add cfoutput around it all. The parts will work correctly if i filled out a part, except if you have more then one part. If you have more the one part it only displays one part. If you go to add a part to it an submit it, then it deletes the part before it an only show the one you added (for some reason).however , if i don't fill out a part it will not work an i get an error, an thats doing it the way i have explained it. However, i can get the empty part to display (an any part filled in) if i do the following.

              Code:
              <div id="part#count1#Name#count#">
              
              <input type="hidden" name="pkpartID_#count1#_#count#" id="pkpartID" value="#pk_partID#" />
              <cfoutput>
              </div>
              </cfoutput>
              but the problem with doing it this way is then the div is not being counted at all.An i know the hidden input line is whats causing it but no clue what to do
              Any ideas?

              Thank you,
              Rach

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                OK, it seems as if you have a problem with the submit page or getting the right format for it. Since it's been a long thread, it's easy to forget what's been added and changed. What's the error message, and what's required for the adding of parts now?

                Comment

                • bonneylake
                  Contributor
                  • Aug 2008
                  • 769

                  Hey Acoder,

                  Well it wont tell me exactly what the problem is, it just says contact administrator. When i look at the full error using the bug it says its with pkpartID, which in the line below. But i know it has to be causing the problem because right now if i do not add a serial or part it brings up an error an it has problems with this line and i get an error and parts don't display. However, if i have a serial and part it does not bring up an error but it will not allow me to have 2 or more parts per serial an i believe this line controlled that. pk_partID makes each part have a unique number (in the table)an keep track of it. So i know this line is important, but it does not seem to act right where it is.I know this line was originally wrapped around the cfloop query="getparts " inside the div. but its not a submission problem because its submitting to the database correct. However, its not displaying right an it has to do with pk_partID

                  Code:
                  <input type="hidden" name="pkpartID_#count1#_#count#" id="pkpartID" value="#pk_partID#" />
                  The only thing i can think of that made the cticketpage2edi t.cfm and the serialpartsdisp lay.cfm different (the original version we had before making the recent changes ). Was in cticketpage2edi t.cfm i had the line pkpartID line, however, in serialpartsdisp lay.cfm i didn't have the pkpartID. The pkpartID is only needed if you are displaying previously submitted parts and makes it so each part is unique so recently submitted parts are not deleted an the new ones wont over write the old ones.But i am not sure how to keep the pkpartId to display previously submitted parts an to take it out for parts not added.


                  Thank you,
                  Rach

                  Comment

                  • bonneylake
                    Contributor
                    • Aug 2008
                    • 769

                    Hey Acoder,

                    Ok to update from post 443. I have parts displaying now with or without a part added (with no problems). The main problem i am having now is it will only display one part per serial.If i update a ticket an add 2 parts to 1 serial instead of keeping the old one and adding the new one for some reason its deleteing the old one an inserting the new one. I believe the problem is with this

                    Code:
                    <input type="hidden" name="pkpartID_#count1#_#count#" id="pkpartID" value="#pk_partID#" />
                    the reason is because this makes it so each part is unique and its suppose to where if a user adds another part to a previously submitted part its suppose to say this part is here lets insert another instead of overwritting it or deleteing it.

                    Thank you,
                    Rach

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      Can you post your code for the actual insertion/update on the submit page?

                      I assume the serial code works absolutely fine?

                      Comment

                      • bonneylake
                        Contributor
                        • Aug 2008
                        • 769

                        Hey Acoder,

                        Yes serials works fine.An i think your right about the parts. I went an retested using the old cticketpage2edi t.cfm an it ran into the same problem. But here is what i have on userformedit.cf m

                        Code:
                        <CFIF REQUEST_METHOD EQ "POST">
                         
                        <!---counts how many serials are there--->
                         <cfquery name="countserials" datasource="CustomerSupport">
                        SELECT pka_serialNo from dbo.tbl_CS_serial where pkb_fk_ticketNo=<cfqueryparam value="#Form.pk_ticketID#">
                         </cfquery>
                         <cfset currSerialNo = 1>
                         
                        <!--- the array gets serials that have been inserted and updated to avoid deleteing the ones that need to be inserted or updated--->
                         <cfset serialcheck = ArrayNew(1)>
                        <!--- first loop inserts/update serials--->
                         <CFLOOP list="#form.serialcount#" index="machineCount">
                        <CFSET serialnum       = Form["serialnum_" & machineCount]>
                        <CFSET modelno         = Form["modelno_" & machineCount]>
                        <CFSET producttype     = Form["producttype_" & machineCount]>
                        <CFSET softhardware    = Form["softhardware_" & machineCount]>
                        <CFSET resolution      = Form["resolution_" & machineCount]>
                        <CFSET resdate         = Form["resdate_" & machineCount]>
                        <CFSET resvertified    = Form["resvertified_" & machineCount]>
                        <CFSET vertifidate     = Form["vertifidate_" & machineCount]>
                        <CFSET deptvendor      = Form["deptvendor_" & machinecount]>
                        <CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
                        <CFSET thedescription  = Form["thedescription_" & machineCount]>
                        <!---the array checks to see what serials are there--->
                        <CFSET ArrayAppend(serialcheck, "#Form["serialnum_" & machineCount]#")> 
                        
                        
                        <!--- counts how many parts are available--->
                         <cfquery name="countparts" datasource="CustomerSupport">
                        SELECT pk_partID from dbo.tbl_CS_parts where fk_serialNo=<cfqueryparam value="#serialnum#"> and fk_ticketNo=<cfqueryparam value="#Form.pk_ticketID#">
                         </cfquery>
                        <!--- the array gets parts that have been inserted and updated to avoid deleteing the ones that need to be inserted or updated--->
                        <cfset partcheck = ArrayNew(1)>
                        
                        
                         <!--- inserts information into the serial table--->
                         <cfquery name="serialinsertupdate" datasource="CustomerSupport">
                            exec usp_CS_Updateinsertserial 
                             <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                             "#Form.pk_ticketID#",
                             <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
                              <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
                             <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
                             <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
                             <cfqueryparam value="#resdate#">,
                             <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
                             <cfqueryparam value="#vertifidate#">,
                            <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
                             <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">   
                             </cfquery>
                        
                         <!---Inserts information into notes_descr table.--->
                        
                         <!--- the pk_num makes each description added unique, this allows us to delete one descriptoin instead of all description associated with a serial--->
                         <cfif thedescription neq "">
                        <cfquery name="description" datasource="CustomerSupport">
                            exec usp_CS_Insertdescription
                           <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                           '#Form.pk_ticketID#',
                           <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
                           '#Form.fk_addedBy#'
                        </cfquery>
                        <cfelse>
                         </cfif>
                        
                          
                          <!---Inserts  information into parts table.--->
                          <!---because it is a bit we don't use 'ticks' around defective for parts table--->
                         <cfparam name="form.partscount#machinecount#" default="">
                         <cfloop list="#form['partscount' & machinecount]#" index="ps">
                         <!--- the pkpartID makes each part added unique, this allows us to delete one part instead of all parts associated with a serial--->
                          <cfparam name="Form.pkpartID_#ps#_#machinecount#" default="">
                         <cfparam name="Form.hcpn_#ps#_#machinecount#" default="">
                         <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
                         <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
                         <cfparam name="Form.rma_#ps#_#machinecount#" default="">
                        <!--- the pkpartID makes each part added unique, this allows us to delete one part instead of all parts associated with a serial--->
                         <CFSET pkpartID           = Form["pkpartID_" & "#ps#" & "_#machinecount#"]>
                         <CFSET hcpn            = Form["hcpn_" & "#ps#" & "_#machinecount#"]>
                         <CFSET partsreturn     = Form["partsreturn_" & "#ps#" & "_#machinecount#"]>
                         <CFSET defective       = Form["defective_" & "#ps#" & "_#machinecount#"]>
                         <CFSET rma             = Form["rma_" & "#ps#" & "_#machineCount#"]>
                        <!---the array checks to see what parts are there--->
                        <CFSET ArrayAppend(partcheck, "#Form["pkpartID_" & "#ps#" & "_#machinecount#"]#")>
                        <!---if hcpn is not equal to blank (meaning if it doesn't have a value) it will not insert a part. However if hcpn 
                        has a value it will insert the part into the table.--->
                        <cfif hcpn neq "">
                        <cfquery name="parts" datasource="CustomerSupport">
                           exec usp_CS_Updateinsertparts 
                           <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                           '#Form.pk_ticketID#',
                            <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
                            <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
                            <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">,
                           <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
                         </cfquery> 
                         <cfelse>
                         </cfif>
                        </cfloop>
                        
                        <!---THIS DELETES FOR THE PARTS TABLE--->
                        <!---setting a list for parts--->
                        <cfset partList = ArrayToList(partcheck, ",")>
                        <!---when inserting/updating for part's table is done it then delete parts not being updated/inserted or was to be deleted on purpose--->
                        <cfloop query="countparts">
                        <cfset pk_partID= #pk_partID#>
                        <!---if the part is not found in the list it begins deleteing--->
                        <cfif not listFind(partList,pk_partID)>
                        <cfquery name="deleteparts" datasource="CustomerSupport">
                        exec usp_CS_Deleteparts
                        <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                        '#Form.pk_ticketID#'
                        </cfquery>
                        </cfif>
                        </cfloop>
                        
                        
                        
                        </CFLOOP>
                        
                         <!---THIS DELETES FOR SERIAL TABLE AND ANY PARTS ASSOCIATED WITH THE SERIAL--->
                         <!---setting a list for serial--->
                         <cfset serialList = ArrayToList(serialcheck, ",")>
                         <!---when inserting/updating for serial's table is done it then delete serials not being updated/inserted or was to be deleted on purpose--->
                         <cfloop query="countserials">
                         <CFSET serialnum = #pka_serialNo#>
                         <!---if the serial is not found in the list it begins deleteing--->
                         <cfif not listFind(serialList,serialnum)>
                         <cfquery name="deleteserialparts" datasource="CustomerSupport">
                         exec usp_CS_Deleteserialparts   
                         <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                         '#Form.pk_ticketID#'
                         </cfquery>
                        <!--- if a serial is deleted, then the description for that serial will be deleted as well.--->
                        <cfquery name="deletedescription" datasource="CustomerSupport">
                        exec usp_CS_Deletenotesdescription
                        <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                        '#Form.pk_ticketID#'
                         </cfquery>
                         </cfif>
                         </cfloop>
                        
                        </CFIF>
                        i am starting to think the problem might not be with are statement but with my stored procedure. If the pk_partId exists it will update, but if it doesn't it inserts. I think because the pk_partID already exists its updating instead of inserting.could this possible be the problem? because i have noticed it is only updating.

                        Thank you :),
                        Rach

                        Comment

                        • bonneylake
                          Contributor
                          • Aug 2008
                          • 769

                          hey acoder,

                          I figured it out.It was my stored procedure.basic ally no matter what the hcpn number was, even if it was different from the first one. For example i inserted 1 and 2 at the same time it would still update to the newest one so i added in my stored procedure

                          Code:
                          WHERE  fk_serialNo=@fk_serialNo and fk_ticketNo=@fk_ticketNo and hc_partNo=@hc_partNo

                          but anyway this made it where if a hc_partNo and pk_part already exists it would update, if not it would insert. The part i am worried about is what if they have 2 hcpn_partNo for the same part? this doesnt seem a problem if for example i have a 2 with serial 1 and 2 with serial 2. It inserted fine with that. But if i try to insert 2 parts both with the same serial its a problem..Any suggestions or is this a problem all just have to deal with? The only solution i can think of is to add another field an count (like did serial) so that then i can do where the serial number, ticket number an whatever the new field i add is it makes it unique even if i add 1 twice in the same serial.

                          Thank you,
                          Rach

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            Well done on that part (no pun intended ;))! I think the solution should be quite straightforward now. Use the pk_partID (which is unique).

                            Comment

                            • bonneylake
                              Contributor
                              • Aug 2008
                              • 769

                              Hey Acoder,

                              ok i must admit i am confused. Are you saying in my where statement instead of using ticket,serial and the hcpn to use ticket, serial and pk_partid? because i tryed that an it inserted the same part twice perfectly! But i can not get the delete right. Instead of deleteing its adding. But here is what i did

                              stored procedure for update insert parts

                              Code:
                              set ANSI_NULLS ON
                              set QUOTED_IDENTIFIER ON
                              go
                              
                              
                              
                              -- =============================================
                              -- Author:        <Author,,Name>
                              -- Create date: <Create Date,,>
                              -- Description:    <Description,,>
                              -- =============================================
                              ALTER PROCEDURE [dbo].[usp_CS_Updateinsertparts]
                              -- Add the parameters for the stored procedure here
                                         (
                                  @fk_serialNo nvarchar(100),
                                  @fk_ticketNo nvarchar(100),
                                  @hc_partNo nvarchar(50),
                                  @part_returned char(10),
                                  @rma_number nvarchar(1000),
                                  @defective bit
                                  )
                              AS
                              BEGIN
                                     --- SET should be the first statement .. before everything else
                                  -- SET NOCOUNT ON added to prevent extra result sets from
                                  -- interfering with SELECT statements.
                                  SET NOCOUNT ON;
                              
                                  DECLARE @pk_partID nvarchar(55)
                              
                                  
                                  -- If @fk_custNum already exists, get the pk_contactID
                                  SELECT @pk_partID = ( SELECT MAX(pk_partID) FROM dbo.tbl_CS_parts WHERE  fk_serialNo=@fk_serialNo and fk_ticketNo=@fk_ticketNo and pk_partID=@pk_partID)
                              
                                  -- If  @fk_custNum already exists in the table, update it
                                  IF @pk_partID IS NOT NULL
                                  BEGIN
                              
                                          UPDATE    dbo.tbl_CS_parts
                                          SET          
                                                    
                                                    fk_ticketNo=@fk_ticketNo,
                                                    hc_partNo=@hc_partNo,
                                                    part_returned=@part_returned,
                                                    rma_number=@rma_number,
                                                    defective=@defective  
                                          
                                          
                                          WHERE  (pk_partID=@pk_partID and fk_serialNo=@fk_serialNo and fk_ticketNo=@fk_ticketNo and pk_partID=@pk_partID )
                              
                                  END
                                  -- the @fk_custNum does NOT exist. insert a new record
                                  ELSE
                                  BEGIN
                              
                                          -- insert a new record
                                          SET @pk_partID = (SELECT max_num FROM tbl_CS_ID_HELPER WHERE table_name='tbl_CS_parts')
                                          UPDATE tbl_CS_ID_helper SET  max_num=max_num+1 WHERE table_name='tbl_CS_parts'
                              
                                      -- Insert statements for procedure here
                                      INSERT INTO tbl_CS_parts
                                      (
                                          pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,part_returned ,defective ,rma_number
                                      )
                                      VALUES
                                      (
                                          @pk_partID,@fk_serialNo,@fk_ticketNo,@hc_partNo,@part_returned,@defective ,@rma_number
                                      )
                                  END
                              
                                  --- return the @pk_contactID
                                  SELECT @pk_partID AS partID
                              
                                  SET NOCOUNT OFF
                              END
                              delete for parts

                              Code:
                              set ANSI_NULLS ON
                              set QUOTED_IDENTIFIER ON
                              go
                              
                              
                              
                              
                              -- =============================================
                              -- Author:		<Author,,Name>
                              -- Create date: <Create Date,,>
                              -- Description:	<Description,,>
                              -- =============================================
                              ALTER PROCEDURE [dbo].[usp_CS_Deleteparts]
                              -- Add the parameters for the stored procedure here
                                  (@pk_partID nvarchar(55),
                              @fk_serialNo nvarchar(100),
                                   @fk_ticketNo nvarchar(100)) 
                              AS
                              
                              DELETE FROM tbl_CS_parts
                              
                              
                              WHERE (pk_partID = @pk_partID and fk_serialNo = @fk_serialNo and  fk_ticketNo=@fk_ticketNo)
                              an then on the userformedit.cf m i did the following to the parts section
                              Code:
                              <!--- counts how many parts are available--->
                               <cfquery name="countparts" datasource="CustomerSupport">
                              SELECT pk_partID from dbo.tbl_CS_parts where fk_serialNo=<cfqueryparam value="#serialnum#"> and fk_ticketNo=<cfqueryparam value="#Form.pk_ticketID#">
                               </cfquery>
                              <!--- the array gets parts that have been inserted and updated to avoid deleteing the ones that need to be inserted or updated--->
                              <cfset partcheck = ArrayNew(1)>
                              
                              
                              the above appears under the serial cfsets an the below is the main parts section
                              
                                <!---Inserts  information into parts table.--->
                                <!---because it is a bit we don't use 'ticks' around defective for parts table--->
                               <cfparam name="form.partscount#machinecount#" default="">
                               <cfloop list="#form['partscount' & machinecount]#" index="ps">
                               <!--- the pkpartID makes each part added unique, this allows us to delete one part instead of all parts associated with a serial--->
                                <cfparam name="Form.pkpartID_#ps#_#machinecount#" default="">
                              
                               <cfparam name="Form.hcpn_#ps#_#machinecount#" default="">
                               <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
                               <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
                               <cfparam name="Form.rma_#ps#_#machinecount#" default="">
                              <!--- the pkpartID makes each part added unique, this allows us to delete one part instead of all parts associated with a serial--->
                              
                               <CFSET pkpartID           = Form["pkpartID_" & "#ps#" & "_#machinecount#"]>
                               <CFSET hcpn            = Form["hcpn_" & "#ps#" & "_#machinecount#"]>
                               <CFSET partsreturn     = Form["partsreturn_" & "#ps#" & "_#machinecount#"]>
                               <CFSET defective       = Form["defective_" & "#ps#" & "_#machinecount#"]>
                               <CFSET rma             = Form["rma_" & "#ps#" & "_#machineCount#"]>
                              <!---the array checks to see what parts are there--->
                              <CFSET ArrayAppend(partcheck, "#Form["pkpartID_" & "#ps#" & "_#machinecount#"]#")>
                              <!---if hcpn is not equal to blank (meaning if it doesn't have a value) it will not insert a part. However if hcpn 
                              has a value it will insert the part into the table.--->
                              <cfif hcpn neq "">
                              <cfquery name="parts" datasource="CustomerSupport">
                                 exec usp_CS_Updateinsertparts 
                                 <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                                 '#Form.pk_ticketID#',
                                  <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
                                  <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
                                  <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">,
                                 <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
                               </cfquery> 
                               <cfelse>
                               </cfif>
                              </cfloop>
                              
                              <!---THIS DELETES FOR THE PARTS TABLE--->
                              <!---setting a list for parts--->
                              <cfset partList = ArrayToList(partcheck, ",")>
                              <!---when inserting/updating for part's table is done it then delete parts not being updated/inserted or was to be deleted on purpose--->
                              <cfloop query="countparts">
                              <cfset pk_partID= #pk_partID#>
                              <!---if the part is not found in the list it begins deleteing--->
                              <cfif not listFind(partList,pk_partID)>
                              <cfquery name="deleteparts" datasource="CustomerSupport">
                              exec usp_CS_Deleteparts
                              <cfqueryparam value="#pkpartID#" CFSQLType = "CF_SQL_VARCHAR">,
                              <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                              '#Form.pk_ticketID#'
                              
                              </cfquery>
                              </cfif>
                              </cfloop>




                              Thank you,
                              Rach

                              Comment

                              • acoder
                                Recognized Expert MVP
                                • Nov 2006
                                • 16032

                                In your update/insert stored procedure, you have hcpn missing, and in your Coldfusion code, you've missed out the part ID, so the wrong data is being passed for the fields.

                                Comment

                                Working...