-
您的位置:首页 → 网页设计 → ASP实例 → 制作我们自己的Ebay拍卖系统7
制作我们自己的Ebay拍卖系统7
时间:2004/11/7 2:52:00来源:本站整理作者:蓝点我要评论(0)
-
Chris Payne
September 11, 2000
Well, now your auction can run for an indefinite time. People can keep placing bids until you decide to
stop them (good for the seller, but makes bidders kind of unhappy, to say the least). Let's discuss the
mechanisms for stopping an auction.
There are two easy ways to do it. The first, and easiest to perform, though requiring more manual
intervention in the long run, is to simply build in an "Active" bit field into your tblAuctions table.
When you decide to stop the auction, flip the bit, and the auction is over. (You'll also have to add some
code to make sure that the DoBids and ResolveBids functions don't operate on closed auctions.) Then simply
query the database, find out the winner(s), and let them and the seller know. Easy as pie.
The second method is to go by the end date the seller specifies (better business, believe me). To do this,
you can manually stop the auction (via the process above) when the appropriate date comes, or you can
schedule a task to turn an auction off at the appropriate times. There are a few ways to do this, via your
database program and the Windows NT Task Scheduler, so I won't go through each one. You could simply set
the script to run every midnight or so to stop the auction and determine the winners.
If you let the seller specify an exact time for the auction to end, then you're introducing a whole new
set of complications. One way to handle this is to programmatically set a scheduled task as soon as the
seller submits the auction, for the end date of the auction. This requires minimum intervention, but
requires you to know how to do that (for documentation on the Task Scheduler, read this MSDN article).
Another method is to create your own specific version of task scheduler; create a small program that will
run in the background and watch the times on auctions. When an auction end date passes, flip the bit.
Okay, so the auction is over. Now what?
Assuming that you would like minimal manual intervention, and you don't really care who wins (like the
head guys at Ebay care who wins every single auction), then you could create a function to send alerts to
the winner(s) and seller that will kick off when the auction is over. This function could also in turn
kick off some type of payment system, but that is beyond the scope of this article. Let's look at the
function:
Function SelectWinners(AuctionID, itemID)
'Set variables and create objects
dim totItems, intAvailable
totItems = 0
strConnectionString = "DSN=MyAuction;UID=username;PWD=password;Database=MyAuctionDB"
set rst = Server.CreateObject("ADODB.Recordset")
'Find the number of items available
strSQL = "SELECT Available FROM tblAuctionItems WHERE " & _
"IID = " & ItemID
rst.open strSQL, strConnectionString
intAvailable = rst(1)
rst.close
'find the winners
'If two customers bid the same amount, the customer requesting
more items will win. If still tied, the customer placing the
earliest bid will win
strSQL = "SELECT UID, WinPrice, WinItems FROM tblAuctionBids " & _
"WHERE IID = " & itemID & " ORDER BY WinItems DESC, Time"
rst.open strSQL, strConnectionString
if not rst.eof then
do until rst.eof OR totItems >= intAvailable
'Keep a running tally of items distributed
totItems = totItems + rst(2)
If totItems <= intAvailable then 'This buyer won
'Send an email alerting this buyer
call SendWinningEmail(rst(0))
End if
rst.movenext
loop
end if
End Function
This is a pretty simple function. Simply loop through the bids in the correct order (by number of items
won first, and then by date), and alert the buyers that they've won. Once the number of items bid for gets
higher than the number of items available, every one else loses, and you can stop the loop. I won't go
into the SendWinningEmail() function, but all it does is send the user specified by rst(0) an email that
says they've won and for how much and how many. (For an example using email, check out this WDVL article.)
相关阅读
Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
-
热门文章
没有查询到任何记录。
最新文章
迅雷新手完全入门手册
asp下面javascript上传图片限制格式大小方法告诉大家网页弹出窗口应用总结ASP常见错误类型大全asp常见错误分析和解决办法
人气排行
总是弹出visual studio 实时调试器 三种解决SQLSERVER存储过程及调用详解Asp获取真实IP地址ASP中连接Mssql的几种方法一个简单好用的UBB编辑器(含代码)如何用Split将字符串转换为数组并获取数组下ASP防止表单重复提交的办法告诉你免费的简单聊天室源代码
查看所有0条评论>>