private void Button_Finish(object sender, RoutedEventArgs e)
        {
            if (usernId == 0)
            {
                MessageBox.Show("You have to log in before manage order!");
                return;
            }
            if (orderLinesToOrder.Count == 0)
            {
                MessageBox.Show("You have to add products to order before finish it!");
                return;
            }

            BankAccountService.BankAccountB bank = new BankAccountService.BankAccountB();
            bank = bankClient.GetBankAccountById(userBankAccId);

            if (totalPrice > bank.Amount)
            {
                MessageBox.Show("Your balance is less than the total price, you have to remove some order lines!");
                return;
            }

            OrderService.Order order = new OrderService.Order();
            order.OrderDate = DateTime.Now;
            order.UserId    = usernId;

            int orderId = orderClient.CreateOrderAndReturnId(order);

            foreach (OrderLineService.OrderLine line in orderLinesToOrder)
            {
                line.OrderID = orderId;
                orderLineClient.UpdateOrderLine(line);
            }

            bool pay = true;

            pay = bankClient.donateMoneyToAllDisasters(totalPrice, userBankAccId);

            if (pay)
            {
                MessageBox.Show("Your order was paid!");
            }

            MessageBox.Show("Your order was finished!");

            listBox.SelectedItem            = null;
            listBox_OrderLines.SelectedItem = null;
            listBox_OrderLines.Items.Clear();
            orderLinesToOrder = null;
            this.Content      = null;
            ShopPage refreshPage = new ShopPage(userInfoData);

            NavigationService.Navigate(refreshPage);
        }
Esempio n. 2
0
        private void btn_Shop(object sender, RoutedEventArgs e)
        {
            ShopPage shopPage = new ShopPage(userInfoData);

            mainFrame.Navigate(shopPage);
        }