Make our own ebay (auction system) (7)

Source: Internet
Author: User
Tags date manual requires
Chris Payne

September 11, 2000

Now your auction can run for a indefinite time. People can keep placing bids until to
Stop them (good for the seller, but makes bidders kind of unhappy, to say the least). Let ' s discuss the
Mechanisms for stopping a auction.

There are two easy ways to do it. The easiest to perform, though requiring more manual
Intervention in the long run, are to simply builds in a "Active" bit field into your tblauctions table.
When you decide to stop the auction, flip the bit, and the auction are 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 was to go by the end date the seller specifies (Better business, believe me). To does this,
Can manually stop the auction (via the process above) when the appropriate date comes, or you can
Schedule a task to turn an auction on the appropriate times. There are a few ways to does 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 have the seller specify a exact time for the "auction to", then you ' re introducing a whole new
Set of complications. One way to handle it 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 the "for documentation on the" Task Scheduler, read this MSDN article).
Another method are to create your own specific version of Task Scheduler; Create a small program that would
Run in the background and watch the "Times" on auctions. When a auction end date passes, flip the bit.

Okay, so the auction are over. Now what?

Assuming that you would like minimal manual intervention, and you don ' t really care who wins
Head guys on Ebay care who wins every single auction), then your could create a function to send alerts to
The winner (s) and seller that would kick off the auction are over. This function could also in turn
Kick off some type of payment system, but which 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 would win. If still tied, the customer placing the
Earliest bid would 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-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 are send the user specified by RST (0) a email that
Says they ' ve won and for how much and how many. (For a example using email, check out this WDVL article.)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.