public static AMCViewModel Create(int itemId, int storeId, int amcRange, DateTime endDate)
        {
            var vwGetAllItemsRepository = new vwGetAllItemsRepository();
            var amcrepo         = new AmcReportRepository();
            var allItemIdsonamc = amcrepo.AllAmcReport().SingleOrDefault(m => m.ItemID == itemId && m.StoreID == storeId);
            var products        = vwGetAllItemsRepository.AllItems().SingleOrDefault(m => m.ID == itemId);
            var startDate       = endDate.Subtract(TimeSpan.FromDays(amcRange * 30));
            var viewModel       = new AMCViewModel
            {
                ItemID          = itemId,
                StoreID         = storeId,
                AmcRange        = amcRange,
                IssueInAmcRange = Builder.CalculateTotalConsumptionWithoutDOS(itemId, storeId, startDate, endDate),
                DaysOutOfStock  = Builder.CalculateStockoutDays(itemId, storeId, startDate, DateTime.Now),
                AmcWithDos      = Builder.CalculateAverageConsumption(itemId, storeId, startDate, endDate, CalculationOptions.Monthly),
                IssueWithDOS    = Builder.CalculateTotalConsumptionAMC(itemId, storeId, startDate, endDate)
            };

            AddorUpdateAmc(itemId, storeId, amcRange, endDate, amcrepo, viewModel, allItemIdsonamc, startDate);
            if (products != null)
            {
                viewModel.FullItemName = products.FullItemName;
            }
            viewModel.AmcWithoutDos = Convert.ToDouble(Builder.CalculateTotalConsumptionWithoutDOS(itemId, storeId, startDate, endDate)) / Convert.ToDouble(viewModel.AmcRange);
            return(viewModel);
        }
Example #2
0
        private Boolean IsCalculatedToday()
        {
            AmcReportRepository _amcReportRepository = new AmcReportRepository();
            int count = _amcReportRepository.AllAmcReport().Where(amc => amc.LastIndexedTime.Value.Date == DateTime.Today.Date).Select(amc => amc.ID).Count();

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
 private void loadamc()
 {          
     var allamcs = _amcReportRepository.AllAmcReport();
     gridControl1.DataSource = allamcs.Distinct().Where(m => m.StoreID == Convert.ToInt32(cboStores.EditValue)).OrderBy(m=>m.FullItemName);
 }