public string createFaktura(Sprzedaz nowyRekordSprzedazy, Controler controler) { var exportFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string nazwa = nowyRekordSprzedazy.nr_dok.Replace('/', '_'); var exportFile = System.IO.Path.Combine(fakturyPath + nazwa + ".pdf"); controler.Klienci.TryGetValue(controler.KlientID, out Klient klient); try { using (var writer = new PdfWriter(exportFile)) { using (var pdf = new PdfDocument(writer)) { var doc = new Document(pdf);; ImageData imageData = ImageDataFactory.Create("LOGO.png"); Image image = new Image(imageData).ScaleAbsolute(100, 100).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.RIGHT); doc.Add(image); var naglowek = new Paragraph("Faktura " + nowyRekordSprzedazy.nr_dok).SetRelativePosition(200, 0, 200, 0); doc.Add(naglowek); doc.Add(new Paragraph("Kupujacy:" + klient.nazwa)); doc.Add(new Paragraph("Adres:" + klient.adres)); doc.Add(new Paragraph("NIP/REGON:" + klient.NIP)); doc.Add(new Paragraph("Data:" + nowyRekordSprzedazy.data)); var table = new Table(new float[] { 2, 6, 4, 4 }); table.SetWidth(UnitValue.CreatePercentValue(100)); table.AddHeaderCell(new Cell().Add(new Paragraph("Nr"))); table.AddHeaderCell(new Cell().Add(new Paragraph("Produkt"))); table.AddHeaderCell(new Cell().Add(new Paragraph("Cena"))); table.AddHeaderCell(new Cell().Add(new Paragraph("Vat"))); int numerator = 1; foreach (int id_prod in nowyRekordSprzedazy.tabIDs) { controler.Asortyment.TryGetValue(id_prod, out Przedmiot rzecz); table.AddCell(new Cell().Add(new Paragraph(numerator.ToString()))); table.AddCell(new Cell().Add(new Paragraph(rzecz.nazwa))); table.AddCell(new Cell().Add(new Paragraph(rzecz.cena.ToString()))); table.AddCell(new Cell().Add(new Paragraph((rzecz.cena * rzecz.VAT / 100).ToString()))); numerator++; } table.AddCell(new Cell().Add(new Paragraph(""))); table.AddCell(new Cell().Add(new Paragraph(""))); table.AddCell(new Cell().Add(new Paragraph(nowyRekordSprzedazy.kwotaNetto + "zl"))); table.AddCell(new Cell().Add(new Paragraph(nowyRekordSprzedazy.podatekVat + "zl"))); doc.Add(table); doc.Add(new Paragraph("Kwota netto:" + nowyRekordSprzedazy.kwotaNetto + "zl").SetRelativePosition(400, 0, 0, 0)); doc.Add(new Paragraph("Podatek:" + nowyRekordSprzedazy.podatekVat + "zl").SetRelativePosition(400, 0, 0, 0)); doc.Add(new Paragraph("PDF created with itext7 under AGPL license").SetFixedPosition(0, 0, 300)); doc.Close(); } } } catch (Exception e) { MessageBox.Show("Blad tworzenia pdf'a " + e.ToString()); } return(exportFile); }
public MainWindow(Controler controler) { InitializeComponent(); _controler = controler; fillDataGrid(); }
public void usunZKoszykCena(int index, Controler controler) { controler.Asortyment.TryGetValue(index, out Przedmiot linia); controler.KoszykSuma = controler.KoszykSuma - linia.cena; controler.koszykPodatek = controler.koszykPodatek - (linia.cena * linia.VAT / 100); }
public Obsługa(Controler controler) { InitializeComponent(); _controler = controler; }