%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
option explicit
%>
<%
Dim prdtID, prdtName
Dim query
Dim cat1RS, cat2RS, cat3RS, pRS, ppRS, maxPID
Dim cat1RSCnt, cat2RSCnt, cat3RSCnt, pRSCnt, ppRSCnt
Dim cur_cat1, cur_cat2, cur_cat3
Dim cat_x, cat_y, cat_z, prdt_cnt
Dim default_style
cat_x = 0
cat_y = 0
cat_z = 0
default_style = "none"
prdtName = ""
'ConnectDB_TS_MDB()
ConnectDB_TS_MSSQL()
Set maxPID = CreateObject("ADODB.RecordSet")
query = "select max(p_id) max_pid from " + db_product + " where p_cat1 <> ''"
maxPID.Open query, objDBConn_TS_MDB
Set cat1RSCnt = CreateObject("ADODB.RecordSet")
query = "select count(distinct p_cat1) count from " + db_product + " where p_cat1 <> ''"
cat1RSCnt.Open query, objDBConn_TS_MDB
Set cat1RS = CreateObject("ADODB.RecordSet")
'query = "select distinct p_cat1 from " + db_product + " with (nolock) order by p_cat1"
'query = "select distinct p_cat1 from " + db_product + " where p_cat1 <> '' order by p_cat1"
query = "select a.p_id, a.p_cat1 from " + db_product + " a right outer join (select p_cat1, min(p_cat2) p_cat2 from " + db_product + " group by p_cat1) b on a.p_cat1 = b.p_cat1 and a.p_cat2 = b.p_cat2 order by a.p_cat1"
cat1RS.Open query, objDBConn_TS_MDB
'for each x in cat1RS.fields
' response.write(x.name)
' response.write(" = ")
' response.write(x.value)
'next
'If NOT cat1RS.EOF Then
' WHILE NOT cat1RS.EOF
' response.write("check p_cat1="&cat1RS("p_cat1")&" ")
' cat1RS.MoveNext
' WEnd
'End If
dim iwidth, iHeight
sub ImgDimension(img)
dim myImg, fs
Set fs= CreateObject("Scripting.FileSystemObject")
'Response.write("Check file" & img)
if not fs.fileExists(Trim(img)) then exit sub
'Response.write("file found" & img)
set myImg = loadpicture(Trim(img))
iwidth = myImg.width
iHeight = myImg.height
set myImg = nothing
set fs = nothing
end sub
%>
<%
If cat1RSCnt.Fields("count") > 0 Then
cat_x = 0
WHILE NOT cat1RS.EOF
cur_cat1 = cat1RS("p_cat1")
cat_x = cat_x + 1
Set cat2RSCnt = CreateObject("ADODB.RecordSet")
query = "select count(distinct p_cat2) count from " + db_product + " where p_cat1 = N'" & cat1RS("p_cat1") & "' and p_cat2 <> ''"
cat2RSCnt.Open query, objDBConn_TS_MDB
Set cat2RS = CreateObject("ADODB.RecordSet")
'query = "select distinct p_cat2 from " + db_product + " with (nolock) where p_cat1 = N'" & cat1RS("p_cat1") & "' and p_cat2 <> '' order by p_cat2"
'query = "select top 1 p_id, p_cat2 from " + db_product + " where p_cat1 = N'" & cat1RS("p_cat1") & "' and p_cat2 <> '' order by p_cat2, p_cat3"
query = "select a.p_id, a.p_cat2 from " + db_product + " a right outer join (select p_cat1, p_cat2, min(p_cat3) p_cat3 from " + db_product + " where p_cat1 = N'" & cat1RS("p_cat1") & "' and p_cat2 <> '' group by p_cat1, p_cat2) b on a.p_cat1 = b.p_cat1 and a.p_cat2 = b.p_cat2 and a.p_cat3 = b.p_cat3 order by a.p_cat2"
cat2RS.Open query, objDBConn_TS_MDB
%>
<%
If cat2RSCnt.Fields("count") > 0 Then
%>
<%
Else
%>
<%
End If
%>
');" style="cursor:hand"><%=cur_cat1%>
<%
If cat2RSCnt.Fields("count") > 0 Then
cat_y = 0
WHILE NOT cat2RS.EOF
cur_cat2 = cat2RS("p_cat2")
cat_y = cat_y + 1
%>
');" style="cursor:hand"><%=cur_cat2%>
<%
Set cat3RSCnt = CreateObject("ADODB.RecordSet")
query = "select count(distinct p_cat3) count from " + db_product + " where p_cat1 = N'" & cat1RS("p_cat1") & "' and p_cat2 = N'" & cat2RS("p_cat2") & "' and p_cat3 <> ''"
cat3RSCnt.Open query, objDBConn_TS_MDB
Set cat3RS = CreateObject("ADODB.RecordSet")
'query = "select distinct p_cat3 from " + db_product + " with (nolock) where p_cat1 = N'" & cat1RS("p_cat1") & "' and p_cat2 = N'" & cat2RS("p_cat2") & "' and p_cat3 <> '' order by p_cat3"
'query = "select p_id, p_cat3 from " + db_product + " where p_cat1 = N'" & cat1RS("p_cat1") & "' and p_cat2 = N'" & cat2RS("p_cat2") & "' and p_cat3 <> '' order by p_cat3"
query = "select a.p_id, a.p_cat3 from " + db_product + " a right outer join (select p_cat1, p_cat2, p_cat3 from " + db_product + " where p_cat1 = N'" & cat1RS("p_cat1") & "' and p_cat2 = N'" & cat2RS("p_cat2") & "' and p_cat3 <> '') b on a.p_cat1 = b.p_cat1 and a.p_cat2 = b.p_cat2 and a.p_cat3 = b.p_cat3 order by a.p_cat3"
cat3RS.Open query, objDBConn_TS_MDB
'response.write("cat 1: " & cat1RS("p_cat1") & " cat 2: " & cat2RS("p_cat2") & " cat 3: " & cat3RS("p_cat3") & " ")
If cat3RSCnt("count") > 0 Then
cat_z = 0
WHILE NOT cat3RS.EOF
cur_cat3 = cat3RS("p_cat3")
cat_z = cat_z + 1
%>
');" style="cursor:hand"><%=cur_cat3%>
<%
cat3RS.MoveNext
WEnd
End If
Set cat3RS = Nothing
cat2RS.MoveNext
WEnd
End If
Set cat2RS = Nothing
cat1RS.MoveNext
WEnd
End If
Set cat1RS = Nothing
%>
<%
Set pRSCnt = CreateObject("ADODB.RecordSet")
query = "select Count(p_id) count from " + db_product + " with (nolock)"
pRSCnt.Open query, objDBConn_TS_MDB
Set pRS = CreateObject("ADODB.RecordSet")
query = "select p_id, case when p_cat3 is not null and p_cat3 <> '' then p_cat3 when p_cat2 is not null and p_cat2 <> '' then p_cat2 else p_cat1 end p_name from " + db_product
pRS.Open query, objDBConn_TS_MDB
prdt_cnt = 0
If pRSCnt("Count") > 0 Then
WHILE NOT pRS.EOF
prdtName = pRS("p_name")
prdtID = pRS("p_id")
prdt_cnt = prdt_cnt + 1
If prdt_cnt = 1 Then
%>
<%
Else
%>
<%
End If
%>
<%=prdtName%>
<%
If prdtName <> "Garment Accessories" Then
%>
Click the thumbnail to view larger image.
<%
Else
%>
http://www.tattshing.com/Shing/buckle_ball.htm
<%
End If
%>
<%
Set ppRS = CreateObject("ADODB.RecordSet")
query = "select * from " + db_product_photo + " with (nolock) where pp_pid = " & prdtID & " order by pp_seq"
ppRS.Open query, objDBConn_TS_MDB
WHILE NOT ppRS.EOF
%>
<%
ImgDimension(Server.MapPath("Uploads/") + "\" + ppRS("pp_photo"))
'Response.write("width"&CDbl(iwidth))
'Response.write("height"&CDbl(iHeight))
If CDbl(iwidth)/CDbl(110) > CDbl(iHeight)/CDbl(83) Then
%>
" width="110" onclick="popitup('Uploads/<%=ppRS("pp_photo")%>');" style="cursor:hand">
<%
Else
%>
" height="83" onclick="popitup('Uploads/<%=ppRS("pp_photo")%>');" style="cursor:hand">
<%
End If
%>
<%
ppRS.MoveNext
If NOT ppRS.EOF Then
%>
<%
ImgDimension(Server.MapPath("Uploads/") + "\" + ppRS("pp_photo"))
'Response.write("width"&CDbl(iwidth))
'Response.write("height"&CDbl(iHeight))
If CDbl(iwidth)/CDbl(110) > CDbl(iHeight)/CDbl(83) Then
%>
" width="110" onclick="popitup('Uploads/<%=ppRS("pp_photo")%>');" style="cursor:hand">
<%
Else
%>
" height="83" onclick="popitup('Uploads/<%=ppRS("pp_photo")%>');" style="cursor:hand">
<%
End If
%>
<%
ppRS.MoveNext
Else
%>
<%
End If
WEnd
Set ppRS = Nothing
pRS.MoveNext
WEnd
Set pRS = Nothing
%>