Пример #1
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            try
            {

                foreach (ListViewItem item in listView.SelectedItems)
                {
                    int id = Convert.ToInt16(item.Tag);
                    Customer customer = new Customer(id);
                    if (customer.InvoiceCount == 0)
                    {
                        if (MessageBox.Show(this, "Are you sure you want to delete " + customer.Name + "?", Properties.Settings.Default.companyname, MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                        {
                            customer.Delete();
                            loadList();
                        }
                    }
                    else
                    {
                        Tools.ShowInfo("Customer has " + customer.InvoiceCount + " invoices, can not delete this customer");
                    }
                }
            }
            catch (Exception ex)
            {
                Tools.ShowError("Unable to delete customer\n" + ex.Message);
            }
        }
Пример #2
0
        public Statement(Customer customer, Boolean zeroBased, DateTime startdate, DateTime enddate)
        {
            this.customer = customer;
            this.zerobased = zeroBased;
            this.filtered = true;
            this.startdate = startdate;
            this.enddate = enddate;
            this.openingbalance = 0;
            this.closingbalance = customer.Balance;
            try
            {
                String start_datetimestring = startdate.Year + "-" + startdate.Month + "-" + startdate.Day;
                String end_datetimestring = enddate.Year + "-" + enddate.Month + "-" + enddate.Day;
                dal = new Dal();
                HashSet<Hashtable> results = dal.executeAsHashset("call getStatementByCustomerAndDate(" + this.customer.Id + ", '" + start_datetimestring + "', '" + end_datetimestring + "');");
                populateFromResults(results);

                HashSet<Hashtable> openingresults = dal.executeAsHashset("call getCustomerBalanceByDate(" + this.customer.Id + ", '" + start_datetimestring + "');");
                populateOpeningFromResults(openingresults);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to load statement for customer by id " + this.customer.Id, ex);
            }
        }
Пример #3
0
        public customerForm(Context context)
        {
            this.context = context;

            InitializeComponent();
            customer = new Customer();
            populateFields();
        }
Пример #4
0
        public customerForm(Context context, Customer customer)
        {
            this.context = context;

            InitializeComponent();
            this.customer = customer;
            populateFields();
        }
Пример #5
0
        public statementForm(Context context, Customer customer, DateTime startdate, DateTime enddate)
        {
            this.context = context;

            InitializeComponent();

            this.statement = new Statement(customer, false, startdate, enddate);
            populateFields();
        }
Пример #6
0
        public statementForm(Context context, Customer customer, Boolean zerobased)
        {
            this.context = context;

            InitializeComponent();

            this.statement = new Statement(customer, zerobased);
            populateFields();
        }
Пример #7
0
        public paymentForm(Context context, Customer customer)
        {
            this.context = context;

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

            populateFields();
        }
Пример #8
0
        public paymentForm(Context context, Invoice invoice)
        {
            this.context = context;

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

            populateFields();
        }
Пример #9
0
 public Invoice()
 {
     try
     {
         customer = new Customer();
         datetime = DateTime.Now;
     }
     catch (Exception ex)
     {
         throw new Exception("Unable to load invoice", ex);
     }
 }
Пример #10
0
        public static Customer[] listCustomers()
        {
            Customer[] customers = new Customer[0];

            Dal dal = new Dal();
            HashSet<Hashtable> results = dal.executeAsHashset("call listCustomers();");
            customers = new Customer[results.Count];
            int counter = 0;
            foreach (Hashtable table in results)
            {
                Customer customer = new Customer(table);
                customers[counter] = customer;
                counter++;
            }
            return customers;
        }
Пример #11
0
 public Statement(Customer customer, Boolean zeroBased)
 {
     this.customer = customer;
     this.zerobased = zeroBased;
     try
     {
         this.openingbalance = 0;
         this.closingbalance = customer.Balance;
         dal = new Dal();
         HashSet<Hashtable> results = dal.executeAsHashset("call getStatementByCustomerAndDate(" + this.customer.Id + ", null, null);");
         populateFromResults(results);
     }
     catch (Exception ex)
     {
         throw new Exception("Unable to load statement for customer by id " + this.customer.Id, ex);
     }
 }
Пример #12
0
 public Payment(Invoice Invoice)
 {
     this.invoice = Invoice;
     this.customer = invoice.Customer;
 }
Пример #13
0
        private void buttonEmail_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (ListViewItem item in listView.SelectedItems)
                {
                    int id = Convert.ToInt16(item.Tag);
                    Customer customer = new Customer(id);
                    if (!customer.EmailAddress.Equals(""))
                    {
                        DateTime enddate = DateTime.Now;
                        DateTime begindate = DateTime.Now.AddMonths(-1);
                        begindate = new DateTime(begindate.Year, begindate.Month, 1);
                        Statement statement = new Statement(customer, true, begindate, enddate);

                        Email email = new Email();
                        if (email.Send(customer.EmailAddress, customer.Name, "MeulenFoods Statement: " + begindate.ToShortDateString() + "-" + enddate.ToShortDateString(), statement.EmailHTML))
                        {
                            Tools.ShowInfo("Statement email sent to " + customer.Name + " [" + 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 customer\n" + ex.Message);
            }
        }
Пример #14
0
 private void editSelection()
 {
     try
     {
         if(Security.allowCustomerManagement(this.context.User)){
             foreach (ListViewItem item in listView.SelectedItems)
             {
                 int id = Convert.ToInt16(item.Tag);
                 Customer customer = new Customer(id);
                 customerForm form = new customerForm(this.context, customer);
                 form.ShowDialog(this);
                 loadList();
             }
         }
     }
     catch (Exception ex)
     {
         Tools.ShowError("Unable to load customer\n" + ex.Message);
     }
 }
Пример #15
0
 private void buttonStatement_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (ListViewItem item in listView.SelectedItems)
         {
             int id = Convert.ToInt16(item.Tag);
             Customer customer = new Customer(id);
             statementSearchForm form = new statementSearchForm(this.context, customer);
             form.ShowDialog(this);
         }
     }
     catch (Exception ex)
     {
         Tools.ShowError("Unable to load customer to load statement\n" + ex.Message);
     }
 }
Пример #16
0
 private void buttonPayment_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Are you sure you want to pay the customer without selecting a invoice?", "Payment direct to customer", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             foreach (ListViewItem item in listView.SelectedItems)
             {
                 int id = Convert.ToInt16(item.Tag);
                 Customer customer = new Customer(id);
                 paymentForm form = new paymentForm(this.context, customer);
                 form.ShowDialog(this);
                 loadList();
             }
         }
     }
     catch (Exception ex)
     {
         Tools.ShowError("Unable to load customer to perform payment\n" + ex.Message);
     }
 }
Пример #17
0
 private void populateCustomerFields(Customer customer)
 {
     comboBoxCustomers.Text = customer.Name;
     textBoxStreet.Text = customer.Street;
     textBoxCity.Text = customer.City;
     textBoxZip.Text = customer.Zipcode;
     textBoxVat.Text = customer.VatNumber;
     textBoxPhone.Text = customer.Phone;
     textBoxFax.Text = customer.Fax;
     textBoxContact.Text = customer.Contact;
     textBoxEmail.Text = customer.EmailAddress;
     comboBoxPaymentType.SelectedIndex = Convert.ToInt16(customer.PaymentType);
     calculateDueDate();
     loadListReps(customer.Rep);
 }
Пример #18
0
 public Payment(Customer Customer)
 {
     this.customer = Customer;
 }