// GET: CashBook
        public IActionResult Index(int?id, DateTime?EDate, string ModeType, string OpsType)
        {
            string sWebRootFolder = _hostingEnvironment.WebRootPath;
            string fileName       = Path.Combine(sWebRootFolder, "Export_" + DateTime.Now.ToFileTimeUtc().ToString() + ".xlsx");

            CashBookManagerExporter managerexporter = new CashBookManagerExporter();
            CashBookManager         manager         = new CashBookManager();
            List <CashBook>         cashList;

            if (!String.IsNullOrEmpty(OpsType))
            {
                if (OpsType == "Correct")
                {
                    //TODO: Implement Correct cash in hand
                    ViewBag.Message = "Cash Book Correction: ";
                    if (ModeType == "MonthWise")
                    {
                        managerexporter.CorrectCashInHands(db, EDate.Value.Date, fileName, false);
                    }
                    else
                    {
                        managerexporter.CorrectCashInHands(db, EDate.Value.Date, fileName, true);
                    }
                }
                else
                {
                    ViewBag.Message = "";
                }
            }


            if (EDate != null)
            {
                if (ModeType == "MonthWise")
                {
                    cashList = manager.GetMontlyCashBook(db, EDate.Value.Date);
                }
                else
                {
                    cashList = manager.GetDailyCashBook(db, EDate.Value.Date);
                }
            }
            else if (id == 101)
            {
                cashList = manager.GetDailyCashBook(db, DateTime.Now);
            }
            else
            {
                cashList = manager.GetMontlyCashBook(db, DateTime.Now);
            }

            if (cashList != null)
            {
                return(View(cashList));
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 2
0
        // GET: CashBook
        public IActionResult Index(int?id, DateTime?EDate, string ModeType, string OpsType, string OutputType)
        {
            string   fileName = /*"ExcelFiles\\" +*/ "Export_CashBook_" + DateTime.Now.ToFileTimeUtc().ToString() + ".xlsx";
            string   path     = Path.Combine("wwwroot", fileName);
            FileInfo file     = new FileInfo(path);

            if (!file.Directory.Exists)
            {
                file.Directory.Create();
            }
            ViewBag.FileName = "";

            CashBookManager managerexporter = new CashBookManager(StoreId);
            CashBookManager manager         = new CashBookManager(StoreId);
            List <CashBook> cashList;

            if (!String.IsNullOrEmpty(OpsType))
            {
                if (OpsType == "Correct")
                {
                    //TODO: Implement Correct cash in hand
                    ViewBag.Message = "Cash Book Correction  ";

                    if (ModeType == "MonthWise")
                    {
                        cashList = managerexporter.CorrectCashInHands(db, EDate.Value.Date, path, StoreId, false);
                    }
                    else
                    {
                        cashList = managerexporter.CorrectCashInHands(db, EDate.Value.Date, path, StoreId, true);
                    }

                    ViewBag.FileName = "/" + fileName;
                }
                else
                {
                    ViewBag.Message = "";
                }
            }
            if (EDate != null)
            {
                if (ModeType == "MonthWise")
                {
                    cashList = manager.GetMontlyCashBook(db, EDate.Value.Date, StoreId);
                }
                else
                {
                    cashList = manager.GetDailyCashBook(db, EDate.Value.Date, StoreId);
                }
            }
            else if (id == 101)
            {
                cashList = manager.GetDailyCashBook(db, DateTime.Now, StoreId);
            }
            else
            {
                cashList = manager.GetMontlyCashBook(db, DateTime.Now, StoreId);
            }
            if (cashList != null)
            {
                if (!String.IsNullOrEmpty(OutputType) && OutputType == "PDF")
                {
                    string fName = ReportPrinter.PrintCashBook(cashList);
                    return(File(fName, "application/pdf"));
                }
                else if (!String.IsNullOrEmpty(OutputType) && OutputType == "XLS")
                {
                    //TODO: Remove Comment     if (OpsType == "List")
                    //TODO: Remove Comment     ExcelExporter.CashBookExporter(path, cashList, "CashBook", StoreId);

                    return(File(fileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
                }
                return(View(cashList));
            }
            else
            {
                return(NotFound());
            }
        }