public List <LedgerListForView> VoucherListByType(VoucherReportViewRequest request) { using (var _context = new AccountsEntities()) { string dataList = "[Acc_LedgerInfoForEdit] '" + request.voucherNo + "','" + request.voucherType + "'"; var list = _context.Database.SqlQuery <LedgerListForView>(dataList).ToList <LedgerListForView>(); return(list); } }
public ActionResult VoucherReport_HTML(VoucherReportViewRequest request) { var response = new VoucherReportViewResponse(); var headerHtml = ""; var reportHeaderHtml = ""; var firstSection = ""; var table = ""; try { var list = _dalLedger.VoucherListByType(request).ToList(); if (list.Any()) { reportHeaderHtml = " <div align='left' class='ReportBorderL' >" + "<div style='position:absolute;'>" + "<img src='/UploadFiles/" + list.FirstOrDefault().LogoLocation + "' width='60' border='0' />" + " </div>" + "<table style='width: 100%'>" + "<tr>" + "<td class='Company'>" + list.FirstOrDefault().CompanyName + "</td>" + "</tr>" + "<tr>" + "<td class='Address1'>" + list.FirstOrDefault().CompanyAddress + "</td>" + "</tr>" + " <tr>" + " <td class='Address2'>" + list.FirstOrDefault().CompanyEmail + ", " + list.FirstOrDefault().CompanyContact + "</td>" + "</tr>" + // "<tr>" + // "<td class='Address3'>" + list.FirstOrDefault().CompanyContact + "</td>" + //" </tr>" + "<tr>" + "<td style='text-align: center'>" + "<div align='center'>" + " <div class='ReportTitle'> " + list.FirstOrDefault().Voucher + "" + "</div>" + "</div>" + "</td>" + "</tr>" + "</table>" + "<div runat='server' id='reportContent'></div>" + "<br />"; firstSection = firstSection + "</br></br> <table style='font-size:13px; background-color:#d2c8c8; width: 100%'>"; firstSection = firstSection + " <tr>"; firstSection = firstSection + "<td style='width: 102px'><b> Transaction Date</b></td>"; firstSection = firstSection + " <td style='width: 4px'><b>:</b></td>"; firstSection = firstSection + " <td style='width: 240px;'>" + list.FirstOrDefault().TransactionDate + "</td>"; firstSection = firstSection + "</tr>"; firstSection = firstSection + " <td style='width: 102px'><b>Reference</b></td>"; firstSection = firstSection + "<td style='width: 4px'><b>:</b></td>"; firstSection = firstSection + " <td style='width: 240px;'>" + list.FirstOrDefault().Reference + "</td>"; //firstSection = firstSection + " <td style='width: 102px'><b>To Line</b></td>"; //firstSection = firstSection + "<td style='width: 4px'><b>:</b></td>"; //firstSection = firstSection + " <td style='width: 240px;'>" + list.FirstOrDefault().Search_ToLine + "</td>"; firstSection = firstSection + "</tr></table>"; table = "<table class='tableApproval' cellspacing='0' style='font-size:12px; width: 100%; '><tr>" + "<td style='font-weight:bold'>Voucher</td>" + "<td style='font-weight:bold'>Chart of Account</td>" + "<td style='font-weight:bold'>Description</td>" + "<td style='font-weight:bold'>Narration</td>" + "<td style='font-weight:bold'>Debit</td>" + "<td style='font-weight:bold'>Credit</td>" + "</tr>"; var itemList = list.GroupBy(x => x.LedgerId).Select(x => x.ToList()); int i = 0; foreach (var item in itemList) { i++; foreach (var lastItem in item) { table = table + "<tr><td>" + lastItem.Voucher + "</td>" + "<td>" + lastItem.ChartOfAccount + "</td>" + "<td>" + lastItem.Description + "</td>" + "<td>" + lastItem.Narration + "</td>" + "<td>" + lastItem.Debit + "</td>" + "<td>" + lastItem.Credit + "</td></tr>"; } if (itemList.Count() == i) { table = table + "<tr><td colspan='4' style='font-weight:bold'>Total</td>" + "<td style='font-weight:bold'>" + list.Sum(x => x.Debit) + "</td>" + "<td style='font-weight:bold'>" + list.Sum(x => x.Credit) + "</td></tr></br>"; } } table = table + "</table>"; headerHtml = headerHtml + table; response.StatusCode = "200"; response.StatusMessage = "Successfully Get Data"; response.Report = reportHeaderHtml + firstSection + headerHtml + "</div>"; } else { response.StatusCode = "404"; response.StatusMessage = "No Data Found"; response.Report = ""; } } catch (Exception ex) { response.StatusCode = "500"; response.StatusMessage = ex.Message.ToString(); } var camelCaseFormatter = new JsonSerializerSettings(); camelCaseFormatter.ContractResolver = new CamelCasePropertyNamesContractResolver(); var returnJson = Json(JsonConvert.SerializeObject(response, camelCaseFormatter), JsonRequestBehavior.AllowGet); returnJson.MaxJsonLength = Int32.MaxValue; return(returnJson); }