示例#1
0
        private void BtnChange_Click(object sender, EventArgs e)
        {
            comboBoxDepartment.Enabled = true;

            try
            {
                departmentBusinessComponent = new DepartmentBusinessComponent();
                var allDepartments = departmentBusinessComponent.FetchDepartments();
                comboBoxDepartment.DataSource
                    = allDepartments
                      .Where(d => !d.DepartmentName.Equals(employee.DepartmentInfo.DepartmentName))
                      .ToList <Department>();
                comboBoxDepartment.DisplayMember = "DepartmentName";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#2
0
 private void LoadDepartments()
 {
     try
     {
         departmentBusinessComponent = new DepartmentBusinessComponent();
         var departments = departmentBusinessComponent.FetchDepartments();
         if (departments != null && departments.Count > 0)
         {
             comboBoxDepartment.DataSource    = departments;
             comboBoxDepartment.DisplayMember = "DepartmentName";
         }
         else
         {
             MessageBox.Show("no department records found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }