예제 #1
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            Patient aPatient = new Patient();

            aPatient.Name          = patientNameTextBox.Text;
            aPatient.DateOfBirth   = dateOfBirthTextBox.Text;
            aPatient.MobileNo      = mobileNoTextBox.Text;
            aPatient.BillAmount    = Convert.ToDouble(totalTextBox.Text);
            aPatient.PaymentStatus = 0;
            string date = DateTime.Now.ToString("yyyy-MM-dd");

            if (aTestRequestManager.SavePatient(aPatient) != "Please use another Mobile No !")
            {
                foreach (Test anyTest in (List <Test>)Session["TempTest"])
                {
                    TestRequest aTestRequest = new TestRequest();
                    aTestRequest.PatientId = aTestRequestManager.GetPatientId(aPatient.MobileNo);
                    aTestRequest.TestId    = anyTest.TestId;
                    aTestRequest.EntryDate = date;

                    outputLabel.Text = aTestRequestManager.SaveTestRequest(aTestRequest);
                }


                PDFManager aPdfManager = new PDFManager();
                Document   pdfDocument = new Document(PageSize.A4, 50f, 50f, 50f, 50f);
                PdfWriter.GetInstance(pdfDocument, Response.OutputStream);

                pdfDocument.Open();
                pdfDocument.Add(aPdfManager.GetBillPdfParagraph(date, aTestRequestManager.GetPatientId(aPatient.MobileNo), aPatient.Name, aPatient.DateOfBirth, aPatient.MobileNo, testRequestGridView, totalTextBox.Text));
                pdfDocument.Close();

                patientNameTextBox.Text        = string.Empty;
                dateOfBirthTextBox.Text        = string.Empty;
                mobileNoTextBox.Text           = string.Empty;
                testRequestGridView.DataSource = null;
                testRequestGridView.DataBind();
                Session["TempTest"] = null;
                totalTextBox.Text   = String.Empty;
                testTypeDropDown.ClearSelection();

                Response.ContentType = "application/pdf";
                Response.AppendHeader("content-disposition", "attachment;filename=Bill.pdf");
                Response.Write(pdfDocument);
                Response.Flush();
                Response.End();
            }
            else
            {
                outputLabel.Text = "Please use another Mobile No !";
            }
        }