国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

制作我們自己的Ebay(拍賣系統)(6)

2019-11-18 22:02:07
字體:
來源:轉載
供稿:網友
Resolving Bids - Page 6

Chris Payne

September 11, 2000



Function ResolveBids(ItemID)


'Set variables and create objects
dim monIncrement, monHighPRice, intAvailable, intTotItems, flgQuit
dim blnResolved


'Assume bids are resolved
blnResolved = True
strConnectionString = "DSN=MyAuction;UID=username;PWD=passWord;Database=MyAuctionDB"
set rst = Server.CreateObject("ADODB.Recordset")


'Get information from items table
strSQL = "SELECT Increment, Available FROM tblAuctionItems WHERE " & _
"IID = " & ItemID
rst.open strSQL, strConnectionString
monIncrement = rst(0)
intAvailable = rst(1)
rst.close


'Find the highest bid and total number items bid for
strSQL = "SELECT max(WinPrice) AS WinPrice, sum(WinItems) as " & _
"WinItems FROM tblAuctionBids WHERE " & _
"ItemID = " & ItemID
rst.open strSQL, strConnectionString
monHighPrice = rst(0)
intTotItems = rst(1)
rst.close


'If a user with a higher max bid exists, then
' update their bid if and only if available items is exceeded
strSQL = "SELECT MaxBid, UID, BidItems, WinPrice FROM " & _
"tblAuctionBids WHERE ItemID = " & ItemID
rst.open strSQL, strConnectionString
if not rst.eof then
do until rst.eof
if (rst(0) > monHighPrice + monIncrement) AND (intTotItems > intAvailable) & _
AND (rst(3) <> monHighPrice) then
monHighPrice = monHighPrice + monIncrement
call DoBids(ItemID, rst(1), monHighPrice)
blnResolved = False
end if
rst.MoveNext
'If we're at the end of the recordset
and the bids are not yet resolved, go back to the beginning
if not blnResolved AND rst.eof then
rst.MoveFirst
blnResolved = True
end if
loop
end if
rst.close

End Function


The main part of the above code is the last do...loop section. The process is as follows:


Enter a user's bid (using the DoBids() function)
Find the highest bid for the item, and total number of items bid for
Loop through database and:
IF the current bidder's maximum bid is higher than the highest winning bid,
AND the total number of items bid for is greater than the number of items available,
AND the current bidder's bid is not the highest bid,
THEN increment the current bidder's bid by the increment value.
If we reach the end of the recordset, and the bids are still not resolved, the start over.
This process will automatically update all bids appropriately, and weed out those whose max bids are not
high enough. The reason we check to make sure the total number of items bid for is greater than the number
of total items available in step 4 is because if all bids are placed and items claimed, and there are
still lots available, then everyone wins and bids do not need to be incremented.

For example, imagine there are 10 lots available, and there are 3 bidders. If bidder A wants 3 lots at $3,
bidder B wants 3 lots at $2, and bidder C wants 3 lots at $1, everyone will win because there is enough
lots to go around, and then some. The do loop above will only have to go through once.

However, suppose bidder C now wants 5 items. Since there are not enough items to go around, someone will
have to lose out. The loop in the code above weeds this person out by checking max bids and updating the
winning bids. If everyone's max bids in this scenario was $20, and the increment was $2, then bidder C and
whichever of bidder A and B placed the first bid would win (remember that bid priority is placed on most
lots bid for, followed by bid time).



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 四会市| 大理市| 宜兰县| 泌阳县| 鹤山市| 江油市| 唐山市| 乡城县| 泽州县| 白玉县| 岗巴县| 玉门市| 新巴尔虎右旗| 扬中市| 长丰县| 威海市| 漯河市| 万州区| 黔江区| 宝清县| 陇南市| 峡江县| 夏邑县| 万全县| 喜德县| 乌兰察布市| 牙克石市| 手机| 奉贤区| 赤壁市| 荣成市| 镇赉县| 西盟| 抚州市| 福清市| 上犹县| 台中县| 涡阳县| 宁明县| 迁安市| 达拉特旗|