Example #1
0
        public ActionResult GetVoucherPreview(string VchrNo, string FinYear)
        {
            RBACUser rUser = new RBACUser(Session["UserName"].ToString());

            if (!rUser.HasPermission("RptVoucherPreview_Preview"))
            {
                string errMsg = "No Preview Permission for this User !!";
                return(RedirectToAction("SearchVoucher", "VchrPreview", new { errMsg }));
            }
            if (VchrNo != null)
            {
                var ledger = _LedgerCapService.All().ToList().FirstOrDefault(x => x.SP_Name == "rptVoucher");
                ViewBag.RptCap  = ledger.RptCap;
                ViewBag.Col1Cap = ledger.Col1Cap;
                ViewBag.Col2Cap = ledger.Col2Cap;
                ViewBag.Col3Cap = ledger.Col3Cap;
                ViewBag.Col4Cap = ledger.Col4Cap;
                ViewBag.Col5Cap = ledger.Col5Cap;
                ViewBag.Col6Cap = ledger.Col6Cap;
                ViewBag.Col7Cap = ledger.Col7Cap;
                string BranchCode = Session["BranchCode"].ToString();
                ViewBag.Branch = _BranchService.All().Where(x => x.BranchCode == BranchCode.Trim()).Select(s => s.BranchName).ToString();

                FinYear = Session["FinYear"].ToString();
                string sql = string.Format("EXEC rptVoucher '" + FinYear + "','" + VchrNo + "'");
                List <VchrPreviewVM> rptVchr = _VchrPreviewVMService.SqlQueary(sql).ToList();
                //if (rptVchr.Count == 0)
                //{
                //    string errMsg = "There is no data in this combination. Please try again !!!";
                //    return RedirectToAction("SearchVoucher", "VchrPreview", new { errMsg });
                //}
                //else
                //{
                double amt = 0;
                foreach (var item in rptVchr)
                {
                    if (item.cramount != 0)
                    {
                        amt += item.cramount;
                    }
                }
                string InWordsamt = InWord.ConvertToWords(amt.ToString());
                ViewBag.InWordsAmt = InWordsamt;
                return(View(rptVchr));
                //}
            }
            else
            {
                string errMsg = "Voucher no is required!";
                return(RedirectToAction("SearchVoucher", "VchrPreview", new { errMsg }));
            }
        }
        public ActionResult GetVoucherPreview(string VchrNo, string FinYear)
        {
            var ledger = _LedgerCapService.All().ToList().FirstOrDefault(x => x.SP_Name == "rptVoucher");

            ViewBag.RptCap  = ledger.RptCap;
            ViewBag.Col1Cap = ledger.Col1Cap;
            ViewBag.Col2Cap = ledger.Col2Cap;
            ViewBag.Col3Cap = ledger.Col3Cap;
            ViewBag.Col4Cap = ledger.Col4Cap;
            ViewBag.Col5Cap = ledger.Col5Cap;
            ViewBag.Col6Cap = ledger.Col6Cap;
            ViewBag.Col7Cap = ledger.Col7Cap;
            string BranchCode = Session["BranchCode"].ToString();

            ViewBag.Branch = _BranchService.All().FirstOrDefault(x => x.BranchCode == BranchCode.Trim()).BranchName.ToString();

            FinYear = Session["FinYear"].ToString();
            string sql = string.Format("EXEC rptVoucher '" + FinYear + "','" + VchrNo + "'");
            List <VchrPreviewVM> rptVchr = _VchrPreviewVMService.SqlQueary(sql).ToList();
            //if (rptVchr.Count == 0)
            //{
            //    string errMsg = "There is no data in this combination. Please try again !!!";
            //    return RedirectToAction("SearchVoucher", "VchrPreview", new { errMsg });
            //}
            //else
            //{
            double amt = 0;

            foreach (var item in rptVchr)
            {
                if (item.cramount != 0)
                {
                    amt += item.cramount;
                }
            }
            string InWordsamt = InWord.ConvertToWords(amt.ToString());

            ViewBag.InWordsAmt = InWordsamt;
            return(View("~/Views/VchrPreview/GetVoucherPreview.cshtml", rptVchr));
            //}
        }