Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        public paymentForm(Context context, Invoice invoice)
        {
            this.context = context;

            InitializeComponent();
            this.invoice = invoice;
            this.customer = invoice.Customer;
            payment = new Payment(invoice);

            populateFields();
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
 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);
     }
 }
Exemplo n.º 11
0
 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);
     }
 }
Exemplo n.º 12
0
 private void populateInvoiceFields(Invoice invoice)
 {
     dateTimePickerInvoiceDate.Value = invoice.Date;
     textBoxInstructions.Text = invoice.Instructions;
 }
Exemplo n.º 13
0
 public Payment(Invoice Invoice)
 {
     this.invoice = Invoice;
     this.customer = invoice.Customer;
 }