ASP网页编程之制造我们本人的Ebay(拍卖体系EN) - Res...
对用户来说可预见费用、节约费用,可以做到花少钱办大事。由于省去了购买软件和硬件等的前期费用,用户可以租用较高级的应用软件。ASP的收费是根据软件的类型、客制化程度、用户数量、服务期限来定的,对客户来说这笔费用是可以预见的。方便于客户应用软件的升级。ResolvingBids-Page6ChrisPayne
September11,2000
FunctionResolveBids(ItemID)
Setvariablesandcreateobjects
dimmonIncrement,monHighPrice,intAvailable,intTotItems,flgQuit
dimblnResolved
Assumebidsareresolved
blnResolved=True
strConnectionString="DSN=MyAuction;UID=username;PWD=password;Database=MyAuctionDB"
setrst=Server.CreateObject("ADODB.Recordset")
Getinformationfromitemstable
strSQL="SELECTIncrement,AvailableFROMtblAuctionItemsWHERE"&_
"IID="&ItemID
rst.openstrSQL,strConnectionString
monIncrement=rst(0)
intAvailable=rst(1)
rst.close
Findthehighestbidandtotalnumberitemsbidfor
strSQL="SELECTmax(WinPrice)ASWinPrice,sum(WinItems)as"&_
"WinItemsFROMtblAuctionBidsWHERE"&_
"ItemID="&ItemID
rst.openstrSQL,strConnectionString
monHighPrice=rst(0)
intTotItems=rst(1)
rst.close
Ifauserwithahighermaxbidexists,then
updatetheirbidifandonlyifavailableitemsisexceeded
strSQL="SELECTMaxBid,UID,BidItems,WinPriceFROM"&_
"tblAuctionBidsWHEREItemID="&ItemID
rst.openstrSQL,strConnectionString
ifnotrst.eofthen
dountilrst.eof
if(rst(0)>monHighPrice+monIncrement)AND(intTotItems>intAvailable)&_
AND(rst(3)monHighPrice)then
monHighPrice=monHighPrice+monIncrement
callDoBids(ItemID,rst(1),monHighPrice)
blnResolved=False
endif
rst.MoveNext
Ifwereattheendoftherecordset
andthebidsarenotyetresolved,gobacktothebeginning
ifnotblnResolvedANDrst.eofthen
rst.MoveFirst
blnResolved=True
endif
loop
endif
rst.close
EndFunction
Themainpartoftheabovecodeisthelastdo...loopsection.Theprocessisasfollows:
Enterausersbid(usingtheDoBids()function)
Findthehighestbidfortheitem,andtotalnumberofitemsbidfor
Loopthroughdatabaseand:
IFthecurrentbiddersmaximumbidishigherthanthehighestwinningbid,
ANDthetotalnumberofitemsbidforisgreaterthanthenumberofitemsavailable,
ANDthecurrentbiddersbidisnotthehighestbid,
THENincrementthecurrentbiddersbidbytheincrementvalue.
Ifwereachtheendoftherecordset,andthebidsarestillnotresolved,thestartover.
Thisprocesswillautomaticallyupdateallbidsappropriately,andweedoutthosewhosemaxbidsarenot
highenough.Thereasonwechecktomakesurethetotalnumberofitemsbidforisgreaterthanthenumber
oftotalitemsavailableinstep4isbecauseifallbidsareplacedanditemsclaimed,andthereare
stilllotsavailable,theneveryonewinsandbidsdonotneedtobeincremented.
Forexample,imaginethereare10lotsavailable,andthereare3bidders.IfbidderAwants3lotsat$3,
bidderBwants3lotsat$2,andbidderCwants3lotsat$1,everyonewillwinbecausethereisenough
lotstogoaround,andthensome.Thedoloopabovewillonlyhavetogothroughonce.
However,supposebidderCnowwants5items.Sincetherearenotenoughitemstogoaround,someonewill
havetoloseout.Theloopinthecodeaboveweedsthispersonoutbycheckingmaxbidsandupdatingthe
winningbids.Ifeveryonesmaxbidsinthisscenariowas$20,andtheincrementwas$2,thenbidderCand
whicheverofbidderAandBplacedthefirstbidwouldwin(rememberthatbidpriorityisplacedonmost
lotsbidfor,followedbybidtime).
</p>缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。 接下来就不能纸上谈兵了,最好的方法其实是实践。实践,只能算是让你掌握语言特性用的。而提倡做实际的Project也不是太好,因为你还没有熟练的能力去综合各种技术,这样只能使你自己越来越迷糊。 还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。 我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。 兴趣爱好,那么你无须学编程,申请一个域名和空间,在网上下载一些免费开源的CMS系统,你不用改代码,只须熟悉它们的后台操作,像office一样简单方便,很快就能建一个站点,很多站长都是这样做的 Server:这个表示的服务器,操作服务器的一些东西使用这个,如Server.Mappath转换服务器路径,Server.CreateObject实例化一个组件 封装性使得代码逻辑清晰,易于管理,并且应用到ASP.Net上就可以使业务逻辑和Html页面分离,这样无论页面原型如何改变,业务逻辑代码都不必做任何改动;继承性和多态性使得代码的可重用性大大提高。 我们必须明确一个大方向,不要只是停留在因为学而去学,我们应有方向应有目标. 我可以结合自己的经验大致给你说一说,希望对你有所帮助,少走些弯路。
页:
[1]