如果类别不是“dish”,我如何检查文本框中的数量是否高于或低于数据库列中的数量?运动模拟

oaxa6hgo  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(161)

我有一个问题,在我的代码我将如何检查文本框值,如果它高于或低于我的数据库中的值?这是我的密码:

Public Sub additem()
    Dim str As String
    Dim cmd As New MySqlCommand
    Dim dr As MySqlDataReader
    Try
    str = "select * from tbl_items where ItemName = '" & TextBox1.Text & "'"
    con.Open()
    With cmd
        .CommandText = str
        .Connection = con

    End With
    dr = cmd.ExecuteReader
        While dr.Read
            Dim qty As String = dr("quantity")
            Dim ctgy1 As String = dr("category")
            If quantity.Text = "" Then
                MsgBox("Please Add Quantity or Number of Order(s)!", MsgBoxStyle.Information, "Quantity")
            ElseIf ctgy1 IsNot "Dish" Then
                If TextBox1.Text > qty Then
                    MsgBox("Insufficient Stock!", MsgBoxStyle.Information, "Quantity")
                Else
                    Dim price As Decimal = dr("Price")
                    Dim itemcode As String = dr("ItemName")
                    Dim ctgy As String = dr("category")
                    Dim desc As String = dr("description")
                    totalprice = Val(quantity.Text) * price
                    CashRegister.BunifuCustomDataGrid2.Rows.Add(itemcode, price, quantity.Text, totalprice, ctgy, desc)
                    CashRegister.BunifuCustomDataGrid2.Columns("category").Visible = False

                    con.Close()
                    UpdateDecreaseQuantity()
                    loadtables()
                    dr.Close()
                    Me.Close()

                End If
            Else
                Dim price As Decimal = dr("Price")
                Dim itemcode As String = dr("ItemName")
                Dim ctgy As String = dr("category")
                Dim desc As String = dr("description")
                totalprice = Val(quantity.Text) * price
                CashRegister.BunifuCustomDataGrid2.Rows.Add(itemcode, price, quantity.Text, totalprice, ctgy, desc)
                CashRegister.BunifuCustomDataGrid2.Columns("category").Visible = False

                con.Close()
                UpdateDecreaseQuantity()
                loadtables()
                dr.Close()
                Me.Close()
            End If
        End While

    Catch ex As Exception

    Finally

    End Try

End Sub

我想发生的是,如果类别不等于菜或甜点,它会检查文本框中输入的数量,并与数据库中的数量进行比较。有人能帮我吗?谢谢您!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题