public PDFCreator(Invoice invoice) { this.invoice = invoice; this.client = invoice.Client; this.owner = invoice.Owner; this.products = invoice.products; }
public Invoice(string date, string invoicenumber, Client client, Owner owner, List<Product> products) { this.Date = date; this.Client = client; this.Owner = owner; this.products = products; this.NumberOfInvoice = invoicenumber; this.ClientId = client.Id; this.OwnerId = owner.Id; }
/// <summary> /// Adding new Client to database /// </summary> /// <param name="name">Client name</param> /// <param name="address">Client address</param> /// <param name="nip">Client NIP</param> private void AddClientToDatabase(string name, string address, string city, string postcode, string nip) { var client = new Client(name, address, city, postcode, nip); DBManager.AddClient(client); }
private void btnSaveInvoice_Click(object sender, EventArgs e) { if (CheckEmptyFields() && items.Count != 0) { try { Client client = new Client(txtClientName.Text, txtClientAddress.Text, txtClientCity.Text, txtClientPostCode.Text, txtClientNip.Text); Owner owner = new Owner(txtSellerName.Text, txtSellerAddress.Text, txtSellerCity.Text, txtSellerPostCode.Text, txtSellerNip.Text); invoice = new Invoice(dtpDate.Text, txtNumber.Text, client, owner, products); DBManager.SaveInvoice(invoice); MessageBox.Show("Zapisano fakturę w systemie"); } catch (Exception err) { MessageBox.Show(err.ToString()); } } else { MessageBox.Show("Wprowadź wszystkie dane!"); } }
private void btnCreatePDF_Click(object sender, EventArgs e) { if (CheckEmptyFields() && items.Count != 0) { try { Client client = new Client(txtClientName.Text, txtClientAddress.Text, txtClientCity.Text, txtClientPostCode.Text, txtClientNip.Text); Owner owner = new Owner(txtSellerName.Text, txtSellerAddress.Text, txtSellerCity.Text, txtSellerPostCode.Text, txtSellerNip.Text); invoice = new Invoice(dtpDate.Text, txtNumber.Text, client, owner, products); PDFCreator creator = new PDFCreator(invoice); creator.CreatePDF(); } catch (Exception err) { MessageBox.Show(err.ToString()); } } else { MessageBox.Show("Wprowadź wszystkie dane.", "Błąd"); } }
//Adding client to DB public static void AddClient(Client client) { using (var context = new FakturyContext()) { context.Clients.Add(client); context.SaveChanges(); } }