Exemplo n.º 1
0
        protected void btnTestRequst_Click(object sender, EventArgs e)
        {
            if (txtMobileNo.Text.Length != 11)
            {
                messageLabel.ForeColor = Color.Red;
                messageLabel.Text      = "Please Enter valid mobile No.";
                return;
            }
            else
            {
                messageLabel.Text = "";
                testList          = (List <Tests>)ViewState["Test"];

                string   name        = txtPatientName.Text;
                DateTime dateOfBirth = Convert.ToDateTime(txtDateOfBirth.Text);
                int      mobileNo    = Convert.ToInt32(txtMobileNo.Text);
                HiddenField1.Value = patientManager.Get8Digits();
                string   billNo   = HiddenField1.Value;
                DateTime billDate = System.DateTime.Now;
                decimal  totalFee = testList.Sum(x => x.testFee);
                decimal  PaidBill = 0;

                Patients patient = new Patients(name, dateOfBirth, mobileNo, billNo, billDate, totalFee, PaidBill);

                try
                {
                    patientManager.AddPatient(patient);
                }
                catch (Exception exception)
                {
                    lblMessage.Visible = true;
                    lblMessage.Text    = exception.Message;
                }
                int PatientId = patientManager.GetAllPatient().Max(x => x.ID);
                foreach (var test in testList)
                {
                    int            patientID   = PatientId;
                    int            testID      = test.ID;
                    PatientRequest testRequest = new PatientRequest(patientID, testID);
                    TestRequestManager.AddTestRequest(testRequest);
                }

                Generate_PDF();
            }
        }