コード例 #1
0
        public static List <SalesAndCollectionModel> EverydaySalesAndCollections(string dealerCode)
        {
            var dealersHistory = new List <SalesAndCollectionModel>();

            if (SalesAndCollectionData.Count > 0)
            {
                var dealer = DealerManager.FindDealer(dealerCode);

                dealersHistory = SalesAndCollectionData.Where(x => x.DealerCode.Equals(dealerCode)).ToList();

                var everydayDealersHistory = new List <SalesAndCollectionModel>();

                if (dealersHistory.Count > 0)
                {
                    var allDates = dealersHistory.Select(x => x.Date).Distinct().ToList();
                    allDates = allDates.OrderBy(x => x.Value).ToList();

                    int count = 1;
                    foreach (var date in allDates)
                    {
                        var thatDaysHistory      = dealersHistory.Where(x => x.Date == date).ToList();
                        var mergeThatDaysHistory = new SalesAndCollectionModel();

                        mergeThatDaysHistory.Address    = dealer.Address;
                        mergeThatDaysHistory.Contact    = dealer.Contact;
                        mergeThatDaysHistory.DealerName = dealer.DealerName;
                        mergeThatDaysHistory.DealerCode = dealer.Code;
                        mergeThatDaysHistory.Date       = date;
                        mergeThatDaysHistory.IC_NO      = "";
                        mergeThatDaysHistory.MR_NO      = "";
                        mergeThatDaysHistory.Remarks    = "";
                        mergeThatDaysHistory.SyncType   = "Daily";
                        mergeThatDaysHistory.Sl         = (count++).ToString();

                        mergeThatDaysHistory.OpeningBalance   = thatDaysHistory.FirstOrDefault().OpeningBalance;
                        mergeThatDaysHistory.SalesAmount      = thatDaysHistory.Sum(x => x.SalesAmount);
                        mergeThatDaysHistory.CollectionAmount = thatDaysHistory.Sum(x => x.CollectionAmount);
                        mergeThatDaysHistory.ClosingBalance   = thatDaysHistory.LastOrDefault().ClosingBalance;

                        everydayDealersHistory.Add(mergeThatDaysHistory);
                    }
                }

                return(everydayDealersHistory);
            }

            return(dealersHistory);
        }
コード例 #2
0
        public static List <SalesAndCollectionModel> EverydaySalesAndCollections()
        {
            var allDealers = DealerManager.GetAllDealers();

            var allDealersHistory = new List <SalesAndCollectionModel>();

            int count = 1;

            foreach (var dealer in allDealers)
            {
                var dealersHistory = EverydaySalesAndCollections(dealer.Code);

                foreach (var history in dealersHistory)
                {
                    history.Sl = (count++).ToString();
                }

                allDealersHistory.AddRange(dealersHistory);
            }

            return(allDealersHistory);
        }