gsc123
Programmer
- Jan 24, 2008
- 197
I have a bit of a problem, I seem to be re-inventing the wheel around my site the problem lies with two talbe
products and bidhistory
products as a price(which is current high bid and 0 if no bids) and startprice, the starting price of the item
Bidhistory is empty if there are no bids so I have to result in using this loop to list items but it seems everywhere I need to view a product I have the same problem
do while not rsTempProducts.eof and count < rsTempProducts.pageSize
pPriceMin = 0
flagproxy = 0
pidProduct = rsTempProducts("idproduct")
pDescription = rsTempProducts("description")
pPrice = rsTempProducts("price")
pStartPrice = rsTempProducts("startPrice")
'sql = "SELECT Min(bidAmount) AS price FROM BidHistory WHERE (((BidHistory.bidAmount) In (SELECT Min(BidAmount) FROM BidHistory WHERE BidAmount<10009999 and idproduct = "&pidProduct&")))"
'if noone is logged in show lowest possible bid
if Len(trim(Session("idCustomer"))) > 0 then
sql="SELECT TOP 2 bidhistory.bidAmount AS price FROM bidhistory WHERE (((bidhistory.idProduct)="&pidProduct&") AND ((bidhistory.idCustomerBid)<>"&session("idcustomer")&")) ORDER BY bidhistory.bidAmount DESC "
else
sql="SELECT TOP 2 bidhistory.bidAmount AS price FROM bidhistory WHERE (((bidhistory.idProduct)="&pidProduct&")) ORDER BY bidhistory.bidAmount DESC "
end if
set rsMin = conntemp.execute(sql)
'Response.Write sql &"<br>"
if not rsMin.eof then
' if there is only one bid grab the first one
pPriceMin1 = rsMin("price")
rsMin.MoveNext
pPriceMin2 = rsMin("price")
if CInt(pPriceMin2) <= 0 then
sql = "SELECT TOP 1 bidhistory.bidAmount AS price FROM bidhistory WHERE (((bidhistory.idProduct)="&pidProduct&") AND ((bidhistory.idCustomerBid)="&session("idcustomer")&")) ORDER BY bidhistory.bidAmount DESC"
set rs = conntemp.Execute(sql)
pPriceMax = rs("price")
'Response.Write sql &"<br>"
if CInt(pPriceMin1) >= CInt(pPriceMax) then
pPriceMin = pPriceMax
flagproxy = 1
else
flagproxy = 1
pPriceMin = pPriceMin1
end if
else
flagproxy = 1
pPriceMin = pPriceMin2
end if
end if
'Response.Write "min price ="&pPriceMin&" price ="&pPrice&" start price = "&pStartPrice&" my max bid in bid history is "&pPriceMax
if CInt(pPriceMin) = 0 then
'Response.Write "failed 1"
pPrice = pStartPrice
else
if CInt(pPrice) > 0 or CInt(pPriceMin) > 0 then
'Response.Write "numeric value yes"
'Response.Write "failed 3"
if CInt(pPriceMin) > CInt(pPrice) then
'Response.Write "failed 4"
pPrice = pPriceMin
else
'Response.Write "failed 5"
if flagproxy = 1 then
pPrice = pPriceMin
end if
end if
else
'Response.Write "failed 6"
'Response.Write "numeric value no"
pPrice = pStartPrice
end if
end if
pImageURL = rsTempProducts("imageURL")
pEndDate = rsTempProducts("endDate")
pSupplierName = rsTempProducts("supplierName")
pIdSupplier = rsTempProducts("idsupplier")
'sql = "SELECT Max(bidAmount) AS price FROM BidHistory WHERE (((BidHistory.bidAmount) In (SELECT Max(BidAmount) FROM BidHistory WHERE BidAmount<10009999 and idproduct = "&pidProduct&" and idcustomerbid="&Session("idCustomer")&")))"
'set rsMax = conntemp.execute(sql)
'pMaxBid = rsMax("price")
%><!--#include file="itemdetailsm.asp"--><%
count = count + 1
rsTempProducts.MoveNext
loop
products and bidhistory
products as a price(which is current high bid and 0 if no bids) and startprice, the starting price of the item
Bidhistory is empty if there are no bids so I have to result in using this loop to list items but it seems everywhere I need to view a product I have the same problem
do while not rsTempProducts.eof and count < rsTempProducts.pageSize
pPriceMin = 0
flagproxy = 0
pidProduct = rsTempProducts("idproduct")
pDescription = rsTempProducts("description")
pPrice = rsTempProducts("price")
pStartPrice = rsTempProducts("startPrice")
'sql = "SELECT Min(bidAmount) AS price FROM BidHistory WHERE (((BidHistory.bidAmount) In (SELECT Min(BidAmount) FROM BidHistory WHERE BidAmount<10009999 and idproduct = "&pidProduct&")))"
'if noone is logged in show lowest possible bid
if Len(trim(Session("idCustomer"))) > 0 then
sql="SELECT TOP 2 bidhistory.bidAmount AS price FROM bidhistory WHERE (((bidhistory.idProduct)="&pidProduct&") AND ((bidhistory.idCustomerBid)<>"&session("idcustomer")&")) ORDER BY bidhistory.bidAmount DESC "
else
sql="SELECT TOP 2 bidhistory.bidAmount AS price FROM bidhistory WHERE (((bidhistory.idProduct)="&pidProduct&")) ORDER BY bidhistory.bidAmount DESC "
end if
set rsMin = conntemp.execute(sql)
'Response.Write sql &"<br>"
if not rsMin.eof then
' if there is only one bid grab the first one
pPriceMin1 = rsMin("price")
rsMin.MoveNext
pPriceMin2 = rsMin("price")
if CInt(pPriceMin2) <= 0 then
sql = "SELECT TOP 1 bidhistory.bidAmount AS price FROM bidhistory WHERE (((bidhistory.idProduct)="&pidProduct&") AND ((bidhistory.idCustomerBid)="&session("idcustomer")&")) ORDER BY bidhistory.bidAmount DESC"
set rs = conntemp.Execute(sql)
pPriceMax = rs("price")
'Response.Write sql &"<br>"
if CInt(pPriceMin1) >= CInt(pPriceMax) then
pPriceMin = pPriceMax
flagproxy = 1
else
flagproxy = 1
pPriceMin = pPriceMin1
end if
else
flagproxy = 1
pPriceMin = pPriceMin2
end if
end if
'Response.Write "min price ="&pPriceMin&" price ="&pPrice&" start price = "&pStartPrice&" my max bid in bid history is "&pPriceMax
if CInt(pPriceMin) = 0 then
'Response.Write "failed 1"
pPrice = pStartPrice
else
if CInt(pPrice) > 0 or CInt(pPriceMin) > 0 then
'Response.Write "numeric value yes"
'Response.Write "failed 3"
if CInt(pPriceMin) > CInt(pPrice) then
'Response.Write "failed 4"
pPrice = pPriceMin
else
'Response.Write "failed 5"
if flagproxy = 1 then
pPrice = pPriceMin
end if
end if
else
'Response.Write "failed 6"
'Response.Write "numeric value no"
pPrice = pStartPrice
end if
end if
pImageURL = rsTempProducts("imageURL")
pEndDate = rsTempProducts("endDate")
pSupplierName = rsTempProducts("supplierName")
pIdSupplier = rsTempProducts("idsupplier")
'sql = "SELECT Max(bidAmount) AS price FROM BidHistory WHERE (((BidHistory.bidAmount) In (SELECT Max(BidAmount) FROM BidHistory WHERE BidAmount<10009999 and idproduct = "&pidProduct&" and idcustomerbid="&Session("idCustomer")&")))"
'set rsMax = conntemp.execute(sql)
'pMaxBid = rsMax("price")
%><!--#include file="itemdetailsm.asp"--><%
count = count + 1
rsTempProducts.MoveNext
loop