• Log in or sign up for an account here: https://www.sythe.org/login

Code thus not work as expected. HELP

  • Thread starter Thread starter Ben Nerd
  • Start date Start date
B

Ben Nerd

Guest
Haii...
I hope one u guys can really help me. Because its quite urgent.

Ok what i try to develop an ordering system. There are two form involve, 1. is the MainMenu which display 10 tables as button and 2. OrderForm, where the cashier can input the order. Also 2 class involve 1. TableClass - which shall determine wether the table is already been occupied, if not then shall enter the order form. 2. OrderItemClass - to insert order into the system.

But the problem here is the TableClass. what i try to achieve is whenever cashier click on the table, for example table 1. For every button i assigned table no, so the table number shall be passed to Table Class.

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
        Dim Cust_table As New TableClass
        Cust_table.Table_No = 1

End Sub

The Table class did receive the table no, because the OrderForm did pop up. But what i confuse is i already set in the database in table CounterMeja that table 1 the counter is 1.


Lets go through the first part of the class.
This part will receive the table number, upon receiving the table number.
The code will select Counter either the data is 0/1 from table Meja.
Code:
Public Property Table_No()
        
        Get
            Return Cust_table
        End Get
        
        Set(ByVal value)
            Cust_table = value

            Dim Conn As New SqlConnection("Data Source=ANNAS;Initial       
            Catalog=RMS01;Integrated Security=True")
            Dim command As New SqlCommand("SELECT Counter FROM 
            CounterMeja WHERE Meja = @Cust_table", Conn)

            Conn.Open()
            command.Parameters.AddWithValue("Cust_table", Cust_table)
            command.ExecuteScalar()

Here, if Counter is not equal to 0, a message will appear indicating that the table is being occupied. But the problem here is, even though in the database i already put counter is 1, but the OrderForm still display, like this part never work. Can anybody figure it out please

Code:
  If Counter = 0 Then

                Dim command2 As New SqlCommand("Update CounterMeja Set 
                Counter = 1 Where Meja = @Cust_table", Conn)
                command2.Parameters.AddWithValue("@Cust_table", Cust_table)
                command2.ExecuteNonQuery()
                OrderForm.Show()
            Else
                Dim Result As String
                Result = ("Sorry this table has already been occupied")
            End If

            Conn.Close()

        End Set
    End Property
End Class
 
Runescape Gamblingrunescape gambling
Back
Top