NY Giants Football Team Category Management
Adding Category 923  Admin > Category Add > Product RelationshipsLog Off
SubCatID New categories are assigned to Main.
Subordinate TO Category
Category Type (CatID = 923)
Select Category if has subordinate categories
Select Product if this is the lowest level category
Category Name
Image name
                                                         
Before Removing a Category is it suggested that you double check to make certain the products assigned to this Category are reassigned.
Turn ON/OFF Source Display (One Level deep include files are also shown)
<!-- #include file="../DatabaseInclude.asp" -->
This include file is NOT output to debug file.<%
CIfunction = Request.QueryString("Function")
CatID = Request.QueryString("CatID")

if CIfunction = "ADD" then

  'SQL Fails
    sql="SELECT max(categoryID) from categories"
    set rsCategoriesSQL = dbc.Execute(sql)
    CustomID= rsCategoriesSQL(0)
    Session("categoryID")=CustomID
    
    Set rsCategories=Server.CreateObject("ADODB.Recordset")
    
    SQLstr = "INSERT INTO [categories] ([categoryID],[catdescription],[subordinateName]) VALUES (" & CustomID+1 &",'New_Category_Description','Main')"
      Set rs = dbc.Execute(SQLstr)
  
    sql="SELECT max(categoryID) as maxCount from categories"
    set rsCategories= dbc.Execute(sql)
  
    CatID = rsCategories("maxCount")
    rsCategories.close
    set rsCategories = nothing
  
  'SQL Fails  
    sql="SELECT max(categoryID) from categories"
    set rsCategoriesSQL =dbc.Execute(sql)
    CatID=rsCategoriesSQL(0)
    Session("categoryID")=CatID
    rsCategoriesSQL.close  

end IF
%>

<table class="TableSkins">
  <tr>
    <td class="TDHeader" colspan="3">
      <%=Session("CompanyName")%> Category Management
    </td>
  </tr>
  
  <tr>
    <td class="TDHeader" colspan="3">
      <%if CIfunction = "ADD" then%>
        Adding Category
      <%else%>
        Editing Category
      <% end if %>
      <%= CatID%>  <a href="Index.asp">Admin</a>
      
      <%if CIfunction = "ADD" then%>
        > Category Add
      <%else%>
        > <a href="CategoryList.asp">Select Category to EDIT</a>
      <%end if %> >
      <a href="ProductRelationships.asp?View=Main&Type=Category">Product Relationships</a>
      >  <a href=".SessionClose.asp">Log Off</a>
    </td>
  </tr>

      <%If CatID = "" Then
        RESPONSE.REDIRECT "../error.asp?msg=" & Server.URLEncode ("Product Catalog ID is blank.")
      End If
          
      Set rsCategories = Server.CreateObject ("adodb.Recordset")
      rsCategories.Open "categories", dbc, adOpenForwardOnly, adLockReadOnly, adCmdTable
      rsCategories.Filter = "categoryID = " & Clng(CatID)
      ' Session("categoryID")= rsCategories("categoryID")
      Session("categoryID")=Clng(CatID)%>

      
    <%if rsCategories("subordinateName") = "Don't Change Top Level" or ucase(rsCategories("catdescription")) = ucase("Main") then%>
      The Main category entry  can NOT be modified! <br>
      The name has to = Main be subordinate to "Don't Change Top Level", <br>
      this is where the online catalog starts.
    <%else%>

    <form method="POST" action="CategoryWrite.asp">
    
      <input type="hidden" value="<%=CatID%>" name="CatID">

      <p>
      <%if rsCategories("subordinateName") = "Main" and left(ucase(rsCategories("catdescription")),4) = Ucase("new_") then%>

        </p>

        <tr>
          <td class="TDSkins">
            SubCatID
          </td>
          <td>
            New categories are assigned to Main.
          </td>
        </tr>
      <%end if%>
      
      <tr>
      
        <td class="TDSkins">
          Subordinate TO Category
        </td>

        <td class="TDSkins">

          <select class="SelectSkins" size="1" input type="number" name="subordinateName" tabindex="2" style="width: 359; height: 22">
          <%
          'create recordset to show categories from database
          intCategory = rsCategories("subordinateName")
          rsCategories.Close
          Set rsCategories = Server.CreateObject ("adodb.Recordset")
          
          'SQLstr = "SELECT * FROM categories ORDER BY catdescription;"
          'New Categories can not be subordinate to a Product Category
          SQLstr = SQLstr & "SELECT categories.categoryID, categories.categoryType, categories.catdescription, "
          SQLstr = SQLstr & "categories.catimageurl, categories.SubordinateTo, categories.SubordinateName "
          SQLstr = SQLstr & "FROM categories "
          SQLstr = SQLstr & "WHERE (((categories.categoryType)<>'Product')) "
          SQLstr = SQLstr & "ORDER BY categories.catdescription;"


          SQLstr = "SELECT * FROM categories WHERE (((categories.categoryType)<>'Product'));"
          
          rsCategories.Open SQLstr, dbc
          
          While Not rsCategories.EOF
            if trim(ucase(DuplicateCatDesc)) <> trim(ucase(rsCategories("catdescription"))) then
              DuplicateCatDesc = trim(ucase(rsCategories("catdescription")))%>

            
              <option class="OptionSkins" value="<%= rsCategories("catdescription") %>"
              <%if intcategory = rscategories("catdescription") then%> selected>
                <%=rsCategories("catdescription") %> <%else%>> <%=rsCategories("catdescription") %>
              </option>
              <%end if
            end if
            rsCategories.MoveNext
          Wend%>

          
        <option class="OptionSkins" value="Temporary To Be Defined Later Category">Temporary To Be Defined Later Category
        </option>
        <%
          rsCategories.Close
          Set rsCategories = Server.CreateObject ("adodb.Recordset")
          rsCategories.Open "categories", dbc, adOpenForwardOnly, adLockReadOnly, adCmdTable
          rsCategories.Filter = "categoryID = " & Clng(CatID)
          %>
</select>
        </td>
      </tr>

      <tr>
        <td class="TDSkins">
          Category Type (CatID = <%=CatID%>)
        </td>
  
        <td class="TDSkins">
          <select class="SelectSkins" size="2" name="categoryType">
          <%if not ucase(CIfunction) = ucase("add") then%>
            <option class="OptionSkins" value="<%=rsCategories("categoryType")%>" selected> <%= ucase(rsCategories("categoryType")) %>
            </option>
            
              <%if ucase(rsCategories("categoryType")) = ucase("product") then %>
                <option class="OptionSkins" value="category"> CATEGORY
                </option>
              <%else%>
                <option class="OptionSkins" value="product"> PRODUCT
                </option>
              <%end if%>
        
          <%else%>
            <option class="OptionSkins" value="category" selected> CATEGORY
            </option>
            <option class="OptionSkins" value="product"> PRODUCT
            </option>
          <%end if%></select> <br>
            Select Category if has subordinate categories<br>
            Select Product if this is the lowest level category
        </td>
      </tr>
      
      <tr>
        <td class="TDSkins">Category Name </td>
        <td class="TDSkins">
        <input class="InputSkins" type="text" value="<%= rsCategories("catdescription") %>" name="catdescription" size="50"></td>
        <input type="hidden" value="<%= rsCategories("catdescription") %>" name="Originalcatdescription">
        </td>
      </tr>
      
      <tr>
        <td class="TDSkins">Image name </td>
        <td class="TDSkins">
        <input class="InputSkins" type="text" value="<%= rsCategories("catimageurl") %>" name="catimageurl" size="50"></td>
      </tr>
      
      <tr>
        <td class="TDSkins"> </td>
        <td class="TDSkins">
        <input class="InputSkins" type="submit" value="Exit" name="submit_category_changes">                                                       
        <input class="InputSkins" type="submit" value="Apply" name="submit_category_changes"></td>
      </tr>
      
      <%if rsCategories("catimageurl") <> "" then %>
        <tr>
          <td class="TDSkins">
          <p align="center">
          <img src="../Cart/db/<%= rsCategories("catimageurl") %>" style="border: 4 inset #FFDEAD; margin: 0">
          </p>
          </td>
        </tr>
      <%end if%>
      
      <tr>
        <td class="TDSkins" colspan="2">
          Before Removing a Category is it suggested
          that you double check to make certain the products assigned to this
          Category are reassigned.
          <input class="InputSkins" type="submit" value="REMOVE" name="submit_category_changes" style="color: #FF0000">
        </td>
      </tr>
      
    </table>
</form>
<%'here is the end of main
end if%>
<%
rsCategories.close
  set rsCategories= nothing
dbc.close
  set dbc= nothing
%>

</body>
</html>
<!-- #include file="../ReadFile.asp" -->
This include file is NOT output to debug file.