Esempio n. 1
0
        private async void Load()
        {
            await Task.Run(() =>
            {
                string result = API.GetAllTable();
                stuff         = JsonConvert.DeserializeObject(result);

                if (result == "")
                {
                    return;
                }

                this.Dispatcher.Invoke(() =>
                {
                    foreach (var item in stuff)
                    {
                        Tables.Add(new Model.Table()
                        {
                            id           = item._id,
                            number       = item.number,
                            numberOfSeat = item.numberOfSeat,
                            type         = item.type,
                            status       = item.status,
                            note         = item.note,
                            customer     = new Customer()
                            {
                                fullName = item.customer.fullName, phone = item.customer.phone
                            }
                        });
                    }
                    ;
                });
            });

            await Task.Run(() =>
            {
                Thread.Sleep(1000);
                this.Dispatcher.Invoke(() =>
                {
                    for (int i = 0; i < Tables.Count; i++)
                    {
                        if (Tables[i].type == "standard")
                        {
                            ListViewItem lvi1 = ListViewTable.ItemContainerGenerator.ContainerFromIndex(i) as ListViewItem;
                            var cp1           = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                            var dt1        = cp1.ContentTemplate as DataTemplate;
                            var rt1        = (Grid)dt1.FindName("TicketType", cp1);
                            rt1.Background = Brushes.Blue;
                        }
                    }
                    ;
                });
            });
        }
        private void ListViewSearchRoom_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (ListViewSearchRoom.SelectedIndex == -1)
            {
                return;
            }

            if (ListViewSearchRoom.ItemContainerGenerator.ContainerFromIndex(ListViewSearchRoom.SelectedIndex) is ListViewItem lvi)
            {
                var bc = new BrushConverter();

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var dt = cp.ContentTemplate as DataTemplate;
                var tb = (TextBlock)dt.FindName("NumberRoom", cp);
                var rt = (Rectangle)dt.FindName("BackGround", cp);
                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");


                Customername.Text = "";
                CustomerID.Text   = "";
                Note.Text         = "";

                NumberRoom.Text = phongHienTai.soPhong;
                TypeRoom.Text   = phongHienTai.loaiPhong;
                if (phongHienTai.tinhTrang == 1)
                {
                    Customername.Text = phongHienTai.KhachHang.hoTen;
                    CustomerID.Text   = phongHienTai.KhachHang.cmnd;
                    Note.Text         = phongHienTai.ghiChu;
                }
                if (phongHienTai.loaiPhong.Contains("Tiêu chuẩn"))
                {
                    NumberRoom.Foreground = (Brush)bc.ConvertFrom("#FF2195F2");
                    TypeRoom.Foreground   = (Brush)bc.ConvertFrom("#FF2195F2");
                }
                else
                {
                    NumberRoom.Foreground = (Brush)bc.ConvertFrom("#FFF3F311");
                    TypeRoom.Foreground   = (Brush)bc.ConvertFrom("#FFF3F311");
                }
            }
        }
Esempio n. 3
0
        private async void LoadTicket()
        {
            await Task.Run(() =>
            {
                Thread.Sleep(1000);
                this.Dispatcher.Invoke(() =>
                {
                    for (int i = 0; i < Employees.Count; i++)
                    {
                        if (Employees[i].role == "employee")
                        {
                            ListViewItem lvi1 = ListViewEmployee.ItemContainerGenerator.ContainerFromIndex(i) as ListViewItem;
                            var cp1           = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                            var dt1        = cp1.ContentTemplate as DataTemplate;
                            var rt1        = (Grid)dt1.FindName("TicketType", cp1);
                            rt1.Background = Brushes.Blue;
                        }
                    }
                    ;
                });
            });
        }
Esempio n. 4
0
        private void ListViewEmployee_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                var bc = new BrushConverter();

                for (int j = 0; j < Employees.Count; j++)
                {
                    ListViewItem lvi1 = ListViewEmployee.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1 = cp1.ContentTemplate as DataTemplate;
                    var rt1 = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1 = (TextBlock)dt1.FindName("Username", cp1);
                    rt1.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var            dt = cp.ContentTemplate as DataTemplate;
                var            rt = (Rectangle)dt.FindName("BackGround", cp);
                var            tb = (TextBlock)dt.FindName("Username", cp);
                Model.Employee employeeSelected = new Model.Employee();

                foreach (var item in Employees)
                {
                    if (item.username == tb.Text)
                    {
                        employeeSelected = item;
                        break;
                    }
                }
                ;

                Username.Text       = employeeSelected.username;
                NameEmployee.Text   = employeeSelected.displayName;
                DateOfBirth.Text    = employeeSelected.dateOfBirth;
                IdentityNumber.Text = employeeSelected.identityNumber;
                Phone.Text          = employeeSelected.phone;
                if (employeeSelected.role == "admin")
                {
                    TypeEmployee.SelectedIndex = 1;
                }
                else
                {
                    TypeEmployee.SelectedIndex = 0;
                }

                id.Text = employeeSelected.id;

                btnUpdate.IsEnabled = true;
                btnDelete.IsEnabled = true;

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }
Esempio n. 5
0
        private void ListViewEmptyVIPRoom_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                var bc = new BrushConverter();

                for (int j = 0; j < EmptyVIPSingleRooms.Count; j++)
                {
                    ListViewItem lvi1 = ListViewEmptyVIPSingleRoom.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1 = cp1.ContentTemplate as DataTemplate;
                    var rt1 = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1 = (TextBlock)dt1.FindName("NumberRoom", cp1);

                    rt1.Fill = Brushes.White;
                }

                for (int j = 0; j < EmptyVIPCoupleRooms.Count; j++)
                {
                    ListViewItem lvi2 = ListViewEmptyVIPCoupleRoom.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp2  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi2);

                    var dt2 = cp2.ContentTemplate as DataTemplate;
                    var rt2 = (Rectangle)dt2.FindName("BackGround", cp2);
                    var tb2 = (TextBlock)dt2.FindName("NumberRoom", cp2);

                    rt2.Fill = Brushes.White;
                }

                for (int j = 0; j < EmptyVIPGroupRooms.Count; j++)
                {
                    ListViewItem lvi3 = ListViewEmptyVIPGroupRoom.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp3  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi3);

                    var dt3 = cp3.ContentTemplate as DataTemplate;
                    var rt3 = (Rectangle)dt3.FindName("BackGround", cp3);
                    var tb3 = (TextBlock)dt3.FindName("NumberRoom", cp3);

                    rt3.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var dt = cp.ContentTemplate as DataTemplate;
                var rt = (Rectangle)dt.FindName("BackGround", cp);
                var tb = (TextBlock)dt.FindName("NumberRoom", cp);

                foreach (var room in DataProvider.Ins.DB.Phongs.ToList())
                {
                    if (tb.Text == room.soPhong)
                    {
                        phongHienTai    = room;
                        NumberRoom.Text = room.soPhong;
                        TypeRoom.Text   = room.loaiPhong;
                        break;
                    }
                }

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }
        private void ListViewUsingStandardRoom_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                lvHienTai  = (ListView)sender;
                lviHienTai = lvi;

                var bc = new BrushConverter();

                for (int j = 0; j < UsingStandardSingleRooms.Count; j++)
                {
                    ListViewItem lvi1 = ListViewUsingStandardSingleRoom.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1 = cp1.ContentTemplate as DataTemplate;
                    var rt1 = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1 = (TextBlock)dt1.FindName("NumberRoom", cp1);

                    rt1.Fill = Brushes.White;
                }

                for (int j = 0; j < UsingStandardCoupleRooms.Count; j++)
                {
                    ListViewItem lvi2 = ListViewUsingStandardCoupleRoom.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp2  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi2);

                    var dt2 = cp2.ContentTemplate as DataTemplate;
                    var rt2 = (Rectangle)dt2.FindName("BackGround", cp2);
                    var tb2 = (TextBlock)dt2.FindName("NumberRoom", cp2);

                    rt2.Fill = Brushes.White;
                }

                for (int j = 0; j < UsingStandardGroupRooms.Count; j++)
                {
                    ListViewItem lvi3 = ListViewUsingStandardGroupRoom.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp3  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi3);

                    var dt3 = cp3.ContentTemplate as DataTemplate;
                    var rt3 = (Rectangle)dt3.FindName("BackGround", cp3);
                    var tb3 = (TextBlock)dt3.FindName("NumberRoom", cp3);

                    rt3.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var dt = cp.ContentTemplate as DataTemplate;
                var rt = (Rectangle)dt.FindName("BackGround", cp);
                var tb = (TextBlock)dt.FindName("NumberRoom", cp);

                foreach (var room in DataProvider.Ins.DB.Phongs.ToList())
                {
                    if (tb.Text == room.soPhong)
                    {
                        phongHienTai = room;

                        NumberRoom.Text    = room.soPhong;
                        TypeRoom.Text      = room.loaiPhong;
                        Customername.Text  = room.KhachHang.hoTen;
                        CustomerID.Text    = room.KhachHang.cmnd;
                        NoteTextBlock.Text = room.ghiChu;
                        Time.Text          = ((DateTime.Now - room.thoiGianBatDau).Value.Days).ToString() + " ngày " + ((DateTime.Now - room.thoiGianBatDau).Value).ToString(@"hh\:mm\:ss");
                        Total.Text         = Math.Round((((DateTime.Now - room.thoiGianBatDau).Value.Hours + ((DateTime.Now - room.thoiGianBatDau).Value.Days) * 24) * phongHienTai.DanhSachBangGia.cacGioSau + phongHienTai.DanhSachBangGia.gioDau), 0).ToString();

                        break;
                    }
                }

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }
        private void ListViewEmptyStandardTable_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                var bc = new BrushConverter();

                for (int j = 0; j < EmptyStandard4PersonTables.Count; j++)
                {
                    ListViewItem lvi1 = ListViewEmptyStandard4PersonTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1     = cp1.ContentTemplate as DataTemplate;
                    var rt1     = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1     = (TextBlock)dt1.FindName("NumberTable", cp1);
                    var tbtype1 = (TextBlock)dt1.FindName("TypeTable", cp1);

                    rt1.Fill = Brushes.White;
                }

                for (int j = 0; j < EmptyStandard8PersonTables.Count; j++)
                {
                    ListViewItem lvi2 = ListViewEmptyStandard8PersonTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp2  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi2);

                    var dt2     = cp2.ContentTemplate as DataTemplate;
                    var rt2     = (Rectangle)dt2.FindName("BackGround", cp2);
                    var tb2     = (TextBlock)dt2.FindName("NumberTable", cp2);
                    var tbtype2 = (TextBlock)dt2.FindName("TypeTable", cp2);

                    rt2.Fill = Brushes.White;
                }

                for (int j = 0; j < EmptyStandard12PersonTables.Count; j++)
                {
                    ListViewItem lvi3 = ListViewEmptyStandard12PersonTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp3  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi3);

                    var dt3     = cp3.ContentTemplate as DataTemplate;
                    var rt3     = (Rectangle)dt3.FindName("BackGround", cp3);
                    var tb3     = (TextBlock)dt3.FindName("NumberTable", cp3);
                    var tbtype3 = (TextBlock)dt3.FindName("TypeTable", cp3);

                    rt3.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var dt     = cp.ContentTemplate as DataTemplate;
                var rt     = (Rectangle)dt.FindName("BackGround", cp);
                var tb     = (TextBlock)dt.FindName("NumberTable", cp);
                var tbtype = (TextBlock)dt.FindName("TypeTable", cp);


                NumberTable.Text = tb.Text;
                TypeTable.Text   = "Bàn " + tbtype.Text + " người";

                CustomerNameTextBox.IsEnabled = true;
                CustomerPhone.IsEnabled       = true;
                NoteTextBox.IsEnabled         = true;

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }
        private void ListViewPromotion_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                var bc = new BrushConverter();

                for (int j = 0; j < Promotions.Count; j++)
                {
                    ListViewItem lvi1 = ListViewPromotion.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1 = cp1.ContentTemplate as DataTemplate;
                    var rt1 = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1 = (TextBlock)dt1.FindName("NamePromotion", cp1);
                    rt1.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var             dt = cp.ContentTemplate as DataTemplate;
                var             rt = (Rectangle)dt.FindName("BackGround", cp);
                var             tb = (TextBlock)dt.FindName("NamePromotion", cp);
                Model.Promotion promotionSelected = new Model.Promotion();

                foreach (var item in Promotions)
                {
                    if (item.code == tb.Text)
                    {
                        promotionSelected = item;
                        break;
                    }
                }
                ;

                NamePromotion.Text  = promotionSelected.code;
                valuePromotion.Text = promotionSelected.value.ToString();
                if (promotionSelected.type == "percent")
                {
                    TypePromotion.SelectedIndex = 0;
                }
                else
                {
                    TypePromotion.SelectedIndex = 1;
                }
                rulePromotion.Text = promotionSelected.rule;
                if (promotionSelected.active)
                {
                    ActivePromotion.SelectedIndex = 0;
                }
                else
                {
                    ActivePromotion.SelectedIndex = 1;
                }
                id.Text = promotionSelected.id;

                btnUpdate.IsEnabled = true;
                btnDelete.IsEnabled = true;

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }
        private void ListViewFood_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                var bc = new BrushConverter();

                for (int j = 0; j < Foods.Count; j++)
                {
                    ListViewItem lvi1 = ListViewFood.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1 = cp1.ContentTemplate as DataTemplate;
                    var rt1 = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1 = (TextBlock)dt1.FindName("NameFood", cp1);
                    rt1.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var        dt           = cp.ContentTemplate as DataTemplate;
                var        rt           = (Rectangle)dt.FindName("BackGround", cp);
                var        tb           = (TextBlock)dt.FindName("NameFood", cp);
                Model.Food foodSelected = new Model.Food();

                foreach (var item in Foods)
                {
                    if (item.name == tb.Text)
                    {
                        foodSelected = item;
                        break;
                    }
                }
                ;

                NameFood.Text    = foodSelected.name;
                Price.Text       = foodSelected.price;
                Ingredients.Text = foodSelected.ingredients;
                Note.Text        = foodSelected.note;

                if (foodSelected.type == "appetizer")
                {
                    TypeFood.SelectedIndex = 0;
                }
                else if (foodSelected.type == "dish")
                {
                    TypeFood.SelectedIndex = 1;
                }
                else
                {
                    TypeFood.SelectedIndex = 2;
                }

                id.Text = foodSelected.id;

                btnUpdate.IsEnabled = true;
                btnDelete.IsEnabled = true;

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }
        private void ListViewFood_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                ListView ListViewSelected = (ListView)sender;
                var      bc = new BrushConverter();

                for (int j = 0; j < Food1.Count; j++)
                {
                    ListViewItem lvi1 = ListViewFood1.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1 = cp1.ContentTemplate as DataTemplate;
                    var rt1 = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1 = (TextBlock)dt1.FindName("NameFood", cp1);
                    rt1.Fill = Brushes.White;
                }

                for (int j = 0; j < Food2.Count; j++)
                {
                    ListViewItem lvi2 = ListViewFood2.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp2  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi2);

                    var dt2 = cp2.ContentTemplate as DataTemplate;
                    var rt2 = (Rectangle)dt2.FindName("BackGround", cp2);
                    var tb2 = (TextBlock)dt2.FindName("NameFood", cp2);
                    rt2.Fill = Brushes.White;
                }

                for (int j = 0; j < Food3.Count; j++)
                {
                    ListViewItem lvi3 = ListViewFood3.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp3  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi3);

                    var dt3 = cp3.ContentTemplate as DataTemplate;
                    var rt3 = (Rectangle)dt3.FindName("BackGround", cp3);
                    var tb3 = (TextBlock)dt3.FindName("NameFood", cp3);
                    rt3.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var dt = cp.ContentTemplate as DataTemplate;
                var rt = (Rectangle)dt.FindName("BackGround", cp);
                var tb = (TextBlock)dt.FindName("NameFood", cp);
                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");

                if (ListViewSelected.Name == "ListViewFood1")
                {
                    foreach (var item in Food1)
                    {
                        if (item.name == tb.Text)
                        {
                            foodSelected = item;
                            break;
                        }
                    }
                }
                else if (ListViewSelected.Name == "ListViewFood2")
                {
                    foreach (var item in Food2)
                    {
                        if (item.name == tb.Text)
                        {
                            foodSelected = item;
                            break;
                        }
                    }
                }
                else
                {
                    foreach (var item in Food3)
                    {
                        if (item.name == tb.Text)
                        {
                            foodSelected = item;
                            break;
                        }
                    }
                }

                string result = API.AddFoodInBill(tableSelected.number, foodSelected);
                if (result == "")
                {
                    return;
                }
                dynamic stuffAddFood = JsonConvert.DeserializeObject(result);

                if (stuffAddFood.message != "successfull")
                {
                    MessageBox.Show("Có lỗi sảy ra, vui lòng thử lại!!!");
                }
                else
                {
                    MessageBox.Show("Thêm món thành công!!!");
                    UpdateBillLayout();
                    rt.Fill = Brushes.White;
                }
            }
        }
        private void ListViewUsingStandardTable_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                ListView ListViewSelected = (ListView)sender;

                var bc = new BrushConverter();

                for (int j = 0; j < UsingStandard4PersonTables.Count; j++)
                {
                    ListViewItem lvi1 = ListViewUsingStandard4PersonTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1         = cp1.ContentTemplate as DataTemplate;
                    var rt1         = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1         = (TextBlock)dt1.FindName("NumberTable", cp1);
                    var tbtype1     = (TextBlock)dt1.FindName("TypeTable", cp1);
                    var tbcustomer1 = (TextBlock)dt1.FindName("CustomerName", cp1);

                    rt1.Fill = Brushes.White;
                }

                for (int j = 0; j < UsingStandard8PersonTables.Count; j++)
                {
                    ListViewItem lvi2 = ListViewUsingStandard8PersonTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp2  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi2);

                    var dt2 = cp2.ContentTemplate as DataTemplate;
                    var rt2 = (Rectangle)dt2.FindName("BackGround", cp2);
                    var tb2 = (TextBlock)dt2.FindName("NumberTable", cp2);

                    rt2.Fill = Brushes.White;
                }

                for (int j = 0; j < UsingStandard12PersonTables.Count; j++)
                {
                    ListViewItem lvi3 = ListViewUsingStandard12PersonTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp3  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi3);

                    var dt3 = cp3.ContentTemplate as DataTemplate;
                    var rt3 = (Rectangle)dt3.FindName("BackGround", cp3);
                    var tb3 = (TextBlock)dt3.FindName("NumberTable", cp3);

                    rt3.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var dt = cp.ContentTemplate as DataTemplate;
                var rt = (Rectangle)dt.FindName("BackGround", cp);
                var tb = (TextBlock)dt.FindName("NumberTable", cp);

                if (ListViewSelected.Name == "ListViewUsingStandard4PersonTable")
                {
                    foreach (var item in UsingStandard4PersonTables)
                    {
                        if (item.number == tb.Text)
                        {
                            tableSelected = item;
                            break;
                        }
                    }
                }
                else if (ListViewSelected.Name == "ListViewUsingStandard8PersonTable")
                {
                    foreach (var item in UsingStandard8PersonTables)
                    {
                        if (item.number == tb.Text)
                        {
                            tableSelected = item;
                            break;
                        }
                    }
                }
                else
                {
                    foreach (var item in UsingStandard12PersonTables)
                    {
                        if (item.number == tb.Text)
                        {
                            tableSelected = item;
                            break;
                        }
                    }
                }

                UpdateBillLayout();

                AddFood.IsEnabled             = true;
                BtnPay.IsEnabled              = true;
                DiscountCodeTextBox.IsEnabled = true;

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }
Esempio n. 12
0
        private void ListViewTable_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                var bc = new BrushConverter();

                for (int j = 0; j < Tables.Count; j++)
                {
                    ListViewItem lvi1 = ListViewTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1 = cp1.ContentTemplate as DataTemplate;
                    var rt1 = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1 = (TextBlock)dt1.FindName("NumberTable", cp1);
                    rt1.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var         dt            = cp.ContentTemplate as DataTemplate;
                var         rt            = (Rectangle)dt.FindName("BackGround", cp);
                var         tb            = (TextBlock)dt.FindName("NumberTable", cp);
                Model.Table tableSelected = new Model.Table();

                foreach (var item in Tables)
                {
                    if (item.number == tb.Text)
                    {
                        tableSelected = item;
                        break;
                    }
                }
                ;

                NumberTable.Text  = tableSelected.number;
                CustomerName.Text = tableSelected.customer.fullName;
                Phone.Text        = tableSelected.customer.phone;
                if (tableSelected.type == "standard")
                {
                    TypeTable.SelectedIndex = 0;
                }
                else
                {
                    TypeTable.SelectedIndex = 1;
                }

                if (tableSelected.numberOfSeat == 4)
                {
                    NumberOfSeat.SelectedIndex = 0;
                }
                else if (tableSelected.numberOfSeat == 8)
                {
                    NumberOfSeat.SelectedIndex = 1;
                }
                else
                {
                    NumberOfSeat.SelectedIndex = 2;
                }

                if (tableSelected.status == "empty")
                {
                    Status.SelectedIndex = 0;
                }
                else
                {
                    Status.SelectedIndex = 1;
                }
                Note.Text = tableSelected.note;
                ID.Text   = tableSelected.id;

                btnUpdate.IsEnabled = true;
                btnDelete.IsEnabled = true;

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }