Public Function CheckIfItemPresent(ByVal userID As String, ByVal itemID As String, ByVal itemPrice As Integer, ByVal offer As String) As Boolean
On Error GoTo galti
Dim sqlStatement As String = "SELECT itemQtty FROM shoppingCart WHERE userID = '" & _
userID & "' AND itemID = '" & itemID & "'" & _
" AND itemPrice = " & itemPrice & " AND offer = '" & offer & "'"
Dim con As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;" & _
"AttachDbFilename=|DataDirectory|\database.mdf;" & _
"Integrated Security=True;User Instance=True")
Dim sql As New SqlClient.SqlCommand(sqlStatement, con)
Dim reader As SqlClient.SqlDataReader
con.Open()
reader = sql.ExecuteReader
reader.Read()
Dim itemQtty As Integer = reader.Item("itemQtty")
reader.Close()
If itemQtty > 0 Then
If ***MsgBox("Item already present. Add another one? Currently, number of this item in cart: " & itemQtty, MsgBoxStyle.YesNo, "") = MsgBoxResult.Yes*** Then
itemQtty = itemQtty + 1
sql.CommandText = "UPDATE shoppingCart SET itemQtty = " & itemQtty & " WHERE " & _
"userID = '" & userID & "' AND itemID = '" & itemID & "' AND itemPrice=" & _
itemPrice & " AND offer = '" & offer & "'"
sql.ExecuteNonQuery()
Else
End If
End If
con.Close()
con.Dispose()
Return True
Exit Function
galti:
con.Close()
con.Dispose()
Return Fals开发者_如何学Ce
End Function
how to use javascript conformation box instead of asp.net msgbox...please check the portion in between *
There is no drop-in replacement to do that with Javascript.
To interact with the user you have to send a response back to the browser that it can display, then the user can make the choise and send another request to the server containing the information about the choise.
So, you have to divide this into two separate steps on the server side.
To make a confirmation box in Javascript you can use the confirm
method. Example:
var choise = window.confirm('Item already present. Add another one? Currently, number of this item in cart: 42');
精彩评论