private void FillSelectedEmployees() { if (sheduler != null) { StaffShedulerEmployeesLogic shedulerEmployees = new StaffShedulerEmployeesLogic(manager); var employees = shedulerEmployees.GetBySheduler(sheduler.ID).Select(a => new { a.StaffEmployee.ID, Name = a.StaffEmployee.LastName + " " + a.StaffEmployee.FirstName + " " + a.StaffEmployee.MiddleName }); foreach (var employee in employees) { ItemIntValue item = new ItemIntValue(); item.ID = employee.ID; item.Name = employee.Name; SelectedEmployeesLB.Items.Add(item); } } }
private void DataGV_SelectionChanged(object sender, EventArgs e) { if (DataGV.SelectedRows.Count > 0) { StaffShedulerEmployeesLogic shedulerEmployees = new StaffShedulerEmployeesLogic(manager); int shedulerId = Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value); var employees = shedulerEmployees.GetBySheduler(shedulerId).Select(a => new { a.StaffEmployee.ID, Name = a.StaffEmployee.LastName + " " + a.StaffEmployee.FirstName + " " + a.StaffEmployee.MiddleName }); SelectedEmployeesLB.ValueMember = "ID"; SelectedEmployeesLB.DisplayMember = "Name"; SelectedEmployeesLB.DataSource = employees.ToList(); } }