Пример #1
0
        public List <cHostOrder> GetOrders()
        {
            SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=Restaurant.db;Version=3;");

            m_dbConnection.Open();
            int current_row = 1;
            List <cHostOrder> pastorders  = new List <cHostOrder>();
            string            commandtext = "SELECT * FROM ORDERS";
            SQLiteCommand     ordercmd    = new SQLiteCommand(commandtext, m_dbConnection);
            SQLiteDataReader  orderreader = ordercmd.ExecuteReader();
            List <iHostItem>  items       = new List <iHostItem>();

            while (orderreader.Read())
            {
                string        itemcommandtext = "Select Name from Items join Order_Items on Items.id = Order_Items.Itemid join Orders on Order_Items.orderID = Orders.id where Orders.id = @orderid";
                SQLiteCommand itemcommand     = new SQLiteCommand(itemcommandtext, m_dbConnection);
                itemcommand.Parameters.Add(new SQLiteParameter("@orderid", current_row));
                SQLiteDataReader itemreader = itemcommand.ExecuteReader();
                while (itemreader.Read())
                {
                    items.Add(new iHostItem((string)itemreader["Name"]));
                }

                cHostOrder neworder = new cHostOrder((string)orderreader["Date"], (int)orderreader["PartySize"], (int)orderreader["TableNum"], (double)orderreader["Cost"], items);
                pastorders.Add(neworder);
                current_row++;
                items.Clear();
            }


            m_dbConnection.Close();
            return(pastorders);
        }
Пример #2
0
        private void ConfirmOrder()
        {
            //0 = ORDER
            //1 = date
            //2 = party size
            //3 = table number
            //4 = total cost
            //5 = order comma separated.
            cHostOrder _order = new cHostOrder(message_from_client);

            if (_order.GetDate() != "INVALID")
            {
                //lock until it is done
                Monitor.Enter(orders);
                orders.Add(_order);
            }
        }