Beispiel #1
0
        public IViewComponentResult Invoke()
        {
            var lstModel = new List <SimpleReportViewModel>();

            var days       = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
            var carHistory = this.interventionService.GetFinishedCarsForCurrentMunth();

            for (int i = 1; i < days + 1; i++)
            {
                var report = new SimpleReportViewModel
                {
                    DimensionOne = i.ToString(),
                    Quantity     = 0
                };
                if (carHistory.ContainsKey(i))
                {
                    report.Quantity = carHistory[i];
                }
                lstModel.Add(report);
            }

            var model = new FinishedCarsChartViewModel
            {
                XLabels = Newtonsoft.Json.JsonConvert.SerializeObject(lstModel.Select(x => x.DimensionOne).ToList()),
                YValues = Newtonsoft.Json.JsonConvert.SerializeObject(lstModel.Select(x => x.Quantity).ToList())
            };

            return(this.View(WebConstants.ViewComponentDefault, model));
        }
Beispiel #2
0
        public void ValidateVM()
        {
            var simpleVM = new SimpleReportViewModel();

            Assert.Equal(0, simpleVM.ProductionOrderId);

            var reportVM = new ReportStockWarehouseViewModel();

            Assert.Null(reportVM.Construction);
            Assert.Null(reportVM.Unit);
            Assert.Null(reportVM.Motif);
            Assert.Null(reportVM.Color);
            Assert.Null(reportVM.Jenis);
            Assert.Null(reportVM.Ket);
            Assert.Null(reportVM.Satuan);
        }
        public ActionResult Chem6WeekChart()
        {
            int             PId    = 0;
            ChemicalPricing Objdal = new DAL.ChemicalPricing();


            List <SA_Chem6PriceWeekly> obj = null;
            string compare = string.Empty;

            string currentYear  = DateTime.Now.Year.ToString();
            string currentMonth = DateTime.Now.ToMonthName().ToUpper();
            string currentWeek  = ((Convert.ToInt32(DateTime.Now.Day) / 7) + 1).ToString();

            //               Convert.ToInt32(DateTime.Now.Day / 7).ToString();


            obj = Objdal.GetChem6WeekWise(currentYear, currentMonth, currentWeek);
            List <string> Year        = obj.Select(p => p.day).Distinct().ToList();
            List <string> Discription = obj.Select(p => p.Discription).Distinct().ToList();

            var lstModel = new List <StackedViewModel>();

            for (int i = 0; i < Year.Count; i++)
            {
                List <SA_Chem6PriceWeekly> Chartdata = obj.Where(Chart => Chart.day == Year[i]).ToList();
                PId = Chartdata.FirstOrDefault().Product.Value;
                //sales of product sales by quarter
                StackedViewModel Report = new StackedViewModel();
                Report.StackedDimensionOne = Year[i];

                List <SimpleReportViewModel> Data         = new List <SimpleReportViewModel>();
                List <SimpleReportViewModel> QuantityList = new List <ViewModel.SimpleReportViewModel>();


                foreach (var item in obj.Select(p => p.ProductVariant).Distinct().ToList())
                {
                    SimpleReportViewModel Quantity = new SimpleReportViewModel()
                    {
                        DimensionOne = item,// item.Month,
                        Quantity     = Chartdata.Where(x => x.ProductVariant == item).Sum(x => x.count.Value),
                        // MDimensionOne = Chartdata.FirstOrDefault(w=>w.ProductVariant== item).day
                    };
                    QuantityList.Add(Quantity);
                }


                //foreach (var item in Chartdata)
                //{
                //    SimpleReportViewModel Quantity = new SimpleReportViewModel()
                //    {
                //        DimensionOne = item.ProductVariant,
                //        Quantity = item.count.HasValue? item.count.Value:0,
                //        MDimensionOne = item.day
                //};
                //    QuantityList.Add(Quantity);
                //}
                Report.LstData = QuantityList;

                lstModel.Add(Report);

                lstModel[0].ProductName = ObjProduct.GetProductByid(PId).ProductName;
            }



            if (lstModel.Count() > 0)
            {
                return(PartialView("~/Views/PartialView/YearlyChartChemical6.cshtml", lstModel));
            }
            else
            {
                return(PartialView("~/Views/PartialView/YearlyChemical.cshtml", lstModel));
            }
        }
        public ActionResult Chem1WeekChart(string year = "2019")
        {
            ChemAnalystContext _context = new ChemAnalystContext();
            int custid = 0;

            if (year == "")
            {
                year = DateTime.Now.Year.ToString();
            }
            ViewBag.CYear = year;
            ChemicalPricing Objdal = new DAL.ChemicalPricing();
            //ViewBag.QYears = Objdal.GetYear("W");

            List <SA_ChemPriceWeekly> obj = null;



            //var id= _context.SA_Product.OrderBy(x => new { x.Category, x.id }).FirstOrDefault().id;
            var catId = _context.SA_Category.OrderBy(x => x.id).FirstOrDefault().id;


            var product = _context.SA_Product.Where(w => w.Category == catId).OrderBy(x => x.id).FirstOrDefault().id.ToString();

            obj = Objdal.SA_Chem1PriceWeekly(product, year);



            List <string> Day         = obj.Select(p => p.Week).Distinct().ToList();
            List <string> Discription = obj.Select(p => p.Discription).Distinct().ToList();


            var lstModel = new List <StackedViewModel>();


            for (int i = 0; i < Day.Count; i++)
            {
                List <SA_ChemPriceWeekly> Chartdata = obj.Where(Chart => Chart.Week == Day[i]).ToList();;
                //obj.Where(Chart => Chart.year == DateTime.Now.Year.ToString() && Chart.day == Day[i]).ToList();
                //sales of product sales by quarter
                StackedViewModel Report = new StackedViewModel();
                Report.StackedDimensionOne = Day[i];
                Report.Discription         = Discription;
                Report.category            = Objdal.GetctegotyBYproduct(obj[0].Product);
                Report.Product             = (obj[0].Product).ToString();
                Report.Year = year;


                List <SimpleReportViewModel> Data         = new List <SimpleReportViewModel>();
                List <SimpleReportViewModel> QuantityList = new List <ViewModel.SimpleReportViewModel>();


                foreach (var item in obj.Select(p => p.ProductVariant).Distinct().ToList())
                {
                    SimpleReportViewModel Quantity = new SimpleReportViewModel()
                    {
                        DimensionOne = item,// item.Month,
                        Quantity     = Chartdata.Where(x => x.ProductVariant == item).Sum(x => x.count)
                    };
                    QuantityList.Add(Quantity);
                }


                Report.LstData = QuantityList;
                if (product == null)
                {
                    Report.ChartType = "line";
                    Report.range     = "Week";
                }
                else
                {
                    Report.Product   = product;
                    Report.ChartType = "bar";
                    Report.range     = "Weekly";
                }
                lstModel.Add(Report);
            }

            ViewBag.Category = Objdal.GetctegotyBYproduct(int.Parse(product));

            lstModel[0].ProductName = ObjProduct.GetProductByid(Convert.ToInt32(product)).ProductName;
            if (lstModel.Count() > 0)
            {
                return(PartialView("~/Views/PartialView/YearlyChartChemical1.cshtml", lstModel));
            }
            else
            {
                return(PartialView("~/Views/PartialView/YearlyChemical.cshtml", lstModel));
            }
        }