private void PopulateStaff() { DataBase db = new StaffData(); List <Staff> list = db.GetList().ConvertAll(x => x as Staff); List <Staff> list1 = db.GetList().ConvertAll(x => x as Staff); Staff staff = new Staff(); staff.FullAddress = string.Empty; staff.PersonId = 0; list.Insert(0, staff); list1.Insert(0, staff); cmbActivityCentreCoach.DataSource = list; cmbResidentCoach.DataSource = list1; cmbActivityCentreCoach.DisplayMember = "FullName"; cmbActivityCentreCoach.ValueMember = "PersonId"; cmbResidentCoach.DisplayMember = "FullName"; cmbResidentCoach.ValueMember = "PersonId"; cmbActivityCentreCoach.DataBindings.Add("SelectedValue", _student, "ActivityCentreCoachId"); cmbResidentCoach.DataBindings.Add("SelectedValue", _student, "ResidentCoachId"); }
private void PopulateComboBoxes() { DataBase db; db = new StaffData(); List <Staff> list = db.GetList().ConvertAll(x => x as Staff); cmbStaff.DataSource = list; cmbStaff.DisplayMember = "FullName"; cmbStaff.ValueMember = "PersonId"; cmbStaff.SelectedIndex = -1; List <Staff> whoReported = new List <Staff>(); List <Staff> coordinators = db.GetList("SELECT * FROM vw_Staff Where TitleId =" + 3).ConvertAll(x => x as Staff); List <Staff> managers = db.GetList("SELECT * FROM vw_Staff Where TitleId =" + 4).ConvertAll(x => x as Staff); List <Staff> hsOfficers = db.GetList("SELECT * FROM vw_Staff Where TitleId = " + 6).ConvertAll(x => x as Staff); whoReported.AddRange(list); cmbWhoReported.DataSource = whoReported; cmbWhoReported.DisplayMember = "FullName"; cmbWhoReported.ValueMember = "PersonId"; cmbWhoReported.SelectedIndex = -1; cmbCoordinator.DataSource = coordinators; cmbCoordinator.DisplayMember = "FullName"; cmbCoordinator.ValueMember = "PersonId"; cmbCoordinator.SelectedIndex = -1; cmbManager.DataSource = managers; cmbManager.DisplayMember = "FullName"; cmbManager.ValueMember = "PersonId"; cmbManager.SelectedIndex = -1; cmbHSOfficer.DataSource = hsOfficers; cmbHSOfficer.DisplayMember = "FullName"; cmbHSOfficer.ValueMember = "PersonId"; cmbHSOfficer.SelectedIndex = -1; db = new StudentData(); List <Student> list5 = db.GetList().ConvertAll(x => x as Student); cmbStudent.DataSource = list5; cmbStudent.DisplayMember = "FullName"; cmbStudent.ValueMember = "PersonId"; cmbStudent.SelectedIndex = -1; LocationData ld = new LocationData(); List <Location> list6 = ld.GetList("SELECT * FROM vw_Locations WHERE IsStudentCentre = true"); cmbLocation.DataSource = list6; cmbLocation.DisplayMember = "LocationName"; cmbLocation.ValueMember = "LocationId"; cmbLocation.SelectedIndex = -1; }
private void PopulateStaff() { cmbStaff.SelectedIndexChanged -= cmbStaff_SelectedIndexChanged; DataBase db = new StaffData(); List <Staff> staffList = db.GetList().ConvertAll(x => x as Staff); cmbStaff.DataSource = GetStaffListWithoutSystemUserLogin(staffList); cmbStaff.DisplayMember = "FullName"; cmbStaff.ValueMember = "PersonId"; cmbStaff.SelectedIndex = -1; cmbStaff.SelectedIndexChanged += cmbStaff_SelectedIndexChanged; }
private void cmbStaff_SelectedIndexChanged(object sender, EventArgs e) { if (cmbStaff.SelectedIndex == -1) { _incident.Staff = null; } else { StaffData staffData = new StaffData(); List <Staff> list = staffData.GetList((int)cmbStaff.SelectedValue).ConvertAll(x => x as Staff);; if (list.Count > 0) { _incident.Staff = list[0]; } } }
public void LoadFullList() { ep.SetError(dataGridView1, ""); try { //DataBase db; //if(rbAllStudents.Checked) // db = new StudenData(); //else DataBase db = new StaffData(); _allStaff = db.GetList(); _filteredStaffList = _allStaff; } catch (Exception ex) { ep.SetError(dataGridView1, ex.Message); } }
public void PopulateCmboBoxes() { try { SpecialistData sd = new SpecialistData(); List <ProfessionalServiceType> list = sd.GetProfessionalServiceTypes(); ProfessionalServiceType specialistType = new ProfessionalServiceType(); cmbAppointmentType.DataSource = list; cmbAppointmentType.DisplayMember = "ProfessionalServiceProviderType"; cmbAppointmentType.ValueMember = "ProfessionalServiceProviderTypeId"; cmbAppointmentType.Refresh(); StaffData staffData = new StaffData(); List <Staff> staff = staffData.GetList().ConvertAll(x => x as Staff); cmbStaffAccompanyingId.DataSource = staff; cmbStaffAccompanyingId.ValueMember = "PersonId"; cmbStaffAccompanyingId.DisplayMember = "FullName"; cmbStaffAccompanyingId.Refresh(); StudentData studentData = new StudentData(); List <Student> students = studentData.GetList("SELECT * FROM vw_Residents").ConvertAll(x => x as Student); cmbResidentId.DataSource = students; cmbResidentId.ValueMember = "PersonId"; cmbResidentId.DisplayMember = "FullName"; cmbResidentId.Refresh(); //cmbAppointmentType.SelectedIndex = -1; // cmbSpecialistId.SelectedIndex = -1; //cmbStaffAccompanyingId.SelectedIndex = -1; //cmbResidentId.SelectedIndex = -1; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }