예제 #1
0
 public PDFCreator(Invoice invoice)
 {
     this.invoice = invoice;
     this.client = invoice.Client;
     this.owner = invoice.Owner;
     this.products = invoice.products;
 }
예제 #2
0
 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!");
     }
         
 }
예제 #3
0
 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");
     }
    
 }
예제 #4
0
        //Saving invoice
        public static void SaveInvoice(Invoice invoiceToSave)
        {
            using (var context = new FakturyContext())
            {
                var client = context.Clients
                    .Where(n => n.NIP == invoiceToSave.Client.NIP)
                    .First();

                var owner = context.Owners
                    .Where(n => n.NIP == invoiceToSave.Owner.NIP)
                    .First();
                Invoice invoice = new Invoice(invoiceToSave.Date, invoiceToSave.NumberOfInvoice, client, owner, invoiceToSave.products);

                context.Invoices.Add(invoice);
                context.SaveChanges();
            }
        }