//G public static void searchPatientName(string[] name, bool main) { //create sql statement DBConnection connection = DBConnection.getDBConnectionInstance(); if (name[2].Contains('/')) { string sqlQuery = @"SELECT * FROM Patients WHERE Patient_name = @Name AND Patient_surname = @Surname AND Patient_date_of_birth = @DobOrAddress;"; DataSet patientData = connection.searchPatientByName(sqlQuery, name[0], name[1], name[2]); //checks that the query returned exactly one result int count = patientData.Tables[0].Rows.Count; if (count == 1) { individual_patient patient = new individual_patient(patientData.Tables[0].Rows[0].Field <int>("Patient_Id").ToString(), patientData); patient.Show(); } else { MessageBox.Show("No patient found."); if (main) { main_screen frm = new main_screen(); frm.Show(); } else { Patients frm = new Patients(); frm.Show(); } } } else { string query = @"SELECT * FROM Patients WHERE Patient_name = @Name AND Patient_surname = @Surname AND Patient_postcode = @DobOrAddress;"; DataSet patientDataPostcode = connection.searchPatientByName(query, name[0], name[1], name[2]); //checks that the query returned exactly one result int count = patientDataPostcode.Tables[0].Rows.Count; if (count == 1) { individual_patient patient = new individual_patient(patientDataPostcode.Tables[0].Rows[0].Field <int>("Patient_Id").ToString(), patientDataPostcode); patient.Show(); } else { MessageBox.Show("No patient found."); if (main) { main_screen frm = new main_screen(); frm.Show(); } else { Patients frm = new Patients(); frm.Show(); } } } }
//G public static void searchPatient(string id, bool main) { //creates the SQL query string query = @"SELECT * FROM Patients WHERE Patient_Id = @ID;"; DBConnection connection = DBConnection.getDBConnectionInstance(); DataSet patientData = connection.getDataById(query, id); //checks that the query returned exactly one result int count = patientData.Tables[0].Rows.Count; if (count == 1) { individual_patient patient = new individual_patient(id, patientData); patient.Show(); } else { MessageBox.Show("No patient found."); if (main) { main_screen frm = new main_screen(); frm.Show(); } else { Patients frm = new Patients(); frm.Show(); } } }
private void bt_patients_Click(object sender, RoutedEventArgs e) { this.Hide(); Patients frm = new Patients(); frm.Show(); this.Close(); }