private void buttonEmail_Click(object sender, EventArgs e) { try { foreach (ListViewItem item in listView.SelectedItems) { int id = Convert.ToInt16(item.Tag); Invoice invoice = new Invoice(id); if (!invoice.Customer.EmailAddress.Equals("")) { Email email = new Email(); if (email.Send(invoice.Customer.EmailAddress, invoice.Customer.Name, "MeulenFoods Invoice " + invoice.Id, invoice.HTMLEmail)) { Tools.ShowInfo("Invoice email sent to " + invoice.Customer.Name + " [" + invoice.Customer.EmailAddress + "]"); } else { Tools.ShowError(email.ErrorMessage); } } else { Tools.ShowInfo("Customer does not have a email address, update the customer email address first."); } } } catch (Exception ex) { Tools.ShowError("Unable to load invoice to perform email\n" + ex.Message); } }
public static Invoice[] listInvoices(DateTime startDate, DateTime endDate, String customer) { Invoice[] invoices = new Invoice[0]; Dal dal = new Dal(); String startdate = startDate.Year + "-" + startDate.Month + "-" + startDate.Day; String enddate = endDate.Year + "-" + endDate.Month + "-" + endDate.Day; String query = ""; if ((customer != null)&&(!customer.Equals(""))) { query = "call listInvoicesByDateAndCustomer('" + startdate + "','" + enddate + "','%" + customer + "%');"; } else { query = "call listInvoicesByDateAndCustomer('" + startdate + "','" + enddate + "',null);"; } HashSet<Hashtable> results = dal.executeAsHashset(query); invoices = new Invoice[results.Count]; int counter = 0; DateTime now = DateTime.Now; foreach (Hashtable table in results) { Invoice invoice = new Invoice(table); invoices[counter] = invoice; counter++; } DateTime after = DateTime.Now; //now.Subtract(after) return invoices; }
public paymentForm(Context context, Invoice invoice) { this.context = context; InitializeComponent(); this.invoice = invoice; this.customer = invoice.Customer; payment = new Payment(invoice); populateFields(); }
public static Invoice[] listInvoices() { Invoice[] invoices = new Invoice[0]; Dal dal = new Dal(); HashSet<Hashtable> results = dal.executeAsHashset("call listInvoices();"); invoices = new Invoice[results.Count]; int counter = 0; foreach (Hashtable table in results) { Invoice invoice = new Invoice(table); invoices[counter] = invoice; counter++; } return invoices; }
public invoiceForm(Context context, Invoice invoice) { this.context = context; InitializeComponent(); this.invoice = invoice; searchcustomers = Manager.listSearchCustomers(); loadCustomersList(); buttonSave.Enabled = buttonSavePrint.Enabled = Security.allowInvoiceManagement(context.User); buttonAddProduct.Enabled = buttonEditProduct.Enabled = buttonRemoveProduct.Enabled = Security.allowInvoiceManagement(context.User); populateInvoiceFields(invoice); loadListProducts(); populateCustomerFields(invoice.Customer); }
public invoiceForm(Context context) { this.context = context; InitializeComponent(); invoice = new Invoice(); searchcustomers = Manager.listSearchCustomers(); loadCustomersList(); enableCustomerFields(); buttonPrint.Visible = buttonSave.Visible = Security.allowInvoiceManagement(context.User); populateInvoiceFields(invoice); loadListProducts(); populateCustomerFields(invoice.Customer); }
private void buttonDelete_Click(object sender, EventArgs e) { try{ foreach (ListViewItem item in listView.SelectedItems) { int id = Convert.ToInt16(item.Tag); Invoice invoice = new Invoice(id); if(MessageBox.Show(this, "Are you sure you want to delete " + invoice.Id + "?", Properties.Settings.Default.companyname, MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes)) { invoice.Delete(); loadList(); } } } catch (Exception ex) { Tools.ShowError("Unable to delete invoice\n" + ex.Message); } }
private void editSelection() { try { foreach (ListViewItem item in listView.SelectedItems) { int id = Convert.ToInt16(item.Tag); Invoice invoice = new Invoice(id); invoiceForm form = new invoiceForm(this.context, invoice); form.ShowDialog(this); loadList(); } } catch (Exception ex) { Tools.ShowError("Unable to load invoice\n" + ex.Message); } }
private void buttonPrint_Click(object sender, EventArgs e) { try { foreach (ListViewItem item in listView.SelectedItems) { int id = Convert.ToInt16(item.Tag); Invoice invoice = new Invoice(id); Printer printer = new Printer(this.context, this); printer.PrintPreview(invoice.HTML); } } catch (Exception ex) { Tools.ShowError("Unable to print invoice\n" + ex.Message); } }
private void buttonPayment_Click(object sender, EventArgs e) { try { foreach (ListViewItem item in listView.SelectedItems) { int id = Convert.ToInt16(item.Tag); Invoice invoice = new Invoice(id); paymentForm form = new paymentForm(this.context, invoice); form.ShowDialog(this); loadList(); } } catch (Exception ex) { Tools.ShowError("Unable to load invoice to perform payment\n" + ex.Message); } }
private void buttonFinalize_Click(object sender, EventArgs e) { try { foreach (ListViewItem item in listView.SelectedItems) { int id = Convert.ToInt16(item.Tag); Invoice invoice = new Invoice(id); if(MessageBox.Show("Are you sure you want to " + buttonFinalize.Text + " the invoice " + invoice.Id + "?", "Finalize/Unfinalize Invoice", MessageBoxButtons.YesNo, MessageBoxIcon.Question)==DialogResult.Yes){ invoice.Finalized = buttonFinalize.Text.Equals("Finalize") ? true : false; invoice.Save(); loadList(); } } } catch (Exception ex) { Tools.ShowError("Unable to load invoice to perform finalize\n" + ex.Message); } }
private void populateInvoiceFields(Invoice invoice) { dateTimePickerInvoiceDate.Value = invoice.Date; textBoxInstructions.Text = invoice.Instructions; }
public Payment(Invoice Invoice) { this.invoice = Invoice; this.customer = invoice.Customer; }