private void Button1_Click(object sender, EventArgs e) { FrmEmployeesManager employeesOverView = new FrmEmployeesManager(); if (_department != null) { _createEditDepartmentViewModel.SetDepartmentForEmployee((int)_department.ManagerEmployeeId, null); lblBossName.Text = ""; } employeesOverView.ShowDialog(); if (employeesOverView.DialogResult == DialogResult.OK) { _bossId = employeesOverView.SelectedId; if (_department != null) { _department.ManagerEmployeeId = _bossId; } ModelEmployee boss = _createEditDepartmentViewModel.GetEmployee(_bossId); lblBossName.Text = $"{_departmentType.ToString()} Boss Name: {boss.Title} {boss.Name} {boss.Surname}"; btnConfirm.Enabled = true; } }
public List <ModelDepartment> GetListOfDepartments(EnumDepartmentsType.DepartmentType departmentType) { List <ModelDepartment> myListOfCompanies = new List <ModelDepartment>(); RepositoryManager.ExecuteSqlCommand((command) => { command.CommandText = @"select * from [dbo].[Department] where DepartmentType=@DepartmentType"; command.Parameters.Add("@DepartmentType", SqlDbType.NVarChar).Value = departmentType.ToString(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ModelDepartment company = new ModelDepartment { Id = reader.GetInt32(0), Name = reader.GetString(1), Code = reader.GetString(2), DepartmentType = departmentType, SuperiorDepartmentId = reader.IsDBNull(4) ? null : (int?)reader.GetInt32(4), ManagerEmployeeId = reader.IsDBNull(5) ? null : (int?)reader.GetInt32(5) }; myListOfCompanies.Add(company); } } }); return(myListOfCompanies); }