public ActionResult Ledger() { DtoLedger ledger = new DtoLedger { StartDate = DateTime.Now, EndDate = DateTime.Now }; return(View(ledger)); }
public ActionResult Ledger(DtoLedger ledger) { ledger.EndDate = ledger.EndDate.AddDays(1); DataTable Ledgers = new DataTable(); Ledgers = _repo.GetLedgers(ledger); Ledgers.TableName = "Ledger"; ReportViewer reportViewer = new ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; reportViewer.Width = Unit.Percentage(900); reportViewer.Height = Unit.Percentage(900); reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"Reports\Ledger.rdlc"; reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Ledger", Ledgers)); ViewBag.ReportViewer = reportViewer; ViewBag.ReportTitle = "Ledger"; return(View("_ReportView")); }
public DataTable GetLedgers(DtoLedger ledger) { DataTable ledgers = new DataTable(); //var ledgers = _db.AccVouchers.Where(v => v.AccString.Equals(ledger.AccString)).ToList(); if (ledger.WithoutDate) { ledgers = (from v in _db.AccVouchers where v.AccString.Equals(ledger.AccString) select new { VoucherDate = v.VDate, Ref = v.VType + " - " + v.VNo, Description = v.VDescription, Debit = v.Debit, Credit = v.Credit, //v.HeadCode, // if 1 or 5 then debit-credit=balance else credit-debit=balance Balance = v.HeadCode.ToString().Substring(0, 1) == "1" || v.HeadCode.ToString().Substring(0, 1) == "5" ? (v.Debit - v.Credit) : (v.Credit - v.Debit) }).ToList().ToDataTable(); } else { ledgers = (from v in _db.AccVouchers where v.AccString.Equals(ledger.AccString) && v.VDate <= ledger.EndDate && v.VDate >= ledger.StartDate select new { VoucherDate = v.VDate, Ref = v.VType + " - " + v.VNo, Description = v.VDescription, Debit = v.Debit, Credit = v.Credit, Balance = 0 }).ToList().ToDataTable(); } return(ledgers); }