public ShowWindow(Invoice inv) { Text = "Förhandsgranskning - Faktura"; Width = 561; Height = 770; invoice = inv; Paint += DrawInvoice; }
public PrintInvoice(Invoice inv) { invoice = inv; }
public EditWindow(Invoice invoice, string file, InvoiceDirectory idir_, InvoicesChanged cb) : base(WindowType.Toplevel) { loadedFile = file; idir = idir_; callback = cb; VBox box = new VBox(false, 0); table = new Table(7, 3, false); Table tablespec = new Table(16, 4, false); tablesum = new Table(4, 2, false); HButtonBox buttons = new HButtonBox(); Button save = Button.NewWithLabel("Spara"); Button abort = Button.NewWithLabel("Avbryt"); namn = new Entry(); address = new Entry(); postnr = new Entry(); postort = new Entry(); referens = new Entry(); datum = new Entry(); fakturanr = new Entry(); antaldgr = new Entry(); ScrolledWindow scrolled = new ScrolledWindow(); Button GetAddress = Button.NewWithLabel("Slå upp address"); Add(box); scrolled.AddWithViewport(tablespec); scrolled.SetPolicy(PolicyType.Never, PolicyType.Automatic); box.PackStart(table, false, false, 0); box.PackStart(scrolled, true, true, 0); scrolled.SetUsize(~1, 250); box.PackStart(tablesum, false, false, 0); box.PackStart(buttons, false, false, 0); buttons.PackStart(save); buttons.PackStart(abort); specs = new Spec[15]; for (uint i=0; i<15; i++) { specs[i] = new Spec(invoice.specs[i], tablespec, i + 1); specs[i].Changed += RecalcSum; } tablespec.Attach(new Label("Beskrivning"), 0, 1, 0, 1, 0, 0, 0, 0); tablespec.Attach(new Label("Antal"), 1, 2, 0, 1, 0, 0, 0, 0); tablespec.Attach(new Label("À pris"), 2, 3, 0, 1, 0, 0, 0, 0); tablespec.Attach(new Label("Belopp"), 3, 4, 0, 1, 0, 0, 0, 0); SetPosition(WindowPosition.Center); namn.Changed += UpdateTitle; fakturanr.Changed += UpdateTitle; namn.Text = invoice.namn; address.Text = invoice.address; postnr.Text = invoice.postnr; postort.Text = invoice.postort; referens.Text = invoice.referens; datum.Text = invoice.datum; fakturanr.Text = invoice.fakturanr; antaldgr.Text = invoice.antaldgr; labround = new Label("0"); labsum = new Label("0"); labmoms = new Label("0"); labtot = new Label("0"); RecalcSum(); Attach2(0, "Namn", namn); table.Attach(GetAddress, 2, 3, 0, 1, 0, 0, 0, 0); Attach2(1, "Address", address); Attach2(2, "Postnummer", postnr); Attach2(3, "Postort", postort); Attach2(4, "Er referens", referens); Attach2(5, "Datum", datum); Attach2(6, "Fakturanummer", fakturanr); Attach2(7, "Antal dagar", antaldgr); Attach3(0, "Avrundning", labround); Attach3(1, "Summa", labsum); Attach3(2, "Moms", labmoms); Attach3(3, "Att betala", labtot); abort.Clicked += Abort; save.Clicked += Save; GetAddress.Clicked += FindAddress; box.ShowAll(); }
void Save(object sender, EventArgs args) { Invoice i = new Invoice(fakturanr.Text); i.namn = namn.Text; i.address = address.Text; i.postnr = postnr.Text; i.postort = postort.Text; i.referens = referens.Text; i.datum = datum.Text; i.antaldgr = antaldgr.Text; for (int k=0; k<specs.Length; k++) { i.specs[k].beskrivning = specs[k].description.Text; i.specs[k].antal = specs[k].number.Text; i.specs[k].styckpris = specs[k].price.Text; i.specs[k].belopp = specs[k].total.Text; } if (loadedFile != null) InvoiceDirectory.remove(loadedFile); i.save(idir.PathName(i.fakturanr + " " + i.namn)); callback(); Destroy(); }
void FindAddress(object sender, EventArgs args) { idir.Invoices().ForEach(delegate (string name) { Invoice invoice = new Invoice(); invoice.load(idir.PathName(name)); if (String.Compare(invoice.namn, namn.Text, true) == 0) { address.Text = invoice.address; postnr.Text = invoice.postnr; postort.Text = invoice.postort; referens.Text = invoice.referens; } }); }
private void ShowInvoice(object sender, EventArgs args) { try { string name; if (SelectedInvoice(out name)) { Invoice invoice = new Invoice(); string file = idir.PathName(name); invoice.load(file); ShowWindow sw = new ShowWindow(invoice); sw.Show(); // PrintInvoice printDoc = new PrintInvoice(invoice); // System.Windows.Forms.PrintPreviewDialog dlgPrintPreview = new System.Windows.Forms.PrintPreviewDialog(); // dlgPrintPreview.Document = printDoc; // dlgPrintPreview.WindowState = System.Windows.Forms.FormWindowState.Maximized; // dlgPrintPreview.ShowDialog(); } } catch (System.Exception e) { MessageDialog("Error in " + e.TargetSite + ": " + e.Message); } }
private void PrintInvoice(object sender, EventArgs args) { try { string name; if (SelectedInvoice(out name)) { Invoice invoice = new Invoice(); string file = idir.PathName(name); invoice.load(file); PrintInvoice printDoc = new PrintInvoice(invoice); System.Windows.Forms.PrintDialog dlg = new System.Windows.Forms.PrintDialog(); dlg.AllowSomePages = true; dlg.ShowHelp = true; dlg.Document = printDoc; dlg.PrinterSettings.MinimumPage = 1; dlg.PrinterSettings.MaximumPage = 2; dlg.PrinterSettings.FromPage = 1; dlg.PrinterSettings.ToPage = 2; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { printDoc.Print(); } } } catch (System.Exception e) { MessageDialog("Error in " + e.TargetSite + ": " + e.Message); } }
private void Edit(object sender, EventArgs args) { try { string name; if (SelectedInvoice(out name)) { Invoice invoice = new Invoice(); string file = idir.PathName(name); invoice.load(file); Window editWindow = new EditWindow(invoice, file, idir, UpdateHDList); editWindow.Show(); } } catch (System.Exception e) { MessageDialog("Error in " + e.TargetSite + ": " + e.Message); } }