예제 #1
0
        private async void backgroundDoWork(object sender, DoWorkEventArgs e)
        {
            try {
                while (!backgroundWorker.CancellationPending)
                {
                    var temp     = (await Firebase.GetAsync <OrderDatabaseReturn>()).Orders;
                    var tempList = new List <string>();
                    foreach (var item in temp)
                    {
                        if (item.Value.Status != "placed")
                        {
                            tempList.Add(item.Key);
                        }
                    }
                    foreach (var item in tempList)
                    {
                        temp.Remove(item);
                    }

                    if (temp != orders)
                    {
                        orders = temp;
                        Invoke(new Action(() => {
                            orderList.Items.Clear();

                            foreach (var item in orders)
                            {
                                orderList.Items.Add(item.Key.Replace("_", " "));
                            }
                        }));
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(2));
                }
            } catch (Exception) { }
        }
예제 #2
0
        private async void orderClick(object sender, EventArgs e)
        {
            sendDumbyFocus();
            if (lastClicked != null)
            {
                int orderNum = await Firebase.GetAsync <int>("", "next_order");

                await Firebase.InsertAsync <int>("", "next_order", orderNum + 1);

                Order order = new Order {
                    OrderNum    = orderNum,
                    OrderString = orderTextbox.Text,
                    Status      = "placed",
                    TableNum    = Helper.GetTableNumber(lastClicked),
                    Waiter      = user.username
                };
                var orderKey = Helper.GetOrderKey(orderNum);
                await Firebase.InsertAsync <Order>("Orders", orderKey, order);

                orderTextbox.Text    = "";
                lastOrder            = orderKey;
                undoButton.Enabled   = true;
                comfirmLabel.Visible = true;
                Thread.Sleep(TimeSpan.FromSeconds(5));
                comfirmLabel.Visible = false;
            }
        }
예제 #3
0
        private async void orderClick(object sender, EventArgs e)
        {
            lastSelected = orderList.GetItemText(orderList.SelectedItem);
            var temp  = lastSelected.Replace(" ", "_");
            var order = await Firebase.GetAsync <Order>("Orders", temp);

            orderTextbox.Text = order.OrderString;
        }
예제 #4
0
        private async void orderClick(object sender, EventArgs e)
        {
            var temp  = (orderList.GetItemText(orderList.SelectedItem)).Replace(" ", "_");
            var order = await Firebase.GetAsync <Order>("Orders", temp);

            orderTextbox.Text  = order.OrderString;
            orderNumLabel.Text = "Order " + order.OrderNum.ToString();
            var status = order.Status;

            status = char.ToUpper(status[0]) + status.Substring(1);
            orderStatusLabel.Text = status;
        }
예제 #5
0
        private async void formLoad(object sender, EventArgs e)
        {
            var temp = await Firebase.GetAsync <EmployeeDatabaseReturn>();

            foreach (var item in temp.Employees)
            {
                if (item.Key != Program.user.username)
                {
                    Employee_Box.Items.Add(item.Key);
                }
            }
        }
예제 #6
0
        private async Task refreshList()
        {
            var temp = (await Firebase.GetAsync <OrderDatabaseReturn>()).Orders;

            Invoke(new Action(() => {
                orderList.Items.Clear();

                foreach (var item in temp)
                {
                    orderList.Items.Add(item.Key.Replace("_", " "));
                }
            }));
        }
예제 #7
0
        internal static async Task <Table> SetTableStatus(int table_num, string status, string waiter)
        {
            var old = await Firebase.GetAsync <Table>("Tables", "Table_" + table_num.ToString());

            var temp = new Table()
            {
                AssignedWaiter = waiter,
                Status         = status,
                TableNumber    = old.TableNumber
            };
            await Firebase.UpdateAsync <Table>("Tables", "Table_" + table_num.ToString(), temp);

            return(old);
        }
예제 #8
0
        internal static async Task <User> GetEmployee(string user, string pass)
        {
            User employee = new User();

            Employee responce = await Firebase.GetAsync <Employee>("Employees", user);

            if (responce != null && responce.Username.ToLower() == user.ToLower() && responce.PassHash == pass)
            {
                employee.firstName = responce.FirstName;
                employee.lastName  = responce.LastName;
                employee.username  = responce.Username;

                string type = responce.UserType.ToLower();

                switch (type)
                {
                case "busboy":
                    employee.type = UserType.Busboy;
                    break;

                case "cook":
                    employee.type = UserType.Cook;
                    break;

                case "host":
                    employee.type = UserType.Host;
                    break;

                case "manager":
                    employee.type = UserType.Manager;
                    break;

                case "waiter":
                    employee.type = UserType.Waiter;
                    break;

                default:
                    employee.type = UserType.None;
                    break;
                }
            }
            else
            {
                employee = new User();
            }

            return(employee);
        }
예제 #9
0
        private async void readyClick(object sender, EventArgs e)
        {
            if (lastSelected != null)
            {
                var temp  = lastSelected.Replace(" ", "_");
                var order = await Firebase.GetAsync <Order>("Orders", temp);

                lastChanged  = order;
                order.Status = "ready";
                await Firebase.UpdateAsync <Order>("Orders", temp, order);

                orderList.SelectedItem = null;
                lastSelected           = null;
                undoButton.Enabled     = true;
            }
        }
예제 #10
0
        private async void backgroundDoWork(object sender, DoWorkEventArgs e)
        {
            try {
                while (!backgroundWorker.CancellationPending)
                {
                    var    tempTables = (await Firebase.GetAsync <TableDatabaseReturn>()).Tables;
                    Button b;

                    foreach (var table in tempTables)
                    {
                        b = Helper.GetButton(LayoutPanel, table.Value.TableNumber);
                        if (table.Value.AssignedWaiter == user.username)
                        {
                            b.BackColor = Color.Green;
                            b.ForeColor = Color.White;
                        }
                        else
                        {
                            b.BackColor = Color.Red;
                            b.ForeColor = Color.White;
                        }
                    }

                    var tempOrders = (await Firebase.GetAsync <OrderDatabaseReturn>()).Orders;

                    foreach (var item in tempOrders)
                    {
                        if (item.Value.Waiter == user.username && item.Value.Status == "ready")
                        {
                            MessageBox.Show("Food ready for table " + item.Value.TableNum.ToString());
                            Order order = new Order()
                            {
                                OrderNum    = item.Value.OrderNum,
                                Status      = "complete",
                                TableNum    = item.Value.TableNum,
                                Waiter      = item.Value.Waiter,
                                OrderString = item.Value.OrderString
                            };
                            await Firebase.UpdateAsync <Order>("Orders", item.Key, order);
                        }
                    }

                    Thread.Sleep(TimeSpan.FromSeconds(2));
                }
            } catch (Exception) { }
        }
예제 #11
0
        internal static async Task <Table> SetTableStatus(int table_num, string status)
        {
            var old = await Firebase.GetAsync <Table>("Tables", "Table_" + table_num.ToString());

            var temp = new Table()
            {
                AssignedWaiter = old.AssignedWaiter,
                Status         = status,
                TableNumber    = old.TableNumber
            };

            if (status != "occupied" && temp.AssignedWaiter != "")
            {
                temp.AssignedWaiter = "";
            }
            await Firebase.UpdateAsync <Table>("Tables", "Table_" + table_num.ToString(), temp);

            return(old);
        }
예제 #12
0
        private async void backgroundDoWork(object sender, DoWorkEventArgs e)
        {
            try {
                while (!backgroundWorker.CancellationPending)
                {
                    TableDatabaseReturn tables;
                    tables = await Firebase.GetAsync <TableDatabaseReturn>();

                    Button b;

                    foreach (var table in tables.Tables)
                    {
                        b = Helper.GetButton(layoutPanel, table.Value.TableNumber);
                        Helper.SetButton(b, table.Value.Status, "dirty", Color.Red, Color.Green);
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(2));
                }
            } catch (Exception) { }
        }
예제 #13
0
        private async void backgroundDoWork(object sender, DoWorkEventArgs e)
        {
            try {
                while (!backgroundWorker.CancellationPending)
                {
                    var tables = await Firebase.GetAsync <TableDatabaseReturn>();

                    Button b;

                    foreach (var table in tables.Tables)
                    {
                        b = Helper.GetButton(LayoutPanel, table.Value.TableNumber);
                        Helper.SetButton(b, table.Value.Status, "clean", Color.Green, Color.Red);
                    }

                    var temp = await Firebase.GetAsync <WaiterDatabaseReturn>();

                    if (!temp.Waiters.Equals(waiters))
                    {
                        waiters = temp.Waiters;
                        Invoke(new Action(() => {
                            waiterNames.Items.Clear();
                            waiterClockoutTimes.Items.Clear();

                            foreach (var item in waiters)
                            {
                                waiterNames.Items.Add(item.Key);
                                waiterClockoutTimes.Items.Add(item.Value.Clockout);
                            }
                        }));
                    }

                    Thread.Sleep(TimeSpan.FromSeconds(2));
                }
            } catch (Exception) { }
        }