コード例 #1
0
ファイル: User.cs プロジェクト: ModernOSs/UWP-Project
        // 加入其它list类

        public User(string username, string password)
        {
            this.username = username;
            this.password = password;
            // 后期加入“数据包”
            // 测试数据
            incomesList = new IncomesList();
            goalsList   = new GoalsList();
            incomesList.addIncome(kind.food, "火锅", 120.5, new DateTime(2016, 5, 3), "支出");
            incomesList.addIncome(kind.entertainment, "唱K", 30, new DateTime(2016, 5, 3), "支出");
        }
コード例 #2
0
        private async void initializeData()
        {
            this.incomesList = App.user.incomesList;
            this.goalsList   = App.user.goalsList;
            double incomes = 0, outcomes = 0, todayOutcomes = 0, todayIncomes = 0;

            Debug.WriteLine(incomesList.AllIncomes.Count);
            for (int i = 0; i < incomesList.AllIncomes.Count; i++)
            {
                if (incomesList.AllIncomes.ToArray()[i].date.Month == DateTimeOffset.Now.Month)
                {
                    if (incomesList.AllIncomes.ToArray()[i].inOrOut == "支出")
                    {
                        outcomes += incomesList.AllIncomes.ToArray()[i].amount;
                    }
                    else
                    {
                        incomes += incomesList.AllIncomes.ToArray()[i].amount;
                    }
                }
                if (incomesList.AllIncomes.ToArray()[i].date.Day == DateTimeOffset.Now.Day)
                {
                    if (incomesList.AllIncomes.ToArray()[i].inOrOut == "支出")
                    {
                        todayOutcomes += incomesList.AllIncomes.ToArray()[i].amount;
                    }
                    else
                    {
                        todayIncomes += incomesList.AllIncomes.ToArray()[i].amount;
                    }
                }
            }
            incomesText.Text       = ((int)incomes).ToString();
            outcomesText.Text      = ((int)outcomes).ToString();
            todayOutcomesText.Text = ((int)todayOutcomes).ToString();
            todayIncomesText.Text  = ((int)todayIncomes).ToString();

            int goalsCount = goalsList.AllGoals.Count;

            goalsNumberText.Text = goalsCount.ToString();
            Thickness margin;

            margin.Top     = 440 * outcomes / (incomes + 1) - 220;
            margin.Left    = 0; margin.Right = 0; margin.Bottom = 0;
            webview.Margin = margin;
            webview.Source = new Uri("ms-appx-web:///WaterTank.html");

            double balance = outcomes / incomes;

            if (balance > 1)
            {
                tips.Content = "本月收支严重不平衡,要吃灰啦(>﹏<)";
            }
            else if (balance > 0.8)
            {
                tips.Content = "余额不足20%,要剁手啦~>_<~";
            }
            else if (balance > 0.6)
            {
                tips.Content = "本月余额不足40%,要注意节约哦~";
            }
            else
            {
                tips.Content = "本月财务状况良好,犒劳一下自己吧(*_*)";
            }

            string tempName = goalsList.nameOfFirstUnfinishedGoal();

            if (tempName == "")
            {
                goal.Content = "心愿单里没有未完成的心愿哦,去添加一个吧~";
            }
            else
            {
                goal.Content = "目标" + tempName + "xx还没完成,去给它攥点钱吧~ ";
            }
        }