您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

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

来源:未知 责任编辑:智问网络 发表时间:2013-09-03 12:18 点击:
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.



    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • WAP常见问题问答大全(四)
    • ASP开发必备:WEB打印代码大全
    • ASP调用系统ping命令
    • asp缓存技术
    • ASP教程:第三篇 ASP基础
    • 用ASP+XML打造留言本(4)
    • 关于ASP Recordset 分页出现负数解决方法及建议
    • 用asp怎样编写文档搜索页面(5)
    • ASP处理多关键词查询实例代码
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1