protected void btnAddItem_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
                return;

            if (InvoiceData.GetInvoiceData().InvoiceItems.Count >= 100)
            {
                lblInvoiceTemplateMessage.Text = "The maximum number of items reached.";
                lblInvoiceTemplateMessage.Visible = true;
                return;
            }

            InvoiceItem newInvoiceItem = new InvoiceItem(textBoxProductCode.Text, textBoxProductDescription.Text,
                textBoxProductName.Text, double.Parse(textBoxProductPrice.Text.Trim()), int.Parse(textBoxProductQuantity.Text.Trim()));

            InvoiceData.GetInvoiceData().AddItem(newInvoiceItem);

            ShowItemsCount();
            LoadInvoiceItems();
        }
Example #2
0
 public void AddItem(InvoiceItem invoiceItem)
 {
     invoiceItems.Add(invoiceItem);
     totalInvoice += invoiceItem.ItemPrice;
 }