public WindowMakeCreditNota(Invoice invoice) { InitializeComponent(); this.invoice = invoice; TextBoxCustomer.Text = invoice.Order.Customer.CompanyName; TextBoxDateOfDelivery.Text = invoice.DateOfDelivery.ToString(); TextBoxFormOfDelivery.Text = invoice.FormOfDelivery; TextBoxFormOfPayment.Text = invoice.FormOfPayment; Orderlines.ItemsSource = orderlineRepository.DisplayOrderlines(invoice.Order); TextBoxTotalPrice.Text = invoice.Order.TotalPrice.ToString(); }
private void ComboBoxOffers_SelectionChanged(object sender, SelectionChangedEventArgs e) { int comboBoxNumber = ComboBoxOffers.SelectedIndex - 1; if (comboBoxNumber != -1) { order = nonActiveOrders[comboBoxNumber]; TextBoxCustomer.Text = $"{order.Customer.CompanyName}"; TextBoxDateOfPurchase.Text = $"{order.DateOfPurchase}"; TextBoxTotalPrice.Text = $"{order.TotalPrice}"; Orderlines.ItemsSource = orderlineRepository.DisplayOrderlines(order); RadioButtonIsOrder.IsChecked = true; RadioButtonIsOffer.IsEnabled = false; } else { order = new Order(); TextBoxCustomer.Text = $""; TextBoxDateOfPurchase.Text = $""; TextBoxTotalPrice.Text = $""; Orderlines.ItemsSource = null; RadioButtonIsOrder.IsChecked = false; RadioButtonIsOffer.IsChecked = false; RadioButtonIsOffer.IsEnabled = true; } }
private void ComboBoxOrders_SelectionChanged(object sender, SelectionChangedEventArgs e) { int comboBoxNumber = ComboBoxOrders.SelectedIndex - 1; if (comboBoxNumber != -1) { List <Order> tempList = new List <Order>(); for (int i = 0; i < activeOrders.Count; i++) { int index = invoices.FindIndex(item => item.Order.OrderID == activeOrders[i].OrderID); if (index < 0) { tempList.Add(activeOrders[i]); } } invoice.Order = tempList[comboBoxNumber]; TextBoxCustomer.Text = $"{invoice.Order.Customer.CompanyName}"; TextBoxTotalPrice.Text = $"{invoice.Order.TotalPrice}"; Orderlines.ItemsSource = orderlineRepository.DisplayOrderlines(invoice.Order); } else { invoice.Order = new Order(); TextBoxCustomer.Text = $""; TextBoxTotalPrice.Text = $""; Orderlines.ItemsSource = null; } }
private void ButtonYes_Click(object sender, RoutedEventArgs e) { List <Orderline> orderlines = orderlineRepository.DisplayOrderlines(order); for (int i = 0; i < orderlines.Count; i++) { Product product = orderlines[i].Product; product.ProductAmount += orderlines[i].Amount; productRepository.EditProduct(product); orderlineRepository.DeleteOrderline(orderlines[i].OrderlineNumber); } orderRepository.DeleteOrder(order.OrderID); this.Close(); }
private void Update() { orderlines = orderlineRepository.DisplayOrderlines(order); Orderlines.ItemsSource = orderlines; CollectionViewSource.GetDefaultView(Orderlines.ItemsSource).Refresh(); }