/// <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); } } } }
/// <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); }
/// <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(); } }
/// <summary> /// /// </summary> /// <param name="_EmpNif"></param> /// <param name="_TeamCode"></param> /// <returns></returns> public static bool addToTeam(/*pojo.Employee pEmployee, pojo.Team pTeam*/ String _EmpNif, String _TeamCode) { model.pojo.TeamHistory _oTeamHistory = new model.pojo.TeamHistory(); if (_EmpNif != null && _TeamCode != null) { using (var q = new synupEntities()) { _oTeamHistory.id_employee = _EmpNif; _oTeamHistory.id_team = _TeamCode; //_oTeamHistory.Employee = pEmployee; //_oTeamHistory.Team = pTeam; _oTeamHistory.entranceDay = DateTime.Today; //database.TeamHistories.Add(_oTeamHistory); q.TeamHistories.Add(_oTeamHistory); return(commitChanges(q)); } } return(false); }