/// <summary>
        // Frontend Page: Report page(Branch Summary report)
        /// Title: Display Branch Summary report
        /// Designed: Piyumi Perera
        /// User story: 
        /// Developed: Piyumi Perera
        /// Date created: 
        /// </summary>
        public void RenderReport(int branchId,string branchName, List<RptBranchSummary> branchSummary)
        {
            //check authentication session is null, if null return
            if (Session["AuthenticatedUser"] == null) return;
            User userData = (User)Session["AuthenticatedUser"];

            //set reportviewr properties
            rptViewerBranchSummary.ProcessingMode = ProcessingMode.Local;
            rptViewerBranchSummary.Reset();
            rptViewerBranchSummary.LocalReport.EnableExternalImages = true;
            rptViewerBranchSummary.LocalReport.ReportPath = Server.MapPath("~/Reports/RptBranchSummary.rdlc");
            rptViewerBranchSummary.ZoomMode = ZoomMode.PageWidth;

            ReportAccess ra = new ReportAccess();
            User usr = new User();
            usr = (new UserAccess()).retreiveUserByUserId(userData.UserId);
            List<LoanDetailsRpt> details = new List<LoanDetailsRpt>();
            LoanDetailsRpt detail = new LoanDetailsRpt();
            detail.CompanyName = userData.CompanyName;
            if (userData.RoleId == 1)
            {
                detail.LenderBrnchName = branchName;
            }
            else
            {
                detail.LenderBrnchName = userData.BranchName;
            }
            
            detail.ReportDate = DateTime.Now.ToString("MM/dd/yyyy");
            detail.CreaterName = usr.FirstName + " " + usr.LastName;
            details.Add(detail);
            rptViewerBranchSummary.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", details));

            foreach (var dates in details)
            {
                dates.ReportDate = DateTime.Now.ToString("MM/dd/yyyy");
            }
            
            rptViewerBranchSummary.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", branchSummary));
        }
        public List<LoanDetailsRpt> GetLoanDetailsRptforCompanySummary(int companyId, int userId)
        {
            List<LoanDetailsRpt> loanDetails = new List<LoanDetailsRpt>();

            DataHandler dataHandler = new DataHandler();
            List<object[]> paramertList = new List<object[]>();
            paramertList.Add(new object[] { "@user_id", userId });
            paramertList.Add(new object[] { "@company_id", companyId });

            DataSet dataSet = dataHandler.GetDataSet("spGetLoanDetailsByLoanIdRpts_CompanySummary", paramertList);

            if (dataSet != null && dataSet.Tables.Count != 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    LoanDetailsRpt details = new LoanDetailsRpt();

                    details.CreaterName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(dataRow["first_name"] + " " + dataRow["last_name"]);
                    details.CompanyName = dataRow["company_name"].ToString();
                    details.ReportDate = DateTime.Now.ToString("MM/dd/yyyy"); 

                    loanDetails.Add(details);

                    break;
                }
            }

            return loanDetails;
        }
        public List<LoanDetailsRpt> GetLoanDetailsRpt(int loanId, int userId)
        {
            List<LoanDetailsRpt> loanDetails = new List<LoanDetailsRpt>();

            DataHandler dataHandler = new DataHandler();
            List<object[]> paramertList = new List<object[]>();
            paramertList.Add(new object[] { "@user_id", userId });
            paramertList.Add(new object[] { "@loan_id", loanId });

            DataSet dataSet = dataHandler.GetDataSet("spGetLoanDetailsByLoanIdRpts", paramertList);

            if (dataSet != null && dataSet.Tables.Count != 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    LoanDetailsRpt details = new LoanDetailsRpt();

                    details.CreaterName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(dataRow["first_name"] + " " + dataRow["last_name"]);
                    details.LenderBrnchName = dataRow["branch_name"].ToString();
                    details.DealerBrnchName = dataRow["nr_branch_name"].ToString();
                    details.LoanNumber = dataRow["loan_number"].ToString();

                    loanDetails.Add(details);

                    break;
                }
            }

            return loanDetails;
        }