制作我们自己的Ebay(拍卖系统)(6)

2016-01-29 17:20 3 1 收藏

制作我们自己的Ebay(拍卖系统)(6),制作我们自己的Ebay(拍卖系统)(6)

【 tulaoshi.com - ASP 】

  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).


 

来源:http://www.tulaoshi.com/n/20160129/1501036.html

延伸阅读
标签: 脱毛
问答 图钉提问: 夏天最好的脱毛方法是什么??哪位达人帮忙解决一下 图老师解答: 病情分析:       您好,最好是采用激光脱毛,激光脱毛方式具有一定的高科技含量和强大的物理学基础,主要原理是应用了一个物理学的概念,即某一颜色的物质,一定对某一特殊波长的光吸收率最强。     &nbs...
标签: 美容 美容方法
你是否有过这些苦恼,是否遭遇过这些尴尬,是否无奈?是否无助? 别急,图老师图老师小编虽然不能带你拯救地球,但可以教你如何去拯救自己的肌肤。 在一次匆忙的上眉毛油之后,你突然发现眼睫毛卷在一起了 解决:在化妆清洁器上滴一滴挥发清洁剂,在快干的时候,将睫毛上的粘质擦拭掉(在下睫毛下面放置折叠的纸接掉下的残渣)...
婴儿期心理发育 1、2个月婴儿心理发育     这个时期的孩子与外界接触很少,是以自我为中心地生活着,只关心自己的满足。当他们的生活需求得到满足时,就非常平静,而当饥饿、消化不良或疲劳的刺激时,就会不停地啼哭。孩子的注意力有了一定的发展,发亮的或彩色鲜艳的物体出现在视野内时,他会发出愉...
标签: windows系统
Win8怎样自己制作系统主题?   Windows 8主题是一组由图片和声音定制而成的桌面元素集合,可以给人们以视听享受。我们可以通过自定义主题的方式来实现你的要求。 右击桌面空白处,选择快捷菜单中的个(图老师整理)性化命令。 在弹出的个性化窗口中,任意选择一组主题。选择之后,下面的桌面背景相应就变成了该主题所使用...
标签: 暗黑3
《暗黑3》拍卖不能拍卖物品的解决方案 本人今天下午第一次遇到这个情况,开始以为是AH繁忙。后来发现可能是物品本身的问题,因为不是所有东西都不可以拍卖。于是baidu,google 了很久,在官网的论坛上,也有很多人遇到。但是没有找到好的方案。 已知可行的有2个。 1.如果是有孔的,请卸掉宝石就可以,本人没有遇到这种物品,但是有玩家成功。 2....

经验教程

575

收藏

43
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部