Exemplo n.º 1
0
 private void btnAddToAccount_Click(object sender, EventArgs e)
 {
     if (btnAddToAccount.Enabled)
     {
         if (lstProducts.SelectedIndex != -1)
         {
             Product     p = lstProducts.SelectedItem as Product;
             AccountItem a = new AccountItem(p, (int)numQuantity.Value);
             lstItems.Items.Add(a);
             calculateTotal();
         }
     }
 }
Exemplo n.º 2
0
        public void calculateTotal()
        {
            float total        = 0;
            float totalWithTax = 0;

            foreach (object obj in lstItems.Items)
            {
                AccountItem i = obj as AccountItem;
                total += (i.Product.Price * i.Quantity);
            }
            totalWithTax = total * (float)(1 + numTax.Value / 100);
            //danokot se dobiva so pretvaranje na procentot + 1
            tbTotal.Text    = string.Format("{0:#.##}", total.ToString());
            tbPaycheck.Text = string.Format("{0:#.##}", totalWithTax.ToString());
        }