public static void assignDonor(PatientInfo patientData) { MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection(); try { //define the command reference MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand(); msqlCommand.Connection = msqlConnection; msqlCommand.CommandText = "UPDATE patient SET assigned_donor=@assigned_donor, assigned_donor_contact = @assigned_donor_contact WHERE patient_id=@patient_id"; msqlCommand.Parameters.AddWithValue("@patient_id", patientData.id); msqlCommand.Parameters.AddWithValue("@assigned_donor", patientData.assignedDonor); msqlCommand.Parameters.AddWithValue("@assigned_donor_contact", patientData.donorContact); msqlCommand.ExecuteNonQuery(); } catch (Exception er) { } finally { //always close the connection msqlConnection.Close(); } }
private void searchBtn_Click(object sender, RoutedEventArgs e) { PatientInfo patientiInfoObj = new PatientInfo(); patientiInfoObj.name = searchTxtBlck.Text; List<PatientInfo> patients = BDMSDb.DbInteraction.SearchAllPatientList(patientiInfoObj); _patientCollection.Clear(); foreach (PatientInfo patient in patients) { _patientCollection.Add(patient); } }
private void submitRegistrationBtn_Click(object sender, RoutedEventArgs e) { PatientInfo patientData = new BDMSData.PatientInfo(); patientData.id = patientsIdTB.Text; patientData.assignedDonor = assignedDonorComboBox.Text; patientData.donorContact = donorContactBtn.Text; BDMSDb.DbInteraction.assignDonor(patientData); this.Close(); }
private static int DoRegisterNewPatientInDb(PatientInfo patientDetails) { int returnVal = 0; MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection(); try { //define the command reference MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand(); //define the connection used by the command object msqlCommand.Connection = msqlConnection; msqlCommand.CommandText = "INSERT INTO patient(patient_id,patient_name,patient_blood_group,patient_age,patient_address,patient_contact,patient_admited_address,patient_expected_date) " + "VALUES(@patient_id,@patient_name,@patient_blood_group,@patient_age,@patient_address,@patient_contact,@patient_admitted_address,@patient_expected_date)"; msqlCommand.Parameters.AddWithValue("@patient_id", patientDetails.id); msqlCommand.Parameters.AddWithValue("@patient_name", patientDetails.name); msqlCommand.Parameters.AddWithValue("@patient_blood_group", patientDetails.bloodGroup); msqlCommand.Parameters.AddWithValue("@patient_age", patientDetails.age); msqlCommand.Parameters.AddWithValue("@patient_address", patientDetails.address); msqlCommand.Parameters.AddWithValue("@patient_contact", patientDetails.phone); msqlCommand.Parameters.AddWithValue("@patient_admitted_address", patientDetails.admittedAddress); msqlCommand.Parameters.AddWithValue("@patient_expected_date", patientDetails.expectedDate); msqlCommand.ExecuteNonQuery(); returnVal = 1; } catch (Exception ex) { returnVal = 0; } finally { //always close the connection msqlConnection.Close(); } return returnVal; }
public static List<PatientInfo> GetAllPatientListWithAssignedDonor() { List<PatientInfo> PatientList = new List<PatientInfo>(); MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection(); try { //define the command reference MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand(); msqlCommand.Connection = msqlConnection; msqlCommand.CommandText = "Select * From patient;"; MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader(); while (msqlReader.Read()) { PatientInfo Patient = new PatientInfo(); Patient.id = msqlReader.GetString("patient_id"); Patient.name = msqlReader.GetString("patient_name"); Patient.bloodGroup = msqlReader.GetString("patient_blood_group"); Patient.age = msqlReader.GetInt32("patient_age"); Patient.address = msqlReader.GetString("patient_address"); Patient.phone = msqlReader.GetString("patient_contact"); Patient.admittedAddress = msqlReader.GetString("patient_admited_address"); Patient.expectedDate = msqlReader.GetDateTime("patient_expected_date"); Patient.assignedDonor = msqlReader.GetString("assigned_donor"); Patient.donorContact = msqlReader.GetString("assigned_donor_contact"); PatientList.Add(Patient); } } catch (Exception er) { } finally { //always close the connection msqlConnection.Close(); } return PatientList; }
public static void EditPatient(PatientInfo patientToEdit) { MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection(); try { //define the command reference MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand(); msqlCommand.Connection = msqlConnection; msqlCommand.CommandText = "UPDATE patient SET patient_name=@patient_name,patient_blood_group=@patient_blood_group,patient_age=@patient_age,patient_contact=@patient_contact,patient_address=@patient_address,patient_admited_address=@patient_admited_address,patient_expected_date=@patient_expected_date WHERE patient_id=@patient_id"; msqlCommand.Parameters.AddWithValue("@patient_name", patientToEdit.name); msqlCommand.Parameters.AddWithValue("@patient_blood_group", patientToEdit.bloodGroup); msqlCommand.Parameters.AddWithValue("@patient_age", patientToEdit.age); msqlCommand.Parameters.AddWithValue("@patient_contact", patientToEdit.phone); msqlCommand.Parameters.AddWithValue("@patient_address", patientToEdit.phone); msqlCommand.Parameters.AddWithValue("@patient_admited_address", patientToEdit.admittedAddress); msqlCommand.Parameters.AddWithValue("@patient_expected_date", patientToEdit.expectedDate); msqlCommand.Parameters.AddWithValue("@patient_id", patientToEdit.id); msqlCommand.ExecuteNonQuery(); } catch (Exception er) { } finally { //always close the connection msqlConnection.Close(); } }
public static int DoRegisterPatient(PatientInfo patientDetails) { return DoRegisterNewPatientInDb(patientDetails); }
public static List<PatientInfo> SearchAllPatientList(PatientInfo patientiInfoObj) { return SrchAllPatientList(patientiInfoObj); }
private static List<PatientInfo> SrchAllPatientList(PatientInfo patientiInfoObj) { List<PatientInfo> PatientList = new List<PatientInfo>(); MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection(); try { //define the command reference MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand(); msqlCommand.Connection = msqlConnection; msqlCommand.CommandText = "Select * From patient where patient_name = @input or patient_blood_group = @input or patient_age = @input or patient_address = @input or patient_contact = @input or patient_admited_address = @input;"; msqlCommand.Parameters.AddWithValue("@input", patientiInfoObj.name); MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader(); while (msqlReader.Read()) { PatientInfo Patient = new PatientInfo(); Patient.id = msqlReader.GetString("patient_id"); Patient.name = msqlReader.GetString("patient_name"); Patient.bloodGroup = msqlReader.GetString("patient_blood_group"); Patient.age = msqlReader.GetInt32("patient_age"); Patient.address = msqlReader.GetString("patient_address"); Patient.phone = msqlReader.GetString("patient_contact"); Patient.admittedAddress = msqlReader.GetString("patient_admited_address"); Patient.expectedDate = msqlReader.GetDateTime("patient_expected_date"); //Patient.admittedAddress = msqlReader.GetString("assigned_donor"); //Patient.expectedDate = msqlReader.GetDateTime("assigned_donor_contact"); PatientList.Add(Patient); } } catch (Exception er) { } finally { //always close the connection msqlConnection.Close(); } return PatientList; }