private void ultraBtnRefresh_Click(object sender, EventArgs e) { try { objHospitalDB = new HospitalDB(); Doctor objDoctor = new Doctor(objHospitalDB); DoctorRow objDoctorRow = new DoctorRow(); ultraGridDoc.DataSource = objDoctor.GetAll(); /* dsDoctor = new DataSet(); * SqlCommand cmd = objHospitalDB.CreateCommand("Select * from [Hospital].[dbo].[Doctor]", false); * SqlDataAdapter sda = new SqlDataAdapter(); * sda.SelectCommand = cmd; * sda.Fill(dsDoctor); * ultraGridDoc.DataSource = dsDoctor.Tables[0];*/ } catch (Exception ex) { MessageBox.Show(ex.Message); if (objHospitalDB != null) { objHospitalDB.Dispose(); } } }
public void Test_DoctorEmptyAtFirst() { //Arrange, Act int result = Doctor.GetAll().Count; //Assert Assert.Equal(0, result); }
public void Doctor_GetAll_DatabaseEmptyOnload() { List <Doctor> testList = Doctor.GetAll(); List <Doctor> controlList = new List <Doctor> { }; Assert.Equal(controlList, testList); }
public void Doctor_Save_SaveToDatabase() { Doctor newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology"); newDoctor.Save(); Doctor testDoctor = Doctor.GetAll()[0]; Assert.Equal(newDoctor, testDoctor); }
private void frmDoctorView_Load(object sender, EventArgs e) { objHospitalDB = new HospitalDB(); Doctor objDoctor = new Doctor(objHospitalDB); DoctorRow objDoctorRow = new DoctorRow(); ultraGridDoc.DataSource = objDoctor.GetAll(); /* SqlCommand cmd = objHospitalDB.CreateCommand("SELECT * FROM Doctor"); * SqlDataAdapter sda = new SqlDataAdapter(cmd); * dtDoctor = new DataTable(); * sda.Fill(dtDoctor); * ultraGridDoc.DataSource = dtDoctor;*/ }
public void Test_Save_SavesDoctorToDatabase() { //Arrange Doctor testDoctor = new Doctor("Dr. Nick", "Neurologist", 1); testDoctor.Save(); //Act List <Doctor> result = Doctor.GetAll(); List <Doctor> testList = new List <Doctor> { testDoctor }; //Assert Assert.Equal(testList, result); }
public HomeModule() { Get["/"] = _ => { List <Doctor> AllDoctors = Doctor.GetAll(); return(View["index.cshtml", AllDoctors]); }; Get["/patients"] = _ => { List <Patient> AllPatients = Patient.GetAll(); return(View["patients.cshtml", AllPatients]); }; Get["/doctors"] = _ => { List < Doctors AllDoctors = Doctors GetAll(); return(View["doctors.cshtml", AllDoctors]); }; }
public void Doctor_Delete_DeletesSingleDoctor() { Doctor doctor1 = new Doctor("John", "tom567", "567", "Physician"); doctor1.Save(); Doctor doctor2 = new Doctor("John", "tom567", "567", "Cardiology"); doctor2.Save(); doctor1.DeleteSingleDoctor(); List <Doctor> testList = Doctor.GetAll(); List <Doctor> controlList = new List <Doctor> { doctor2 }; Assert.Equal(controlList, testList); }
private void ultraBtnDelete_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Are you sure you want to delete?", "delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { objHospitalDB = new HospitalDB(); Doctor objDoctor = new Doctor(objHospitalDB); DoctorRow objDoctorRow = new DoctorRow(); objDoctorRow.Doctor_ID = Convert.ToInt32(this.id); objDoctor.Delete(objDoctorRow); ultraGridDoc.DataSource = objDoctor.GetAll(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } /*try * { * objHospitalDB = new HospitalDB(); * // con.Open(); * ultraGridDoc.Rows[this.ultraGridDoc.ActiveRow.Index].Delete(true); * SqlCommand query = objHospitalDB.CreateCommand("delete from Doctor where Doctor_ID='" + this.id + "';", false); * int p = query.ExecuteNonQuery(); * * MessageBox.Show(p + "Deleted"); * } * catch (Exception ex) * { * MessageBox.Show(ex.Message); * if(objHospitalDB!=null) * { * objHospitalDB.Dispose(); * } * }*/ }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/doctors"] = _ => { return(View["doctor_login.cshtml"]); }; Post["/doctors/new"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; Doctor newDoctor = new Doctor(Request.Form["name"], Request.Form["username"], Request.Form["password"], Request.Form["specialty"]); newDoctor.Save(); model.Add("newDoctor", newDoctor); return(View["doctor_login.cshtml", model]); }; Get["/doctors/login"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; List <Doctor> loggedIn = Doctor.Login(Request.Query["login-username"], Request.Query["login-password"]); if (loggedIn.Count == 0) { model.Add("login-status", false); return(View["doctor_login.cshtml", model]); } else { model.Add("doctor", loggedIn[0]); model.Add("appointments", loggedIn[0].GetAppointments()); model.Add("patients", loggedIn[0].GetPatients()); // model.Add("patients-delete", false); return(View["doctor.cshtml", model]); } }; Get["/patients"] = _ => { return(View["patient_login.cshtml"]); }; Post["/patients/new"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; Patient newPatient = new Patient(Request.Form["name"], Request.Form["username"], Request.Form["password"], Request.Form["date"]); newPatient.Save(); model.Add("newPatient", newPatient); return(View["patient_login.cshtml", model]); }; Get["/patients/login"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; List <Patient> loggedIn = Patient.Login(Request.Query["login-username"], Request.Query["login-password"]); if (loggedIn.Count == 0) { model.Add("login-status", false); return(View["patient_login.cshtml", model]); } else { model.Add("patient", loggedIn[0]); model.Add("appointments", loggedIn[0].GetAppointments()); model.Add("patient-doctors", loggedIn[0].GetDoctors()); return(View["patient.cshtml", model]); } }; Get["/patients/{id}/appointments/new"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; List <Doctor> allDoctors = Doctor.GetAll(); model.Add("patient-id", parameters.id); model.Add("patient-doctors", Patient.Find(parameters.id).GetDoctors()); return(View["appointment_form.cshtml", model]); }; Post["/patients/{id}/appointments/added"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Patient selectedPatient = Patient.Find(parameters.id); selectedPatient.CreateAppointment(Request.Form["date"], Doctor.Find(Request.Form["doctor"]), Request.Form["description"]); model.Add("patient", selectedPatient); model.Add("appointments", selectedPatient.GetAppointments()); model.Add("patient-doctors", selectedPatient.GetDoctors()); return(View["patient.cshtml", model]); }; Get["/patients/{id}/doctors/choose"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; List <Doctor> allDoctors = Doctor.GetAll(); model.Add("patient-id", parameters.id); model.Add("patient-doctors", Patient.Find(parameters.id).GetDoctors()); model.Add("all-doctors", allDoctors); return(View["choose_doctor_form.cshtml", model]); }; Post["/patients/{id}/doctors/added"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Patient selectedPatient = Patient.Find(parameters.id); selectedPatient.AddDoctor(Doctor.Find(Request.Form["selected-doctor"])); model.Add("patient", selectedPatient); model.Add("appointments", selectedPatient.GetAppointments()); model.Add("patient-doctors", selectedPatient.GetDoctors()); return(View["patient.cshtml", model]); }; Get["/doctors/{id}/patients/delete"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Doctor selectedDoctor = Doctor.Find(parameters.id); model.Add("doctor", selectedDoctor); model.Add("appointments", selectedDoctor.GetAppointments()); model.Add("patients", selectedDoctor.GetPatients()); model.Add("patients-delete", true); return(View["doctor.cshtml", model]); }; Delete["/doctors/{id}/patients/delete"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Doctor selectedDoctor = Doctor.Find(parameters.id); string patients = Request.Form["patient"]; if (patients != null) { string[] values = patients.Split(','); foreach (string patientId in values) { selectedDoctor.DeletePatientRelationship(Patient.Find(int.Parse(patientId))); } } model.Add("doctor", selectedDoctor); model.Add("appointments", selectedDoctor.GetAppointments()); model.Add("patients", selectedDoctor.GetPatients()); return(View["doctor.cshtml", model]); }; Get["/patients/{id}/update"] = parameters => { Patient selectedPatient = Patient.Find(parameters.id); return(View["patient_update_form.cshtml", selectedPatient]); }; Patch["/patients/{id}/update"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Patient selectedPatient = Patient.Find(parameters.id); selectedPatient.Update(Request.Form["name"], Request.Form["username"], Request.Form["password"]); model.Add("patient", selectedPatient); model.Add("appointments", selectedPatient.GetAppointments()); model.Add("patient-doctors", selectedPatient.GetDoctors()); return(View["patient.cshtml", model]); }; Get["/patients/{id}/search/doctors"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Patient selectedPatient = Patient.Find(parameters.id); string nameQuery = Request.Query["name-search"]; string specialtyQuery = Request.Query["specialty-search"]; List <Doctor> results = new List <Doctor> { }; if (nameQuery != "" && specialtyQuery != "") { results = Doctor.CombineSearch(nameQuery, specialtyQuery); } else if (nameQuery != "") { results = Doctor.SearchByName(nameQuery); } else { results = Doctor.SearchBySpecialty(specialtyQuery); } model.Add("patient-id", parameters.id); model.Add("patient-doctors", Patient.Find(parameters.id).GetDoctors()); model.Add("all-doctors", Doctor.GetAll()); model.Add("show-results", true); model.Add("results", results); return(View["choose_doctor_form.cshtml", model]); }; }