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; }
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 owner to DB public static void AddOwner(Owner owner) { using (var context = new FakturyContext()) { context.Owners.Add(owner); context.SaveChanges(); } }
/// <summary> /// Adding new owner to database /// </summary> /// <param name="name">Owner name</param> /// <param name="address">Owner address</param> /// <param name="nip">Owner NIP</param> private void AddOwnerToDatabase(string name, string address, string city, string postcode, string nip) { var owner = new Owner(name, address, city, postcode, nip); DBManager.AddOwner(owner); }