public async Task <IActionResult> MonthReport(string dateInput)
        {
            DateTime     date   = DateTime.ParseExact(dateInput, "MM/yyyy", CultureInfo.InvariantCulture);
            List <Order> orders = await _context.Orders
                                  .Include(p => p.OrderedProducts)
                                  .ThenInclude(o => o.Product)
                                  .Where(o => o.PlacementDate.Month == date.Month && o.PlacementDate.Year == date.Year)
                                  .ToListAsync();

            List <ImportOrder> importOrders = await _context.ImportOrders
                                              .Include(p => p.ImportedProducts)
                                              .ThenInclude(o => o.Product)
                                              .Where(io => io.PlacementDate.Month == date.Month && io.PlacementDate.Year == date.Year)
                                              .ToListAsync();

            decimal revenue  = orders.Sum(o => o.OrderedProducts.Sum(op => op.Product.Price * op.Quantity));
            decimal expenses = importOrders.Sum(io => io.ImportedProducts.Sum(ip => ip.Product.ImportPrice * ip.Quantity));

            MonthReportViewModel model = new MonthReportViewModel
            {
                DateInput        = date,
                Revenue          = revenue,
                Expenses         = expenses,
                Income           = revenue - expenses,
                OrdersList       = orders,
                ImportOrdersList = importOrders,
            };

            return(View(model));
        }
        public void Execute(object parameter)
        {
            var report = new MonthReportViewModel(periodReportWindowViewModel.BeginDate, periodReportWindowViewModel.EndDate);

            report.ReportEmbeddedResource = "TestAndTunes.Reports.Layouts.SummaryReportForPeriod.rdlc";
            report.SetReportParameters    = (localReport) =>
            {
                localReport.SetParameters(new ReportParameter("BeginDate", periodReportWindowViewModel.BeginDate.ToString()));
                localReport.SetParameters(new ReportParameter("EndDate", periodReportWindowViewModel.EndDate.ToString()));
            };
            periodReportWindowViewModel.Report = report;
        }
Пример #3
0
        public UCMonthReport()
        {
            InitializeComponent();
            _repo     = Di.Container.Instance.Resolve <IReportRepo>();
            viewModel = new MonthReportViewModel();

            numericUpDownTotalCost.DataBindings.Add("Value", viewModel, nameof(viewModel.TotalCost));
            numericUpDownTotalPrice.DataBindings.Add("Value", viewModel, nameof(viewModel.TotalPrice));
            numericUpDownTotalIncoming.DataBindings.Add("Value", viewModel, nameof(viewModel.TotalIncoming));

            numericUpDownTotalCost.Controls[0].Enabled     = false; // Disable the arrow buttons.
            numericUpDownTotalPrice.Controls[0].Enabled    = false;
            numericUpDownTotalIncoming.Controls[0].Enabled = false;
        }
Пример #4
0
        public static MonthReportViewModel MainFormReport()
        {
            DateTime             sd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 01);
            DateTime             ed = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 30);
            MonthReportViewModel monthReportViewModel = new MonthReportViewModel();

            using (MainContext db = new MainContext())
            {
                var income = db.BaseRepositoryAccounting.Get(a => a.TypeID == 1 && a.DateTime >= sd && a.DateTime <= ed).Select(a => a.Amount);
                var cost   = db.BaseRepositoryAccounting.Get(a => a.TypeID == 2 && a.DateTime >= sd && a.DateTime <= ed).Select(a => a.Amount);
                monthReportViewModel.InCome  = income.Sum();
                monthReportViewModel.Cost    = cost.Sum();
                monthReportViewModel.Balance = (income.Sum() - cost.Sum());
                return(monthReportViewModel);
            }
        }