public ActionResult Create(//[Bind(Include = "LoanId,UserId,RepaymentStartDate,RePaymentInterval,RequestedAmount,ProposedAmount,LoanAmount,TotalInstallments,Status,ChequeDetails,InteresRate,SanctionedDate,SanctionedBy,Notes,CreatedOn,ModifiedOn,CreatedBy,ModifiedBy,IsDeleted,DeletedBy,DeletedOn")] sdtoLoanInfo LoanInfo) { if (ModelState.IsValid) { LoanInfo.InstallmentAmount = LoanInfo.LoanAmount / LoanInfo.TotalInstallments; LoanInfo.CreatedOn = DateTime.Now; bfReport objReport = new bfReport(db); LoanInfo.CreatedBy = CurrentUserSession.UserId; LoanInfo.LoanCode = objReport.GenerateCode("LoanInfo"); db.sdtoLoanInfoes.Add(LoanInfo); db.SaveChanges(); bfTransaction objTrans = new bfTransaction(db); objTrans.PostLoanIssue(LoanInfo); SetDisplayMessage("Loan is created successfully"); return RedirectToAction("Index"); } var listUsers = db.User.Where(x => x.UserType == UserType.Member && x.IsDeleted == false); var users = listUsers.Select(x => new SelectListItem() { Value = x.UserID.ToString(), Text = x.FirstName + " " + x.LastName }).ToList(); users.Insert(0, new SelectListItem() { Value = "0", Text = "Select a Member" }); ViewBag.UserList = new SelectList(users, "Value", "Text"); return View(LoanInfo); }
// GET: Loan/Create public ActionResult Create(long? UserId) { var loan = new sdtoLoanInfo(); loan.RePaymentInterval = Data.Models.Enumerations.RepaymentInterval.Monthly; loan.Status = Data.Models.Enumerations.LoanStatus.Active; bfReport objReport = new bfReport(db); var bankInterest = db.GeneralSettings.FirstOrDefault().BankInterest; loan.InteresRate = Convert.ToSingle(bankInterest == null ? 0 : bankInterest.Value); var listUsers = db.User.Where(x => x.UserType == UserType.Member && x.IsDeleted == false && (UserId == null || UserId.Value == 0 || x.UserID == UserId)); if (listUsers == null || listUsers.Count(x => x.UserID > 0) == 0) { SetDisplayMessage("Please create a loan member first"); return RedirectToAction("Create", "Member"); } loan.LoanCode = objReport.GenerateCode("LoanInfo"); var userList = listUsers.OrderBy(x => x.FirstName).ToList(); var users = userList.Select(x => new SelectListItem() { Value = x.UserID.ToString(), Text = x.FirstName + " " + x.LastName }).ToList(); users.Insert(0, new SelectListItem() { Value = "0", Text = "Select a Member" }); ViewBag.UserList = new SelectList(users, "Value", "Text"); return View(loan); }
public JsonResult DepositSummaryInfo(LoanManagementSystem.Models.sdtoViewReportFilter Filter) { Filter.DepositIds = GetList(Filter.DepositIds.FirstOrDefault()); Filter.AccountIds = GetList(Filter.AccountIds.FirstOrDefault()); Filter.LoanIds = GetList(Filter.LoanIds.FirstOrDefault()); Filter.MemberIds = GetList(Filter.MemberIds.FirstOrDefault()); Filter.StatusIds = GetList(Filter.StatusIds.FirstOrDefault()); sdtoUser sessionUser = UtilityHelper.UserSession.GetSession(UtilityHelper.UserSession.LoggedInUser) as sdtoUser; long CompanyId = 0; if (sessionUser != null && sessionUser.CompanyId != null) CompanyId = sessionUser.CompanyId.Value; DataTable dtRptParams = new DataTable(); dtRptParams.Columns.Add(new DataColumn("EntityId", typeof(long))); dtRptParams.Columns.Add(new DataColumn("EntityStartDate", typeof(DateTime))); dtRptParams.Columns.Add(new DataColumn("EntityEndDate", typeof(DateTime))); dtRptParams.Columns.Add(new DataColumn("EntityIntVal", typeof(int))); dtRptParams.Columns.Add(new DataColumn("EntityStrVal", typeof(string))); dtRptParams.Columns.Add(new DataColumn("EntityType", typeof(string))); foreach (string Id in Filter.MemberIds) { DataRow row = dtRptParams.NewRow(); row.ItemArray = new object[] { Id, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, "U" }; dtRptParams.Rows.Add(row); } foreach (string Id in Filter.DepositIds) { DataRow row = dtRptParams.NewRow(); row.ItemArray = new object[] { Id, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, "L" }; dtRptParams.Rows.Add(row); } foreach (string Id in Filter.StatusIds) { DataRow row = dtRptParams.NewRow(); row.ItemArray = new object[] { Id, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, "S" }; dtRptParams.Rows.Add(row); } DataRow rowDate = dtRptParams.NewRow(); rowDate.ItemArray = new object[] { 0, Filter.StartDate, Filter.EndDate, DBNull.Value, DBNull.Value, "D" }; dtRptParams.Rows.Add(rowDate); DataRow rowMisc = dtRptParams.NewRow(); rowMisc.ItemArray = new object[] { 0, DBNull.Value, DBNull.Value, DBNull.Value, Filter.MiscFilter, "M" }; dtRptParams.Rows.Add(rowMisc); bfReport objReport = new bfReport(null); return Json(objReport.GetRptDepositSummary(CompanyId, dtRptParams), JsonRequestBehavior.AllowGet); }
public JsonResult JournalEntryInfo() { long CompanyId = 0; sdtoUser session = UtilityHelper.UserSession.GetSession(UtilityHelper.UserSession.LoggedInUser) as sdtoUser; if (session != null) CompanyId = session.CompanyId.Value; bfReport objReport = new bfReport(db); var CashReceiptPayments = objReport.GetJournalEntries(CompanyId, string.Empty); var result = Json(CashReceiptPayments, JsonRequestBehavior.AllowGet); result.MaxJsonLength = int.MaxValue; return result; }
public JsonResult BankDepositWithdrawalInfo() { long CompanyId = 0; sdtoUser session = UtilityHelper.UserSession.GetSession(UtilityHelper.UserSession.LoggedInUser) as sdtoUser; if (session != null) CompanyId = session.CompanyId.Value; bfReport objReport = new bfReport(db); var Deposits = objReport.GetBankDepositWithdrawal(CompanyId, string.Empty); var result = Json(Deposits, JsonRequestBehavior.AllowGet); result.MaxJsonLength = int.MaxValue; return result; }
public ActionResult TrialBalance(sdtoViewReportFilter filter) { //sdtoLedgerReport sessionUser = UtilityHelper.UserSession.GetSession(UtilityHelper.UserSession.LoggedInUser) as sdtoLedgerReport; //long CompanyId = 0; //bfReport objReport = new bfReport(null); //List<sdtoLedgerReport> lst = new List<sdtoLedgerReport>(); //lst = objReport.GetRptLedgerReport(CompanyId, 1, DateTime.Now.Date.AddDays(-20), DateTime.Now, "1,2,3,4,5,6,7,8,9,10").ToList(); //ReportDocument rd = new ReportDocument(); //rd.Load(Path.Combine(Server.MapPath("~/Report"), "TrailBalance.rpt")); ////rd.SetParameterValue("Heading", "Ledger Report"); //rd.SetDatabaseLogon("sa", "TechnoCrunchLabs", @"DELL-PC\SQLEXPRESS", "LoanManagement"); //rd.SetDataSource(lst); //Response.Buffer = false; //Response.ClearContent(); //Response.ClearHeaders(); //try //{ // System.IO.MemoryStream mem = (System.IO.MemoryStream)rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); // Response.Clear(); // Response.Buffer = true; // Response.ContentType = "application/pdf"; // Response.BinaryWrite(mem.ToArray()); // Stream str = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); // str.Seek(0, SeekOrigin.Begin); // return File(str, "application/pdf", "TrialBalance.pdf"); //} //catch (Exception e) //{ // throw e.InnerException; //} var filterModel = GetMutipleSelectionModel(filter.Accounts.PostedItems); // ledger report -> account id // cash book -> account id (book type cash only) // bank book -> account (book type bank only) // trial balance long CompanyId = 0; sdtoUser sessionUser = UtilityHelper.UserSession.GetSession(UtilityHelper.UserSession.LoggedInUser) as sdtoUser; if (sessionUser != null) CompanyId = sessionUser.CompanyId.Value; List<int> l = new List<int>(); string.Join(",", l.Select(x => x)); bfReport objReport = new bfReport(null); List<sdtoLedgerReport> lst = new List<sdtoLedgerReport>(); lst = objReport.GetRptLedgerReport(Convert.ToInt64(filter.CompanyId), filter.OperationId, filter.StartDate, filter.EndDate, filter.Accounts != null && filter.Accounts.PostedItems != null && filter.Accounts.PostedItems.Ids != null ? string.Join(",", filter.Accounts.PostedItems.Ids.Select(x => x)) : ""); //setup properties var modelAccountHeads = new MultipleSelectionModel(); var selectedAccounts = new List<MutipleSelectionItem>(); //setup a view model modelAccountHeads.Items = dbContext.AccountHeads.Select(x => new MutipleSelectionItem() { Value = x.AccountHeadId.ToString(), Text = x.AccountName }).ToList(); // model.SelectedFruits = selectedFruits; filter.Accounts = modelAccountHeads; long cCompanyId = 0; if (sessionUser != null && sessionUser.CompanyId != null) cCompanyId = sessionUser.CompanyId.Value; var cmpList = dbContext.Companies.Where(x => x.IsDeleted == false).ToList(); cmpList.Insert(0, new sdtoCompany() { CompanyId = 0, CompanyName = "Select a company" }); filter.Companies = new SelectList(cmpList, "CompanyId", "CompanyName", cCompanyId); ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Report"), "TrailBalance.rpt")); //rd.SetParameterValue("Heading", "Ledger Report"); string strConn = ConfigurationManager.ConnectionStrings["LoanDBContext"].ConnectionString; System.Data.SqlClient.SqlConnection obj = new System.Data.SqlClient.SqlConnection(strConn); string uName = ConfigurationManager.AppSettings["DbUserName"]; string uPassword = ConfigurationManager.AppSettings["DbPassword"]; rd.SetDatabaseLogon(uName, uPassword, obj.DataSource, obj.Database); rd.SetDataSource(lst); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { //System.IO.MemoryStream mem = (System.IO.MemoryStream)rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); //Response.Clear(); //Response.Buffer = true; //Response.ContentType = "application/pdf"; //Response.BinaryWrite(mem.ToArray()); Stream str = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); str.Seek(0, SeekOrigin.Begin); return File(str, "application/pdf", "TrialBalance.pdf"); } catch (Exception e) { throw e.InnerException; } return View(filter); }
public ActionResult SmsLoanDefaulters(sdtoViewLoanDefaulters Defaulters) { string senderID = "Pallikunnel"; string baseMessage = "Please pay the loan due amount for the loan {0} at the earliest"; bfReport objReport = new bfReport(db); List<sdtoViewLoanDefaulterDetails> DefaulterList = objReport.GetLoanDefaulters(Defaulters.LoanDefaultInterval); string[] selectionLoans = Defaulters.InputSelection.Trim(" []".ToCharArray()).Split(','); if (selectionLoans != null && selectionLoans.Length > 0) { string apiKey = "6209qu7258jl67i8on8"; WebClient wc = null; for (int iLoanId = 0; iLoanId < selectionLoans.Length; iLoanId++) { if (selectionLoans[iLoanId].Equals("true", StringComparison.InvariantCultureIgnoreCase)) { var defaulter = DefaulterList.Find(x => x.LoanId == iLoanId); wc = new WebClient(); wc.DownloadStringCompleted += HttpsCompleted; wc.DownloadString(new Uri("http://sms.iconinfoware.com/api/web2sms.php?workingkey=" + apiKey + "&to=" + defaulter.Mobile1.Trim() + "&sender=" + senderID + "&message=" + string.Format(baseMessage, defaulter.LoanCode).Trim())); } } SetDisplayMessage("Sms notification is send to the selected recipients"); RedirectToAction("Index"); } return View(Defaulters); }
public ActionResult SmsLoanDefaulters(int? LoanDefaultDays) { sdtoViewLoanDefaulters defaulters = new sdtoViewLoanDefaulters(); if (LoanDefaultDays == null) LoanDefaultDays = 3; bfReport objReport = new bfReport(db); defaulters.Defaulters = objReport.GetLoanDefaulters(LoanDefaultDays.Value); defaulters.LoanDefaultInterval = LoanDefaultDays.Value; return View(defaulters); }
public ActionResult Create(//[Bind(Include = "LoanRepaymentId,LoanId,RepaymentCode,PrincipalAmount,InterestAmount,InterestRate,RepaymentAmount,PendingPrincipalAmount,Status,PaymentMode,ChequeDetails,Notes,CreatedOn,ModifiedOn,CreatedBy,ModifiedBy,IsDeleted,DeletedBy,DeletedOn")] sdtoLoanRepayment sdtoLoanRepayment) { if (ModelState.IsValid) { if (sdtoLoanRepayment.LoanId > 0) { var loandetails = db.sdtoLoanInfoes.Find(sdtoLoanRepayment.LoanId); var loanPendingAmt = loandetails.LoanAmount; var loanInterest = loandetails.InteresRate; var loanPendingInstallments = loandetails.TotalInstallments; var loanRepayment = db.sdtoLoanRepayments.Where(x => x.LoanId == sdtoLoanRepayment.LoanId && x.IsDeleted == false && x.Status != RepaymentStatus.Cancelled).OrderByDescending(x => x.LoanRepaymentId).FirstOrDefault(); var repaymentInterest = loanInterest; var repaymentInterestAmt = (loanPendingAmt * Convert.ToDecimal(repaymentInterest / 100)) / 365; var lastRepaymentDate = loandetails.RepaymentStartDate.Value; var days = (DateTime.Now.Date - loandetails.RepaymentStartDate.Value).Days; bfReport objReport = new bfReport(db); if (loanRepayment != null && loanRepayment.LoanRepaymentId > 0) { if (loanRepayment.RepaymentDate != null) lastRepaymentDate = loanRepayment.RepaymentDate.Value; days = (sdtoLoanRepayment.RepaymentDate.Value - lastRepaymentDate).Days; days = days == 0 ? 1 : days; if (days < 0) days = 0; loanPendingAmt = loanRepayment.PendingPrincipalAmount; loanPendingInstallments = loanRepayment.PendingInstallments; repaymentInterest = loanRepayment.InterestRate; repaymentInterestAmt = (loanPendingAmt * Convert.ToDecimal(repaymentInterest / 100) * days) / 365; sdtoLoanRepayment.RepaymentCode = loanRepayment.RepaymentCode; decimal paymentBalance = sdtoLoanRepayment.RepaymentAmount - repaymentInterestAmt - (loandetails.InstallmentAmount * days); decimal previousDue = paymentBalance > 0 ? (loanRepayment.PreviousPaymentDueAmount - paymentBalance) : (loanRepayment.PreviousPaymentDueAmount + paymentBalance); sdtoLoanRepayment.PreviousPaymentDueAmount = previousDue; } sdtoLoanRepayment.InterestAmount = Math.Round(repaymentInterestAmt, 2); sdtoLoanRepayment.PendingPrincipalAmount = loanPendingAmt - (loandetails.InstallmentAmount * days) + sdtoLoanRepayment.PreviousPaymentDueAmount; //(sdtoLoanRepayment.RepaymentAmount - repaymentInterestAmt); sdtoLoanRepayment.PendingInstallments -= Convert.ToInt32(Math.Floor(sdtoLoanRepayment.PendingPrincipalAmount / loandetails.InstallmentAmount)); sdtoLoanRepayment.PrincipalAmount = loandetails.LoanAmount; sdtoLoanRepayment.Status = Data.Models.Enumerations.RepaymentStatus.Paid; sdtoLoanRepayment.CreatedOn = DateTime.Now; sdtoLoanRepayment.RepaymentCode = objReport.GenerateCode("LoanRepayment"); db.sdtoLoanRepayments.Add(sdtoLoanRepayment); db.SaveChanges(); bfTransaction objTrans = new bfTransaction(db); objTrans.PostLoanRepayment(sdtoLoanRepayment); return RedirectToAction("Index", new { LoanId = sdtoLoanRepayment.LoanId }); } } var itemsLoan = db.sdtoLoanInfoes.Include(x => x.Member).ToList(); var itemsLoans = itemsLoan.Select(x => new SelectListItem() { Value = x.LoanId.ToString(), Text = x.LoanId + " - " + x.LoanAmount + "[" + x.Member.FirstName + " " + x.Member.LastName + "]" }).ToList(); itemsLoans.Insert(0, new SelectListItem() { Value = "0", Text = "Select a loan" }); ViewBag.LoanList = new SelectList(itemsLoans, "Value", "Text"); return View(sdtoLoanRepayment); }
public ActionResult Create(int? LoanId) { sdtoLoanRepayment repay = new sdtoLoanRepayment(); var itemsLoan = db.sdtoLoanInfoes.Include(x => x.Member).Where(x => x.Status == LoanStatus.Active).ToList(); var itemsLoans = itemsLoan.Select(x => new SelectListItem() { Value = x.LoanId.ToString(), Text = x.LoanId + " - " + x.LoanAmount + "[" + x.Member.FirstName + " " + x.Member.LastName + "]" }).ToList(); itemsLoans.Insert(0, new SelectListItem() { Value = "0", Text = "Select a loan" }); ViewBag.LoanList = new SelectList(itemsLoans, "Value", "Text"); bfReport objReport = new bfReport(db); if (LoanId != null && LoanId.Value > 0) { var loandetails = db.sdtoLoanInfoes.Find(LoanId); var loanPendingAmt = loandetails.LoanAmount; var loanInterest = loandetails.InteresRate; var loanPendingInstallments = loandetails.TotalInstallments; var loanRepayment = db.sdtoLoanRepayments.Where(x => x.LoanId == LoanId && x.IsDeleted == false && x.Status != RepaymentStatus.Cancelled).OrderByDescending(x => x.LoanRepaymentId).FirstOrDefault(); var repaymentInterest = loanInterest; var days = (DateTime.Now.Date - loandetails.RepaymentStartDate.Value).Days; days = days == 0 ? 1 : days; if (days < 0) days = 0; var repaymentInterestAmt = (loanPendingAmt * Convert.ToDecimal(repaymentInterest / 100) * days) / 365; var lastRepaymentDate = loandetails.RepaymentStartDate.Value; if (loanRepayment != null && loanRepayment.LoanRepaymentId > 0) { if (loanRepayment.RepaymentDate != null) lastRepaymentDate = loanRepayment.RepaymentDate.Value; days = (DateTime.Now.Date - lastRepaymentDate).Days; days = days == 0 ? 1 : days; if (days < 0) days = 0; loanPendingAmt = loanRepayment.PendingPrincipalAmount; loanPendingInstallments = loanRepayment.PendingInstallments; repaymentInterest = loanRepayment.InterestRate; repaymentInterestAmt = (loanPendingAmt * Convert.ToDecimal(repaymentInterest / 100) * days) / 365; repay.RepaymentCode = loanRepayment.RepaymentCode; } repay.RepaymentDate = lastRepaymentDate.AddDays(1); repay.InterestRate = repaymentInterest; repay.InterestAmount = Math.Round(repaymentInterestAmt, 2); repay.PendingPrincipalAmount = loanPendingAmt; repay.PendingInstallments = loanPendingInstallments; repay.PrincipalAmount = loandetails.LoanAmount; repay.Status = Data.Models.Enumerations.RepaymentStatus.Paid; repay.PaymentMode = ModeOfPayment.Cash; repay.RepaymentAmount = (loandetails.InstallmentAmount * days) + repay.InterestAmount + repay.PreviousPaymentDueAmount; repay.RepaymentCode = objReport.GenerateCode("LoanRepayment"); ViewBag.InstallmentAmount = loandetails.InstallmentAmount; } return View(repay); }
public ActionResult ImportView(HttpPostedFileBase DeviceInput) { StreamReader reader = new StreamReader(DeviceInput.InputStream); while (!reader.EndOfStream) { string lineInput = reader.ReadLine(); if (!string.IsNullOrWhiteSpace(lineInput)) { string[] arrLines = lineInput.Split("\0".ToCharArray()); if (arrLines != null && arrLines.Length > 0) { foreach (string strLine in arrLines) { string[] arrValues = strLine.Split(",".ToCharArray()); if (arrValues != null && arrValues.Length > 10) { sdtoLoanRepayment repayment = new sdtoLoanRepayment(); long iLoanId = 0; long.TryParse(arrValues[2], out iLoanId); repayment.LoanId = iLoanId; if (repayment.LoanId > 0) { float fPaymentAmount = 0; float.TryParse(arrValues[3], out fPaymentAmount); DateTime dt = DateTime.Now; DateTime.TryParse(arrValues[8], out dt); repayment.RepaymentDate = dt; var loandetails = db.sdtoLoanInfoes.Find(repayment.LoanId); if (loandetails != null) { var loanPendingAmt = loandetails.LoanAmount; var loanInterest = loandetails.InteresRate; var loanPendingInstallments = loandetails.TotalInstallments; var loanRepayment = db.sdtoLoanRepayments.Where(x => x.LoanId == repayment.LoanId && x.IsDeleted == false && x.Status != RepaymentStatus.Cancelled).OrderByDescending(x => x.LoanRepaymentId).FirstOrDefault(); var repaymentInterest = loanInterest; var repaymentInterestAmt = (loanPendingAmt * Convert.ToDecimal(repaymentInterest / 100)) / 365; if (loanRepayment != null && loanRepayment.LoanRepaymentId > 0) { loanPendingAmt = loanRepayment.PendingPrincipalAmount; loanPendingInstallments = loanRepayment.PendingInstallments; repaymentInterest = loanRepayment.InterestRate; repaymentInterestAmt = (loanPendingAmt * Convert.ToDecimal(repaymentInterest / 100)) / 365; repayment.RepaymentCode = loanRepayment.RepaymentCode; } repayment.InterestAmount = Math.Round(repaymentInterestAmt, 2); repayment.PendingPrincipalAmount = loanPendingAmt - (repayment.RepaymentAmount - repaymentInterestAmt); repayment.PendingInstallments -= Convert.ToInt32(Math.Floor(repayment.PendingPrincipalAmount / loandetails.InstallmentAmount)); repayment.PrincipalAmount = loandetails.LoanAmount; repayment.Status = Data.Models.Enumerations.RepaymentStatus.Paid; repayment.CreatedOn = DateTime.Now; db.sdtoLoanRepayments.Add(repayment); db.SaveChanges(); } } } } } } } reader.Close(); sdtoUser sessionUser = UtilityHelper.UserSession.GetSession(UtilityHelper.UserSession.LoggedInUser) as sdtoUser; long CompanyId = 0; if (sessionUser != null && sessionUser.CompanyId != null) CompanyId = sessionUser.CompanyId.Value; DataTable dtRptParams = new DataTable(); dtRptParams.Columns.Add(new DataColumn("EntityId", typeof(long))); dtRptParams.Columns.Add(new DataColumn("EntityStartDate", typeof(DateTime))); dtRptParams.Columns.Add(new DataColumn("EntityEndDate", typeof(DateTime))); dtRptParams.Columns.Add(new DataColumn("EntityIntVal", typeof(int))); dtRptParams.Columns.Add(new DataColumn("EntityStrVal", typeof(string))); dtRptParams.Columns.Add(new DataColumn("EntityType", typeof(string))); bfReport objReport = new bfReport(null); var loanInfoList = objReport.GetRptLoanSummary(CompanyId, dtRptParams).ToList().Select(x => new sdtoLoanRepayment() { LoanId = x.LoanId, LoanDetails = new sdtoLoanInfo() { Member = new sdtoUser() { FirstName = x.FirstName, LastName = x.LastName } }, PendingPrincipalAmount = x.BalanceLoanAmount }); return View(loanInfoList); }
public ActionResult ExportView() { sdtoUser sessionUser = UtilityHelper.UserSession.GetSession(UtilityHelper.UserSession.LoggedInUser) as sdtoUser; long CompanyId = 0; if (sessionUser != null && sessionUser.CompanyId != null) CompanyId = sessionUser.CompanyId.Value; DataTable dtRptParams = new DataTable(); dtRptParams.Columns.Add(new DataColumn("EntityId", typeof(long))); dtRptParams.Columns.Add(new DataColumn("EntityStartDate", typeof(DateTime))); dtRptParams.Columns.Add(new DataColumn("EntityEndDate", typeof(DateTime))); dtRptParams.Columns.Add(new DataColumn("EntityIntVal", typeof(int))); dtRptParams.Columns.Add(new DataColumn("EntityStrVal", typeof(string))); dtRptParams.Columns.Add(new DataColumn("EntityType", typeof(string))); bfReport objReport = new bfReport(null); var loanInfoList = objReport.GetRptLoanSummary(CompanyId, dtRptParams).ToList().Select(x => new sdtoLoanRepayment() { LoanId = x.LoanId, LoanDetails = new sdtoLoanInfo() { Member = new sdtoUser() { FirstName = x.FirstName, LastName = x.LastName } }, PendingPrincipalAmount = x.BalanceLoanAmount }); return View(loanInfoList); }
public FileStreamResult Export() { //var sdtoLoanInfoes = db.sdtoLoanInfoes.Include(s => s.CreatedByUser).Include(s => s.DeletedByUser).Include(s => s.Member).Include(s => s.ModifiedByUser).Where(x => x.IsDeleted == false && x.Status == LoanStatus.Active); sdtoUser sessionUser = UtilityHelper.UserSession.GetSession(UtilityHelper.UserSession.LoggedInUser) as sdtoUser; long CompanyId = 0; if (sessionUser != null && sessionUser.CompanyId != null) CompanyId = sessionUser.CompanyId.Value; DataTable dtRptParams = new DataTable(); dtRptParams.Columns.Add(new DataColumn("EntityId", typeof(long))); dtRptParams.Columns.Add(new DataColumn("EntityStartDate", typeof(DateTime))); dtRptParams.Columns.Add(new DataColumn("EntityEndDate", typeof(DateTime))); dtRptParams.Columns.Add(new DataColumn("EntityIntVal", typeof(int))); dtRptParams.Columns.Add(new DataColumn("EntityStrVal", typeof(string))); dtRptParams.Columns.Add(new DataColumn("EntityType", typeof(string))); bfReport objReport = new bfReport(null); var loanInfoList = objReport.GetRptLoanSummary(CompanyId, dtRptParams).ToList().Select(x => new sdtoLoanRepayment() { LoanId = x.LoanId, LoanDetails = new sdtoLoanInfo() { Member = new sdtoUser() { FirstName = x.FirstName, LastName = x.LastName } }, PendingPrincipalAmount = x.BalanceLoanAmount }).ToList(); //string HeaderData = ""; string Data = ""; //HeaderData = "Member ID" + " " + "Name of customer" + " " + "STOL" + " " + "Amount" + " " + "Interest" + Environment.NewLine; //Data = HeaderData; foreach (sdtoLoanRepayment Linfo in loanInfoList) { Data += Linfo.LoanId + " " + Linfo.LoanDetails.Member.FirstName + " " + Linfo.LoanDetails.Member.FirstName + " STOL " + Linfo.PendingPrincipalAmount + " " + Linfo.LoanDetails.InteresRate + " "; //Data += Linfo.Member.UserID.ToString() + " " + Linfo.Member.FirstName + " " + "STOL" + " " + Linfo.LoanAmount.ToString() + " " + Linfo.InteresRate.ToString() + Environment.NewLine; } var byteArray = Encoding.ASCII.GetBytes(Data); var stream = new MemoryStream(byteArray); return File(stream, "text/plain", "LoanData.DAT"); }