コード例 #1
0
        public decimal TotalGoldBalance()
        {
            DailyExpenses expenses = this.EarningsAndExpenses[1] as DailyExpenses;
            DailyEarnings earnings = this.EarningsAndExpenses[0] as DailyEarnings;

            if (expenses == null || earnings == null)
            {
                return(0m);
            }
            return(earnings.TotalMoneyEarned() - expenses.TotalMoneySpent());
        }
コード例 #2
0
 public DailyGoldBalance()
 {
     this.earnings            = new DailyEarnings();
     this.expenses            = new DailyExpenses();
     this.EarningsAndExpenses = new ObservableCollection <GoldBalance>()
     {
         this.earnings, this.expenses
     };
     foreach (var item in this.EarningsAndExpenses)
     {
         item.SetOwner(this);
     }
     this.Date = DateUtils.GetTodaysDate();
 }
コード例 #3
0
        public GoldBalancePage()
        {
            this.InitializeComponent();
            this.mainWindow = Application.Current.Windows.OfType <MainWindow>().ElementAt(0);
            #region TREEVIEW_TEST
#if DEBUG
            DailyGoldBalance balance = new DailyGoldBalance();
            DailyExpenses    expense = new DailyExpenses();
            DailyEarnings    earning = new DailyEarnings();
            expense.BoughtItems.Add(new Item("Arrow Shaft", 20, 24));
            earning.Add(new Item("Arrow Shaft", 40, 80));
            balance.EarningsAndExpenses.Add(earning);
            balance.EarningsAndExpenses.Add(expense);
            mainWindow.DailyGoldBalances.Add(balance);
            this.GoldBalanceView.ItemsSource = mainWindow.DailyGoldBalances;
#endif
            #endregion
        }
コード例 #4
0
        //overrides and operators
        public override string ToString()
        {
            StringBuilder sb       = new StringBuilder();
            DailyExpenses expenses = this.EarningsAndExpenses[1] as DailyExpenses;
            DailyEarnings earnings = this.EarningsAndExpenses[0] as DailyEarnings;

            if (expenses == null || earnings == null)
            {
                return("");
            }
            sb.Append("Total gold balance for ");
            sb.Append(this.Date);
            sb.Append(":\n");
            if (earnings.SoldItems.Count <= 0 && expenses.BoughtItems.Count <= 0)
            {
                sb.Append("No data");
            }
            else
            {
                if (earnings.SoldItems.Count > 0)
                {
                    sb.Append("- ");
                    sb.Append("Earnings: ");
                    sb.Append(earnings.TotalMoneyEarned().ToString("#,##0"));
                    sb.Append("gp\n");
                }
                if (expenses.BoughtItems.Count > 0)
                {
                    sb.Append("- ");
                    sb.Append("Expenses: ");
                    sb.Append(expenses.TotalMoneySpent().ToString("#,##0"));
                    sb.Append("gp\n");
                }
                sb.Append("Total balance: ");
                sb.Append(this.TotalGoldBalance().ToString("#,##0"));
                sb.Append("gp\n");
            }
            return(sb.ToString());
        }