Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        //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;
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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
     });
 }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
 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,
         });
     }
 }
Ejemplo n.º 11
0
        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();
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        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();
            }
        }
Ejemplo n.º 14
0
        public void Edit(TechnicalStaff technicalStaff)
        {
            _technicalStaves.Attach(technicalStaff);

            _dbContext.Entry(technicalStaff).State = EntityState.Modified;
        }
Ejemplo n.º 15
0
        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();
        }