コード例 #1
0
        void ExecuteLoadIncomesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Incomes.Clear();
                var incomes = DataStore.Get(true).OrderByDescending(x => x.Date);
                foreach (var item in incomes)
                {
                    item.BackgroundColor = Color.FromRgb(104, 222, 45);
                    Incomes.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    Incomes.Clear();
                    Outcomes.Clear();
                }

                // TODO: освободить неуправляемые ресурсы (неуправляемые объекты) и переопределить ниже метод завершения.
                Incomes    = null;
                Outcomes   = null;
                IncomeSum  = 0;
                OutcomeSum = 0;

                disposedValue = true;
            }
        }
コード例 #3
0
        private void SetStat()
        {
            var fromTxt = dpFrom.Text;
            var toTxt   = dpTo.Text;

            if (fromTxt == "")
            {
                fromTxt = "1200-01-01";
            }

            if (toTxt == "")
            {
                toTxt = "3000-01-01";
            }

            var from = Convert.ToDateTime(fromTxt);
            var to   = Convert.ToDateTime(toTxt);

            var inc = Database.GetIncomes(from, to);
            var exp = Database.GetExpenses(from, to);

            Incomes.Clear();
            Expenses.Clear();

            decimal expenses = 0;
            decimal incomes  = 0;

            foreach (var el in exp)
            {
                Expenses.Add(el);
                expenses += el.Amount;
            }
            foreach (var el in inc)
            {
                Incomes.Add(el);
                incomes += el.Amount;
            }

            decimal profit = incomes - expenses;

            tblockIncome.Text       = incomes.ToString();
            tblockIncome.Foreground = Brushes.Green;

            tblockExpense.Text       = expenses.ToString();
            tblockExpense.Foreground = Brushes.Red;

            tbProfit.Text       = profit.ToString();
            tbProfit.Foreground = Brushes.Black;

            if (profit > 0)
            {
                tbProfit.Foreground = Brushes.Green;
                tbProfitName.Text   = "Прибыль";
            }

            if (profit < 0)
            {
                tbProfitName.Text   = "Убыток";
                tbProfit.Foreground = Brushes.Red;
            }
            if (profit == 0)
            {
                tbProfitName.Text   = "В ноль";
                tbProfit.Foreground = Brushes.Black;
            }
        }