private Boolean saveInvoice() { Boolean success = false; if (!comboBoxCustomers.Text.Equals("") && !textBoxVat.Text.Equals("") && !textBoxContact.Text.Equals("") && !textBoxPhone.Text.Equals("")) { Customer customer = invoice.Customer; if (Security.allowCustomerManagement(context.User)) { if (customer.Id == 0) { customer.Name = comboBoxCustomers.Text; } customer.Street = textBoxStreet.Text; customer.City = textBoxCity.Text; customer.Zipcode = textBoxZip.Text; customer.Phone = textBoxPhone.Text; customer.Fax = textBoxFax.Text; customer.VatNumber = textBoxVat.Text; customer.Contact = textBoxContact.Text; customer.EmailAddress = textBoxEmail.Text; customer.PaymentType = (PaymentType)comboBoxPaymentType.SelectedIndex; customer.Rep = (User)comboBoxRep.Items[comboBoxRep.SelectedIndex]; customer.Save(); } if (invoice.Customer.Id != 0) { if ((invoice.Id == 0) || (invoice.CreatedBy.Equals(""))) { invoice.CreatedBy = context.User.Username; } invoice.Date = dateTimePickerInvoiceDate.Value; invoice.Instructions = textBoxInstructions.Text; invoice.PaymentDue = (PaymentType)comboBoxPaymentType.SelectedIndex; invoice.Save(); success = true; } else { Tools.ShowError("Customer name required"); } } else { Tools.ShowError("All mandatory fields required"); } return(success); }
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 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); } }