protected void saveBillButton_Click(object sender, EventArgs e) { Patient aPatient = new Patient(); aPatient.Name = nameOfPatientTextBox.Text; aPatient.DateOfBirth = dateTextBox.Text; aPatient.Mobile = mobileTextBox.Text; string patientSaved = aPatientManager.SavePatient(aPatient); Bill aBill = new Bill(); List <Bill> aBillList = (List <Bill>)ViewState["Bill"]; string billSave = ""; if (patientSaved == "Patient saved") { DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); long ms = (long)(DateTime.UtcNow - epoch).TotalMilliseconds; ViewState["BillNo"] = ms.ToString(); foreach (Bill Bill in aBillList) { aBill.TestName = Bill.TestName; aBill.Fee = Bill.Fee; aBill.BillNo = ms.ToString(); aBill.Total = (double)ViewState["Total"]; aBill.PatientId = aPatientManager.GetPatientId(aPatient.Mobile); DateTime dateTime = DateTime.UtcNow.Date; aBill.DateTime = dateTime.ToString("MM/dd/yyyy"); //aBill.DateTime = DateTime.Now.ToString("MM/dd/yyyy"); billSave = aPatientManager.AddBill(aBill); } if (billSave == "Bill not added") { patientMessageLabel.Text = "Not Saved"; } else { patientMessageLabel.Text = "Saved"; GetBillPDF(aBill.BillNo); } } else { patientMessageLabel.Text = patientSaved; } clear(); }