Esempio n. 1
0
        private void RefreshGrid()
        {
            switch (_eFrmType)
            {
            case EFrmType.employees:
                dataGridView.DataSource                           = "";
                dataGridView.DataSource                           = _employeesLogic.GetEmployees();
                dataGridView.Columns["ID"].Visible                = false;
                dataGridView.Columns["Title"].HeaderText          = "Titul";
                dataGridView.Columns["FirstName"].HeaderText      = "Krstné meno";
                dataGridView.Columns["Lastname"].HeaderText       = "Priezvisko";
                dataGridView.Columns["Telephone"].HeaderText      = "Klapka/Telefón";
                dataGridView.Columns["Email"].HeaderText          = "Email";
                dataGridView.Columns["DepartmentName"].HeaderText = "Oddelenie";
                dataGridView.Columns["DepartmentID"].Visible      = false;
                dataGridView.Columns["FullName"].Visible          = false;
                break;

            case EFrmType.departments:
                dataGridView.DataSource                                 = "";
                dataGridView.DataSource                                 = _departmentsLogic.GetDepartments();
                dataGridView.Columns["ID"].Visible                      = false;
                dataGridView.Columns["Code"].HeaderText                 = "Kód oddelenia";
                dataGridView.Columns["Name"].HeaderText                 = "Názov oddelenia";
                dataGridView.Columns["Hierarchy"].HeaderText            = "Úroveň oddelenia";
                dataGridView.Columns["ParentDepartmentID"].Visible      = false;
                dataGridView.Columns["HeadEmployeeID"].Visible          = false;
                dataGridView.Columns["ParentDepartmentName"].HeaderText = "Nadriadené oddelenie";
                dataGridView.Columns["HeadEmployeeName"].HeaderText     = "Zodpovedný zamestnanec";

                RefreshTreeList();
                break;
            }
        }
Esempio n. 2
0
        private void btnSaveExist_Click(object sender, EventArgs e)
        {
            //get all departments from db
            List <DepartmentModel> departmentsList = _departmentsLogic.GetDepartments();
            //get new departmentModel from frm
            DepartmentModel departmentNew = LoadDeparmentFromFrm();

            //to secure that ID is not changed
            departmentNew.ID = _department.ID;

            //check if deparment have choosen parent department
            if (CheckIfCanSave(departmentNew))
            {
                //check if department have child departments or if it is changed hierarchy of department
                departmentsList = departmentsList.Where(dep => dep.ParentDepartmentID == departmentNew.ID).ToList();
                if (departmentsList.Count == 0 || departmentNew.Hierarchy == _department.Hierarchy)
                {
                    _departmentsLogic.UpdateDepartment(departmentNew);
                    Close();
                }
                else
                {
                    MessageBox.Show("Nie je možné uložiť zmenu oddelenia, pokiaľ má podriadené oddelenia");
                }
            }
            else
            {
                MessageBox.Show("Nie je možné uložiť oddelenie, pokiaľ nemá nadriadené oddelenie");
            };
        }
Esempio n. 3
0
        public frmEmployee(EFrmAction eFrmAction, EmployeeModel employee)
        {
            InitializeComponent();

            DepartmentsLogic departmentsLogic = new DepartmentsLogic();

            cmbDepartment.DataSource    = departmentsLogic.GetDepartments();
            cmbDepartment.DisplayMember = "Name";
            cmbDepartment.ValueMember   = "ID";

            _employee = employee;

            switch (eFrmAction)
            {
            case EFrmAction.add:
                Text = "Pridanie nového zamestnanca";
                lblNameOfFrm.Text    = "Pridanie nového zamestnanca";
                btnSaveExist.Visible = false;
                break;

            case EFrmAction.edit:
                Text = "Editácia existujúceho zamestnanca";
                lblNameOfFrm.Text  = "Editácia existujúceho zamestnanca";
                btnSaveNew.Visible = false;
                FillFrmFromEmployee(_employee);
                break;

            default:
                break;
            }
        }