Exemple #1
0
        private void PrevMonth_Click(object sender, RoutedEventArgs e)
        {
            if (AllMonthExp.monthCount > 0)
            {
                AllMonthExp.monthObjectsList[AllMonthExp.monthCount] = AllExp;
                AllMonthInc.monthObjectsList[AllMonthExp.monthCount] = AllInc;

                File.WriteAllText("MonthsExp.json", JsonConvert.SerializeObject(AllMonthExp));
                File.WriteAllText("MonthsInc.json", JsonConvert.SerializeObject(AllMonthInc));

                AllMonthExp = JsonConvert.DeserializeObject <monthsExp>(File.ReadAllText("MonthsExp.json"));
                AllMonthInc = JsonConvert.DeserializeObject <monthsInc>(File.ReadAllText("MonthsInc.json"));
                AllMonthExp.monthCount--;

                AllExp = JsonConvert.DeserializeObject <Exp>(AllMonthExp.monthObjectsList[AllMonthExp.monthCount].ToString());
                AllInc = JsonConvert.DeserializeObject <Inc>(AllMonthInc.monthObjectsList[AllMonthExp.monthCount].ToString());

                AllExp.showExpsOnMain(CarExpLabel, HouseExpLabel, sportExpLabel, EatExpLabel,
                                      RestaurantExpLabel, HobbiesExpLabel, BuyExpLabel, HealthExpLabel, allExpValue,
                                      allExpValueIncExp);
                AllInc.showIncOnMain(SalaryIncLabel, FreelanceIncLabel, SellIncLabel, RentIncLabel,
                                     allExpValueIncomes, allIncValue);

                CurMonth.Content = months[AllExp.dateOfCreation.Month - 1].ToString() + ' ' + AllExp.dateOfCreation.Year;
                File.WriteAllText("MonthsExp.json", JsonConvert.SerializeObject(AllMonthExp));

                LightArrows();
            }
        }
Exemple #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try {
                DateTime now = DateTime.Now;

                if (Convert.ToInt32(AllMonthExp.currentMonth) != now.Month)
                {
                    AllMonthExp.currentMonth = now.Month;

                    AllMonthExp.monthCount += 1;

                    AllMonthExp.monthObjectsList.Add(AllExp);
                    AllMonthInc.monthObjectsList.Add(AllInc);

                    CurMonth.Content = months[now.Month - 1].ToString() + ' ' + now.Year;
                    AllExp.showExpsOnMain(CarExpLabel, HouseExpLabel, sportExpLabel, EatExpLabel,
                                          RestaurantExpLabel, HobbiesExpLabel, BuyExpLabel, HealthExpLabel, allExpValue,
                                          allExpValueIncExp);
                    AllInc.showIncOnMain(SalaryIncLabel, FreelanceIncLabel, SellIncLabel, RentIncLabel,
                                         allExpValueIncomes, allIncValue);

                    File.WriteAllText("MonthsExp.json", JsonConvert.SerializeObject(AllMonthExp));
                    File.WriteAllText("MonthsInc.json", JsonConvert.SerializeObject(AllMonthInc));
                }
                else
                {
                    AllExp = JsonConvert.DeserializeObject <Exp>(AllMonthExp.monthObjectsList.Last().ToString());
                    AllInc = JsonConvert.DeserializeObject <Inc>(AllMonthInc.monthObjectsList.Last().ToString());

                    AllExp.showExpsOnMain(CarExpLabel, HouseExpLabel, sportExpLabel, EatExpLabel,
                                          RestaurantExpLabel, HobbiesExpLabel, BuyExpLabel, HealthExpLabel, allExpValue,
                                          allExpValueIncExp);
                    AllInc.showIncOnMain(SalaryIncLabel, FreelanceIncLabel, SellIncLabel, RentIncLabel,
                                         allExpValueIncomes, allIncValue);

                    CurMonth.Content = months[AllExp.dateOfCreation.Month - 1].ToString() + ' ' + AllExp.dateOfCreation.Year;
                }
                LightArrows();
            } catch
            {
                MessageBox.Show("Сбой работы программы");
            }
        }