internal void GroupExpenseReportsByAge()
        {
            var query = from expenseReport in ExpenseReports
                        orderby expenseReport.DateResolved descending
                        group expenseReport by((DateTime)expenseReport.DateResolved).Year into g
                        select new
            {
                GroupName = g.Key,
                Count     = g.Count(),
                Amount    = g.Sum(e => e.Amount),
                Items     = g
            };

            this.GroupedExpenseReports.Clear();
            var groups = new GroupInfoList <object>();

            foreach (var group in query)
            {
                var items = new GroupInfoList <object>();
                items.Key     = group.GroupName;
                items.Amount  = System.Convert.ToDecimal(group.Amount);
                items.Summary = string.Format("{0} for {1:C}",
                                              group.Count, items.Amount);
                items.ImportList(group.Items.ToArray());
                this.GroupedExpenseReports.Add(items);
            }
        }
        internal GroupInfoList <object> GroupExpenseReportsBySubmitter()
        {
            var query = from expenseReport in ExpenseReports
                        orderby expenseReport.Status
                        group expenseReport by expenseReport.EmployeeId into g
                        select new
            {
                GroupName = g.Key,
                Count     = g.Count(),
                Amount    = g.Sum(e => e.Amount),
                Items     = g
            };

            var groups = new GroupInfoList <object>();

            foreach (var group in query)
            {
                var groupedExpenses = new GroupInfoList <object>();
                groupedExpenses.Key = string.Format(
                    "{0} ({1} items for {2:C})", group.GroupName, group.Count, group.Amount);
                groupedExpenses.Amount = System.Convert.ToDecimal(group.Amount);
                foreach (var item in groupedExpenses)
                {
                    groupedExpenses.Add(item);
                }
                groups.Add(groupedExpenses);
            }

            return(groups);
        }
示例#3
0
        internal GroupInfoList <object> GroupItemsBySubmitter()
        {
            var query = from item in Charges
                        orderby item.EmployeeId
                        group item by item.EmployeeId into g
                        select new
            {
                GroupName = g.Key,
                Count     = g.Count(),
                Amount    = g.Sum(e => e.TransactionAmount),
                Items     = g
            };

            var groups = new GroupInfoList <object>();

            foreach (var group in query)
            {
                var items = new GroupInfoList <object>();
                items.Key = string.Format(
                    "{0} ({1:C})", group.GroupName, group.Amount);
                items.Amount = System.Convert.ToDecimal(group.Amount);
                foreach (object item in items)
                {
                    items.Add(item);
                }
                groups.Add(items);
            }

            return(groups);
        }
        internal GroupInfoList <object> GroupExpenseReportsByCategory()
        {
            var query = from expenseReport in ExpenseReports
                        orderby expenseReport.Status
                        group expenseReport by expenseReport.Status into g
                        select new
            {
                GroupName = g.Key,
                Count     = g.Count(),
                Amount    = g.Sum(e => e.Amount),
                Items     = g
            };

            var groups = new GroupInfoList <object>();

            foreach (var group in query)
            {
                var    groupedExpenses         = new GroupInfoList <object>();
                string statusTypeName          = null;
                ExpenseReportStatus statusType = (ExpenseReportStatus)group.GroupName;
                switch (statusType)
                {
                case ExpenseReportStatus.Approved:
                    statusTypeName = "Approved";
                    break;

                case ExpenseReportStatus.Pending:
                    statusTypeName = "Pending";
                    break;

                case ExpenseReportStatus.Saved:
                    statusTypeName = "Saved";
                    break;

                default:
                    break;
                }
                groupedExpenses.Key = string.Format(
                    "{0} ({1} items for {2:C})", statusTypeName, group.Count, group.Amount);
                groupedExpenses.Amount = System.Convert.ToDecimal(group.Amount);
                foreach (var item in groupedExpenses)
                {
                    groupedExpenses.Add(item);
                }
                groups.Add(groupedExpenses);
            }

            return(groups);
        }
        private void GroupItemsByTypeAndAmount()
        {
            var query = from item in SummaryItems
                        orderby item.ItemType, item.Amount descending
            group item by item.ItemType into g
                select new
            {
                GroupName = g.Key,
                Count     = g.Count(),
                Amount    = g.Sum(e => e.Amount),
                Items     = g
            };

            this.GroupedSummaryItems.Clear();
            var groups = new GroupInfoList <object>();

            foreach (var group in query)
            {
                var      items        = new GroupInfoList <object>();
                string   itemTypeName = null;
                ItemType itemType     = (ItemType)group.GroupName;
                switch (itemType)
                {
                case ItemType.Charge:
                    itemTypeName = "Charges";
                    break;

                case ItemType.SavedReport:
                    itemTypeName = "Saved Reports";
                    break;

                case ItemType.PendingReport:
                    itemTypeName = "Pending Reports";
                    break;

                case ItemType.UnresolvedReport:
                    itemTypeName = "Needing Approval";
                    break;

                default:
                    break;
                }
                items.Key = string.Format(
                    "{0} ({1:C})", itemTypeName, group.Amount);
                items.Amount = System.Convert.ToDecimal(group.Amount);
                items.ImportList(group.Items.ToArray());
                this.GroupedSummaryItems.Add(items);
            }
        }
        internal GroupInfoList <object> GroupItemsBySubmitter()
        {
            var query = from item in this.SummaryItems
                        orderby item.Submitter
                        group item by item.Submitter into g
                        select new
            {
                GroupName = g.Key,
                Count     = g.Count(),
                Amount    = g.Sum(e => e.Amount),
                Items     = g
            };

            var groups = new GroupInfoList <object>();

            foreach (var group in query)
            {
                var items = new GroupInfoList <object>();
                if (group.Count > 0)
                {
                    items.Key     = group.GroupName;
                    items.Summary = string.Format("{0} for {1:C}",
                                                  items.Count, items.Amount);
                }
                else
                {
                    items.Key = group.GroupName;
                }
                items.Amount = System.Convert.ToDecimal(group.Amount);
                foreach (object item in items)
                {
                    items.Add(item);
                }
                groups.Add(items);
            }

            return(groups);
        }
        private void GroupItemsByTypeAndAge()
        {
            var query = from item in this.SummaryItems
                        orderby item.ItemType, item.Date ascending
            group item by item.ItemType into g
                select new
            {
                GroupName = g.Key,
                Count     = g.Count(),
                Amount    = g.Sum(e => e.Amount),
                Items     = g
            };

            this.GroupedSummaryItems.Clear();
            var groups = new GroupInfoList <object>();

            foreach (var group in query)
            {
                var      items        = new GroupInfoList <object>();
                string   itemTypeName = null;
                ItemType itemType     = (ItemType)group.GroupName;
                switch (itemType)
                {
                case ItemType.Charge:
                    itemTypeName = "Charges";

                    string beginMonth = this.BeginDateOfCharges.ToString("M").Substring(0, 3);
                    int    beginDay   = this.BeginDateOfCharges.Day;
                    int    beginYear  = this.BeginDateOfCharges.Year;
                    string endMonth   = this.EndDateOfCharges.ToString("M").Substring(0, 3);
                    int    endDay     = this.EndDateOfCharges.Day;
                    int    endYear    = this.EndDateOfCharges.Year;

                    if (beginYear == endYear)
                    {
                        items.Details1 =
                            string.Format("{0} {1} - {2} {3}, {4}",
                                          beginMonth, beginDay, endMonth, endDay, endYear);
                    }
                    else
                    {
                        items.Details1 =
                            string.Format("{0} {1}, {2} - {3} {4}, {5}",
                                          beginMonth, beginDay, beginYear, endMonth, endDay, endYear);
                    }

                    items.Details2 = string.Format("{0} new for {1:C}",
                                                   this.NumberOfChargesLT30Days.ToString(),
                                                   this.AmountOfChargesLT30Days);
                    items.Details3 = string.Format("{0} old for {1:C}",
                                                   this.NumberOfCharges30To44Days.ToString(),
                                                   this.AmountOfCharges30To44Days);
                    items.Details4 = string.Format("{0} late for {1:C}",
                                                   this.NumberOfChargesGT45Days.ToString(),
                                                   this.AmountOfChargesGT45Days);
                    break;

                case ItemType.SavedReport:
                    itemTypeName = "Saved Reports";
                    break;

                case ItemType.PendingReport:
                    itemTypeName   = "Pending Reports";
                    items.Details1 = string.Format("{0:C} owed to employee",
                                                   this._amountOwedToEmployee);
                    items.Details2 = string.Format("{0:C} owed to card",
                                                   this._amountOwedToCreditCard);
                    break;

                case ItemType.UnresolvedReport:
                    itemTypeName = "Needing Approval";
                    break;

                case ItemType.ApprovedReport:
                    itemTypeName = "Past Reports";
                    break;

                default:
                    break;
                }
                items.Key    = itemTypeName;
                items.Amount = System.Convert.ToDecimal(group.Amount);
                if (group.Amount == 0)
                {
                    items.Summary  = "You have none";
                    items.Details1 = string.Empty;
                    items.Details2 = string.Empty;
                    items.Details3 = string.Empty;
                    items.Details4 = string.Empty;
                }
                else
                {
                    items.Summary = string.Format("{0} for {1:C}",
                                                  group.Count, items.Amount);
                }
                items.ImportList(group.Items.ToArray());
                if (!(itemTypeName == "Needing Approval" && !this._employeeViewModel.IsManager))
                {
                    this.GroupedSummaryItems.Add(items);
                }
            }
        }