public FinanceStatisticGroup(StatisticTypeEnum statisticType, string groupName, List <CapitalModel> details, DateTime startDate, DateTime endDate, bool isSortByMonth)
 {
     Init(statisticType, groupName, startDate, endDate, isSortByMonth);
     if (details != null)
     {
         details.Sort();
     }
     DateTime[] spanKeys = GroupDetais.Keys.ToArray();
     foreach (DateTime span in spanKeys)
     {
         if (details == null ||
             details.Count == 0 ||
             span < DateTime.Parse(string.Format("{0}-{1}-1", details[0].GeneralYear, details[0].GeneralMonth)) ||
             span > DateTime.Parse(string.Format("{0}-{1}-1", details[details.Count - 1].GeneralYear, details[details.Count - 1].GeneralMonth)))
         {
             GroupDetais[span] = 0;
         }
         else
         {
             if (isSortByMonth)
             {
                 GroupDetais[span] = details.Where(d => DateTime.Parse(string.Format("{0}-{1}-1", d.GeneralYear, d.GeneralMonth)) <= span).Sum(d => d.Capital);
             }
             else
             {
                 GroupDetais[span] = details.Where(d => DateTime.Parse(string.Format("{0}-{1}-1", d.GeneralYear, d.GeneralMonth)) < span.AddYears(1).AddDays(-1)).Sum(d => d.Capital);
             }
         }
     }
 }
Beispiel #2
0
        public FinanceViewModel(FinanceStatisticBussiness bussiness) : base()
        {
            _bussiness             = bussiness;
            Head                   = new StatisticHeaderViewModel(StatisticFuncEnum.Finance);
            Head.DoSearchingEvent += (statistics, startDate, endDate, isSortedByMonth) =>
            {
                if (CheckValidity(statistics, startDate, endDate))
                {
                    _bussiness.Search(statistics, startDate, endDate, isSortedByMonth);
                }
            };
            Summary = new FinanceSummaryViewModel(bussiness);
            Summary.DeleteRecordEvent += (statisticType, accountID, accountDate, accountItem, accountAmount, note) =>
            {
                _deletedID   = accountID;
                _deletedType = statisticType;
                OperationMsg.Enable(accountDate, accountItem, accountAmount, note);
            };

            OperationMsg = new OperationMessageViewModel(false, "删除");
            OperationMsg.OnOperateEnableEvent(false, false);
            OperationMsg.ConfirmOperationEvent += OnConfirmOperation;

            ColumnColletcion = new SeriesCollection();
            Labels           = new List <string>();
            ChartVis         = Visibility.Hidden;

            _bussiness.FinanceStatisticChangedEvent += OnFinanceStatisticChanged;
            _bussiness.CapitalChangedEvent          += OnCapitalChanged;
        }
        private void Init(StatisticTypeEnum statisticType, string groupName, DateTime startDate, DateTime endDate, bool isSortByMonth)
        {
            GroupName      = groupName;
            StatisticType  = statisticType;
            GroupDetais    = new Dictionary <DateTime, decimal>();
            FinanceDetails = new Dictionary <DateTime, List <T> >();

            GenerateDateInterval(startDate, endDate, isSortByMonth);
        }
 public FinanceRecordViewModel(ClassPaymentModel classPayment, Color recordColor, FinanceStatisticBussiness bussiness)
 {
     _statisticType = StatisticTypeEnum.ClassFee;
     AccountID      = classPayment.PaymentID;
     _classPayment  = classPayment;
     _recordColor   = recordColor;
     RecordItem     = bussiness.GetItemName(classPayment);
     RecordDate     = _classPayment.PaymentDate.ToString("yyyy年MM月dd日");
     RecordAmount   = classPayment.TotalCost.ToString();
     ChangeSelectState(false);
 }
 public FinanceRecordViewModel(TeacherFeeModel teacherFee, Color recordColor, FinanceStatisticBussiness bussiness)
 {
     _statisticType = StatisticTypeEnum.TeacherFee;
     AccountID      = teacherFee.TeacherFeeID;
     _teacherFee    = teacherFee;
     _recordColor   = recordColor;
     RecordItem     = bussiness.GetItemName(teacherFee);
     RecordDate     = _teacherFee.PaymentDate.ToString("yyyy年MM月dd日");
     RecordAmount   = teacherFee.Amount.ToString();
     ChangeSelectState(false);
 }
 public FinanceStatisticGroup(StatisticTypeEnum statisticType, string groupName, List <ClassPaymentModel> details, DateTime startDate, DateTime endDate, bool isSortByMonth)
 {
     Init(statisticType, groupName, startDate, endDate, isSortByMonth);
     DateTime[] spanKeys = GroupDetais.Keys.ToArray();
     foreach (DateTime span in spanKeys)
     {
         GroupDetais[span] = details == null ? 0 : details.Where(d => d.PaymentDate >= span && d.PaymentDate < (isSortByMonth ? span.AddMonths(1) : span.AddYears(1)))
                             .Sum(d => d.TotalCost);
         FinanceDetails[span] = details == null ? null : (List <T>)Convert.ChangeType(
             details.Where(d => d.PaymentDate >= span && d.PaymentDate < (isSortByMonth ? span.AddMonths(1) : span.AddYears(1))).ToList(), typeof(List <T>));
     }
 }
 public FinanceRecordViewModel(AccountInfoModel normalAccount, Color recordColor)
 {
     _statisticType = StatisticTypeEnum.NormalAccount;
     AccountID      = normalAccount.AccountID;
     _normalAccount = normalAccount;
     _recordColor   = recordColor;
     RecordItem     = ItemManagementBussiness.Instance.Items.Where(i => i.ItemID == _normalAccount.ItemID).First().ItemName;
     RecordDate     = _normalAccount.AccountDate.ToString("yyyy年MM月dd日");
     Note           = normalAccount.Notice;
     RecordAmount   = normalAccount.AccountAmount.ToString();
     ChangeSelectState(false);
 }
 public void AddSummaryItem(string itemName, decimal itemAmount, StatisticTypeEnum statisticType, Color color)
 {
     SummaryItems.Add(new FinanceSummaryItemViewModel(itemName, itemAmount, statisticType, color));
     SummaryItems.Last().SummaryItemClickedEvent += (statistic, itemColor) =>
     {
         foreach (FinanceSummaryItemViewModel item in SummaryItems.Where(i => i.Statistic != statistic))
         {
             item.ChangeSelectState(false);
         }
         SummaryItemClickedEvent?.Invoke(statistic, SummaryDate, IsTotal, itemColor);
     };
     ChangeGroupWidth(SummaryItems.Count);
 }
        public void DeletePayment(StatisticTypeEnum deleteType, string deleteID)
        {
            switch (deleteType)
            {
            case StatisticTypeEnum.ClassFee:
                _paymentDal.DelClassPayment(deleteID);
                break;

            case StatisticTypeEnum.TeacherFee:
                _paymentDal.DelTeacherFee(deleteID);
                break;

            default:
                _paymentDal.DelAccountInfo(deleteID);
                break;
            }
            GeneralCapitalChanged?.Invoke(null, EventArgs.Empty);
        }
        private void OnSummaryClicked(StatisticTypeEnum statisticType, DateTime summaryDate, bool isTotal, Color itemColor)
        {
            if (isTotal)
            {
                foreach (FinanceSummaryGroupViewModel item in SummaryGroupCollection)
                {
                    item.ChangeGroupState(false);
                }
            }
            else
            {
                foreach (FinanceSummaryGroupViewModel item in SummaryGroupCollection.Where(s => s.SummaryDate != summaryDate))
                {
                    item.ChangeGroupState(false);
                }
                TotalSummary.ChangeGroupState(false);
            }

            _currentItemColor = itemColor;
            _bussiness.GetDetails(statisticType, summaryDate, isTotal);
        }
Beispiel #11
0
        public FinanceFilterItemViewModel(StatisticTypeEnum statisticType)
        {
            _model   = StatisticTypeManagement.Instance.StatisticTypeCollection.Where(s => s.StatisticType == statisticType).First();
            ItemName = _model.ShownText;
            switch (_model.Catogery)
            {
            case StatisticCategoryEnum.Income:
                BorderColor = GlobalVariables.IncomeColor;
                break;

            case StatisticCategoryEnum.Outcome:
                BorderColor = GlobalVariables.ExpenseColor;
                break;
            }
            if (statisticType == StatisticTypeEnum.Diff)
            {
                BorderColor = GlobalVariables.SecondaryColor;
            }
            if (statisticType == StatisticTypeEnum.Capital)
            {
                BorderColor = GlobalVariables.MainColor;
            }
            Init();
        }
Beispiel #12
0
 private void OnDeleteRecord(StatisticTypeEnum statisticType, string accountID, string accountDate, string accountItem, string accountAmount, string note)
 {
     DeleteRecordEvent?.Invoke(statisticType, accountID, accountDate, accountItem, accountAmount, note);
 }
        public void GetDetails(StatisticTypeEnum statisticType, DateTime summaryDate, bool isTotal)
        {
            List <AccountInfoModel>  normalStatistic;
            List <TeacherFeeModel>   teacherFeeStatistic;
            List <ClassPaymentModel> classpaymentStatistic;

            normalStatistic       = new List <AccountInfoModel>();
            teacherFeeStatistic   = new List <TeacherFeeModel>();
            classpaymentStatistic = new List <ClassPaymentModel>();
            if (isTotal)
            {
                if (statisticType == StatisticTypeEnum.AllIncome)
                {
                    foreach (List <AccountInfoModel> item in _normalStatisticGroup.Where(g => g.StatisticType == StatisticTypeEnum.AllIncome).First().FinanceDetails.Values)
                    {
                        if (item != null)
                        {
                            normalStatistic.AddRange(item);
                        }
                    }
                    if (_classPaymentStatisticGroup != null)
                    {
                        foreach (List <ClassPaymentModel> item in _classPaymentStatisticGroup.FinanceDetails.Values)
                        {
                            classpaymentStatistic.AddRange(item);
                        }
                    }
                }
                else if (statisticType == StatisticTypeEnum.AllOutcome)
                {
                    foreach (List <AccountInfoModel> item in _normalStatisticGroup.Where(g => g.StatisticType == StatisticTypeEnum.AllOutcome).First().FinanceDetails.Values)
                    {
                        if (item != null)
                        {
                            normalStatistic.AddRange(item);
                        }
                    }
                    if (_teacherFeeStatistcGroup != null)
                    {
                        foreach (List <TeacherFeeModel> item in _teacherFeeStatistcGroup.FinanceDetails.Values)
                        {
                            teacherFeeStatistic.AddRange(item);
                        }
                    }
                }
                else if (statisticType == StatisticTypeEnum.ClassFee)
                {
                    if (_classPaymentStatisticGroup != null)
                    {
                        foreach (List <ClassPaymentModel> item in _classPaymentStatisticGroup.FinanceDetails.Values)
                        {
                            classpaymentStatistic.AddRange(item);
                        }
                    }
                }
                else if (statisticType == StatisticTypeEnum.TeacherFee)
                {
                    if (_teacherFeeStatistcGroup != null)
                    {
                        foreach (List <TeacherFeeModel> item in _teacherFeeStatistcGroup.FinanceDetails.Values)
                        {
                            teacherFeeStatistic.AddRange(item);
                        }
                    }
                }
                else
                {
                    foreach (List <AccountInfoModel> item in _normalStatisticGroup.Where(g => g.StatisticType == statisticType).First().FinanceDetails.Values)
                    {
                        if (item != null)
                        {
                            normalStatistic.AddRange(item);
                        }
                    }
                }
            }
            else
            {
                if (statisticType == StatisticTypeEnum.AllIncome)
                {
                    normalStatistic = _normalStatisticGroup.Where(s => s.StatisticType == StatisticTypeEnum.AllIncome).First().FinanceDetails[summaryDate];
                    if (_classPaymentStatisticGroup != null)
                    {
                        classpaymentStatistic = _classPaymentStatisticGroup.FinanceDetails[summaryDate];
                    }
                }
                else if (statisticType == StatisticTypeEnum.AllOutcome)
                {
                    normalStatistic = _normalStatisticGroup.Where(s => s.StatisticType == StatisticTypeEnum.AllOutcome).First().FinanceDetails[summaryDate];
                    if (_teacherFeeStatistcGroup != null)
                    {
                        teacherFeeStatistic = _teacherFeeStatistcGroup.FinanceDetails[summaryDate];
                    }
                }
                else if (statisticType == StatisticTypeEnum.ClassFee)
                {
                    if (_classPaymentStatisticGroup != null)
                    {
                        classpaymentStatistic = _classPaymentStatisticGroup.FinanceDetails[summaryDate];
                    }
                }
                else if (statisticType == StatisticTypeEnum.TeacherFee)
                {
                    if (_teacherFeeStatistcGroup != null)
                    {
                        teacherFeeStatistic = _teacherFeeStatistcGroup.FinanceDetails[summaryDate];
                    }
                }
                else
                {
                    normalStatistic = _normalStatisticGroup.Where(s => s.StatisticType == statisticType).First().FinanceDetails[summaryDate];
                }
            }

            ShowDetailsEvent?.Invoke(normalStatistic, teacherFeeStatistic, classpaymentStatistic);
        }
 public FinanceSummaryItemViewModel(string itemName, decimal itemAmount, StatisticTypeEnum statisticType, Color color)
     : base(itemName, color)
 {
     ItemAmount     = itemAmount.ToString();
     _statisticType = statisticType;
 }
 public void AddSummary(Dictionary <DateTime, decimal> summaries, Color itemColor, string itemName, StatisticTypeEnum statisticType)
 {
     foreach (DateTime summaryDate in summaries.Keys)
     {
         SummaryGroupCollection.Where(s => s.SummaryDate == summaryDate).First().AddSummaryItem(itemName, summaries[summaryDate], statisticType, itemColor);
     }
     TotalSummary.AddSummaryItem(itemName, summaries.Values.Sum(), statisticType, itemColor);
     if (statisticType == StatisticTypeEnum.Capital)
     {
         TotalSummary.Vis = System.Windows.Visibility.Hidden;
     }
     else
     {
         TotalSummary.Vis = System.Windows.Visibility.Visible;
     }
 }