protected void GenerateReport(object sender, EventArgs e)
        {
            //BECommon objBECommon = new BECommon();
            //BCommon objBCommon = new BCommon();
            //objBECommon.IntUserID = int.Parse(Session[BaseClass.EnumPageSessions.USERID].ToString());
            //objBECommon.DateStartDate = StartDate;
            //objBECommon.DateEndDate = EndDate;

            //objBCommon.BGetExamBillingDetails(objBECommon);

            //DataTable objDt = objBECommon.DsResult.Tables[0];

            //for (int i = 1; i < objBECommon.DsResult.Tables.Count; i++)
            //{
            //    objDt.Merge(objBECommon.DsResult.Tables[i]);
            //}
            //objDt.AcceptChanges();

            ////gvReports.DataSource = objDt;
            //if (objDt != null && objDt.Rows.Count > 0)
            //{
            //    gvReports.DataSource = objDt;
            //    //gvReports.Rebind();
            //    trExportButtons.Visible = true;
            //    trGridView.Visible = true;
            //}
            //else
            //{
            //    gvReports.DataSource = new Object[0];
            //    trExportButtons.Visible = false;
            //    trGridView.Visible = true;
            //}

            //string paidexamfee = string.Empty;
            //string paidondemandfee = string.Empty;

            //BEAdmin objBEAdmin = new BEAdmin();
            //BAdmin objBAdmin = new BAdmin();
            //objBAdmin.BGetPaymentMode(objBEAdmin);
            //if (objBEAdmin.DtResult != null && objBEAdmin.DtResult.Rows.Count > 0)
            //{
            //    paidexamfee = objBEAdmin.DtResult.Rows[0]["PaidBy_ExamFee"].ToString();
            //    paidondemandfee = objBEAdmin.DtResult.Rows[0]["PaidBy_OnDemandFee"].ToString();
            //}
            //lblRecords.Text = objDt.Rows.Count.ToString();
            ////lblExamFee.Text = "$" + objDt.Compute("SUM(ExamFee)", String.Empty);
            ////lblOnDemandFee.Text = "$" + objDt.Compute("SUM(OndemandFee)", String.Empty);
            //if (paidexamfee == "University" && paidondemandfee != "University")
            //{
            //    //tdondemandfee.Visible = false;
            //    //tdondemandfeelabel.Visible = false;
            //    //tdexamfeelabel.Visible = true;
            //    //tdexamfee.Visible = true;
            //    lblexamfeetitle.Text = "Total Exam Fee (University) :";
            //    lblondemandtitle.Text = "Total On-demand Fee (Student) :";
            //    lbltotalfeetitle.Text = "Total Fee (University) :";
            //    lblExamFee.Text = "$" + objDt.Compute("SUM(ExamFee)", String.Empty);
            //    lblOnDemandFee.Text = "$" + objDt.Compute("SUM(OndemandFee)", String.Empty);
            //    lblTotalFee.Text = "$" + objDt.Compute("SUM(ExamFee)", String.Empty);
            //}
            //else if (paidexamfee != "University" && paidondemandfee == "University")
            //{
            //    //tdexamfeelabel.Visible = false;
            //    //tdexamfee.Visible = false;
            //    //tdondemandfee.Visible = true;
            //    //tdondemandfeelabel.Visible = true;
            //    lblexamfeetitle.Text = "Total Exam Fee (Student) :";
            //    lblondemandtitle.Text = "Total On-demand Fee (University) :";
            //    lbltotalfeetitle.Text = "Total Fee (University) :";
            //    lblExamFee.Text = "$" + objDt.Compute("SUM(ExamFee)", String.Empty);
            //    lblOnDemandFee.Text = "$" + objDt.Compute("SUM(OndemandFee)", String.Empty);
            //    lblTotalFee.Text = "$" + objDt.Compute("SUM(OndemandFee)", String.Empty);
            //}
            //else if (paidexamfee == "University" && paidondemandfee == "University")
            //{
            //    //tdexamfeelabel.Visible = true;
            //    //tdexamfee.Visible = true;
            //    //tdondemandfee.Visible = true;
            //    //tdondemandfeelabel.Visible = true;
            //    lblexamfeetitle.Text = "Total Exam Fee (University) :";
            //    lblondemandtitle.Text = "Total On-demand Fee (University) :";
            //    lbltotalfeetitle.Text = "Total Fee (University) :";
            //    lblExamFee.Text = "$" + objDt.Compute("SUM(ExamFee)", String.Empty);
            //    lblOnDemandFee.Text = "$" + objDt.Compute("SUM(OndemandFee)", String.Empty);
            //    lblTotalFee.Text = "$" + objDt.Compute("SUM(TotalFee)", String.Empty);
            //}
            //else if (paidexamfee != "University" && paidondemandfee != "University")
            //{
            //    //lblTotalFee.Text = "$" + objDt.Compute("SUM(TotalFee)", String.Empty);
            //    //tdexamfeelabel.Visible = false;
            //    //tdexamfee.Visible = false;
            //    //tdondemandfee.Visible = false;
            //    //tdondemandfeelabel.Visible = false;
            //    //tdtotalfee.Visible = false;
            //    //tdtotalfeelabel.Visible = false;
            //    lblexamfeetitle.Text = "Total Exam Fee (Student) :";
            //    lblondemandtitle.Text = "Total On-demand Fee (Student) :";
            //    lbltotalfeetitle.Text = "Total Fee (Student) :";
            //    lblExamFee.Text = "$" + objDt.Compute("SUM(ExamFee)", String.Empty);
            //    lblOnDemandFee.Text = "$" + objDt.Compute("SUM(OndemandFee)", String.Empty);
            //    lblTotalFee.Text = "$" + objDt.Compute("SUM(TotalFee)", String.Empty);
            //}

            BEAdmin objBEAdmin = new BEAdmin();
            BAdmin  objBAdmin  = new BAdmin();

            objBAdmin.BGetClientContactDetails(objBEAdmin);
            string ExamIDSeries   = string.Empty;
            string strOrgName     = string.Empty;
            string strStreet1     = string.Empty;
            string strStreet2     = string.Empty;
            string strCity        = string.Empty;
            string strRegion      = string.Empty;
            string strPostalCode  = string.Empty;
            string strName        = string.Empty;
            string strDesignation = string.Empty;


            if (objBEAdmin.DsResult != null && objBEAdmin.DsResult.Tables[0].Rows.Count > 0)
            {
                ExamIDSeries = objBEAdmin.DsResult.Tables[0].Rows[0]["ExamIDSeries"].ToString();
            }

            if (objBEAdmin.DsResult != null && objBEAdmin.DsResult.Tables[1].Rows.Count > 0)
            {
                strOrgName     = objBEAdmin.DsResult.Tables[1].Rows[0]["OrganizationName"].ToString();
                strStreet1     = objBEAdmin.DsResult.Tables[1].Rows[0]["Street1"].ToString();
                strStreet2     = objBEAdmin.DsResult.Tables[1].Rows[0]["Street2"].ToString();
                strCity        = objBEAdmin.DsResult.Tables[1].Rows[0]["City"].ToString();
                strRegion      = objBEAdmin.DsResult.Tables[1].Rows[0]["Region"].ToString();
                strPostalCode  = objBEAdmin.DsResult.Tables[1].Rows[0]["PostalCode"].ToString();
                strName        = objBEAdmin.DsResult.Tables[1].Rows[0]["Name"].ToString();
                strDesignation = objBEAdmin.DsResult.Tables[1].Rows[0]["Designation"].ToString();
            }


            Document document   = new Document(PageSize.A4, 88f, 88f, 10f, 10f);
            Font     NormalFont = FontFactory.GetFont("Times New Roman", 12, Font.NORMAL, Color.BLACK);

            using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
            {
                PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
                //Phrase phrase = null;
                PdfPCell  cell  = null;
                PdfPTable table = null;
                //Color color = null;

                document.Open();

                //Header Table
                table             = new PdfPTable(1);
                table.TotalWidth  = 450f;
                table.LockedWidth = true;
                table.SetWidths(new float[] { 1f });

                document.Add(table);

                table = new PdfPTable(4);
                table.HorizontalAlignment = Element.ALIGN_CENTER;
                table.LockedWidth         = true;
                table.SetWidths(new float[] { 1f, 1f, 1f, 1f });
                table.SpacingBefore = 20f;
                table.TotalWidth    = 450f;


                cell         = PhraseCell(new Phrase(), PdfPCell.ALIGN_CENTER);
                cell.Colspan = 1;
                table.AddCell(cell);
                cell            = PhraseCell(new Phrase("Secure Proctor", FontFactory.GetFont("Times New Roman", 12, Font.UNDERLINE, Color.BLACK)), PdfPCell.ALIGN_CENTER);
                cell.Colspan    = 2;
                cell.PaddingTop = 20f;
                table.AddCell(cell);
                cell               = PhraseCell(new Phrase(), PdfPCell.ALIGN_CENTER);
                cell.Colspan       = 1;
                cell.PaddingBottom = 60f;
                table.AddCell(cell);

                cell         = PhraseCell(new Phrase("BILL TO:\n", FontFactory.GetFont("Times New Roman", 10, Font.BOLD, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 2;
                table.AddCell(cell);
                cell              = PhraseCell(new Phrase("Date:", FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_RIGHT);
                cell.Colspan      = 1;
                cell.PaddingRight = 29f;
                table.AddCell(cell);
                cell         = PhraseCell(new Phrase(String.Format("{0:d}", DateTime.Today), FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 1;
                table.AddCell(cell);

                cell         = PhraseCell(new Phrase(strOrgName, FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 2;
                table.AddCell(cell);
                cell              = PhraseCell(new Phrase("Invoice #:", FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_RIGHT);
                cell.Colspan      = 1;
                cell.PaddingRight = 10f;
                table.AddCell(cell);
                cell         = PhraseCell(new Phrase(String.Format("{0:yyMMdd}", DateTime.Today) + ExamIDSeries, FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 1;
                table.AddCell(cell);

                cell         = PhraseCell(new Phrase(strName + "\n", FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 2;
                table.AddCell(cell);
                cell              = PhraseCell(new Phrase("Terms:", FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_RIGHT);
                cell.Colspan      = 1;
                cell.PaddingRight = 22f;
                table.AddCell(cell);
                cell         = PhraseCell(new Phrase("Due On Receipt", FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 1;
                table.AddCell(cell);

                cell         = PhraseCell(new Phrase(strDesignation + "\n", FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 3;
                table.AddCell(cell);
                cell         = PhraseCell(new Phrase(), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 1;
                table.AddCell(cell);

                cell         = PhraseCell(new Phrase(strStreet1 + " " + strStreet2 + "\n", FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 3;
                table.AddCell(cell);
                cell         = PhraseCell(new Phrase(), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 1;
                table.AddCell(cell);

                cell         = PhraseCell(new Phrase(strCity + "," + strRegion + " " + strPostalCode, FontFactory.GetFont("Times New Roman", 10, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 3;
                table.AddCell(cell);
                cell         = PhraseCell(new Phrase(), PdfPCell.ALIGN_LEFT);
                cell.Colspan = 1;
                table.AddCell(cell);


                cell         = PhraseCell(new Phrase(), PdfPCell.ALIGN_CENTER);
                cell.Colspan = 1;
                table.AddCell(cell);
                cell            = PhraseCell(new Phrase("INVOICE", FontFactory.GetFont("Times New Roman", 14, Font.UNDERLINE, Color.BLACK)), PdfPCell.ALIGN_CENTER);
                cell.Colspan    = 2;
                cell.PaddingTop = 20f;
                table.AddCell(cell);
                cell               = PhraseCell(new Phrase(), PdfPCell.ALIGN_CENTER);
                cell.Colspan       = 1;
                cell.PaddingBottom = 40f;
                table.AddCell(cell);

                document.Add(table);

                table = new PdfPTable(6);
                table.HorizontalAlignment = Element.ALIGN_CENTER;
                table.LockedWidth         = true;
                table.SetWidths(new float[] { 1f, 1f, 1f, 1f, 1f, 1f });
                table.SpacingBefore = 20f;
                table.TotalWidth    = 450f;

                cell               = PhraseCell(new Phrase("DESCRIPTION", FontFactory.GetFont("Times New Roman", 12, Font.BOLD, Color.BLACK)), PdfPCell.ALIGN_CENTER);
                cell.Colspan       = 3;
                cell.MinimumHeight = 40f;
                cell.PaddingTop    = 10f;
                cell.BorderColor   = new Color(System.Drawing.Color.Black);
                cell.Border        = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);
                cell             = PhraseCell(new Phrase("Quantity", FontFactory.GetFont("Times New Roman", 10, Font.BOLD, Color.BLACK)), PdfPCell.ALIGN_CENTER);
                cell.Colspan     = 1;
                cell.BorderColor = new Color(System.Drawing.Color.Black);
                cell.Border      = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);
                cell             = PhraseCell(new Phrase("", FontFactory.GetFont("Times New Roman", 10, Font.BOLD, Color.BLACK)), PdfPCell.ALIGN_CENTER);
                cell.Colspan     = 1;
                cell.BorderColor = new Color(System.Drawing.Color.Black);
                cell.Border      = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);
                cell             = PhraseCell(new Phrase("Amount", FontFactory.GetFont("Times New Roman", 10, Font.BOLD, Color.BLACK)), PdfPCell.ALIGN_CENTER);
                cell.Colspan     = 1;
                cell.BorderColor = new Color(System.Drawing.Color.Black);
                cell.Border      = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);

                document.Add(table);

                table = new PdfPTable(6);
                table.HorizontalAlignment = Element.ALIGN_CENTER;
                table.LockedWidth         = true;
                table.SetWidths(new float[] { 1f, 1f, 1f, 1f, 1f, 1f });
                table.TotalWidth = 450f;

                cell               = PhraseCell(new Phrase(ddlMonths.SelectedItem.Text + " Proctoring " + strOrgName, FontFactory.GetFont("Times New Roman", 8, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan       = 3;
                cell.MinimumHeight = 80f;
                cell.PaddingTop    = 5f;
                cell.BorderColor   = new Color(System.Drawing.Color.Black);
                cell.Border        = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);
                cell               = PhraseCell(new Phrase(lblRecords.Text, FontFactory.GetFont("Times New Roman", 8, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_RIGHT);
                cell.Colspan       = 1;
                cell.MinimumHeight = 80f;
                cell.BorderColor   = new Color(System.Drawing.Color.Black);
                cell.Border        = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);
                cell               = PhraseCell(new Phrase("", FontFactory.GetFont("Times New Roman", 8, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_RIGHT);
                cell.Colspan       = 1;
                cell.MinimumHeight = 80f;
                cell.BorderColor   = new Color(System.Drawing.Color.Black);
                cell.Border        = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);
                cell               = PhraseCell(new Phrase(lblTotalFee.Text, FontFactory.GetFont("Times New Roman", 8, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_RIGHT);
                cell.Colspan       = 1;
                cell.MinimumHeight = 80f;
                cell.BorderColor   = new Color(System.Drawing.Color.Black);
                cell.Border        = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);

                document.Add(table);

                table = new PdfPTable(6);
                table.HorizontalAlignment = Element.ALIGN_CENTER;
                table.LockedWidth         = true;
                table.SetWidths(new float[] { 1f, 1f, 1f, 1f, 1f, 1f });
                table.TotalWidth = 450f;

                cell               = PhraseCell(new Phrase(" Please make checks payable to Secure Proctor and remit to 20 Pickering St,\n Needham, MA 02492", FontFactory.GetFont("Times New Roman", 7, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_LEFT);
                cell.Colspan       = 4;
                cell.MinimumHeight = 40f;
                cell.PaddingTop    = 5f;
                cell.BorderColor   = new Color(System.Drawing.Color.Black);
                cell.Border        = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);
                cell             = PhraseCell(new Phrase("TOTAL", FontFactory.GetFont("Times New Roman", 8, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_RIGHT);
                cell.Colspan     = 1;
                cell.BorderColor = new Color(System.Drawing.Color.Black);
                cell.Border      = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                cell.PaddingTop  = 5f;
                table.AddCell(cell);
                cell             = PhraseCell(new Phrase(lblTotalFee.Text, FontFactory.GetFont("Times New Roman", 8, Font.NORMAL, Color.BLACK)), PdfPCell.ALIGN_RIGHT);
                cell.Colspan     = 1;
                cell.PaddingTop  = 5f;
                cell.BorderColor = new Color(System.Drawing.Color.Black);
                cell.Border      = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER;
                table.AddCell(cell);
                document.Add(table);
                document.Close();
                byte[] bytes = memoryStream.ToArray();
                memoryStream.Close();
                Response.Clear();
                Response.ContentType = "application/pdf";
                Response.AddHeader("Content-Disposition", "attachment; filename=Invoice.pdf");
                Response.ContentType = "application/pdf";
                Response.Buffer      = true;
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.BinaryWrite(bytes);
                Response.End();
                Response.Close();
            }
        }