예제 #1
0
 private void clear_but_Click(object sender, EventArgs e)
 {
     FIOField.Clear();
     NOCField.Clear();
     CostField.Clear();
     Debt.Clear();
     checkBox1.Checked = false;
     checkBox2.Checked = false;
     comboBox1.Text    = "";
 }
예제 #2
0
        /// <summary>
        /// Calculates the costs of claim and debt
        /// </summary>
        public void CostCalculation()
        {
            // CLAIM
            Claim.Clear();
            foreach (Purchase purchase in Session.Household.Purchases)
            {
                if (purchase.UserPayed.Contains(Session.User.Name))
                {
                    foreach (string user in purchase.UsersInvolved)
                    {
                        if (user != Session.User.Name)
                        {
                            if (!purchase.UsersInvolvedPayed.Contains(user))
                            {
                                if (!_claim_dictionary.ContainsKey(user))
                                {
                                    _claim_dictionary.Add(user, purchase.Price / purchase.UsersInvolved.Count);
                                }
                                else
                                {
                                    _claim_dictionary[user] += (purchase.Price / purchase.UsersInvolved.Count);
                                }
                            }
                        }
                    }
                }
            }
            foreach (KeyValuePair <string, double> entry in _claim_dictionary)
            {
                Claim.Add(new UserClaim()
                {
                    Name = entry.Key, Total = entry.Value
                });
                Netto += entry.Value;
            }

            // DEBT
            Debt.Clear();
            foreach (Purchase purchase in Session.Household.Purchases)
            {
                if (purchase.UsersInvolved.Contains(Session.User.Name) && !purchase.UsersInvolvedPayed.Contains(Session.User.Name))
                {
                    if (!_debt_dictionary.ContainsKey(purchase.UserPayed))
                    {
                        _debt_dictionary.Add(purchase.UserPayed, purchase.Price / purchase.UsersInvolved.Count);
                    }
                    else
                    {
                        _debt_dictionary[purchase.UserPayed] += (purchase.Price / purchase.UsersInvolved.Count);
                    }
                }
            }
            foreach (KeyValuePair <string, double> entry in _debt_dictionary)
            {
                Debt.Add(new UserDebt()
                {
                    Name = entry.Key, Total = entry.Value
                });
                Netto -= entry.Value;
            }
        }