Example #1
0
 //**************************************************************************************************
 private void btnModifierMateriel_Click(object sender, EventArgs e)
 {
     // On récupère Tous les attributs du matériel
     using (MaterielManager materielManager = new MaterielManager())
     {
         materielSelectionne.TypeMateriel = textBoxTypeMateriel.Text.Trim();
         materielSelectionne.NumeroTel    = mTxtBoxNumtel.Text.Trim();
         materielSelectionne.Imei         = textBoxCodeIMEI.Text.Trim();
         materielSelectionne.IdGoogle     = textBoxIdGoogle.Text.Trim();
         // il faut chercher si un technicien a en usage le matériel
         // si oui et si etatMatériel n'est pas égale à enService il faut
         // l'enlever de l'affectation du technicien
         using (TechnicienManager technicienManager = new TechnicienManager())
         {
             Technicien technicien = new Technicien();
             technicien.FkIdMateriel = materielSelectionne.IdMateriel;
             // on recherche le technicien qui possédait le matériel
             technicien = technicienManager.getTechnicien(technicien);
             if ((materielSelectionne.EtatMateriel == "enService") && ((string)comBoxEtatMatériel.SelectedItem != "enService"))
             {
                 // il faut retirer l'affectation du matériel au technicien
                 technicien.FkIdMateriel = 0;
                 technicienManager.ajoutModifTechnicien(ref technicien);
             }
         }
         materielSelectionne.EtatMateriel = comBoxEtatMatériel.SelectedItem.ToString();
         materielSelectionne.FkLoginE     = UtilisateurConnecte.Login;
         // On persiste les modifications
         materielManager.insertUpdateMateriel(ref materielSelectionne);
         MessageToast.Show("Matériel modifié avec succès");
         RafraichirIHM();
     }
 }
Example #2
0
        //**************************************************************************************************
        private void dgvMateriels_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int IdxLigneActuelle = e.RowIndex;

            if (IdxLigneActuelle >= 0)
            {
                int idMateriel             = (int)dgvMateriels.Rows[IdxLigneActuelle].Cells[0].Value;
                int indiceDansListMateriel = listMateriel.FindIndex(unMateriel => unMateriel.IdMateriel == idMateriel);
                materielSelectionne = listMateriel[indiceDansListMateriel];

                //On a récupéré l'objet matériel correspondant à la sélection,
                // on rempli les différents champs
                textBoxTypeMateriel.Text           = materielSelectionne.TypeMateriel;
                textBoxNumSerie.Text               = materielSelectionne.NumeroSerie;
                mTxtBoxNumtel.Text                 = materielSelectionne.NumeroTel;
                textBoxCodeIMEI.Text               = materielSelectionne.Imei;
                textBoxIdGoogle.Text               = materielSelectionne.IdGoogle;
                comBoxEtatMatériel.SelectedItem    = materielSelectionne.EtatMateriel;
                lblDateEnregistrementMateriel.Text = materielSelectionne.DateEnregistrement.ToString("dd/MM/yyyy");
                if (materielSelectionne.DateAffectation != DateTime.MinValue)
                {
                    lblValDateAffectation.Text = materielSelectionne.DateAffectation.ToString("dd/MM/yyyy");
                }
                else
                {
                    lblValDateAffectation.Text = "jamais affecté";
                }
                using (TechnicienManager technicienManager = new TechnicienManager())
                {
                    Technicien technicien = new Technicien();
                    technicien.FkIdMateriel = materielSelectionne.IdMateriel;
                    technicien = technicienManager.getTechnicien(technicien);
                    txtBoxAffectationMat.Text = technicien.Prenom + "  " + technicien.Nom;
                }
                btnModifierMateriel.Enabled = true;
            }
        }