Esempio n. 1
0
        private void calculateTotals()
        {
            Double subtotal = 0;
            double vat      = 0;

            invoice.Products = new InvoiceProduct[listView1.Items.Count];
            int counter = 0;

            foreach (ListViewItem item in listView1.Items)
            {
                InvoiceProduct product = new InvoiceProduct();
                product.Name     = item.SubItems[1].Text;
                product.Price    = Convert.ToDouble(item.SubItems[2].Text);
                product.Quantity = Convert.ToDouble(item.Text);

                subtotal += Double.Parse(item.SubItems[3].Text);
                vat      += Double.Parse(item.SubItems[4].Text);
                if (vat > 0)
                {
                    product.HasVat = true;
                }

                invoice.Products[counter] = product;
                counter++;
            }

            textBoxSubTotal.Text   = Utilities.MakeMoneyValue(System.Math.Round(subtotal, 2));
            textBoxVATTotal.Text   = Utilities.MakeMoneyValue(System.Math.Round(vat, 2));
            textBoxGrandTotal.Text = Utilities.MakeMoneyValue(System.Math.Round(subtotal + vat, 2));
        }
Esempio n. 2
0
        public selectProductForm(Context context, InvoiceProduct invoiceproduct)
        {
            this.context = context;

            InitializeComponent();

            searchproducts = Manager.listSearchProducts();
            loadProductsList();

            this.invoiceproduct = invoiceproduct;
            populateFields(invoiceproduct);
        }
Esempio n. 3
0
        public selectProductForm(Context context, InvoiceProduct invoiceproduct)
        {
            this.context = context;

            InitializeComponent();

            searchproducts = Manager.listSearchProducts();
            loadProductsList();

            this.invoiceproduct = invoiceproduct;
            populateFields(invoiceproduct);
        }
Esempio n. 4
0
 private void populateProductsFromResults(HashSet <Hashtable> results)
 {
     if (results.Count > 0)
     {
         this.products = new InvoiceProduct[results.Count];
         int counter = 0;
         foreach (Hashtable table in results)
         {
             products[counter] = new InvoiceProduct(table);
             counter++;
         }
     }
 }
Esempio n. 5
0
        private ListViewItem createItem(InvoiceProduct invoiceproduct)
        {
            ListViewItem item = new ListViewItem();

            item.Text = invoiceproduct.Quantity.ToString();
            item.SubItems.Add(invoiceproduct.Name);
            item.SubItems.Add(Utilities.MakeMoneyValue(invoiceproduct.Price));
            item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round(invoiceproduct.Price * invoiceproduct.Quantity, 2)));
            Double vat = 0;

            if (invoiceproduct.HasVat)
            {
                vat = invoiceproduct.Price * invoiceproduct.Quantity * 14 / 100;
            }
            item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round(vat, 2)));
            item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round((invoiceproduct.Quantity * invoiceproduct.Price) + vat, 2)));
            return(item);
        }
Esempio n. 6
0
        private void addProduct()
        {
            selectProductForm form = new selectProductForm(context);

            form.ShowDialog(this);

            InvoiceProduct invoiceproduct = form.InvoiceProduct;

            if (!invoiceproduct.Name.Equals(""))
            {
                ListViewItem item = new ListViewItem();
                listView1.Items.Add(createItem(invoiceproduct));
                calculateTotals();
            }
            enableDelete((listView1.SelectedItems.Count > 0));
            enableEdit((listView1.SelectedItems.Count > 0));
            showHint();
        }
Esempio n. 7
0
        private void editSelection()
        {
            try
            {
                foreach (ListViewItem item in listView1.SelectedItems)
                {
                    InvoiceProduct invoiceproduct = new InvoiceProduct();
                    invoiceproduct.Quantity = Convert.ToDouble(item.Text);
                    invoiceproduct.Name     = item.SubItems[1].Text.ToString();
                    invoiceproduct.Price    = Convert.ToDouble(item.SubItems[2].Text);

                    selectProductForm form = new selectProductForm(this.context, invoiceproduct);
                    form.ShowDialog(this);
                    invoiceproduct = form.InvoiceProduct;
                    if (!invoiceproduct.Name.Equals(""))
                    {
                        item.SubItems.Clear();
                        item.Text = invoiceproduct.Quantity.ToString();
                        item.SubItems.Add(invoiceproduct.Name);
                        item.SubItems.Add(Utilities.MakeMoneyValue(invoiceproduct.Price));
                        item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round(invoiceproduct.Price * invoiceproduct.Quantity, 2)));
                        Double vat = 0;
                        if (invoiceproduct.HasVat)
                        {
                            vat = invoiceproduct.Price * invoiceproduct.Quantity * 14 / 100;
                        }
                        item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round(vat, 2)));
                        item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round((invoiceproduct.Quantity * invoiceproduct.Price) + vat, 2)));
                        calculateTotals();
                    }
                }
                enableDelete((listView1.SelectedItems.Count > 0));
                enableEdit((listView1.SelectedItems.Count > 0));
                showHint();
            }
            catch (Exception ex)
            {
                Tools.ShowError("Unable to load product\n" + ex.Message);
            }
        }
Esempio n. 8
0
 private void populateFields(InvoiceProduct product)
 {
     comboBoxProducts.Text = product.Name;
     textBoxPrice.Text = product.Price.ToString();
     textBoxQuantity.Text = product.Quantity.ToString();
 }
Esempio n. 9
0
 private void populateProductsFromResults(HashSet<Hashtable> results)
 {
     if (results.Count > 0)
     {
         this.products = new InvoiceProduct[results.Count];
         int counter = 0;
         foreach (Hashtable table in results)
         {
             products[counter] = new InvoiceProduct(table);
             counter++;
         }
     }
 }
Esempio n. 10
0
 private void populateFields(InvoiceProduct product)
 {
     comboBoxProducts.Text = product.Name;
     textBoxPrice.Text     = product.Price.ToString();
     textBoxQuantity.Text  = product.Quantity.ToString();
 }
Esempio n. 11
0
        private void editSelection()
        {
            try
            {
                foreach (ListViewItem item in listView1.SelectedItems)
                {
                    InvoiceProduct invoiceproduct = new InvoiceProduct();
                    invoiceproduct.Quantity = Convert.ToDouble(item.Text);
                    invoiceproduct.Name = item.SubItems[1].Text.ToString();
                    invoiceproduct.Price = Convert.ToDouble(item.SubItems[2].Text);

                    selectProductForm form = new selectProductForm(this.context, invoiceproduct);
                    form.ShowDialog(this);
                    invoiceproduct = form.InvoiceProduct;
                    if (!invoiceproduct.Name.Equals(""))
                    {
                        item.SubItems.Clear();
                        item.Text = invoiceproduct.Quantity.ToString();
                        item.SubItems.Add(invoiceproduct.Name);
                        item.SubItems.Add(Utilities.MakeMoneyValue(invoiceproduct.Price));
                        item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round(invoiceproduct.Price * invoiceproduct.Quantity, 2)));
                        Double vat = 0;
                        if (invoiceproduct.HasVat)
                        {
                            vat = invoiceproduct.Price * invoiceproduct.Quantity * 14 / 100;
                        }
                        item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round(vat, 2)));
                        item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round((invoiceproduct.Quantity * invoiceproduct.Price) + vat, 2)));
                        calculateTotals();
                    }
                }
                enableDelete((listView1.SelectedItems.Count > 0));
                enableEdit((listView1.SelectedItems.Count > 0));
                showHint();
            }
            catch (Exception ex)
            {
                Tools.ShowError("Unable to load product\n" + ex.Message);
            }
        }
Esempio n. 12
0
 private ListViewItem createItem(InvoiceProduct invoiceproduct)
 {
     ListViewItem item = new ListViewItem();
     item.Text = invoiceproduct.Quantity.ToString();
     item.SubItems.Add(invoiceproduct.Name);
     item.SubItems.Add(Utilities.MakeMoneyValue(invoiceproduct.Price));
     item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round(invoiceproduct.Price*invoiceproduct.Quantity,2)));
     Double vat = 0;
     if (invoiceproduct.HasVat)
     {
         vat = invoiceproduct.Price * invoiceproduct.Quantity * 14 / 100;
     }
     item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round(vat, 2)));
     item.SubItems.Add(Utilities.MakeMoneyValue(System.Math.Round((invoiceproduct.Quantity * invoiceproduct.Price)+vat, 2)));
     return item;
 }
Esempio n. 13
0
        private void calculateTotals()
        {
            Double subtotal = 0;
            double vat = 0;
            invoice.Products = new InvoiceProduct[listView1.Items.Count];
            int counter = 0;
            foreach (ListViewItem item in listView1.Items)
            {
                InvoiceProduct product = new InvoiceProduct();
                product.Name = item.SubItems[1].Text;
                product.Price = Convert.ToDouble(item.SubItems[2].Text);
                product.Quantity = Convert.ToDouble(item.Text);

                subtotal += Double.Parse(item.SubItems[3].Text);
                vat += Double.Parse(item.SubItems[4].Text);
                if (vat > 0) product.HasVat = true;

                invoice.Products[counter] = product;
                counter++;
            }

            textBoxSubTotal.Text = Utilities.MakeMoneyValue(System.Math.Round(subtotal,2));
            textBoxVATTotal.Text = Utilities.MakeMoneyValue(System.Math.Round(vat,2));
            textBoxGrandTotal.Text = Utilities.MakeMoneyValue(System.Math.Round(subtotal + vat,2));
        }