private void submit_id_button_Click(object sender, RoutedEventArgs e) { // Check to make sure entry is a number. bool flag = patient_query_textbox_hosp.Text.All(char.IsDigit); if (flag) { data_grid_hosp.Items.Clear(); // Connect to database. AP_AB_Blood_Bank db_hospital = new AP_AB_Blood_Bank("Data Source=DEVSERVERB; Initial Catalog=AP_AB_Blood_Bank; Integrated Security=True"); db_hospital.ObjectTrackingEnabled = false; // Grab Patient Table System.Data.Linq.Table<_ECERESEARCH_Aparisi_Student___Patient_Table_> patient_temp_table_hospital = db_hospital.GetTable<_ECERESEARCH_Aparisi_Student___Patient_Table_>(); // Execute query that grabs patients that have a matching hospital ID with the entry. var patient_query_hospital = from p in patient_temp_table_hospital where p.HospitalID == Int32.Parse(patient_query_textbox_hosp.Text) select p; foreach (var entry in patient_query_hospital) { string blood_id; // Convert blood ID to a blood type. switch (entry.BloodID) { case 1: blood_id = "A+"; break; case 2: blood_id = "A-"; break; case 3: blood_id = "B+"; break; case 4: blood_id = "B-"; break; case 5: blood_id = "AB+"; break; case 6: blood_id = "AB-"; break; case 7: blood_id = "O+"; break; case 8: blood_id = "O-"; break; default: blood_id = "ERROR"; break; } // Add patients to the datagrid. data_grid_hosp.Items.Add(new patient_info { patientid = entry.PatientID.ToString(), firstname = entry.FirstName, lastname = entry.LastName, bloodtype = blood_id, amount = entry.Amount_pint.ToString(), hospitalid = entry.HospitalID.ToString() }); } } // Else, display error. else patient_query_textbox_hosp.Text = "ERROR"; }
private void submit_name_button_Click(object sender, RoutedEventArgs e) { // Check if the entry is not a number. bool flag = patient_name_query_textbox.Text.All(char.IsDigit); if (!flag) { data_grid_n.Items.Clear(); // Connect to database. AP_AB_Blood_Bank db_n = new AP_AB_Blood_Bank("Data Source=DEVSERVERB; Initial Catalog=AP_AB_Blood_Bank; Integrated Security=True"); db_n.ObjectTrackingEnabled = false; // Obtain Patient Table. System.Data.Linq.Table<_ECERESEARCH_Aparisi_Student___Patient_Table_> patient_temp_table_n = db_n.GetTable<_ECERESEARCH_Aparisi_Student___Patient_Table_>(); // Execute query that grabs patients that share a last name with the entry. var patient_query_n = from p in patient_temp_table_n where p.LastName == patient_name_query_textbox.Text select p; foreach (var entry in patient_query_n) { string blood_id; // Convert blood ID to a blood type. switch (entry.BloodID) { case 1: blood_id = "A+"; break; case 2: blood_id = "A-"; break; case 3: blood_id = "B+"; break; case 4: blood_id = "B-"; break; case 5: blood_id = "AB+"; break; case 6: blood_id = "AB-"; break; case 7: blood_id = "O+"; break; case 8: blood_id = "O-"; break; default: blood_id = "ERROR"; break; } // Add patient(s) to data grid. data_grid_n.Items.Add(new patient_info_n { patientid_n = entry.PatientID.ToString(), firstname_n = entry.FirstName, lastname_n = entry.LastName, bloodtype_n = blood_id, amount_n = entry.Amount_pint.ToString(), hospitalid_n = entry.HospitalID.ToString() }); } } else patient_name_query_textbox.Text = "ERROR"; }
private void submit_bloodtype_button_Click(object sender, RoutedEventArgs e) { // Converts the entered blood type to a blood ID. string blood_entry = patient_bloodtype_query_textbox.Text; int blood_id_entry; switch (blood_entry) { case "A+": case "a+": blood_id_entry = 1; break; case "A-": case "a-": blood_id_entry = 2; break; case "B+": case "b+": blood_id_entry = 3; break; case "B-": case "b-": blood_id_entry = 4; break; case "AB+": case "ab+": case "Ab+": case "aB+": blood_id_entry = 5; break; case "AB-": case "ab-": case "Ab-": case "aB-": blood_id_entry = 6; break; case "O+": case "o+": blood_id_entry = 7; break; case "O-": case "o-": blood_id_entry = 8; break; default: blood_id_entry = 999; break; } // Checks to make sure the entry is a valid blood type, as the default case in the above switch statement is the flag. if (blood_id_entry != 999) { data_grid_b.Items.Clear(); // Connect to database. AP_AB_Blood_Bank db_b = new AP_AB_Blood_Bank("Data Source=DEVSERVERB; Initial Catalog=AP_AB_Blood_Bank; Integrated Security=True"); db_b.ObjectTrackingEnabled = false; // Grab Patient Table. System.Data.Linq.Table<_ECERESEARCH_Aparisi_Student___Patient_Table_> patient_temp_table_b = db_b.GetTable<_ECERESEARCH_Aparisi_Student___Patient_Table_>(); var patient_query_b = from p in patient_temp_table_b where p.BloodID == blood_id_entry select p; foreach (var entry in patient_query_b) { // Convert blood ID back to a blood type. string blood_id; switch (entry.BloodID) { case 1: blood_id = "A+"; break; case 2: blood_id = "A-"; break; case 3: blood_id = "B+"; break; case 4: blood_id = "B-"; break; case 5: blood_id = "AB+"; break; case 6: blood_id = "AB-"; break; case 7: blood_id = "O+"; break; case 8: blood_id = "O-"; break; default: blood_id = "ERROR"; break; } // Add patients to the data grid. data_grid_b.Items.Add(new patient_info_b { patientid_b = entry.PatientID.ToString(), firstname_b = entry.FirstName, lastname_b = entry.LastName, bloodtype_b = blood_id, amount_b = entry.Amount_pint.ToString(), hospitalid_b = entry.HospitalID.ToString() }); } } // Else, display an error. else { data_grid_b.Items.Clear(); patient_bloodtype_query_textbox.Text = "ERROR"; } }
public IndividualPatientsbyAllWindow() { InitializeComponent(); // Initializes data grid and establishes columns. DataGridTextColumn col1_all = new DataGridTextColumn(); DataGridTextColumn col2_all = new DataGridTextColumn(); DataGridTextColumn col3_all = new DataGridTextColumn(); DataGridTextColumn col4_all = new DataGridTextColumn(); DataGridTextColumn col5_all = new DataGridTextColumn(); DataGridTextColumn col6_all = new DataGridTextColumn(); data_grid_all.Columns.Add(col1_all); data_grid_all.Columns.Add(col2_all); data_grid_all.Columns.Add(col3_all); data_grid_all.Columns.Add(col4_all); data_grid_all.Columns.Add(col5_all); data_grid_all.Columns.Add(col6_all); col1_all.Header = "Patient ID"; col2_all.Header = "First Name"; col3_all.Header = "Last Name"; col4_all.Header = "Blood Type"; col5_all.Header = "Amount Required"; col6_all.Header = "Hospital ID"; // Create bindings for the columns. col1_all.Binding = new Binding("patientid_all"); col2_all.Binding = new Binding("firstname_all"); col3_all.Binding = new Binding("lastname_all"); col4_all.Binding = new Binding("bloodtype_all"); col5_all.Binding = new Binding("amount_all"); col6_all.Binding = new Binding("hospitalid_all"); data_grid_all.Items.Clear(); // Connect to database. AP_AB_Blood_Bank db_all = new AP_AB_Blood_Bank("Data Source=DEVSERVERB; Initial Catalog=AP_AB_Blood_Bank; Integrated Security=True"); db_all.ObjectTrackingEnabled = false; // Grab Patient Table. System.Data.Linq.Table<_ECERESEARCH_Aparisi_Student___Patient_Table_> patient_temp_table_all = db_all.GetTable<_ECERESEARCH_Aparisi_Student___Patient_Table_>(); // Execute query to grab all patients. var patient_query_all = from p in patient_temp_table_all select p; foreach (var entry in patient_query_all) { string blood_id; // Convert blood ID to a blood type. switch (entry.BloodID) { case 1: blood_id = "A+"; break; case 2: blood_id = "A-"; break; case 3: blood_id = "B+"; break; case 4: blood_id = "B-"; break; case 5: blood_id = "AB+"; break; case 6: blood_id = "AB-"; break; case 7: blood_id = "O+"; break; case 8: blood_id = "O-"; break; default: blood_id = "ERROR"; break; } // Add all patients to the grid. data_grid_all.Items.Add(new patient_info_all { patientid_all = entry.PatientID.ToString(), firstname_all = entry.FirstName, lastname_all = entry.LastName, bloodtype_all = blood_id, amount_all = entry.Amount_pint.ToString(), hospitalid_all = entry.HospitalID.ToString() }); } }
private void submit_id_button_Click_1(object sender, RoutedEventArgs e) { // Check to make sure the entry is a number. bool flag0 = patient_query_textbox.Text.All(char.IsDigit); if (flag0) { // Opens the database. AP_AB_Blood_Bank db_p = new AP_AB_Blood_Bank("Data Source=DEVSERVERB; Initial Catalog=AP_AB_Blood_Bank; Integrated Security=True"); db_p.ObjectTrackingEnabled = false; // Opens the Patient Table System.Data.Linq.Table<_ECERESEARCH_Aparisi_Student___Patient_Table_> patient_temp_table_p = db_p.GetTable<_ECERESEARCH_Aparisi_Student___Patient_Table_>(); // Execute a query to grab the patient with a matching Patient ID. var patient_query_p = from p in patient_temp_table_p where p.PatientID == Int32.Parse(patient_query_textbox.Text) select p; foreach (var entry in patient_query_p) { string blood_id; // Convert the blood ID to a blood type. switch (entry.BloodID) { case 1: blood_id = "A+"; break; case 2: blood_id = "A-"; break; case 3: blood_id = "B+"; break; case 4: blood_id = "B-"; break; case 5: blood_id = "AB+"; break; case 6: blood_id = "AB-"; break; case 7: blood_id = "O+"; break; case 8: blood_id = "O-"; break; default: blood_id = "ERROR"; break; } // Add patient to the data grid. data_grid_p.Items.Add(new patient_info_p { patientid_p = entry.PatientID.ToString(), firstname_p = entry.FirstName, lastname_p = entry.LastName, bloodtype_p = blood_id, amount_p = entry.Amount_pint.ToString(), hospitalid_p = entry.HospitalID.ToString() }); } } // Display error if the entry is not a number. else patient_query_textbox.Text = "ERROR"; }