/// <summary>
        /// Frontend Page: Report(lot inspection fee receipt)
        /// Title:load details of paid lot inspection fees
        /// Deigned:Piyumi Perera
        /// User story:
        /// Developed:Piyumi Perera
        /// Date created:
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int loanId = 0;
                //check selected loan id is not empty and assign to variable
                if (Request.QueryString["loanId"] != "")
                    loanId = Convert.ToInt32(Request.QueryString["loanId"]);
                //check selected start date is not empty and assign to variable
                if (string.IsNullOrEmpty(Request.QueryString["startDate"])) return;
                var startDate = DateTime.ParseExact(Request.QueryString["startDate"], "MM/dd/yyyy", new CultureInfo("en-US"));
                //check selected end date is not empty and assign to variable
                if (string.IsNullOrEmpty(Request.QueryString["endDate"])) return;
                var endDate = DateTime.ParseExact(Request.QueryString["endDate"], "MM/dd/yyyy", new CultureInfo("en-US"));

                ReportAccess ra = new ReportAccess();
                //get paid lot inspection fee details
                List<RptFee> lotInspectionFee = ra.GetFeeReceiptByDateRange(loanId, "lotInspectionFee", startDate, endDate);
                //check list count is >0
                if(lotInspectionFee.Count>0)
                {
                    //load report
                    RenderReport(loanId, startDate, endDate, lotInspectionFee);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowFrame", "ShowDive();", true);
                }
                else
                {
                    //show no data found message
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "HideFrame", "HideDive();", true);
                }
            }
        }
        /// <summary>
        /// Frontend Page: Report page(Advance Fee Receipt Report)
        /// Title: Display Advance Fee Receipt
        /// Designed: Kasun Samarawickrama
        /// User story: 
        /// Developed: Kasun Samarawickrama
        /// Date created: 
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int loanId = 0;

                //if session is not null and assign it.
                if (Request.QueryString["loanId"] != "")
                    loanId = Convert.ToInt32(Request.QueryString["loanId"]);

                if (string.IsNullOrEmpty(Request.QueryString["startDate"])) return;
                var startDate = DateTime.ParseExact(Request.QueryString["startDate"], "MM/dd/yyyy", new CultureInfo("en-US"));

                if (string.IsNullOrEmpty(Request.QueryString["endDate"])) return;
                var endDate = DateTime.ParseExact(Request.QueryString["endDate"], "MM/dd/yyyy", new CultureInfo("en-US"));

                //Get Advance Fee receipt during time period
                ReportAccess ra = new ReportAccess();
                List<RptFee> advanceFeeReceipt = ra.GetFeeReceiptByDateRange(loanId, "advanceFee", startDate, endDate);

                //if result count is greater then zero show report, otherwise give a message
                if (advanceFeeReceipt.Count > 0)
                {
                    //call RenderReport function to show report on report viwer
                    RenderReport(loanId, startDate, endDate, advanceFeeReceipt);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowFrame", "ShowDive();", true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "HideFrame", "HideDive();", true);
                }
            }


        }
        /// <summary>
        /// Frontend Page: Report(lot inspection fee receipt)
        /// Title:print lot inspection fee receipt report
        /// Deigned:Piyumi Perera
        /// User story:
        /// Developed:Piyumi Perera
        /// Date created: 
        /// </summary>
        /// <param name="loanId"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public ReportViewer PrintPage(int loanId, DateTime startDate, DateTime endDate)
        {
            //check authentication session is null, if null return
            if (Session["AuthenticatedUser"] == null) return null;
            User userData = (User)Session["AuthenticatedUser"];

            ReportViewer rptViewerLotInspectionFeeReceiptPrint = new ReportViewer();
            rptViewerLotInspectionFeeReceiptPrint.ProcessingMode = ProcessingMode.Local;
            rptViewerLotInspectionFeeReceiptPrint.Reset();
            rptViewerLotInspectionFeeReceiptPrint.LocalReport.EnableExternalImages = true;
            rptViewerLotInspectionFeeReceiptPrint.LocalReport.ReportPath = Server.MapPath("~/Reports/RptLotInspectionFeeReceipt.rdlc");

            ReportAccess ra = new ReportAccess();
            //get loan details of selected loan
            List<LoanDetailsRpt> details = ra.GetLoanDetailsRpt(loanId, userData.UserId);

            foreach (var dates in details)
            {
                //assign date fields values
                dates.StartRange = startDate.ToString("MM/dd/yyyy");
                dates.EndRange = endDate.ToString("MM/dd/yyyy");
                dates.ReportDate = DateTime.Now.ToString("MM/dd/yyyy");
            }

            //get paid lot inspection fee details
            List<RptFee> curtailments = ra.GetFeeReceiptByDateRange(loanId, "lotInspectionFee", startDate, endDate);
            //add data sources
            rptViewerLotInspectionFeeReceiptPrint.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", details));
            rptViewerLotInspectionFeeReceiptPrint.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", curtailments));

            return rptViewerLotInspectionFeeReceiptPrint;
        }
        /// <summary>
        /// Frontend Page: Report page(Advance Fee Receipt Report)
        /// Title: Display Advance Fee Receipt
        /// Designed: Kasun Samarawickrama
        /// User story: 
        /// Developed: Kasun Samarawickrama
        /// Date created: 
        /// </summary>
        public ReportViewer PrintPage(int loanId, DateTime startDate, DateTime endDate)
        {
            //Check authentication session is null then return
            if (Session["AuthenticatedUser"] == null) return null;
            User userData = (User)Session["AuthenticatedUser"];

            ReportViewer rptViewerAdvanceFeeReceiptPrint = new ReportViewer();

            rptViewerAdvanceFeeReceiptPrint.ProcessingMode = ProcessingMode.Local;
            rptViewerAdvanceFeeReceiptPrint.Reset();
            rptViewerAdvanceFeeReceiptPrint.LocalReport.EnableExternalImages = true;
            rptViewerAdvanceFeeReceiptPrint.LocalReport.ReportPath = Server.MapPath("~/Reports/RptAdvanceFeeReceipt.rdlc");
            rptViewerAdvanceFeeReceiptPrint.ZoomMode = ZoomMode.PageWidth;

            //Get account details
            ReportAccess ra = new ReportAccess();
            List<LoanDetailsRpt> details = ra.TopHeaderDetails(loanId, userData.UserId);

            foreach (var dates in details)
            {
                dates.StartRange = startDate.ToString("MM/dd/yyyy");
                dates.EndRange = endDate.ToString("MM/dd/yyyy");
                dates.ReportDate = DateTime.Now.ToString("MM/dd/yyyy");
            }

            //Get Advance Fee receipt during time period
            List<RptFee> curtailments = ra.GetFeeReceiptByDateRange(loanId, "advanceFee", startDate, endDate);

            //Set data set to report
            rptViewerAdvanceFeeReceiptPrint.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", details));
            rptViewerAdvanceFeeReceiptPrint.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", curtailments));

            //return reportviwer
            return rptViewerAdvanceFeeReceiptPrint;
        }