Ejemplo n.º 1
0
        private void BtnSaveOrder_Click(object sender, RoutedEventArgs e)
        {
            if (customer != null)
            {
                if (selectedBooks.Any())
                {
                    if (MessageBox.Show("Do you want to add this order?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                    {
                        Order order = new Order();
                        order.CustomerId = customer.Id;
                        order.TakedDate  = DateTime.Today;
                        dr.AddOrder(order);
                        RentedBook rentedBook = new RentedBook();
                        foreach (SelectedBook book in selectedBooks)
                        {
                            rentedBook.BookId     = book.Id;
                            rentedBook.OrderId    = order.Id;
                            rentedBook.ReturnDate = book.ReturnDate;
                            rentedBook.CalcPrice  = book.CalcPrice;
                            rentedBook.Price      = book.Price;
                            dr.RentBook(book.Id);
                            dr.AddRentBook(rentedBook);
                        }
                    }
                    this.Close();
                }


                else
                {
                    MessageBox.Show("You not selected Book!!!");
                }
            }
            else
            {
                MessageBox.Show("You not selected Customer!!!");
            }
        }