Code thus not work as expected. HELP

Discussion in 'Programming General' started by Ben Nerd, Mar 16, 2008.

Code thus not work as expected. HELP
  1. Unread #1 - Mar 16, 2008 at 10:04 AM
  2. Ben Nerd
    Referrals:
    0

    Ben Nerd Guest

    Code thus not work as expected. HELP

    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
    
     
< Terminate Process On Close? | Item Price Checker [source] >

Users viewing this thread
1 guest


 
 
Adblock breaks this site