private void InvoiceButton_Click(object sender, EventArgs e) { if (added.Count() <= 0 || ClientTextBoxt.Text == "") { MakeMessage("Favor completar la informacion correctamente."); } else { Invoice invoice = new Invoice(added, ClientTextBoxt.Text); invoice.calculateAmount(); manager.addProduct(available); manager.addInvoice(invoice); MakeMessage("Factura creada, ver en listar."); } cancel(); }
public void addInvoice(Invoice invoice) { List<Invoice> Invoices = new List<Invoice>(); ; Invoices = Deserialize(InvoiceFilePath) as List<Invoice>; if (Invoices != null) { InvoiceId += Invoices.Count() + 1; } else { Invoices = new List<Invoice>(); InvoiceId += 1; } invoice.Id = InvoiceId; Invoices.Add(invoice); Stream write = File.Open(InvoiceFilePath, FileMode.Create); Serializer.Serialize(write, Invoices); write.Close(); }