public ActionResult BindVoucherList(VoucherSearchViewModel obj, int companyId, int financialYear)
        {
            int processId = 0;
            int levelId = 0;
            string urlData = Request.UrlReferrer.Query;
            string[] array = urlData.Split('=');
            if (array.Length > 0)
            {
                processId = Convert.ToInt32(array[1]);
                levelId = Convert.ToInt32(array[2]);
            }
            //var list = "";
            try
            {
                DataTable dt = _cmnApprovalProcessLevelService.GetByCompanyModuleApprovalProcessId(companyId, processId);
                var records = dt.DataTableToList<CmnApprovalProcessLevelMappingViewModel>();
                Collection<CmnProcessLevel> collection = new Collection<CmnProcessLevel>();
                foreach (CmnApprovalProcessLevelMappingViewModel objModel in records)
                {
                    CmnProcessLevel objLevel = new CmnProcessLevel();
                    objLevel.Id = objModel.ProcessLevelId;
                    objLevel.Name = objModel.Name;
                    collection.Add(objLevel);
                }

                Collection<AnFVoucher> list = _IAnFVoucherService.GetForApproval(companyId, financialYear, processId, levelId, obj.DateFrom, obj.ToDate, obj.BusinessId, obj.ProjectId, collection);
                Collection<VoucherSearchResultViewModel> collections = new Collection<VoucherSearchResultViewModel>();
                if (list != null)
                {
                    foreach (AnFVoucher objVoucher in list)
                    {
                        VoucherSearchResultViewModel objValue = new VoucherSearchResultViewModel();
                        objValue.id = objVoucher.Id;
                        objValue.VoucherNumber = objVoucher.VoucherNumber;
                        objValue.DateString = objVoucher.Date.ToString();
                        collections.Add(objValue);
                    }
                }
                return Json(collections, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                throw;
            }
            //Get the vouchers that are waiting for levels(check/pass/arrove)
        }
        public ActionResult SearchAnFVoucher(VoucherSearchViewModel objVoucherSearchViewModel)
        {
            if (ModelState.IsValid)
            {
                int companyId = Convert.ToInt32(Session["companyId"].ToString());
                int financialYearId = Convert.ToInt32(Session["financialYear"].ToString());

                DataTable dt = null;
                dt = _anfVoucherService.GetAnfVoucherList(financialYearId, companyId,
                                             objVoucherSearchViewModel.VoucherTypeId,
                                              objVoucherSearchViewModel.DateFrom,
                                             objVoucherSearchViewModel.ToDate,
                                             objVoucherSearchViewModel.CostcenterId);
                List<ReportVoucherListViewModel> list = dt.DataTableToList<ReportVoucherListViewModel>();

                return Json(list, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return RedirectToAction("Voucher");
            }
        }
        public ActionResult GetAnfVoucherList(VoucherSearchViewModel objVoucherSearchViewModel)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                //string projectName = string.Empty;

                string costCenterName = string.Empty;

                string dateFrom = string.Empty;
                string dateTo = string.Empty;

                int companyId = Convert.ToInt32(Session["companyId"]);
                int financialYearId = Convert.ToInt32(Session["financialYear"]);

                SecCompany objCmnCompany = _CmnCompanyService.GetById(companyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;

                List<ReportParameter> paramList = new List<ReportParameter>();

                if (objVoucherSearchViewModel.CostcenterId != null)
                {
                    costCenterName = _ccService.GetById(objVoucherSearchViewModel.CostcenterId.GetValueOrDefault()).Name;
                }

                dateFrom = objVoucherSearchViewModel.DateFrom.GetValueOrDefault().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                dateTo = objVoucherSearchViewModel.ToDate.GetValueOrDefault().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                ReportParameter objCostCenter = new ReportParameter();
                objCostCenter.Name = "CostCenter";
                objCostCenter.Value = costCenterName;
                paramList.Add(objCostCenter);

                ReportParameter objDateFrom = new ReportParameter();
                objDateFrom.Name = "DateFrom";
                objDateFrom.Value = dateFrom;
                paramList.Add(objDateFrom);

                ReportParameter objDateTo = new ReportParameter();
                objDateTo.Name = "DateTo";
                objDateTo.Value = dateTo;
                paramList.Add(objDateTo);

                #endregion ParameterListPreperation

                if (objVoucherSearchViewModel.ReportType == 2)
                {
                    dt = _anfVoucherService.GetAnfVoucherList(financialYearId, companyId,
                                             objVoucherSearchViewModel.VoucherTypeId,
                                              objVoucherSearchViewModel.DateFrom,
                                             objVoucherSearchViewModel.ToDate,
                                             objVoucherSearchViewModel.CostcenterId);

                    filepath = GetReportPath("AnFVoucherList.rpt");
                }

                if (objVoucherSearchViewModel.ReportType == 3)
                {
                    dt = _anfVoucherService.GetShortDetailAnFVoucherList(financialYearId, companyId,
                                             objVoucherSearchViewModel.VoucherTypeId,
                                              objVoucherSearchViewModel.DateFrom,
                                             objVoucherSearchViewModel.ToDate,
                                             objVoucherSearchViewModel.CostcenterId);
                    filepath = GetReportPath("AnFShortVouchersList.rpt");
                }

                if (objVoucherSearchViewModel.ReportType == 4)
                {
                    dt = _anfVoucherService.GetShortDetailAnFVoucherList(financialYearId, companyId,
                                             objVoucherSearchViewModel.VoucherTypeId,
                                              objVoucherSearchViewModel.DateFrom,
                                             objVoucherSearchViewModel.ToDate,
                                             objVoucherSearchViewModel.CostcenterId);
                    filepath = GetReportPath("AnFDetailVouchers.rpt");
                }
                if (objVoucherSearchViewModel.ReportType == 5)
                {
                    //Payment
                    dt = _anfVoucherService.GetPaymentVouchers(financialYearId, companyId,
                                             objVoucherSearchViewModel.VoucherTypeId,
                                              objVoucherSearchViewModel.DateFrom,
                                             objVoucherSearchViewModel.ToDate,
                                             objVoucherSearchViewModel.CostcenterId);
                    ReportParameter PaymentOrRecieve = new ReportParameter();
                    PaymentOrRecieve.Name = "PaymentOrRecieve";
                    PaymentOrRecieve.Value = "Payment Report";
                    paramList.Add(PaymentOrRecieve);
                    //PaymentOrRecieve
                    filepath = GetReportPath("AnFPayment.rpt");
                }
                if (objVoucherSearchViewModel.ReportType == 6)
                {
                    //Receipt
                    dt = _anfVoucherService.GetPaymentVouchers(financialYearId, companyId,
                                            objVoucherSearchViewModel.VoucherTypeId,
                                             objVoucherSearchViewModel.DateFrom,
                                            objVoucherSearchViewModel.ToDate,
                                            objVoucherSearchViewModel.CostcenterId);
                    ReportParameter PaymentOrRecieve = new ReportParameter();
                    PaymentOrRecieve.Name = "PaymentOrRecieve";
                    PaymentOrRecieve.Value = "Receive Report";
                    paramList.Add(PaymentOrRecieve);
                    //PaymentOrRecieve
                    filepath = GetReportPath("AnFPayment.rpt");
                }
                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("Voucher");
                }
            }
            else
            {
                return RedirectToAction("Voucher");
            }
        }