<%@ LANGUAGE = "VBScript" %> <% verify catcode=valid_sql(request.querystring("catcode")) stage=request.querystring("stage") editcomplete=false if not(catcode=null and catcode="" and not(isnumeric(catcode))) then set rscat=db.execute("select * from categories where catcode=" & catcode) if rscat.eof then response.redirect("error.asp?Unable to locate category!") end if catname=rscat("catname") catdes=rscat("catdes") catimage=rscat("catimage") 'get names and codes of all products in that category set rscatlist=db.execute("select name,productid from products where catcode=" & catcode & " order by name") end if if stage="delete" and catcode<>"" and isnumeric(catcode) then db.execute("delete * from categories where catcode=" & catcode) editMSG="Category deleted successfully" editcomplete=true elseif stage="delete" and pruductid="" then editMSG="Unable to delete category.
No category specified" editcomplete=true end if if stage="save" then catcode=request.querystring("catcode") catname=request.form("catname") catdes=request.form("catdes") catimage=request.form("catimage") 'Error check the information passed ' If complete then either add a new record or update depending on value of pruductid if catname="" or catname=null or len(name)>50 then msg=msg & "
You need to enter a valid category name." end if if len(catimage)>255 then msg=msg & "
The image tag is too long." end if if msg="" then 'Check wether this is an update or insert if catcode=null or catcode="" then 'insert sql="insert into categories (catname" if valid_sql(catdes)<>"" then sql=sql & ",catdes" SQLdes=",'" & valid_sql(catdes) & "'" end if if valid_sql(catimage)<>"" then sql=sql & ",catimage" SQLimage=",'" & valid_sql(catimage) & "'" end if sql=sql & ") values ('" & valid_sql(catname) & "'" & SQLdes& SQLimage & ")" db.execute(sql) else if valid_sql(catimage)<>"" then SQLimage=", catimage='" & valid_sql(catimage) & "'" end if if valid_sql(catdes)<>"" then SQLnotes=", catdes='" & valid_sql(catdes) & "'" end if sql="update categories set catname='" & valid_sql(catname) & "'" & SQLnotes & SQLimage & " where catcode=" & valid_sql(catcode) db.execute(sql) end if editMSG="Category details saved." editcomplete=true end if end if 'stage %> <%= storename %> Administration <% header adminmenu "prod" %>
<% if not(catcode=null and catcode="" and not(isnumeric(catcode))) then %>
<%= rscat("catname") %>
<% 'Display list of other products in category if not rscatlist.eof then rscatlist.movefirst while not rscatlist.eof %> "><%=rscatlist("name")%>
<% rscatlist.movenext wend end if else %>

<% end if %>
<% if editcomplete then %> <%= editmsg %> <% else %> <%= msg %>

<% if catcode="" or catcode=null then %> add new category
· To add a new category just enter its details below and click "Save" <% else %> edit category details
· To change this category's details, just edit the form and click "Save".
· To delete this category just click "Delete".
· To add a new category select "Add Category" on the menu above.
<% end if %> <%= msg %>

category name:  
" maxlength=100>
description:  
image tag:  
" maxlength=100>

<% if catcode<>"" then %> Delete <% end if %> <% end if %>
<% footer %> <% db.close set db=nothing %>