Opdatere tid i database
HejJeg har downloadet et auktionsprogram fra Xcent, som jeg har fået til at fungere fint, men man vil jo altid gøre det bedre og nu vil jeg gerne have at hvis der bliver budt indenfor de sidste fem minutter, så skal sluttiden forlænges med fem minutter fra budtidspunktet.
Alle data er i en Access database, hvor der i en tabel (tblQABids) gemmes bud med tidsangivelse og i en anden tabel (tblQAAuctions) står katalogvaren med udløbsdato/tid.
Jeg vil gerne at når der bliver lagt et bud ind, så skal den tjekke om budtidspunktet der bliver lagt i tabellen tblQABids, er mindre end fem minutter før sluttiden - i givet fald skal den opdatere tiden i tabellen tblQAAuctions med budtidspunktet + 5 minutter.
Jeg har forsøgt forskellige løsninger, men enten fjerner den sluttiden eller også sker der intet med tiden. Håber der er en derude der kan hjælpe mig.
Her er koden på den hvor den opdaterer databasen:
DoPageHeader
TableHead GLS_PlaceBid
OpenDBConn
sUserName = "" & Request.Form("UserName")
sPassword = "" & Request.Form("Password")
iBidPlaced = FVal(Request.Form("Bid"))
iItemID = FVal(Request.Form("ItemID"))
DatoTid = DateAdd("N",5,Now())
lBidderID = 0
sBidderEmail = ""
lCatID = 0
bidSQL = "SELECT * FROM tblQAAuctions WHERE aucID =" & SQLVal(iItemID)
set bidRS = gobjConnect.Execute(bidSQL)
If NOT bidRS.EOF Then
iCurrentBidder = FVAL(bidRs("aucCurrentBidder"))
sItemTitle = "" & bidRS.Fields("aucItemTitle")
vCloseDate = bidRS.Fields("aucCloseDate")
lOwnerID = FVal(bidRS("aucItemOwner"))
lCatID = FVal(bidRS.Fields("aucCategoryID"))
If FVal(bidRS.Fields("aucCurrentBid")) > 0 Then
iBidNeeded = FVal(bidRS.Fields("aucMinimumIncrement") + bidRS.Fields("aucCurrentBid"))
Else
iBidNeeded = FVal(bidRS.Fields("aucStartingBid"))
End If
Else
iCurrentBidder = 0
sItemTitle = ""
vCloseDate = ""
End If
Response.Write "<TABLE BORDER=""0"" CELLPADDING=""5"" CELLSPACING=""0""><TR><TD>"
If UserRegistered Then
If CheckBid Then
PlaceBid
If iCurrentBidder > 0 Then
SendOutbidEmail
End If
End If
End If
Response.Write "</TD></TR></TABLE>"
BidRS.Close
Set BidRS = Nothing
TableFoot
DoPageFooter
CloseDBConn
Sub PlaceBid
uiSQL = "SELECT * FROM tblQARegistration WHERE regUserName = " & SQLStr(sUserName) & " AND regPassword = " & SQLStr(sPassword) & " "
Set UserRS = gobjConnect.Execute(uiSQL)
If NOT UserRS.EOF Then
lBidderID = FVal(UserRS.Fields("regID"))
sBidderEmail = "" & UserRS.Fields("regEmail")
End If
UserRS.Close
Set UserRS = Nothing
upBidsSQL = "INSERT INTO tblQABids (bidItemID, BidAmount, BidDate, bidBidderID) VALUES( " & _
SQLVal(iItemID) & ", " & _
SQLVal(iBidPlaced) & ", " & _
SQLDate(NOW) & ", " & _
SQLVal(lBidderID) & " ) "
gobjConnect.Execute(upBidsSQL)
'Response.Write upBidsSQL & "<BR>"
pbSQL = "UPDATE tblQAAuctions Set " & _
" aucCurrentBid = " & SQLVal(iBidPlaced) & _
" , aucCurrentBidder = " & SQLVal(lBidderID)& " " & _
" WHERE aucID = " & SQLVal(iItemID)
<== HER VIL JEG GERNE HAVE DEN TIL AT OPDATERE FELTET aucCloseDate MED DEN NYE TID ==>
'Response.write pbSQL & "<BR>"
gobjConnect.Execute(pbSQL)
If len(sBidderEmail) > 0 Then
SendBidEmail
End If
sBidMsg = "" & Replace(GLS_SuccessfulBid, "%BIDAMOUNT%", FCurrency(iBidPlaced))
sBidMsg = Replace(sBidMsg, "%ITEMNO%", iItemID)
sBidMsg = Replace(sBidMsg, "%ITEMTITLE%", sItemTitle)
Response.Write gsAuctionTextOpen & sBidMsg & "<BR>"
Response.Write GLS_PrintConfirm & "<BR><P>"
Response.Write "<A HREF=""QAViewAuctions.asp?catID=" & lCatID & """>" & GLS_GoToCategory & "</A><BR>"
Response.Write "<A HREF=""QAViewItem.asp?ItemID=" & iItemID & """>" & GLS_GoToItem & "</A><BR>" & gsAuctionTextClose
End Sub
Sub SendBidEmail
sBody = "" & ReadFile(Server.MapPath("QAEmailTemplates\QABidNotice.txt"))
sBody = Replace(sBody, "%AUCURL%", gsAucURL)
sBody = Replace(sBody, "%TITLE%", sItemTitle)
sBody = Replace(sBody, "%BID%", FCurrency(iBidPlaced))
sBody = Replace(sBody, "%AUCID%", iItemID)
sBody = Replace(sBody, "%AUCCLOSE%", DispShortDateTime(vCloseDate))
sBody = sBody & Chr(13) & Chr(10) & "Powered by QuickAuction © XCENT"
sSubject = GetFirstLine(sBody)
SendEmailMessage sBidderEmail, gsAdminEmail, sSubject, sBody
End Sub
Sub SendOutbidEmail
emailSQL = "SELECT regID, regEmail FROM tblQARegistration WHERE regID = " & SQLVal(iCurrentBidder)
Set emailRS = gobjConnect.Execute(emailSQL)
If NOT emailRS.EOF Then
sBody = "" & ReadFile(Server.MapPath("QAEmailTemplates\QAOutbidNotice.txt"))
sBody = Replace(sBody, "%AUCURL%", gsAucURL)
sBody = Replace(sBody, "%TITLE%", sItemTitle)
sBody = Replace(sBody, "%BID%", FCurrency(iBidPlaced))
sBody = Replace(sBody, "%AUCID%", iItemID)
sBody = Replace(sBody, "%AUCCLOSE%", DispShortDateTime(vCloseDate))
sBody = sBody & Chr(13) & Chr(10) & "Powered by QuickAuction © XCENT"
sTo = "" & emailRS.Fields("regEmail")
sSubject = GetFirstLine(sBody)
SendEmailMessage sTo, gsAdminEmail, sSubject, sBody
End If
emailRS.Close
set emailRS = Nothing
End Sub
Function CheckBid
If iBidPlaced >= iBidNeeded AND lOwnerID <> lBidderID Then
CheckBid = True
Else
Response.Write(gsAuctionTextOpen & GLS_BidError & gaAuctionTextClose & "<BR>")
If iBidPlaced < iBidNeeded Then
Response.Write gsErrorTextOpen & GLS_BidBelowMin & "<BR>" & gsErrorTextClose
End If
If lOwnerID = lBidderID Then
Response.Write gsErrorTextOpen & GLS_BidOwner & "<BR>" & gsErrorTextClose
End If
Response.Write(gsAuctionTextOpen & GLS_GoBack & "<BR>" & gsAuctionTextClose)
CheckBid = False
End If
End Function
Function UserRegistered
regSQL = "SELECT * FROM tblQARegistration WHERE regUsername = " & SQLStr(sUserName) & " AND regPassword = " & SQLStr(sPassword) & " "
Set regRS = gobjConnect.Execute(regSQL)
If NOT regRS.EOF Then
UserRegistered = True
lBidderID = regRS("regID")
Else
Response.Write(gsAuctionTextOpen & GLS_LoginErr & "<BR>")
Response.Write(GLS_GoBack & "<BR><BR>")
Response.Write(GLS_HowToRegister & gsAuctionTextClose)
UserRegistered = False
End If
regRS.Close
Set regRS = Nothing
End Function
%>
