private void SendMessage()
 {
     try
     {
         TcpClient tcp  = new TcpClient(Properties.Settings.Default.server, 80);
         var       json = new JObject();
         json.Add("MSGType", 2);
         json.Add("Id", "2211");
         json.Add("ShopName", "맥도날드");
         json.Add("Group", true);
         json.Add("OrderNumber", OrderNumOp(Customer.getInstance().order_idx));
         var menus = new JArray();
         int max   = OrderState.GetInstance().Count;
         for (int i = 0; i < max; i++)
         {
             OrderState orderMenus = OrderState.GetInstance()[i];
             var        menu       = new JObject();
             menu.Add("Name", orderMenus.Menu);
             menu.Add("Count", orderMenus.Amount);
             menu.Add("Price", orderMenus.Price);
             menus.Add(menu);
         }
         json.Add("Menus", menus);
         byte[]        buff    = Encoding.UTF8.GetBytes(json.ToString());
         NetworkStream network = tcp.GetStream();
         network.Write(buff, 0, buff.Length);
     } catch (SocketException)
     {
         MessageBox.Show("서버와 연결이 되지 않습니다.");
     }
 }
Exemple #2
0
        private void BeforeButton_Click(object sender, RoutedEventArgs e)
        {
            SelectPayment selectPayment = new SelectPayment();

            if (NavigationService.CanGoBack)
            {
                if (OrderState.GetInstance().Count > 0)
                {
                    MessageBoxResult m = MessageBox.Show("선택하신 모든 메뉴가 삭제됩니다.", "이전 페이지로 가시겠습니까?", MessageBoxButton.YesNo);
                    if (m == MessageBoxResult.Yes)
                    {
                        OrderState.GetInstance().Clear();
                        NavigationService.GoBack();
                        return;
                    }
                    else if (m == MessageBoxResult.No)
                    {
                        return;
                    }
                }
                else
                {
                    NavigationService.GoBack();
                }
            }
        }
Exemple #3
0
        private void DeleteAllButton_Click(object sender, RoutedEventArgs e)
        {
            // 모두삭제 버튼
            void DeleteAllMenu()
            {
                OrderState.GetInstance().Clear();
                lvAddedMenu.Items.Refresh();

                OrderButton.IsEnabled     = false;
                DeleteAllButton.IsEnabled = false;
            }

            if (OrderState.GetInstance().Count > 0)
            {
                MessageBoxResult m = MessageBox.Show("선택하신 모든 메뉴가 삭제됩니다.", "모두 삭제 하시겠습니까?", MessageBoxButton.YesNo);
                if (m == MessageBoxResult.Yes)
                {
                    DeleteAllMenu();
                    return;
                }
                else if (m == MessageBoxResult.No)
                {
                    return;
                }
            }
            else
            {
                DeleteAllMenu();
            }
        }
Exemple #4
0
        private void ListView_Load(object sender, RoutedEventArgs e)
        {
            ListView listview = sender as ListView;

            //OrderState.GetInstance().Add(new OrderState() { Menu = "불고기 버거", Price = 3000, Amount = 2, Total = 6000 });
            //OrderState.GetInstance().Add(new OrderState() { Menu = "새우 버거", Price = 3500, Amount = 1, Total = 3500 });
            listview.ItemsSource = OrderState.GetInstance();
        }
        private void Label_Loaded(object sender, RoutedEventArgs e)
        {
            Label label        = (Label)sender;
            float totalPayment = 0;

            for (int i = 0; i < OrderState.GetInstance().Count; i++)
            {
                totalPayment += OrderState.GetInstance()[i].Total;
            }
            label.Content = "총 결제 금액 : " + totalPayment;
        }
        private void InsertAllData()
        {
            var customer = Customer.getInstance();
            var order    = OrderState.GetInstance();

            mysqlDB.InsertData(customer.order_idx, customer.user_idx, customer.tableNum, customer.isCard);

            for (int i = 0; i < order.Count; i++)
            {
                mysqlDB.InsertData(order[i].Menu_idx, customer.order_idx, order[i].Amount, order[i].Total);
            }
        }
Exemple #7
0
        private void MenuDeleteButton_Click(object sender, RoutedEventArgs e)
        {
            OrderState BtnMenu = (sender as Button).DataContext as OrderState;

            for (int i = 0; i < OrderState.GetInstance().Count; i++)
            {
                if (OrderState.GetInstance()[i].Menu.Equals(BtnMenu.Menu))
                {
                    OrderState.GetInstance().Remove(OrderState.GetInstance()[i]);
                    CheckLvAddedMenuEmpty();
                }
            }
            lvAddedMenu.Items.Refresh();
        }
Exemple #8
0
        private void MenuAddButton_Click(object sender, RoutedEventArgs e)
        {
            OrderState BtnMenu = (sender as Button).DataContext as OrderState;

            for (int i = 0; i < OrderState.GetInstance().Count; i++)
            {
                if (OrderState.GetInstance()[i].Menu.Equals(BtnMenu.Menu))
                {
                    OrderState.GetInstance()[i].Amount++;
                    OrderState.GetInstance()[i].Total = OrderState.GetInstance()[i].Amount * OrderState.GetInstance()[i].Price;
                }
            }
            lvAddedMenu.Items.Refresh();
        }
Exemple #9
0
 private void CheckLvAddedMenuEmpty()
 {
     // 선택된 메뉴가 없을시 버튼 비활성화
     if (OrderState.GetInstance().Count <= 0)
     {
         SetButtonEnable(OrderButton, false);
         SetButtonEnable(DeleteAllButton, false);
         return;
     }
     else
     {
         SetButtonEnable(OrderButton, true);
         SetButtonEnable(OrderButton, true);
         return;
     }
 }
Exemple #10
0
        private void MenuMinusButton_Click(object sender, RoutedEventArgs e)
        {
            OrderState BtnMenu = (sender as Button).DataContext as OrderState;

            for (int i = 0; i < OrderState.GetInstance().Count; i++)
            {
                if (OrderState.GetInstance()[i].Menu.Equals(BtnMenu.Menu) && OrderState.GetInstance()[i].Amount > 1)
                {
                    OrderState.GetInstance()[i].Amount--;
                    OrderState.GetInstance()[i].Total = OrderState.GetInstance()[i].Amount * OrderState.GetInstance()[i].Price;
                }
                else if (OrderState.GetInstance()[i].Menu.Equals(BtnMenu.Menu))
                {
                    OrderState.GetInstance().Remove(OrderState.GetInstance()[i]);
                    CheckLvAddedMenuEmpty();
                }
            }
            lvAddedMenu.Items.Refresh();
        }
 private void HomeButton_Click(object sender, RoutedEventArgs e)
 {
     if (OrderState.GetInstance().Count > 0)
     {
         MessageBoxResult m = MessageBox.Show("선택하신 모든 메뉴가 삭제됩니다.", "이전 페이지로 가시겠습니까?", MessageBoxButton.YesNo);
         if (m == MessageBoxResult.Yes)
         {
             OrderMenuPage order = new OrderMenuPage();
             OrderState.GetInstance().Clear();
             //MainContent.Navigate(new Uri("Home.xaml", UriKind.Relative));
             MainContent.Navigate(new Home());
         }
     }
     else
     {
         OrderState.GetInstance().Clear();
         //MainContent.Navigate(new Uri("Home.xaml", UriKind.Relative));
         MainContent.Navigate(new Home());
     }
 }
Exemple #12
0
        private void lbMenus_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            bool isExist = false;
            Food food    = lbMenus.SelectedItem as Food;

            SetButtonEnable(OrderButton, true);
            SetButtonEnable(DeleteAllButton, true);

            if (lbMenus.SelectedIndex == -1)
            {
                return;
            }

            for (int i = 0; i < OrderState.GetInstance().Count; i++)
            {
                if (OrderState.GetInstance()[i].Menu.Equals(food.Name))
                {
                    isExist = true;
                    OrderState.GetInstance()[i].Amount++;
                    OrderState.GetInstance()[i].Total = OrderState.GetInstance()[i].Amount * OrderState.GetInstance()[i].Price;
                }
            }
            if (!isExist)
            {
                OrderState.GetInstance().Add(new OrderState()
                {
                    category = food.category,
                    Menu     = food.Name,
                    Price    = food.Price,
                    Amount   = 1,
                    Total    = food.Price,
                    Menu_idx = food.Menu_idx
                });
            }

            lbMenus.UnselectAll();
            lvAddedMenu.ItemsSource = OrderState.GetInstance();
            lvAddedMenu.Items.Refresh();
        }
 private void DataReset()
 {
     OrderState.GetInstance().Clear();
 }
Exemple #14
0
        private void OrderMenuPage_Loaded(object sender, RoutedEventArgs e)
        {
            lvAddedMenu.ItemsSource = OrderState.GetInstance();
            lvAddedMenu.Items.Refresh();

            // 주문하기, 모두 삭제 버튼 enabled false로 초기화
            if (OrderState.GetInstance().Count == 0)
            {
                SetButtonEnable(OrderButton, false);
                SetButtonEnable(DeleteAllButton, false);
            }
            else
            {
                SetButtonEnable(OrderButton, true);
                SetButtonEnable(DeleteAllButton, true);
            }

            // 카테고리별 리스트 아이템 추가
            for (int i = 0; i < menuList.Count; i++)
            {
                Debug.WriteLine(i);
                if (menuList[i].category.Equals(Category.BUGER))
                {
                    bugerList.Add(new OrderMenu.Food()
                    {
                        Price    = menuList[i].Price,
                        Name     = menuList[i].Name,
                        ImgPath  = menuList[i].ImgPath,
                        Menu_idx = menuList[i].Menu_idx,
                        Amount   = menuList[i].Amount
                    });
                }
                else if (menuList[i].category.Equals(Category.SIDE))
                {
                    sideList.Add(new OrderMenu.Food()
                    {
                        Price    = menuList[i].Price,
                        Name     = menuList[i].Name,
                        ImgPath  = menuList[i].ImgPath,
                        Menu_idx = menuList[i].Menu_idx,
                        Amount   = menuList[i].Amount
                    });
                }
                else if (menuList[i].category.Equals(Category.DRINK))
                {
                    drinkList.Add(new OrderMenu.Food()
                    {
                        Price    = menuList[i].Price,
                        Name     = menuList[i].Name,
                        ImgPath  = menuList[i].ImgPath,
                        Menu_idx = menuList[i].Menu_idx,
                        Amount   = menuList[i].Amount
                    });
                }
                else
                {
                    // 아무것도 선택되지 않으면 버거 리스트를
                    bugerList.Add(new OrderMenu.Food()
                    {
                        Price    = menuList[i].Price,
                        Name     = menuList[i].Name,
                        ImgPath  = menuList[i].ImgPath,
                        Menu_idx = menuList[i].Menu_idx,
                        Amount   = menuList[i].Amount
                    });
                }
            }
            MenuPageButton_Click(sender, e);
        }