private void GroupBy(List <CardPaymentInfo> items, CarFlowStatisticsType statisticsType)
        {
            decimal paid     = 0;
            decimal discount = 0;
            IEnumerable <IGrouping <string, CardPaymentInfo> > groups = null;

            if (items.Count > 0)
            {
                switch (statisticsType)
                {
                case CarFlowStatisticsType.perHour:
                    groups = from c in items
                             orderby c.ChargeDateTime ascending
                             group c by c.ChargeDateTime.ToString("yyyy-MM-dd HH:00:00");

                    break;

                case CarFlowStatisticsType.perDay:
                    groups = from c in items
                             orderby c.ChargeDateTime ascending
                             group c by c.ChargeDateTime.ToString("yyyy-MM-dd");

                    break;

                case CarFlowStatisticsType.perMonth:
                    groups = from c in items
                             orderby c.ChargeDateTime ascending
                             group c by c.ChargeDateTime.ToString("yyyy-MM");

                    break;

                default:
                    break;
                }
                if (groups != null)
                {
                    foreach (var group in groups)
                    {
                        int row = this.customDataGridView1.Rows.Add();
                        ShowGroupOnGridviewRow(this.customDataGridView1.Rows[row], group);
                        paid     += group.Sum(item => item.Paid);
                        discount += group.Sum(item => item.Discount);
                    }
                    this.txtPaid.Text     = paid.ToString();
                    this.txtAccounts.Text = discount.ToString();
                }
            }
        }
Пример #2
0
        private void CarFlowStaticstics(RecordSearchCondition search, CarFlowStatisticsType statisticsType)
        {
            List <CardEventRecord> items = (new CardEventBll(AppSettings.CurrentSetting.ParkConnect)).GetCardEvents(search).QueryObjects;
            IEnumerable <IGrouping <string, CardEventRecord> > groups = null;

            if (items.Count > 0)
            {
                switch (statisticsType)
                {
                case CarFlowStatisticsType.perHour:
                    groups = from c in items
                             orderby c.EventDateTime ascending
                             group c by c.EventDateTime.ToString("yyyy-MM-dd HH:00:00");

                    break;

                case CarFlowStatisticsType.perDay:
                    groups = from c in items
                             orderby c.EventDateTime ascending
                             group c by c.EventDateTime.ToString("yyyy-MM-dd");

                    break;

                case CarFlowStatisticsType.perMonth:
                    groups = from c in items
                             orderby c.EventDateTime ascending
                             group c by c.EventDateTime.ToString("yyyy-MM");

                    break;

                default:
                    break;
                }
                if (groups != null)
                {
                    foreach (var group in groups)
                    {
                        int row = this.customDataGridView1.Rows.Add();
                        ShowGroupOnGridviewRow(this.customDataGridView1.Rows[row], group);
                    }
                }
            }
        }
Пример #3
0
        private void GroupBy(List <CardDeferRecord> items, CarFlowStatisticsType statisticsType)
        {
            IEnumerable <IGrouping <string, CardDeferRecord> > groups = null;

            if (items.Count > 0)
            {
                switch (statisticsType)
                {
                case CarFlowStatisticsType.perHour:
                    groups = from c in items
                             orderby c.DeferDateTime ascending
                             group c by c.DeferDateTime.ToString("yyyy-MM-dd HH:00:00");

                    break;

                case CarFlowStatisticsType.perDay:
                    groups = from c in items
                             orderby c.DeferDateTime ascending
                             group c by c.DeferDateTime.ToString("yyyy-MM-dd");

                    break;

                case CarFlowStatisticsType.perMonth:
                    groups = from c in items
                             orderby c.DeferDateTime ascending
                             group c by c.DeferDateTime.ToString("yyyy-MM");

                    break;

                default:
                    break;
                }
                if (groups != null)
                {
                    foreach (var group in groups)
                    {
                        int row = this.customDataGridView1.Rows.Add();
                        ShowGroupOnGridviewRow(this.customDataGridView1.Rows[row], group);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 车流量统计
        /// </summary>
        public List <CarFlowStatistics> CarFlowStaticstics(RecordSearchCondition search, CarFlowStatisticsType statisticsType)
        {
            List <CarFlowStatistics> statistics = new List <CarFlowStatistics>();
            List <CardEventRecord>   cardEvents = this.GetCardEvents(search).QueryObjects;
            IEnumerable <IGrouping <string, CardEventRecord> > groups = null;

            if (cardEvents.Count > 0)
            {
                switch (statisticsType)
                {
                case CarFlowStatisticsType.perHour:
                    groups = cardEvents.GroupBy(c => c.EventDateTime.ToString("yyyy-MM-dd HH:00:00"));
                    break;

                case CarFlowStatisticsType.perDay:
                    groups = cardEvents.GroupBy(c => c.EventDateTime.ToString("yyyy-MM-dd"));
                    break;

                case CarFlowStatisticsType.perMonth:
                    groups = cardEvents.GroupBy(c => c.EventDateTime.ToString("yyyy-MM"));
                    break;

                default:
                    break;
                }
                if (groups != null)
                {
                    foreach (var group in groups)
                    {
                        CarFlowStatistics item = new CarFlowStatistics
                        {
                            TimeInterval  = group.Key,
                            TempCardIn    = group.Count(c => c.CardType.IsTempCard && !c.IsExitEvent),
                            MonthCardIn   = group.Count(c => c.CardType.IsMonthCard && !c.IsExitEvent),
                            PrepayCardIn  = group.Count(c => c.CardType.IsPrepayCard && !c.IsExitEvent),
                            TempCardOut   = group.Count(c => c.CardType.IsTempCard && c.IsExitEvent),
                            MonthCardOut  = group.Count(c => c.CardType.IsMonthCard && c.IsExitEvent),
                            PrepayCardOut = group.Count(c => c.CardType.IsPrepayCard && c.IsExitEvent)
                        };
                        statistics.Add(item);
                    }
                }
            }
            return(statistics);
        }