private void btnSave_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtTotalBeds.Text) && !string.IsNullOrEmpty(cboGovernedBy.Text)) { String beds = txtTotalBeds.Text; if (int.Parse(beds) <= 0) { MessageBox.Show("No of beds should be a positive number.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; } String strNid = cboGovernedBy.SelectedValue.ToString(); int TotalBeds = int.Parse(beds); int nid = int.Parse(strNid); nurse n = hms.getNurseByNid(nid); room r = new room(); r.totalbeds = TotalBeds; r.availablebeds = TotalBeds; r.nurse = n; String Nursename = cboGovernedBy.Text; hms.addRoom(r); RoomList.Add(r); this.Close(); } else { MessageBox.Show("Make sure all fields are enered.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void dataGrid_Nurse_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.indexSelected = dataGrid_Nurse.SelectedIndex; if (indexSelected == -1 || NurseList.Count <= indexSelected) { nurseSelected = null; btnDelete_Nurse.IsEnabled = false; btnUpdate_Nurse.IsEnabled = false; return; } ; btnDelete_Nurse.IsEnabled = true; btnUpdate_Nurse.IsEnabled = true; //nurseSelected = (nurse)NurseList.ElementAt<nurse>(dataGrid_Nurse.SelectedIndex); nurseSelected = (nurse)dataGrid_Nurse.SelectedItem; txtFirstName_Nurse.Text = nurseSelected.employee.firstname; txtLastName_Nurse.Text = nurseSelected.employee.lastname; txtDob_Nurse.Text = nurseSelected.employee.dob.ToString(); txtUsername_Nurse.Text = nurseSelected.employee.user.username; txtPassword_Nurse.Text = nurseSelected.employee.user.password; txtPhone_Nurse.Text = nurseSelected.employee.phone; txtSalary_Nurse.Text = nurseSelected.employee.salary.ToString(); txtExperience.Text = nurseSelected.experience; }
public NursePanel(user ownerUser, Login login) { InitializeComponent(); this.login = login; owner = hms.getNurseByUid(ownerUser.uid); patientList = hms.getMyPatients(owner); roomList = hms.getMyRooms(owner); dataGrid_Patients.ItemsSource = patientList; dataGrid_Rooms.ItemsSource = roomList; }
private void txtSearch_Nurse_TextChanged(object sender, TextChangedEventArgs e) { TextBox t = (TextBox)sender; string filter = t.Text; ICollectionView cv = CollectionViewSource.GetDefaultView(dataGrid_Nurse.ItemsSource); if (filter == "") { cv.Filter = null; } else { cv.Filter = o => { nurse n = o as nurse; if (cboSearch_Nurse.SelectedValue != null) { String selected = cboSearch_Nurse.SelectedValue.ToString().ToLower(); if (selected == "first name") { return(n.employee.firstname.ToLower().StartsWith(filter.ToLower())); } else if (selected == "last name") { return(n.employee.lastname.ToLower().StartsWith(filter.ToLower())); } else if (selected == "experience") { return(n.experience.ToLower().StartsWith(filter.ToLower())); } else if (selected == "username") { return(n.employee.user.username.ToLower().StartsWith(filter.ToLower())); } else if (selected == "phone") { return(n.employee.phone.ToLower().StartsWith(filter.ToLower())); } else { return(false); } } return(false); }; } btnUpdate_Nurse.IsEnabled = false; btnDelete_Nurse.IsEnabled = false; }
private void btnSave_Click(object sender, RoutedEventArgs e) { String firstname = txtFirstName.Text; String lastname = txtLastName.Text; String username = txtUsername.Text; String password = txtPassword.Text; String type = "nurse"; String phone = txtPhone.Text; String experience = txtExperience.Text; DateTime dob = new DateTime(); if (txtDob.SelectedDate != null) { dob = (DateTime)txtDob.SelectedDate; } int salary = Convert.ToInt32(txtSalary.Text); String gender = "female"; if (!string.IsNullOrEmpty(firstname) && !string.IsNullOrEmpty(lastname) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(phone) && !string.IsNullOrEmpty(txtDob.Text) && !string.IsNullOrEmpty(txtSalary.Text) && !string.IsNullOrEmpty(experience)) { if (hms.getUser(username) != null) { MessageBox.Show("Username already exists!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning); return; } user u = new user(); u.username = username; u.password = password; u.type = type; employee emp = new employee(); emp.firstname = firstname; emp.lastname = lastname; emp.dob = dob; emp.salary = salary; emp.gender = gender; emp.phone = phone; emp.user = u; nurse n = new nurse(); n.experience = experience; n.employee = emp; hms.addNurse(n); NurseList.Add(n); this.Close(); } else { MessageBox.Show("All fields are required.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning); } }