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 False
End Function
如何使用javascript conformation box而不是asp.net msgbox ...请检查 * 之间的部分
答案 0 :(得分:0)
使用Javascript没有直接替代。
要与用户交互,您必须将响应发送回它可以显示的浏览器,然后用户可以进行选择并向服务器发送包含有关选择信息的另一个请求。
因此,您必须在服务器端将其分为两个单独的步骤。
要在Javascript中创建一个确认框,您可以使用confirm
方法。例如:
var choise = window.confirm('Item already present. Add another one? Currently, number of this item in cart: 42');