欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-12-25 15:08:03
this is the complex part - you must make sure everyones bids are correct, update those tha...
this is the complex part - you must make sure everyones bids are correct, update those that have proxy bids, reallocate lots to winners, notify buyers who have been outbid, and perform some upkeep.

first lets look at the code to add a bid.



function dobid(itemid, bidderid, price, optional maxprice, optional maxitems)


set variables and create objects
strconnectionstring = "dsn=myauction;uid=username;pwd=password;database=myauctiondb"
set rst = server.createobject("adodb.recordset")


check to see if a bid already exists for this buyer and auction
strsql = "select bid from tblauctionbids where iid = " & itemid & " and " & _
"uid = " & bidderid
rst.open strsql, strconnectionstring


if rst.eof then a bid does not exist
rst.close
insert info into table
strsql = "insert into tblauctionbids (iid, uid, winprice, maxbid, " & _
"biditems, winitems, time values (" & itemid & ", " & bidderid & _
", " & price & ", " & maxprice & ", " & maxitems & _
", 0, " & now() & ")"
default winitems to 0 for now


else a bid does exist
rst.close
update info in table
strsql = "update tblauctionbids set winprice = " & price & _
" where iid = " & itemid & " and uid = " & bidderid
end if


rst.open strsql, strconnectionstring


fix bidding information
call resolvebids(itemid)


end function



note: this code above is developed for visual basic, and the keyword "optional" in the function opener is not supported in vbscript. in an asp then, simply leave out the keyword "optional" here, and when you call the function, pass in an empty string, i.e.:

call dobid(itemid, bidderid, price, "", "")

this function basically takes some info, and either inserts it or updates it in the bids table - fairly simple stuff. the function resolvebids however is where all the good stuff happens.



上一篇:

下一篇: