Example #1
0
        public async Task <ActionResult> WebAcctTxnSearch(jQueryDataTableParamModel Params, TxnSearchModel Model, bool isDownload = false)
        {
            var _filtered = new List <AcctPostedTxnSearch>();
            var list      = (await TransactionSearchService.GetAccountTransactionSearch(Convert.ToInt64(Model.AcctNo), Convert.ToInt64(Model.CardNo), Model.SelectedTxnCategory, Convert.ToInt32(Model.SelectedTxnCd), Model.FromDate, Model.ToDate, Model.SelectedStatementDate)).transactionSearches;

            if (!isDownload)
            {
                if (!string.IsNullOrEmpty(Params.sSearch))
                {
                    Params.sSearch = Params.sSearch.ToLower();
                }
                if (!string.IsNullOrEmpty(Params.sSearch))
                {
                    _filtered = list.Where(p => p.InvoicDt.ToLower().Contains(Params.sSearch) || p.TxnDate.ToLower().Contains(Params.sSearch)).ToList();
                    _filtered = _filtered.Skip(Params.iDisplayStart).Take(Params.iDisplayLength).ToList();
                }
                else
                {
                    _filtered = list.Skip(Params.iDisplayStart).Take(Params.iDisplayLength).ToList();
                }
                return(Json(new
                {
                    sEcho = Params.sEcho,
                    iTotalRecords = list.Count(),
                    iTotalDisplayRecords = list.Count(),
                    aaData = _filtered.Select(x => new object[] { null, x.InvoicDt, x.TxnDate, x.PrcsDate, x.AcctNo, x.SelectedCardNo, x.AuthCardNo, x.TxnDesp, x.VehRegNo, x.Stan, x.ApproveCd, x.RRn, x.VATNo, x.Dealer, x.TxnId, x.TxnAmt, x.ProductDescp, x.Quantity, x.ProductAmt, x.VATAmt, x.VATCd, x.VATRate, })
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var title    = "Transaction search | Account";
                var toExport = new List <string[]>();
                var Header   = list.First().ExcelHeader;
                foreach (var item in list)
                {
                    toExport.Add(item.ExcelBody());
                }
                var ExcelPkg = Common.CommonHelpers.CreateExcel(Header, toExport, title);
                return(File(ExcelPkg.GetAsByteArray(), "application/vnd.ms-excel", title + ".xlsx"));
            }
        }