protected void btnSavePatient_Click(object sender, EventArgs e) { int patientId = 0; PatientInformation pi = new PatientInformation(); PatientDataContext patientDC = new PatientDataContext(WebConfigurationManager.ConnectionStrings["MyTherapistDatabaseConnectionString"].ConnectionString); PatientInformationTableManager patientTableMgr = new PatientInformationTableManager(); DatabaseObjects.Patient patientInformation = new DatabaseObjects.Patient(); patientInformation.Id = 0; if ((Session["PatientID"] != null) && (Int32.TryParse(Session["PatientID"].ToString(), out patientId))) { patientInformation.Id = patientId; } patientInformation.FirstName = txtboxFirstName.Text; patientInformation.LastName = txtboxLastName.Text; patientInformation.Birthday = String.Format("{0}/{1}/{2} 00:00:00", datepickerMonth.SelectedValue, datepickerDay.SelectedValue, datepickerYear.SelectedValue); patientInformation.PhoneNumber = txtboxPhone.Text; patientInformation.Email = txtboxEmailAddress.Text; patientTableMgr.Update(patientInformation); if (patientCareSaved != null) { patientCareSaved(this, new EventArgs()); } }
protected void btnDeletePatient_Click(object sender, EventArgs e) { PatientDataContext patientDC = new PatientDataContext("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = C:\\SoftwareDevelopmentProjects\\WebProjects\\myTherapist\\myTherapist\\App_Data\\myTherapist.mdf; Integrated Security = True"); PatientInformation patientToDelete = new PatientInformation(); PatientAppointmentInfomationDataContext patientAppointmentInformationDC = new PatientAppointmentInfomationDataContext("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = C:\\SoftwareDevelopmentProjects\\WebProjects\\myTherapist\\myTherapist\\App_Data\\myTherapist.mdf; Integrated Security = True"); PatientAppointmentInformation patientAppointmentInformationToDelete = new PatientAppointmentInformation(); Int32 patientId = 0; if (Session[CommonDefinitions.CommonDefinitions.PATIENT_ID] != null) { if (Session[CommonDefinitions.CommonDefinitions.DELETE_PATIENT_WARNING] == null) { lblWarningText.Text = "Click Delete again to confirm this action."; lblWarningText.ForeColor = System.Drawing.Color.Red; lblWarningText.Visible = true; Session[CommonDefinitions.CommonDefinitions.DELETE_PATIENT_WARNING] = "yes"; } else { if (Int32.TryParse(Session[CommonDefinitions.CommonDefinitions.PATIENT_ID].ToString(), out patientId)) { Session[CommonDefinitions.CommonDefinitions.DELETE_PATIENT_WARNING] = null; PatientInformationTableManager patientTableMgr = new PatientInformationTableManager(); Patient patientInfo = new Patient(); patientInfo.Id = patientId; patientTableMgr.Delete(patientInfo); lblWarningText.Visible = false; PatientListing1.LoadGrid(); } } } else { lblWarningText.Visible = true; lblWarningText.Text = "Select a patient to delete."; lblWarningText.ForeColor = System.Drawing.Color.Red; } }
public void SetEditMode() { Session["EditPatientInformation"] = "true"; Patient patient = new Patient(); patient.Id = Int32.Parse(Session["PatientID"].ToString()); PatientInformationTableManager patientTableMgr = new PatientInformationTableManager(); patient = patientTableMgr.FindPatient(patient); txtboxFirstName.Text = patient.FirstName; txtboxLastName.Text = patient.LastName; int m = DateTime.Parse(patient.Birthday.ToString()).Month; datepickerMonth.Text = months[m]; datepickerDay.Text = DateTime.Parse(patient.Birthday.ToString()).Day.ToString(); datepickerYear.Text = DateTime.Parse(patient.Birthday.ToString()).Year.ToString(); txtboxPhone.Text = patient.PhoneNumber; txtboxEmailAddress.Text = patient.Email; }