所属类别:Asp
文章作者:佚名
特别推荐:免费发布信息 承包关键词~~抢爆了!HOT!
Chris PayneSeptember 11, 2000Well, now your auction can run for an indefinite time. People can keep placing bids until you decide tostop them (good for the seller, but makes bidders kind of unhappy, to say the least). Let's discuss themechanisms for stopping an auction.There are two easy ways to do it. The first, and easiest to perform, though requiring more manualintervention 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 somecode to make sure that the DoBids and ResolveBids functions don't operate on closed auctions.) Then simplyquery 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 canschedule a task to turn an auction off at the appropriate times. There are a few ways to do this, via yourdatabase program and the Windows NT Task Scheduler, so I won't go through each one. You could simply setthe 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 newset of complications. One way to handle this is to programmatically set a scheduled task as soon as theseller submits the auction, for the end date of the auction. This requires minimum intervention, butrequires 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 willrun 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 thehead guys at Ebay care who wins every single auction), then you could create a function to send alerts tothe winner(s) and seller that will kick off when the auction is over. This function could also in turnkick off some type of payment system, but that is beyond the scope of this article. Let's look at thefunction:Function SelectWinners(AuctionID, itemID)'Set variables and create objectsdim totItems, intAvailabletotItems = 0strConnectionString = "DSN=MyAuction;UID=username;PWD=password;Database=MyAuctionDB"set rst = Server.CreateObject("ADODB.Recordset")'Find the number of items availablestrSQL = "SELECT Available FROM tblAuctionItems WHERE " & _ "IID = " & ItemIDrst.open strSQL, strConnectionStringintAvailable = rst(1)rst.close'find the winners'If two customers bid the same amount, the customer requestingmore items will win. If still tied, the customer placing theearliest bid will winstrSQL = "SELECT UID, WinPrice, WinItems FROM tblAuctionBids " & _ "WHERE IID = " & itemID & " ORDER BY WinItems DESC, Time"rst.open strSQL, strConnectionStringif 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 loopend ifEnd FunctionThis is a pretty simple function. Simply loop through the bids in the correct order (by number of itemswon first, and then by date), and alert the buyers that they've won. Once the number of items bid for getshigher than the number of items available, every one else loses, and you can stop the loop. I won't gointo the SendWinningEmail() function, but all it does is send the user specified by rst(0) an email thatsays they've won and for how much and how many. (For an example using email, check out this WDVL article.) 关闭本页
相关信息· GNU make的用法详解
· Eclipse开发经典教程:SWT事件
· 用“vb_net 存取数据库中的图片”文章里的方法,为什存储图片大于60K时会出错?
· RegSeeker注册表清理简单易用体验
27503
62515
