private void dataGrid_Pres_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.indexSelected = dataGrid_Pres.SelectedIndex; if (indexSelected == -1 || presList.Count <= indexSelected) { presSelected = null; btnUpdatePres.IsEnabled = false; return; } ; btnUpdatePres.IsEnabled = true; //presSelected = (prescription)presList.ElementAt<prescription>(dataGrid_Pres.SelectedIndex); presSelected = (prescription)dataGrid_Pres.SelectedItem; if (presSelected.patient.type != null) { cboPatientType_Pres.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(presSelected.patient.type); } if (presSelected.patient.type.Equals("outdoor")) { txtDisease_Pres.IsEnabled = false; } else if (presSelected.patient.type.Equals("indoor")) { indoor indo = hms.getIndoorByPid(presSelected.pid); txtDisease_Pres.IsEnabled = true; txtDisease_Pres.Text = indo.disease; } cboMed_Pres.Text = presSelected.medicine.name; txtDosage_Pres.Text = presSelected.dosage; }
private void dataGrid_Indoor_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.indexSelected = dataGrid_Indoor.SelectedIndex; if (indexSelected == -1 || IndoorList.Count <= indexSelected) { indoorSelected = null; btnAssignRoom.IsEnabled = false; return; } ; btnAssignRoom.IsEnabled = true; //indoorSelected = (indoor)IndoorList.ElementAt<indoor>(dataGrid_Indoor.SelectedIndex); indoorSelected = (indoor)dataGrid_Indoor.SelectedItem; }
private void txtSearch_Indoor_TextChanged(object sender, TextChangedEventArgs e) { TextBox t = (TextBox)sender; string filter = t.Text; ICollectionView cv = CollectionViewSource.GetDefaultView(dataGrid_Indoor.ItemsSource); if (filter == "") { cv.Filter = null; } else { cv.Filter = o => { indoor indo = o as indoor; if (cboSearch_Indoor.SelectedValue != null) { String selected = cboSearch_Indoor.SelectedValue.ToString().ToLower(); if (selected == "patient name") { return(indo.patient.name.ToString().ToLower().StartsWith(filter.ToLower())); } else if (selected == "gender") { return(indo.patient.gender.ToString().ToLower().StartsWith(filter.ToLower())); } else if (selected == "category") { return(indo.patient.category.name.ToLower().StartsWith(filter.ToLower())); } else if (selected == "disease") { return(indo.disease.ToLower().StartsWith(filter.ToLower())); } else if (selected == "room no") { return(indo.rid.ToString().ToLower().StartsWith(filter.ToLower())); } else { return(false); } } return(false); }; } btnAssignRoom.IsEnabled = false; }
private void btnAssignRoom_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(cboRoomNo.Text)) { MessageBox.Show("Please select a room no.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning); return; } indoor indo = (indoor)dataGrid_Indoor.SelectedItem; if (indo.status == "discharged") { MessageBox.Show("Cannot assign room to discharged patient.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (indo.rid != null && indo.status == "admitted") { room currentRoom = hms.getRoom(indo.rid); currentRoom.availablebeds++; hms.updateRoom(currentRoom); } indo.rid = int.Parse(cboRoomNo.Text); room newRoom = hms.getRoom(indo.rid); if (newRoom.availablebeds == 0) { MessageBox.Show("Beds not available in this room. Please select any other room.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning); return; } newRoom.availablebeds--; hms.updateIndoor(indo); hms.updateRoom(newRoom); MessageBox.Show("Room Assigned successfully!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information); dataGrid_Indoor.Items.Refresh(); RoomList = hms.getRooms(); dataGrid_Room.Items.Refresh(); }
private void btnSubmitPre_Click(object sender, RoutedEventArgs e) { if (patSelected == null) { return; } if (string.IsNullOrEmpty(cboPatientType.Text)) { MessageBox.Show("Please select patient type.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (cboPatientType.Text.Equals("Indoor")) { if (string.IsNullOrEmpty(txtDisease.Text)) { MessageBox.Show("Please enter a diease", "Reminder", MessageBoxButton.OK, MessageBoxImage.Information); return; } indoor patIndoor = new indoor(); patIndoor.disease = txtDisease.Text; patIndoor.patient = patSelected; patIndoor.status = "admitted"; hms.addIndoor(patIndoor); patSelected.type = "indoor"; } else { patSelected.type = "outdoor"; } if (!string.IsNullOrEmpty(cboMed1.Text)) { int mid1 = int.Parse(cboMed1.SelectedValue.ToString()); string dosage1 = txtDosage1.Text; prescription p1 = new prescription(); p1.mid = mid1; p1.dosage = dosage1; p1.pid = patSelected.pid; p1.did = docOwner.did; hms.addPrescription(p1); presList.Add(p1); if (!string.IsNullOrEmpty(cboMed2.Text)) { prescription p2 = new prescription(); p2.mid = int.Parse(cboMed2.SelectedValue.ToString()); p2.dosage = txtDosage2.Text; p2.pid = patSelected.pid; p2.did = docOwner.did; hms.addPrescription(p2); presList.Add(p2); } if (!string.IsNullOrEmpty(cboMed3.Text.ToString())) { prescription p3 = new prescription(); p3.mid = int.Parse(cboMed3.SelectedValue.ToString()); p3.dosage = txtDosage3.Text; p3.pid = patSelected.pid; p3.did = docOwner.did; hms.addPrescription(p3); presList.Add(p3); } patSelected.did = docOwner.did; hms.updatePatient(patSelected); NewPatientList.Remove(patSelected); dataGrid_NewPatient.Items.Refresh(); dataGrid_Pres.Items.Refresh(); MessageBox.Show("Prescription submisson success.", "Success!", MessageBoxButton.OK, MessageBoxImage.Information); dataGrid_MyOldPatients.ItemsSource = hms.getMyOldPatients(docOwner); dataGrid_MyOldPatients.Items.Refresh(); } else { MessageBox.Show("At least one medicine is required for prescription", "Reminder", MessageBoxButton.OK, MessageBoxImage.Information); return; } }
private void dataGrid_MyOldPatients_SelectionChanged(object sender, SelectionChangedEventArgs e) { oldPatSelected = (indoor)dataGrid_MyOldPatients.SelectedItem; btnAddPres.IsEnabled = true; btnChangeStatus.IsEnabled = true; }
private void btnUpdatePres_Click(object sender, RoutedEventArgs e) { if (presSelected == null) { return; } String patType = cboPatientType_Pres.Text; int mid = int.Parse(cboMed_Pres.SelectedValue.ToString()); String Dosage = txtDosage_Pres.Text; String disease = null; if (string.IsNullOrEmpty(patType) || string.IsNullOrEmpty(Dosage)) { MessageBox.Show("Please make sure all attributes are compelted.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); return; } string prevType = presSelected.patient.type; presSelected.patient.type = patType.ToLower(); presSelected.mid = mid; presSelected.dosage = Dosage; disease = txtDisease_Pres.Text; indoor indo = hms.getIndoorByPid(presSelected.pid); if (patType.ToLower().Equals("indoor") && prevType.Equals("outdoor")) { if (!String.IsNullOrEmpty(disease)) { indoor i = new indoor(); i.disease = disease; i.pid = presSelected.pid; i.status = "admitted"; hms.addIndoor(i); } else { MessageBox.Show("Please enter a diesease."); return; } } else if (patType.ToLower().Equals("outdoor")) { if (indo != null) { hms.remove(indo); } } else { indo.disease = disease; hms.updateIndoor(indo); } hms.updatePrescription(presSelected); MessageBox.Show("Record updated success.", "Success", MessageBoxButton.OK, MessageBoxImage.Information); dataGrid_Pres.Items.Refresh(); NewPatientList = hms.getPatientList(); dataGrid_NewPatient.Items.Refresh(); }