Example #1
0
        Payment GetDefaultTransaction(Person p)
        {
            Payment pay = p.Payments.FirstOrDefault(t => t.Name == "Default");

            if (pay == null)
            {
                pay = new Payment("Default", p);
            }
            return(pay);
        }
Example #2
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            Person  selected = GetSelectedPerson();
            Payment payment  = GetDefaultTransaction(selected);
            Product product  = new Product("New product", 100, payment, new List <Person>());
            Product edited   = ItemEditor.Edit(product, persons);

            if (edited != null)
            {
                Recalculate();
                RefreshItems();
                RefreshPersons();
                RefreshButtons();
                RefreshSummary();
                SaveData();

                SelectPerson(selected);
                SelectProduct(edited);
            }
            else
            {
                product.Transaction = null;
            }
        }