public async Task Delete(int technicalStaffId, int participationId) { var participationCount = await _participationTechnicalStaves.CountAsync( pt => pt.TechnicalStaffId == technicalStaffId); if (participationCount <= 1) { _participationTechnicalStaves.Remove( await _participationTechnicalStaves.FirstOrDefaultAsync( pt => pt.TechnicalStaffId == technicalStaffId && pt.ParticipationId == participationId)); var technicalStaff = new TechnicalStaff() { Id = technicalStaffId, }; _technicalStaves.Attach(technicalStaff); _technicalStaves.Remove(technicalStaff); } else { _participationTechnicalStaves.Remove( await _participationTechnicalStaves.FirstOrDefaultAsync( pt => pt.TechnicalStaffId == technicalStaffId && pt.ParticipationId == participationId)); } }
//Display the technical Staff Name private void GetDisplayTechStaff() { TechnicalStaff ts = new TechnicalStaff(); List <TechnicalStaff> techStaffData = ts.GetBLTechnical(); int count = 0; int index = -1; foreach (TechnicalStaff item in techStaffData) { string deployed = item.Deployed.ToString(); if (deployed[0] == 'N') { index = count; } else { count++; } } string techName = techStaffData[index].Name; string techSurnam = techStaffData[index].Surname; lblTechnicianName.Text = techName + " " + techSurnam; }
public async Task <IActionResult> PutTechnicalStaff([FromRoute] int id, [FromBody] TechnicalStaff technicalStaff) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != technicalStaff.TechnicalStaffId) { return(BadRequest()); } _context.Entry(technicalStaff).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TechnicalStaffExists(id)) { return(NotFound()); } else { throw; } } technicalStaff = _context.TechnicalStaffs.Include(e => e.Department).FirstOrDefault(e => e.TechnicalStaffId == technicalStaff.TechnicalStaffId); return(Ok(technicalStaff)); }
public void EditApproval(TechnicalStaff technicalStaff) { _technicalStaves.Attach(technicalStaff); _dbContext.Entry(technicalStaff).Property(t => t.IsApproved).IsModified = true; _dbContext.Entry(technicalStaff).Property(t => t.Error).IsModified = true; _dbContext.Entry(technicalStaff).Property(t => t.DormId).IsModified = true; _dbContext.Entry(technicalStaff).Property(t => t.DormNumber).IsModified = true; }
public void Delete(int technicalStaffId) { var technicalStaff = new TechnicalStaff() { Id = technicalStaffId, }; _technicalStaffs.Attach(technicalStaff); _technicalStaffs.Remove(technicalStaff); }
public void Add(TechnicalStaff technicalStaff, int representativeUserId, int competitionId, int roleId) { _competitionCommonTechnicalStaffs.Add(new CompetitionCommonTechnicalStaff { CompetitonId = competitionId, RepresentativeUserId = representativeUserId, TechnicalStaffRoleId = roleId, TechnicalStaff = technicalStaff }); }
public async Task <IActionResult> PostTechnicalStaff([FromBody] TechnicalStaff technicalStaff) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.TechnicalStaffs.Add(technicalStaff); await _context.SaveChangesAsync(); technicalStaff = _context.TechnicalStaffs.Include(e => e.Department).FirstOrDefault(e => e.TechnicalStaffId == technicalStaff.TechnicalStaffId); return(CreatedAtAction("GetTechnicalStaff", new { id = technicalStaff.TechnicalStaffId }, technicalStaff)); }
private void btnInsertTech_Click(object sender, EventArgs e) { string name = txtTechName.Text; string surname = txtTechSurname.Text; string deployed = txtTechDeployed.Text; string deployeDate = txtTechDeployDate.Text; string specialization = cmbSpecialization.Text; TechnicalStaff ts = new TechnicalStaff(); ts.InsertTechnical(name, surname, specialization); FormManagement fm = new FormManagement(); fm.RefreshPage(); this.Close(); }
public void RefreshPage() { List <Employee> emp = new List <Employee>(); List <TechnicalStaff> ts = new List <TechnicalStaff>(); BindingSource bs = new BindingSource(); BindingSource bsTech = new BindingSource(); emp = new Employee().GetEmployee(); bs.DataSource = emp; dgvMan.DataSource = bs; dgvMan.AutoResizeColumns(); ts = new TechnicalStaff().GetBLTechnical(); bsTech.DataSource = ts; dgvTechTeam.DataSource = bsTech; dgvTechTeam.AutoResizeColumns(); }
public void Add(TechnicalStaff technicalStaff, int participationId, int technicalStaffRoleId) { if (technicalStaff.Id == 0) { _technicalStaves.Add(technicalStaff); _participationTechnicalStaves.Add(new ParticipationTechnicalStaff() { ParticipationId = participationId, TechnicalStaffId = technicalStaff.Id, TechnicalStaffRoleId = technicalStaffRoleId, }); } else { _participationTechnicalStaves.Add(new ParticipationTechnicalStaff() { ParticipationId = participationId, TechnicalStaffId = technicalStaff.Id, TechnicalStaffRoleId = technicalStaffRoleId, }); } }
private void btnUpdateOrder_Click(object sender, EventArgs e) { int id = int.Parse(lblTechID.Text); string name = txtTechName.Text; string surname = txtTechSurname.Text; string specialization = cmbSpecialization.Text; string deployed = txtTechDeployed.Text; string deploymentDate = dtpDeployDate.Value.ToString("dd/MM/yyyy"); TechnicalStaff ts = new TechnicalStaff(); ts.UpdateBLTechnical(id, name, surname, specialization, deployed, deploymentDate); MessageBox.Show(deploymentDate); FormManagement fm = new FormManagement(); fm.RefreshPage(); UpdateTechForm utf = new UpdateTechForm(); utf.Close(); }
public async Task Delete(int technicalStaffId, int[] similarParticipationIds) { var paricipationsCount = await _participationTechnicalStaves.Where(pts => pts.TechnicalStaffId == technicalStaffId).CountAsync(); foreach (var similarParticipationId in similarParticipationIds) { _participationTechnicalStaves.Remove( _participationTechnicalStaves.FirstOrDefault( pts => pts.ParticipationId == similarParticipationId && pts.TechnicalStaffId == technicalStaffId)); } if (paricipationsCount == similarParticipationIds.Length) { var technicalStaff = new TechnicalStaff() { Id = technicalStaffId, }; _technicalStaves.Attach(technicalStaff); _technicalStaves.Remove(technicalStaff); } }
private void iconButton3_Click(object sender, EventArgs e) { if (dgvTechTeam.SelectedCells.Count > 0) { int selectedrowindex = dgvTechTeam.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = dgvTechTeam.Rows[selectedrowindex]; string id = Convert.ToString(selectedRow.Cells["TechnicalID"].Value); string name = Convert.ToString(selectedRow.Cells["Name"].Value); string surname = Convert.ToString(selectedRow.Cells["Surname"].Value); DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete " + id + " " + name + " " + surname + " from database ?", "DELETE", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { TechnicalStaff ts = new TechnicalStaff(); ts.DeleteBLEmployee(int.Parse(id)); } else if (dialogResult == DialogResult.No) { this.Close(); } RefreshPage(); } }
public void Edit(TechnicalStaff technicalStaff) { _technicalStaves.Attach(technicalStaff); _dbContext.Entry(technicalStaff).State = EntityState.Modified; }
private void btnConfirm_Click(object sender, EventArgs e) { //Gather all necessary values string contactUID = lblUID.Text; string type = lblContractType.Text; string term = lblTerm.Text; string products = lblProducts.Text; string serviceName = lblService.Text; string installationDate = lblinstalDate.Text; string expirationDate = lblExpirationDate.Text; string maintenancePlane = lblMaintenance.Text; string clientName = lblName.Text; string clientSurname = lblSurnamesig.Text; string clientAddress = lblAddress.Text; int totalCost = int.Parse(lblTotalPrice.Text); int cancellationFee = int.Parse(lblCancelPrice.Text); string address = lblAddress.Text; Contract cr = new Contract(); //Set the appointment for technical stafff TechnicalStaff ts = new TechnicalStaff(); List <TechnicalStaff> techStaffData = ts.GetBLTechnical(); int count = 0; int index = -1; foreach (TechnicalStaff item in techStaffData) { string deployed = item.Deployed.ToString(); if (deployed[0] == 'N') { index = count; } else { count++; } } int technicalID = techStaffData[index].TechnicalID; string techName = techStaffData[index].Name; string techSurnam = techStaffData[index].Surname; string techSpec = techStaffData[index].Specialization; string techDeployed = "YES"; string techStaff = installationDate; ts.UpdateBLTechnical(technicalID, techName, techSurnam, techSpec, techDeployed, techStaff); //Set the client contract to active and expiration date Client cl = new Client(); List <Client> clientData = cl.GetCustomer(); int countClient = 0; int indexClient = -1; foreach (Client itemclient in clientData) { string obetainedclientUID = itemclient.ClientID; if (obetainedclientUID == ClientUID) { indexClient = countClient; } else { countClient++; } } string Contact = clientData[indexClient].Contact; string email = clientData[indexClient].Email; string clientActiveContract = "YES"; string clientExpiration = expirationDate; cl.UpdateBLCustomer(ClientUID, clientName, clientSurname, address, Contact, email, clientActiveContract, clientExpiration); //Store contract values n the database cr.InsertBLContract(contactUID, type, term, products, serviceName, installationDate, expirationDate, maintenancePlane, totalCost, cancellationFee, clientName, clientSurname, address); this.Close(); }