当前位置: 首页 > 图文教程 > 网络编程 > ASP > 制作我们自己的Ebay(拍卖系统)(5)

ASP
二文件上传,才30行代码
用ASP制作在线测试
三级下拉框连动的数据库版
用户注册及跟踪代码(一)
用户注册及跟踪代码(二)
用户注册及跟踪代码(三)
ASP.Net写的浏览器间谍
ASP实现播放Flash的例子
用DataList控件开发一个简单的留言本程序
aspemail组件的应用
编写数据库脚本
用ASP建立邮件列表
用ASP技术编制隐藏用户密码程序
用ASP统计用户在站点的停留时间
HTTP方式上载文件的ASP程序实例
使用VB编写纯ASP程序
用ASP统计用户在站点的停留时间(1)
用ASP统计用户在站点的停留时间(2)
用ASP实现论坛的UBB功能(一)
用ASP实现论坛的UBB功能(二)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 34 ::
收藏到网摘: n/a

  This is the complex part - you must make sure everyone's bids are correct, update those that have proxy bids, reallocate lots to winners, notify buyers who have been outbid, and perform some upkeep.

First let's 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.