Exemple #1
0
        public async Task <FileStreamResult> GetSaleExcel([FromQuery] string das1, string das2)
        {
            DateTime da1;
            DateTime da2;

            if (!DateTime.TryParse(das1, out da1))
            {
                return(null);
            }
            if (!DateTime.TryParse(das2, out da2))
            {
                return(null);
            }

            SaleReturnReportDto saleret = new SaleReturnReportDto();

            saleret.sale = await _dapperContext.QueryAsync <SaleReportDto>("SELECT [Id],[Name],[Amount],[SaleCost], ([Amount] *[SaleCost]) as TotalSaleCost,[Client],[OptCost],[RegDt],[OrderNumber],[Comments],[IsBank] FROM[HistorySaleView] where RegDt between @da1 and @da2", new { da1, da2 });

            saleret.returns = await _dapperContext.QueryAsync <ReturnReportDto>("SELECT [Id],[Name],[ReturnCost],[Amount],[RegDt],[CustomerName] FROM[ReturnView] where RegDt between @da1 and @da2", new { da1, da2 });

            reportToFile = new SalesReport();
            var excel = reportToFile.GetFile($"Продажа по дате: {da1.ToShortDateString()} -  {da2.ToShortDateString()}", saleret);

            return(new FileStreamResult(excel, new MediaTypeHeaderValue("text/plain"))
            {
                FileDownloadName = "Income.xlsx"
            });
        }
Exemple #2
0
        public async Task <FileStreamResult> GetRemainsExcel()
        {
            var remainReport = await _dapperContext.QueryAsync <RemainReportDto>("select p.ID as ProductId, p.Name,p.Code," +
                                                                                 "v.IncomeCost,v.SaleCost,v.OptCost,p.RemainCount, p.Limit from Products as p left join AvCurrentCosts v " +
                                                                                 "on p.Id = v.ProductId where p.Id in (select productId from ProductIncoms) order by p.RemainCount desc; ");

            reportToFile = new RemainReport();
            var excel = reportToFile.GetFile($"Остаток по дате: {TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Central Asia Standard Time")).ToString("dd-MM-yyyy")}", remainReport);

            return(new FileStreamResult(excel, new MediaTypeHeaderValue("text/plain"))
            {
                FileDownloadName = "Remains.xlsx"
            });
        }