Ejemplo n.º 1
0
        /// <summary>
        /// Add selected employee to team
        /// </summary>
        private void addToTeam()
        {
            model.pojo.Employee _oSelectedEmployee = null;
            model.pojo.Team     _oTeam             = null;
            Boolean             _blAdd             = false;

            if (this.dgvEmployees.SelectedRows.Count == 1)                        //If the row selected
            {
                int    _iIndexSelected = this.dgvEmployees.SelectedRows[0].Index; // Recover the index of selected row
                Object _cell           = this.dgvEmployees.Rows[_iIndexSelected].Cells[0].Value;
                if (_cell != null)
                {
                    String _strSelectedRowCode = _cell.ToString();                                     // Recover the code
                    _oSelectedEmployee = Controller.EmployeeService.readEmployee(_strSelectedRowCode); // We look for the employee nif

                    String _SelectedTeam = this.cmbTeamsToAdd.SelectedValue.ToString();
                    _oTeam = this.Controller.TeamService.readTeam(_SelectedTeam);

                    model.pojo.TeamHistory _oCurrentTeam = this.Controller.TeamHistoryService.getCurrentTeamHistoryByEmployee(_oSelectedEmployee.nif, _oTeam.code); //We look if the employee already in team

                    if (_oCurrentTeam == null)
                    {
                        if (_oSelectedEmployee != null && _oTeam != null)
                        {
                            _blAdd = this.Controller.TeamService.addToTeam(_oSelectedEmployee.nif, _oTeam.code);
                        }
                        clMessageBox.showMessage(Literal.ADD_EMPLOYEE_TO_TEAM_SUCCESFULL, true, this);
                    }
                    else
                    {
                        clMessageBox.showMessage(Literal.INFO_ON_TEAM, false, this);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deleted selected employee to team
        /// </summary>
        private bool deleteFromTeam(model.pojo.Employee pEmployee, model.pojo.Team pTeam)
        {
            model.pojo.TeamHistory _oTeamHistoryControl = null;
            Boolean _blUpdateHistory = false;

            if (pEmployee != null && pTeam != null)
            {
                _oTeamHistoryControl = this.Controller.TeamHistoryService.readTeamHistory(pEmployee.nif, pTeam.code);

                if (_oTeamHistoryControl != null)
                {
                    _blUpdateHistory = this.Controller.TeamHistoryService.updateTeamHistory(pEmployee.nif, pTeam.code, DateTime.Now);
                }
            }
            return(_blUpdateHistory);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows the management view window of the teams.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnManagementTeams_Click(object sender, EventArgs e)
        {
            model.pojo.Team _oSelectedTeam = null;
            if (this.dgvTeams.SelectedRows.Count == 1)                        //If the row selected
            {
                int    _iIndexSelected = this.dgvTeams.SelectedRows[0].Index; // Recover the index of selected row
                Object _cell           = this.dgvTeams.Rows[_iIndexSelected].Cells[0].Value;
                if (_cell != null)
                {
                    String _strSelectedRowCode = _cell.ToString();                         // Recover the code
                    _oSelectedTeam = Controller.TeamService.readTeam(_strSelectedRowCode); // We look for the team code
                    this.Controller.TeamMgtView.AuxTeam = _oSelectedTeam;                  // We assign the team to form team management
                }
            }

            this.Controller.TeamMgtView.ShowDialog();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Method that adds selected employees on team
        /// </summary>
        private void addToTeam()
        {
            model.pojo.Employee _oSelectedEmployee = null;
            model.pojo.Team     _oTeam             = null;

            if (this.dgvEmployees.SelectedRows.Count >= 1)
            {
                Boolean _blAllCorrect = true;

                DataGridViewSelectedRowCollection _selected = dgvEmployees.SelectedRows;

                foreach (DataGridViewRow _row in _selected)
                {
                    int    _iIndexSelected = _row.Index; // Recover the index of selected row
                    Object _cell           = this.dgvEmployees.Rows[_iIndexSelected].Cells[0].Value;
                    if (_cell != null)
                    {
                        String _strSelectedRowCode = _cell.ToString();                                     // Recover the code
                        _oSelectedEmployee = Controller.EmployeeService.readEmployee(_strSelectedRowCode); // We look for the employee nif

                        _oTeam = AuxTeam;
                        model.pojo.TeamHistory _oCurrentTeam = this.Controller.TeamHistoryService.getCurrentTeamHistoryByEmployee(_oSelectedEmployee.nif, _oTeam.code); //We look if the employee already in team

                        if (_oCurrentTeam == null)
                        {
                            if (_oSelectedEmployee != null && _oTeam != null)
                            {
                                Boolean _blAdd = this.Controller.TeamService.addToTeam(_oSelectedEmployee.nif, _oTeam.code);
                            }
                        }
                        else
                        {
                            _blAllCorrect = false;
                        }
                    }
                }

                if (!_blAllCorrect)
                {
                    clMessageBox.showMessage(Literal.ADD_ALL_EMPLOYEE_TO_TEAM_ERROR, false, this);
                }
                this.Close();
            }
        }