private void btnSaveInvoice_Click(object sender, RoutedEventArgs e) { // MessageBox.Show("Plik nie istnieje", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error); Invoice invoice = new Invoice(); invoice.SellerData = tbSellerData.Text; invoice.BuyerData = tbBuyerData.Text; invoice.IssueDate = tbIssueDate.SelectedDate; InvoiceFileService.SaveInvoiceFile(invoice); DBService.InsertInvoice(invoice); if (!string.IsNullOrEmpty(tbProductName1.Text)) { InvoiceItem invoiceItem = new InvoiceItem() { Name = tbProductName1.Text, AmountNet = Convert.ToDouble(tbAmount1.Text) }; invoiceItem.SetAmountNet(Convert.ToDouble(tbNettoPrice1.Text)); invoiceItem.SetVatRate(Convert.ToInt32(tbVat1.Text)); invoiceItem.CalculateGrossAmount(); } if (!string.IsNullOrEmpty(tbProductName2.Text)) { InvoiceItem invoiceItem = new InvoiceItem() { Name = tbProductName2.Text, AmountNet = Convert.ToDouble(tbAmount2.Text) }; invoiceItem.SetAmountNet(Convert.ToDouble(tbNettoPrice2.Text)); invoiceItem.SetVatRate(Convert.ToInt32(tbVat2.Text)); invoiceItem.CalculateGrossAmount(); } }