示例#1
0
        private void EventDeleteDishes(object sender, RoutedEventArgs e)
        {
            OnMyWayDatabase OnMyWayDb = new OnMyWayDatabase();
            Dishe           Adishe    = new Dishe();
            bool            CanCommit = false;

            for (int i = 0; i < DishesDataGrid.SelectedItems.Count; i++)
            {
                if (CanCommit == false)
                {
                    CanCommit = true;
                }
                Adishe = (Dishe)DishesDataGrid.SelectedItems[i];
                var GetDishesQuery = from d in OnMyWayDb.Dishes
                                     where d.DisheId == Adishe.DisheId
                                     select d;
                foreach (Dishe dishe in GetDishesQuery)
                {
                    OnMyWayDb.Dishes.Remove(dishe);
                }
            }
            if (CanCommit == true)
            {
                OnMyWayDb.SaveChanges();
                PushMsg("Dishe Deleted", "Selected dishes was successfully Deleted.");
                ShowDishes();
            }
        }
示例#2
0
        private void SubmitPayment(object sender, RoutedEventArgs e)
        {
            OnMyWayDatabase OnMyWayDb          = new OnMyWayDatabase();
            var             TableSelectedQuery = (from t in OnMyWayDb.TableSelecteds
                                                  where t.Id == 1
                                                  select t).FirstOrDefault();

            if (TableSelectedQuery.TableId != 0)
            {
                var GetTableSelected = (from t in OnMyWayDb.Tables
                                        where t.TableId == TableSelectedQuery.TableId
                                        select t).FirstOrDefault();
                var GetWaiterQuery = (from w in OnMyWayDb.Waiters
                                      where w.WaiterId == GetTableSelected.TableWaiter
                                      select w).FirstOrDefault();
                GetWaiterQuery.MoneyEarned  += TotalPrice;
                GetTableSelected.TableStatus = "Empty";
                GetTableSelected.TableWaiter = 0;
                GetTableSelected.DisheList   = "";
                OnMyWayDb.SaveChanges();
                PushMsg("Bill PAID", "Bill for table " + TableSelectedQuery.TableId + " has been paid.\nTable is now empty.");
            }
            else
            {
                PushMsg("No Table Selected", "Please select a table for the order.");
            }
        }
示例#3
0
        private void SubmitOrder(object sender, RoutedEventArgs e)
        {
            OnMyWayDatabase OnMyWayDb          = new OnMyWayDatabase();
            var             TableSelectedQuery = (from t in OnMyWayDb.TableSelecteds
                                                  where t.Id == 1
                                                  select t).FirstOrDefault();

            if (TableSelectedQuery.TableId != 0)
            {
                Dishe  Adishe        = new Dishe();
                string OrderedDishes = "";
                for (int i = 0; i < AvailableDishesListView.SelectedItems.Count; i++)
                {
                    Adishe         = (Dishe)AvailableDishesListView.SelectedItems[i];
                    OrderedDishes += Adishe.DisheId + ",";
                }
                var GetSelectedTableQuery = (from t in OnMyWayDb.Tables
                                             where t.TableId == TableSelectedQuery.TableId
                                             select t).FirstOrDefault();
                GetSelectedTableQuery.TableStatus = "Eating";
                GetSelectedTableQuery.DisheList   = OrderedDishes;
                OnMyWayDb.SaveChanges();
                PushMsg("Ordered Dishes", "Selected dishes have been set for table: " + TableSelectedQuery.TableId);
            }
            else
            {
                PushMsg("No Table Selected", "Please select a table for the order.");
            }
        }
示例#4
0
        private void EventUpdateDishes(object sender, RoutedEventArgs e)
        {
            OnMyWayDatabase OnMyWayDb = new OnMyWayDatabase();
            Dishe           Adishe    = new Dishe();
            bool            CanCommit = false;

            for (int i = 0; i < DishesDataGrid.Items.Count; i++)
            {
                if (CanCommit == false)
                {
                    CanCommit = true;
                }
                Adishe = (Dishe)DishesDataGrid.Items[i];
                var GetDishesQuery = (from d in OnMyWayDb.Dishes
                                      where d.DisheId == Adishe.DisheId
                                      select d).FirstOrDefault();
                GetDishesQuery.DisheName        = Adishe.DisheName;
                GetDishesQuery.DisheDescription = Adishe.DisheDescription;
                GetDishesQuery.DishePrice       = Adishe.DishePrice;
            }
            if (CanCommit == true)
            {
                OnMyWayDb.SaveChanges();
                PushMsg("Dishes Saved", "All changes to dishes have been saved.");
                ShowDishes();
            }
        }
示例#5
0
        private void EventUpdateWaiters(object sender, RoutedEventArgs e)
        {
            OnMyWayDatabase OnMyWayDb = new OnMyWayDatabase();
            Waiter          Awaiter   = new Waiter();
            bool            CanCommit = false;

            for (int i = 0; i < WaitersDataGrid.Items.Count; i++)
            {
                if (CanCommit == false)
                {
                    CanCommit = true;
                }
                Awaiter = (Waiter)WaitersDataGrid.Items[i];
                var GetWaitersQuery = (from w in OnMyWayDb.Waiters
                                       where w.WaiterId == Awaiter.WaiterId
                                       select w).FirstOrDefault();
                GetWaitersQuery.WaiterName      = Awaiter.WaiterName;
                GetWaitersQuery.WaiterFirstname = Awaiter.WaiterFirstname;
                GetWaitersQuery.Gender          = Awaiter.Gender;
            }
            if (CanCommit == true)
            {
                OnMyWayDb.SaveChanges();
                PushMsg("Waiters Saved", "All changes to waiters have been saved.");
                ShowWaiters();
            }
        }
示例#6
0
        private void ValidWaiter(object sender, RoutedEventArgs e)
        {
            OnMyWayDatabase OnMyWayDb          = new OnMyWayDatabase();
            var             TableSelectedQuery = (from t in OnMyWayDb.TableSelecteds
                                                  where t.Id == 1
                                                  select t).FirstOrDefault();

            if (TableSelectedQuery.TableId != 0)
            {
                Waiter Awaiter     = new Waiter();
                int    TableWaiter = new int();
                Awaiter     = (Waiter)AvailableWaitersListView.SelectedItems[0];
                TableWaiter = Awaiter.WaiterId;
                var GetSelectedTableQuery = (from t in OnMyWayDb.Tables
                                             where t.TableId == TableSelectedQuery.TableId
                                             select t).FirstOrDefault();
                GetSelectedTableQuery.TableWaiter = TableWaiter;
                var GetWaiterQuery = (from w in OnMyWayDb.Waiters
                                      where w.WaiterId == TableWaiter
                                      select w).FirstOrDefault();
                GetWaiterQuery.HandeledTables++;
                GetSelectedTableQuery.TableWaiter = TableWaiter;
                OnMyWayDb.SaveChanges();
                PushMsg("Assigned  Waiter", GetWaiterQuery.WaiterFirstname + " have been assigned to table: " + TableSelectedQuery.TableId);
            }
            else
            {
                PushMsg("No Table Selected", "Please select a table for the order.");
            }
        }
示例#7
0
        private void EventDeleteWaiters(object sender, RoutedEventArgs e)
        {
            OnMyWayDatabase OnMyWayDb = new OnMyWayDatabase();
            Waiter          Awaiter   = new Waiter();
            bool            CanCommit = false;

            for (int i = 0; i < WaitersDataGrid.SelectedItems.Count; i++)
            {
                if (CanCommit == false)
                {
                    CanCommit = true;
                }
                Awaiter = (Waiter)WaitersDataGrid.SelectedItems[i];
                var GetWaitersQuery = from w in OnMyWayDb.Waiters
                                      where w.WaiterId == Awaiter.WaiterId
                                      select w;
                foreach (Waiter waiter in GetWaitersQuery)
                {
                    OnMyWayDb.Waiters.Remove(waiter);
                }
            }
            if (CanCommit == true)
            {
                OnMyWayDb.SaveChanges();
                PushMsg("Waiter Deleted", "Selected waiters was successfully Deleted.");
                ShowWaiters();
            }
        }
示例#8
0
        private void AddWaiter(object sender, RoutedEventArgs e)
        {
            Waiter NewWaiter = new Waiter();
            bool   CanCommit = false;

            if (WaiterNameTextBox.Text.Length != 0)
            {
                NewWaiter.WaiterName = WaiterNameTextBox.Text;
                if (WaiterFirstnameTextBox.Text.Length != 0)
                {
                    NewWaiter.WaiterFirstname = WaiterFirstnameTextBox.Text;
                    if (WaiterGenderTextBox.Text.Length != 0)
                    {
                        if (WaiterGenderTextBox.Text == "Male" || WaiterGenderTextBox.Text == "male" || WaiterGenderTextBox.Text == "M" || WaiterGenderTextBox.Text == "m" ||
                            WaiterGenderTextBox.Text == "Femele" || WaiterGenderTextBox.Text == "female" || WaiterGenderTextBox.Text == "F" || WaiterGenderTextBox.Text == "f")
                        {
                            if ((WaiterGenderTextBox.Text == "Male" || WaiterGenderTextBox.Text == "male" || WaiterGenderTextBox.Text == "M" || WaiterGenderTextBox.Text == "m"))
                            {
                                NewWaiter.Gender = "Male";
                                CanCommit        = true;
                            }
                            if ((WaiterGenderTextBox.Text == "Femele" || WaiterGenderTextBox.Text == "female" || WaiterGenderTextBox.Text == "F" || WaiterGenderTextBox.Text == "f"))
                            {
                                NewWaiter.Gender = "Female";
                                CanCommit        = true;
                            }
                        }
                        else
                        {
                            PushMsg("Gender Error", "Invalid gender input.\n\nPlease Specify the waiters gender:\nMale - male - M - m for \"Male Gender\".\nFemale - female - F - f for \"Female Gender\".");
                        }
                    }
                    else
                    {
                        PushMsg("Gender Error", "Waiter needs a gender!");
                    }
                }
                else
                {
                    PushMsg("Firstname Error", "Waiter needs a firstname!");
                }
            }
            else
            {
                PushMsg("Name Error", "Waiter needs a name!");
            }
            if (CanCommit == true)
            {
                NewWaiter.HandeledTables = 0;
                NewWaiter.MoneyEarned    = 0;
                OnMyWayDatabase OnMyWayDb = new OnMyWayDatabase();
                OnMyWayDb.Waiters.Add(NewWaiter);
                OnMyWayDb.SaveChanges();
                PushMsg("Waiter Added", "Waiter was successfully added.\n\nPlease refresh Admin Panel to view changes.");
            }
        }
示例#9
0
        protected override void OnClosed(EventArgs e)
        {
            OnMyWayDatabase OnMyWayDb          = new OnMyWayDatabase();
            var             TableSelectedQuery = (from t in OnMyWayDb.TableSelecteds
                                                  where t.Id == 1
                                                  select t).FirstOrDefault();

            TableSelectedQuery.TableId = 0;
            OnMyWayDb.SaveChanges();
            base.OnClosed(e);
            Application.Current.Shutdown();
        }
示例#10
0
        public void ShowTables()
        {
            OnMyWayDatabase OnMyWayDb      = new OnMyWayDatabase();
            var             GetTablesQuery = from t in OnMyWayDb.Tables
                                             orderby t.TableId
                                             select t;

            foreach (Table table in GetTablesQuery)
            {
                TableList.Add(table);
                CreateNewTable(table.TablePositionX, table.TablePositionY, table.TableId, false);
            }
        }
示例#11
0
        private void AddDishe(object sender, RoutedEventArgs e)
        {
            Dishe NewDishe  = new Dishe();
            bool  CanCommit = false;

            if (DisheNameTextBox.Text.Length != 0)
            {
                NewDishe.DisheName = DisheNameTextBox.Text;
                if (DisheDescriptionTextBox.Text.Length != 0)
                {
                    NewDishe.DisheDescription = DisheDescriptionTextBox.Text;
                    if (DishePriceTextBox.Text.Length != 0)
                    {
                        try
                        {
                            NewDishe.DishePrice = double.Parse(DishePriceTextBox.Text);
                            CanCommit           = true;
                        }
                        catch
                        {
                            PushMsg("Price Error", "Invalid price input!");
                        }
                    }
                    else
                    {
                        PushMsg("Price Error", "Dishe needs a price!");
                    }
                }
                else
                {
                    PushMsg("Description Error", "Dishe needs a description!");
                }
            }
            else
            {
                PushMsg("Name Error", "Dishe needs a name!");
            }
            if (CanCommit == true)
            {
                OnMyWayDatabase OnMyWayDb = new OnMyWayDatabase();
                OnMyWayDb.Dishes.Add(NewDishe);
                OnMyWayDb.SaveChanges();
                PushMsg("Dishe Added", "Dishe was successfully added.\n\nPlease refresh Admin Panel to view changes.");
            }
        }
示例#12
0
        public void ShowDishes()
        {
            OnMyWayDatabase OnMyWayDb      = new OnMyWayDatabase();
            var             GetDishesQuery = from d in OnMyWayDb.Dishes
                                             orderby d.DisheId
                                             select d;
            List <Dishe> dishes = new List <Dishe>();

            foreach (Dishe dishe in GetDishesQuery)
            {
                dishes.Add(new Dishe()
                {
                    DisheId = dishe.DisheId, DisheName = dishe.DisheName, DisheDescription = dishe.DisheDescription, DishePrice = dishe.DishePrice
                });
            }

            AvailableDishesListView.ItemsSource = dishes;
        }
示例#13
0
        public void ShowWaiters()
        {
            OnMyWayDatabase OnMyWayDb       = new OnMyWayDatabase();
            var             GetWaitersQuery = from w in OnMyWayDb.Waiters
                                              orderby w.WaiterId
                                              select w;
            List <Waiter> waiters = new List <Waiter>();

            foreach (Waiter waiter in GetWaitersQuery)
            {
                waiters.Add(new Waiter()
                {
                    WaiterId = waiter.WaiterId, WaiterName = waiter.WaiterName, WaiterFirstname = waiter.WaiterFirstname, Gender = waiter.Gender, HandeledTables = waiter.HandeledTables, MoneyEarned = waiter.MoneyEarned
                });
            }

            AvailableWaitersListView.ItemsSource = waiters;
        }
示例#14
0
        public void ShowDishes()
        {
            OnMyWayDatabase OnMyWayDb          = new OnMyWayDatabase();
            var             TableSelectedQuery = (from t in OnMyWayDb.TableSelecteds
                                                  where t.Id == 1
                                                  select t).FirstOrDefault();

            if (TableSelectedQuery.TableId != 0)
            {
                var GetTableSelected = (from t in OnMyWayDb.Tables
                                        where t.TableId == TableSelectedQuery.TableId
                                        select t).FirstOrDefault();
                if (GetTableSelected.DisheList != null)
                {
                    var DisheId = GetTableSelected.DisheList.Split(',');

                    List <Dishe> dishes = new List <Dishe>();
                    TotalPrice = 0;
                    foreach (var dishe in DisheId)
                    {
                        if (dishe != "")
                        {
                            int disheId        = Convert.ToInt32(dishe);
                            var GetDishesQuery = (from d in OnMyWayDb.Dishes
                                                  where d.DisheId == disheId
                                                  select d).FirstOrDefault();
                            dishes.Add(new Dishe()
                            {
                                DisheId = GetDishesQuery.DisheId, DisheName = GetDishesQuery.DisheName, DisheDescription = GetDishesQuery.DisheDescription, DishePrice = GetDishesQuery.DishePrice
                            });
                            TotalPrice += GetDishesQuery.DishePrice;
                        }
                    }
                    BillPaymentListView.ItemsSource = dishes;
                    Total.Text = TotalPrice.ToString();
                }
            }
            else
            {
                PushMsg("No Table Selected", "Please select a table for the order.");
            }
        }
示例#15
0
        public void SaveTableChanges(object sender, RoutedEventArgs e)
        {
            OnMyWayDatabase OnMyWayDb = new OnMyWayDatabase();

            foreach (Table table in TableList)
            {
                var GetTableQuery = (from t in OnMyWayDb.Tables
                                     where t.TableId == table.TableId
                                     select t).FirstOrDefault();
                if (GetTableQuery != null)
                {
                    GetTableQuery.TablePositionX = table.TablePositionX;
                    GetTableQuery.TablePositionY = table.TablePositionY;
                }
                else
                {
                    OnMyWayDb.Tables.Add(table);
                }
            }
            OnMyWayDb.SaveChanges();
            PushMsg("Tables Saved", "Changes to the restaurant laying out have been saved.");
        }