Beispiel #1
0
        public void Supprimer()
        {
            if (dataGridElements.SelectedItems.Count == 1)
            {
                //Faire la modif
                Civilite civiliteASupprimer = (Civilite)dataGridElements.SelectedItem;

                if (MessageBox.Show("Êtes-vous sûr de vouloir supprimer cet élément ?",
                                    "Suppression",
                                    MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    ((App)App.Current).entity.Civilite.Remove(civiliteASupprimer);

                    //Sauvegarde
                    ((App)App.Current).entity.SaveChanges();
                }
                else
                {
                    //On rafraichit l'entity pour éviter les erreurs de données "fantomes" mal déliées
                    ((App)App.Current).entity = new ExerciceCSharp_BDDEntities();
                }
            }
            else
            {
                MessageBox.Show("Merci de sélectionner un et un élément maximum");
            }
            RefreshDatas();
        }
Beispiel #2
0
        public IHttpActionResult PutCivilite(int id, Civilite civilite)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != civilite.id_civilite)
            {
                return(BadRequest());
            }

            db.Entry(civilite).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CiviliteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public void Modifier()
        {
            if (dataGridElements.SelectedItems.Count == 1)
            {
                //Faire la modif
                //Civilite civiliteAModifier = dataGridElements.SelectedItem as Civilite;
                Civilite civiliteAModifier = (Civilite)dataGridElements.SelectedItem;

                CiviliteWindow window = new CiviliteWindow(civiliteAModifier);
                window.ShowDialog();

                if (window.DialogResult.HasValue && window.DialogResult == true)
                {
                    //Sauvegarde
                    ((App)App.Current).entity.SaveChanges();
                }
                else
                {
                    //On rafraichit l'entity pour éviter les erreurs de données "fantomes" mal déliées
                    ((App)App.Current).entity = new ExerciceCSharp_BDDEntities();
                }
            }
            else
            {
                MessageBox.Show("Merci de sélectionner un et un élément maximum");
            }
            RefreshDatas();
        }
        private int EmployeeCreate(
            string cin,
            string nom,
            string prenom,
            Civilite civilite,
            SituationFamille situationFamille,
            string numeroCnss,
            string cleCnss,
            string nomJeuneFille,
            string autresNom,
            string numeroInterne,
            CategorieCnss categorie)
        {
            var employee = new Employee
            {
                Civilite         = civilite,
                Nom              = nom,
                Prenom           = prenom,
                SituationFamille = situationFamille,
                CleCnss          = cleCnss,
                NumeroCnss       = numeroCnss,
                Cin              = cin,
                NomJeuneFille    = nomJeuneFille,
                SocieteNo        = DeclarationService.Societe.Id,
                AutresNom        = autresNom,
                CategorieNo      = categorie.Id,
                NumeroInterne    = numeroInterne
            };

            return(_employeeRepository.Create(employee));
        }
        /// <summary>
        /// Permet la convertion d'un objet civilite data en un objet civilite DTO
        /// </summary>
        /// <param name="civilite">civilite Data</param>
        /// <returns>civilite DTO</returns>
        public static Civilite EntityToDto(Data.Civilite civilite)
        {
            Civilite civiliteDto = new Civilite();

            civiliteDto.Id    = civilite.Id;
            civiliteDto.Label = civilite.Label;

            return(civiliteDto);
        }
Beispiel #6
0
 public Participant(Civilite civ, string nom, string prenom, string adresse, string tel, DateTime dateNaissance)
 {
     Nom           = nom;
     Prenom        = prenom;
     Adresse       = adresse;
     Civilite      = civ;
     Telephone     = tel;
     DateNaissance = dateNaissance;
 }
Beispiel #7
0
 public Client(Civilite civilite, string nom, string prenom, string adresse, string telephone, DateTime dateNaissance)
 {
     Nom           = nom;
     Prenom        = prenom;
     Adresse       = adresse;
     Civilite      = civilite;
     Telephone     = telephone;
     DateNaissance = dateNaissance;
 }
Beispiel #8
0
 public Personne(string nom, string prenom, Civilite civilite, string mail, string telephone, string portable, string fax, string commentaire)
 {
     Nom         = nom;
     Prenom      = prenom;
     Civilite    = civilite;
     Telephone   = telephone;
     Portable    = portable;
     Fax         = fax;
     Commentaire = commentaire;
 }
Beispiel #9
0
        public IHttpActionResult GetCivilite(int id)
        {
            Civilite civilite = db.Civilites.Find(id);

            if (civilite == null)
            {
                return(NotFound());
            }

            return(Ok(civilite));
        }
Beispiel #10
0
        //*****************************************************************************************************************
        // pour chaque client il faut :
        // // lire le fichier contenant les données à placer dans la table client (clients.csv)
        // faire un split du string csv représentatnt le client et éventuellment récupérer et convertir l'image du lieu
        // peupler une entité client et la persister en BDD

        private void peuplerTableClient()
        {
            Client client = new Client();

            String[] tabLines = System.IO.File.ReadAllLines(@"..\..\..\DonneesInitialesBdd\Clients.csv", Encoding.GetEncoding("iso-8859-1"));

            using (ClientManager clientManager = new ClientManager())
            {
                // chargement de la list de toutes les civilités
                // On utilise la connexion préalablement établie
                List <Civilite> listCivilites = new List <Civilite>();
                using (Manager manager = new Manager(clientManager.getConnexion()))
                {
                    manager.getListe(ref listCivilites, "civilite");
                    foreach (String line in tabLines)   // pour tous les clients du jeux d'essais
                    {
                        String[] str = line.Split(';'); // on a choisi ; comme séparateur csv
                        client.Entreprise = str[0];
                        // Dans le fichier de peuplement la civilité est fournie sous forme d'abréviation
                        // Il faut donc retrouver l'id correspondante dans la liste des civilités
                        Civilite elementCivilite = listCivilites.Find(uneCivilite => uneCivilite.Abreviation == str[1]);
                        client.FkIdCivilite = elementCivilite.IdCivilite;
                        client.Prenom       = str[2];
                        client.Nom          = str[3];
                        client.Adresse      = str[4];
                        client.CompAdresse  = str[5];
                        client.Ville        = str[6];
                        client.CodePostal   = str[7];
                        client.NumeroTel    = str[8];
                        client.Email        = str[9];
                        if (str[10] != "") // y a t il une image correspondant à l'adresse fournie par le client
                        {
                            // il faut charger et convertir l'image
                            // Conversion fichier photo en tableau de byte pour enregistrement en BDD
                            FileStream fs         = new FileStream(str[10], FileMode.OpenOrCreate, FileAccess.Read); // on ouvre le fichier de la photo
                            byte[]     imageBytes = new byte[fs.Length];                                             // tableau de byte pour recevoir le contenu des octets de la photo
                            fs.Read(imageBytes, 0, Convert.ToInt32(fs.Length));                                      // on place le contenu des octets de la photo dans le tableau
                            client.Photoent = imageBytes;                                                            // on enregistre dans l'entité
                        }
                        else
                        {
                            client.Photoent = new Byte[0];
                        }
                        client.Latitude       = str[11];
                        client.Longitude      = str[12];
                        client.FkIdEtatClient = Convert.ToInt32(str[13]);
                        client.FkLoginE       = str[14];
                        // On persiste l'entité en BDD
                        clientManager.insUpdateClient(client);
                    }
                }
            }
        }
Beispiel #11
0
        public IHttpActionResult PostCivilite(Civilite civilite)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Civilites.Add(civilite);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = civilite.id_civilite }, civilite));
        }
Beispiel #12
0
        public IHttpActionResult DeleteCivilite(int id)
        {
            Civilite civilite = db.Civilites.Find(id);

            if (civilite == null)
            {
                return(NotFound());
            }

            db.Civilites.Remove(civilite);
            db.SaveChanges();

            return(Ok(civilite));
        }
Beispiel #13
0
        public async Task <IEnumerable <Internaute> > Search(string nom, Civilite civilite)
        {
            IQueryable <Internaute> query = _appDbContext.Internautes;

            if (!string.IsNullOrEmpty(nom))
            {
                query = query.Where(i => i.Nom.Contains(nom) || i.Prenom.Contains(nom));
            }
            if (civilite != null)
            {
                query = query.Where(i => i.IdCiviliteNavigation == civilite);
            }
            return(await query.ToListAsync());
        }
        public int EmployeeCreateOrUpdate(
            string cin,
            string nom,
            string prenom,
            Civilite civilite,
            SituationFamille situationFamille,
            string numeroCnss,
            string cleCnss,
            string nomJeuneFille,
            string autresNom,
            string numeroInterne,
            CategorieCnss categorie)
        {
            var employee = new Employee
            {
                Civilite         = civilite,
                Nom              = nom,
                Prenom           = prenom,
                SituationFamille = situationFamille,
                CleCnss          = cleCnss,
                NumeroCnss       = numeroCnss,
                Cin              = cin,
                NomJeuneFille    = nomJeuneFille,
                SocieteNo        = DeclarationService.Societe.Id,
                AutresNom        = autresNom,
                CategorieNo      = categorie.Id,
                NumeroInterne    = numeroInterne
            };
            // checked exist empployee , if not exist then create , else update

            var exist = _employeeRepository.Get(cin, DeclarationService.Societe.Id);

            if (exist == null)
            {
                return(_employeeRepository.Create(employee));
            }
            exist.Civilite         = civilite;
            exist.CleCnss          = cleCnss;
            exist.Nom              = nom;
            exist.Prenom           = prenom;
            exist.SituationFamille = situationFamille;
            exist.CleCnss          = cleCnss;
            exist.NumeroCnss       = numeroCnss;
            exist.Cin              = cin;
            exist.NomJeuneFille    = nomJeuneFille;
            exist.CategorieNo      = categorie.Id;
            _employeeRepository.Update(exist);
            return(exist.Id);
        }
Beispiel #15
0
        public CiviliteWindow(Civilite civiliteAModifier = null)
        {
            InitializeComponent();

            if (civiliteAModifier == null)
            {
                this.DataContext = new Civilite();
            }
            else
            {
                this.DataContext = civiliteAModifier;
            }

            //this.DataContext = civiliteAModifier == null ? new Civilite() : civiliteAModifier;
        }
Beispiel #16
0
        ///// <param name="prenom">Prénom de l'utilisateur</param>
        ///// <param name="nom">Nom de l'utilisateur</param>
        ///// <param name="type">Type d'utilisateur</param>


        /// <summary>
        /// Constructeur d'un Utilisateur prenant son adresse e-mail, mot de passe, nom, prénom, type.
        /// </summary>
        /// <param name="identifiant">Identifiant de l'utilisateur (son adresse mail)</param>
        /// <param name="motDePasse">Mot de passe de l'utilisateur</param>
        /// <param name="prenom">Prénom de l'utilisateur</param>
        /// <param name="nom">Nom de l'utilisateur</param>
        /// <param name="type">Type de l'utilisateur</param>
        public Utilisateur(string identifiant, string motDePasse, string nom, string prenom, ICollection <Telephone> telephones, TypeUtilisateur type, Lieu lieu, Civilite civilite, Parametre parametre, string otherInfo)
        {
            this.ID         = identifiant;
            this.MotDePasse = motDePasse.GetHashCode();
            this.Prénom     = prenom;
            this.Nom        = nom;
            this.Type       = type;
            this.LieuID     = lieu.ID;
            this.Civilite   = civilite;
            this.OtherInfo  = otherInfo;
            this.Telephones = telephones;

            this.ParametreID = parametre.ID;
            parametre.DefaultTextFeedback += $"{prenom} {nom}";
        }
        public static IEnumerable <Employe> GetEmployesByCivilite(string libelleCourtCivilite)
        {
            using (ISession session = SessionFactory.OpenSession())
            {
                Employe  employeAlias  = null;
                Civilite civiliteAlias = null;

                // Equivalent SQL
                // Select * from Employe employeAlias
                // Inner Join Civilite civiliteAlias on employeAlias.Civilite_id = civiliteAlias.Id
                // Where civiliteAlias.libelleCourt = libelleCourtCivilite
                return(session.QueryOver <Employe>(() => employeAlias)
                       .Inner.JoinAlias(() => employeAlias.Civilite, () => civiliteAlias)
                       .Where(() => civiliteAlias.LibelleCourt == libelleCourtCivilite)
                       .List());
            }
        }
Beispiel #18
0
 public Client AjouterClient(Civilite civilite, string prenom, string nom, string email, string telPortable, string telFixe, string pays, string ville, string codePostal, string addr1, string addr2 = "", string entreprise = "")
 {
     return(AjouterClient(new Entities.Client()
     {
         Civilite = civilite,
         Nom = nom,
         Prenom = prenom,
         Email = email,
         TelPortable = telPortable,
         TelFixe = telFixe,
         AdressePays = pays,
         AdresseVille = ville,
         AdresseCp = codePostal,
         Adresse1 = addr1,
         Adresse2 = addr2,
         Entreprise = entreprise
     }));
 }
Beispiel #19
0
        /// <summary>
        /// Sauvegarde la civilité en base de données
        /// </summary>
        /// <param name="civilite">civilite à sauvegarder</param>
        public void SaveCivilite(Civilite civilite)
        {
            SqlCommand insertCommand = new SqlCommand();

            insertCommand.CommandText = "INSERT INTO Civilite(LibelleCourt, LibelleLong) VALUES(@libelleCourt, @libelleLong);";
            insertCommand.Connection  = Connection;

            // Paramètres
            insertCommand.Parameters.Add("@libelleCourt", SqlDbType.NVarChar, 50, "LibelleCourt");
            insertCommand.Parameters.Add("@libelleLong", SqlDbType.NVarChar, 50, "LibelleLong");

            insertCommand.Parameters["@libelleCourt"].Value = civilite.LibelleCourt;
            insertCommand.Parameters["@libelleLong"].Value  = civilite.LibelleLong;

            int nbResult = ExecuteNonQuery(insertCommand);

            Console.WriteLine($"{nbResult} civilité(s) insérée(s)");
        }
        //**************************************************************************************************
        private void dgvClient_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int IdxLigneActuelle = e.RowIndex;

            if (IdxLigneActuelle >= 0)
            {
                int idClient             = (int)dgvClient.Rows[IdxLigneActuelle].Cells[0].Value;
                int indiceDansListClient = listClient.FindIndex(leClientCherché => leClientCherché.IdClient == idClient);
                clientSelectionne = listClient[indiceDansListClient];
                // recupère les données du client
                txtBoxNomEntreprise.Text = clientSelectionne.Entreprise;
                txtBoxNomClient.Text     = clientSelectionne.Nom;
                txtBoxPrenomClient.Text  = clientSelectionne.Prenom;
                txtBoxAdresse.Text       = clientSelectionne.Adresse;
                txtBoxAdresse2.Text      = clientSelectionne.CompAdresse;
                mTxtBoxCodePostal.Text   = clientSelectionne.CodePostal;
                txtBoxVille.Text         = clientSelectionne.Ville;
                mTxtBoxTelephone.Text    = clientSelectionne.NumeroTel;
                txtBoxEmail.Text         = clientSelectionne.Email;

                mTxtBoxLatitude.Text  = clientSelectionne.Latitude;
                mTxtBoxLongitude.Text = Utils.formatageLongitude(clientSelectionne.Longitude, '.');
                // modification de la valeur de l'item sélectionné dans le combobox
                Civilite elementCivilite = ChargementListes.ListCivilites.Find(uneCivilite => uneCivilite.IdCivilite == clientSelectionne.FkIdCivilite);
                cbxCivilite.SelectedItem = elementCivilite;
                // Affichage de l'image liée au client
                Byte[] image = clientSelectionne.Photoent;
                if (image == null || image.Length == 0)
                {
                    pictureBoxImageClient.Image = null;
                }
                else
                {
                    pictureBoxImageClient.Image = Utils.byteArrayToImage(image);
                }

                // modification de la valeur de l'item sélectionné dans le combobox etat client
                EtatClient elementEtatClient = ChargementListes.ListEtatClient.Find(unEtatClient => unEtatClient.IdEtatClient == clientSelectionne.FkIdEtatClient);
                cbxEtatClient.SelectedItem = elementEtatClient;
                // Affichage de la date de création du client
                lblDateEnregistrementClient.Text = clientSelectionne.DateCreation.ToString("dd/MM/yyyy");
            }
        }
Beispiel #21
0
        /// <summary>
        /// Met à jour la civilité passée en paramètre
        /// </summary>
        /// <param name="civilite"></param>
        public void UpdateCivilite(Civilite civilite)
        {
            SqlCommand updateCommand = new SqlCommand();

            updateCommand.Connection  = this.Connection;
            updateCommand.CommandText = "UPDATE Civilite SET LibelleCourt=@libelleCourt, LibelleLong=@libelleLong WHERE Id = @id";

            updateCommand.Parameters.Add("@libelleCourt", SqlDbType.NVarChar, 50, "LibelleCourt");
            updateCommand.Parameters.Add("@libelleLong", SqlDbType.NVarChar, 50, "LibelleLong");
            updateCommand.Parameters.Add("@id", SqlDbType.Int);

            updateCommand.Parameters["@libelleCourt"].Value = civilite.LibelleCourt;
            updateCommand.Parameters["@libelleLong"].Value  = civilite.LibelleLong;
            updateCommand.Parameters["@id"].Value           = civilite.Id;

            int nbResult = ExecuteNonQuery(updateCommand);

            Console.WriteLine($"{nbResult} civilité(s) mise(s) à jour");
        }
Beispiel #22
0
        //*****************************************************************************************************************
        void listerLesClients()
        {
            try
            {
                using (ClientManager clientManager = new ClientManager())
                {
                    List <Client>     listClient     = new List <Client>();
                    List <EtatClient> listEtatClient = new List <EtatClient>();
                    List <Civilite>   listCivilites  = new List <Civilite>();
                    // chargement des listes utilisées
                    // On utilise la connexion préalablement établie
                    using (Manager manager = new Manager(clientManager.getConnexion()))
                    {
                        manager.getListe(ref listCivilites, "civilite");
                        manager.getListe(ref listEtatClient, "etatClient");
                        manager.getListe(ref listClient, "client");;

                        foreach (Client chaqueClient in listClient)
                        {
                            // la civilité est fournie via son Id
                            // Il faut retrouver l'abréviation correspondante dans la liste des civilités
                            Civilite elementCivilite = listCivilites.Find(uneCivilite => uneCivilite.IdCivilite == chaqueClient.FkIdCivilite);
                            // idem pour etat client
                            EtatClient elementEtatClient = listEtatClient.Find(unEtatClient => unEtatClient.IdEtatClient == chaqueClient.FkIdEtatClient);

                            Console.Write(elementCivilite.Abreviation + "   " + chaqueClient.Prenom + "  " + chaqueClient.Nom
                                          + "  " + chaqueClient.DateCreation.ToString()
                                          + "  " + chaqueClient.DateModification.ToString()
                                          + "  " + elementEtatClient.Etat);

                            Console.WriteLine();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #23
0
        public void Ajouter()
        {
            CiviliteWindow window = new CiviliteWindow();

            window.ShowDialog();


            if (window.DialogResult.HasValue && window.DialogResult == true)
            {
                //Sauvegarde
                Civilite civiliteToAdd = (Civilite)window.DataContext;

                ((App)App.Current).entity.Civilite.Add(civiliteToAdd);

                ((App)App.Current).entity.SaveChanges();
            }
            else
            {
                //On rafraichit l'entity pour éviter les erreurs de données "fantomes" mal déliées
                ((App)App.Current).entity = new ExerciceCSharp_BDDEntities();
            }

            RefreshDatas();
        }
Beispiel #24
0
        /// <summary>
        /// Méthode permettant d'ajouter un utilisateur à la liste des utilisateurs de l'application (lors de l'inscription d'un utilisateur).
        /// </summary>
        /// <param name="mail">Mail de l'utilisateur</param>
        /// <param name="motDePasse">Mot de passe de l'utilisateur</param>
        /// <param name="nom">Nom de l'utilisateur</param>
        /// <param name="prenom">Prénom de l'utilisateur</param>
        /// <param name="type">Type de l'utilisateur</param>
        /// <returns>string: Identifiant de l'utilisateur créé</returns>
        public string AjouterUtilisateur(string mail, string motDePasse, string nom, string prenom, TypeUtilisateur type, ICollection <Telephone> telephones, Lieu lieu, Civilite civilite, string otherInfo)
        {
            var param = new Parametre();

            Parametres.Add(param);

            Lieux.Add(lieu);
            SaveChanges();

            var user = new Utilisateur(mail, motDePasse, nom, prenom, telephones, type, lieu, civilite, param, otherInfo);

            Utilisateurs.Add(user);
            SaveChanges();

            Telephones.AddRange(telephones);
            SaveChanges();

            return(user.ID);
        }
        /// <summary>
        /// Ouvre la civilité séléctionnée à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Civilite Look(Civilite civiliteToLook)
        {
            if (this._DataGridMain.SelectedItem != null || civiliteToLook != null)
            {
                if (this._DataGridMain.SelectedItems.Count == 1 || civiliteToLook != null)
                {
                    //Affichage du message "affichage en cours"
                    ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = true;
                    ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Affichage d'une civilite en cours ...";

                    //Création de la fenêtre
                    CiviliteWindow civiliteWindow = new CiviliteWindow();

                    //Initialisation du Datacontext en Commande_Fournisseur et association à l'ativite sélectionnée
                    civiliteWindow.DataContext = new Civilite();
                    civiliteWindow.DataContext = (Civilite)this._DataGridMain.SelectedItem;

                    //Je positionne la lecture seule sur la fenêtre
                    civiliteWindow.lectureSeule();
                    civiliteWindow.soloLecture = true;

                    //J'affiche la fenêtre
                    bool? dialogResult = civiliteWindow.ShowDialog();

                    //Affichage du message "affichage en cours"
                    ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false;
                    ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Affichage d'une civilite terminée : " + this.mesCivilites.Count() + " / " + this.max;

                    //Renvoi null
                    return null;
                }
                else
                {
                    MessageBox.Show("Vous ne devez sélectionner qu'une seule civilite.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return null;
                }
            }
            else
            {
                MessageBox.Show("Vous devez sélectionner une civilite.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return null;
            }
        }
        // modifier ligne declaration
        public void UpdateLigneDeclarationCnss(
            int ligneNo,
            string nom,
            string prenom,
            Civilite civilite,
            string numeroCnss,
            string cleCnss,
            string nomJeuneFille,
            string autreNom,
            string numeroInterne,
            int categorieNo,
            decimal brut1,
            decimal brut2,
            decimal brut3)
        {
            // tester si le l'exercice est cloturé
            if (Exercice.IsCloturer)
            {
                throw new InvalidOperationException("Exercice est cloturé");
            }

            try
            {
                var option = new TransactionOptions
                {
                    IsolationLevel = IsolationLevel.ReadCommitted,
                    Timeout        = TimeSpan.FromSeconds(15)
                };
                using (var scope = new TransactionScope(TransactionScopeOption.Required, option))
                {
                    // charger la ligne declaration
                    LigneCnss ligne = _ligneCnssRepository.Get(ligneNo);
                    if (ligne == null)
                    {
                        throw new ArgumentNullException("ligne");
                    }
                    ligne.Brut1         = brut1;
                    ligne.Brut2         = brut2;
                    ligne.Brut3         = brut3;
                    ligne.CategorieNo   = categorieNo;
                    ligne.NumeroCnss    = numeroCnss;
                    ligne.CleCnss       = cleCnss;
                    ligne.AutresNom     = autreNom;
                    ligne.NomJeuneFille = nomJeuneFille;
                    ligne.Nom           = nom;
                    ligne.Prenom        = prenom;
                    ligne.Civilite      = civilite;
                    // update ligne declaration
                    _ligneCnssRepository.Update(ligne);

                    // charger l'employee
                    var employee = _employeeRepository.Get(ligne.EmployeeNo);
                    if (employee == null)
                    {
                        throw new InvalidOperationException("Employée invalide!");
                    }
                    // modifier les données du l'employée
                    employee.Nom           = nom;
                    employee.Prenom        = prenom;
                    employee.NumeroCnss    = numeroCnss;
                    employee.NumeroInterne = numeroInterne;
                    employee.Civilite      = civilite;
                    employee.CleCnss       = cleCnss;
                    employee.CategorieNo   = categorieNo;
                    employee.AutresNom     = autreNom;
                    employee.NomJeuneFille = nomJeuneFille;
                    // update emplaye
                    _employeeRepository.Update(employee);
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #27
0
        //**************************************************************************************************
        private void btnAjouterClient_Click(object sender, EventArgs e)
        {
            // créer un client et lui affecte les champs remplis
            Client client = new Client();

            using (ClientManager clientManager = new ClientManager()) // appel automatique de la methode dispose qui ferme la connexion
            {
                client.Entreprise = txtBoxNomEntreprise.Text.Trim();

                Civilite laCiviliteSelectionnée = (Civilite)comBoxCivilite.SelectedItem;
                client.FkIdCivilite = laCiviliteSelectionnée.IdCivilite;

                client.Prenom      = txtBoxPrenomClient.Text.Trim();
                client.Nom         = txtBoxNomClient.Text.Trim();
                client.Adresse     = txtBoxAdresse.Text.Trim();
                client.CompAdresse = txtBoxAdresseSuite.Text.Trim();
                client.Ville       = txtBoxVille.Text.Trim();
                client.CodePostal  = mTxtBoxCodePostal.Text;
                client.NumeroTel   = mTxtBoxTelephone.Text;
                // Test validation Email
                String reponseWsValidEmail = "";
                String email = txtBoxEmail.Text.Trim();

                if (email != string.Empty)
                {
                    ValidEmail ValidEmail = new ValidEmail(txtBoxEmail.Text.Trim(), ref reponseWsValidEmail);
                    // uniquement une indication, Le dispatcher peut modifier l'émail et ré-enregistrer le client
                    MessageToast.Show(reponseWsValidEmail, "Message du Service Valide Email", 10);
                }

                client.Email = email;
                Byte[] image;
                // récupération de l'image chargée
                if (pictureBoxImageClient.Image != null)
                {
                    try
                    {
                        FileStream   fs = new FileStream(pictureBoxImageClient.ImageLocation, FileMode.Open, FileAccess.Read);
                        BinaryReader br = new BinaryReader(fs);
                        image           = br.ReadBytes((int)fs.Length);
                        client.Photoent = (Byte[])image;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                else
                {
                    client.Photoent = new Byte[0]; // Pas d'image du tout
                }
                client.FkIdEtatClient = 1;         // Le client est validé à l'inscription

                client.FkLoginE = UtilisateurConnecte.Login;
                try
                {
                    if (clientManager.insUpdateClient(client))
                    {
                        MessageToast.Show("Client ajouté avec succès");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        /// <summary>
        /// Met à jour l'état en bas pour l'utilisateur
        /// </summary>
        /// <param name="typeEtat">texte : "Filtrage", "Ajout", "Modification", "Suppression", "Look", "" ("" = Chargement)</param>
        /// <param name="dao">un objet Commande_Fournisseur soit pour l'ajouter au listing, soit pour afficher qui a été modifié ou supprimé</param>
        public void MiseAJourEtat(string typeEtat, Civilite lib)
        {
            //Je racalcul le nombre max d'élements
            this.recalculMax();
            //En fonction de l'libion, j'affiche le message
            if (typeEtat == "Filtrage")
            {
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "filtrage des civilité terminée : " + this.mesCivilites.Count() + " / " + this.max;
            }
            else if (typeEtat == "Ajout")
            {
                //J'ajoute la commande_fournisseur dans le linsting
                this.mesCivilites.Add(lib);
                //Je racalcul le nombre max d'élements après l'ajout
                this.recalculMax();
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'une civilité dénommée '" + lib.Libelle_Long + "' effectué avec succès. Nombre d'élements : " + this.mesCivilites.Count() + " / " + this.max;
            }
            else if (typeEtat == "Modification")
            {
                //Je raffraichis mon datagrid
                this._DataGridMain.Items.Refresh();
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Modification de la civilité dénommée : '" + lib.Libelle_Long + "' effectuée avec succès. Nombre d'élements : " + this.mesCivilites.Count() + " / " + this.max;
            }
            else if (typeEtat == "Suppression")
            {
                //Je supprime de mon listing l'élément supprimé
                this.mesCivilites.Remove(lib);
                //Je racalcul le nombre max d'élements après la suppression
                this.recalculMax();
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Suppression de la civilité dénommée : '" + lib.Libelle_Long + "' effectuée avec succès. Nombre d'élements : " + this.mesCivilites.Count() + " / " + this.max;
            }
            else if (typeEtat == "Look")
            {

            }
            else
            {
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Chargement des civilités terminé : " + this.mesCivilites.Count() + " / " + this.max;
            }
            //Je retri les données dans le sens par défaut
            this.triDatas();
            //J'arrete la progressbar
            ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false;
        }
        /// <summary>
        /// Ajoute une nouvelle civilité à la liste à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Civilite Add()
        {
            //Affichage du message "ajout en cours"
            ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = true;
            ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'une civilité en cours ...";

            //Initialisation de la fenêtre
            CiviliteWindow civiliteWindow = new CiviliteWindow();

            //Création de l'objet temporaire
            Civilite tmp = new Civilite();

            //Mise de l'objet temporaire dans le datacontext
            civiliteWindow.DataContext = tmp;

            //booléen nullable vrai ou faux ou null
            bool? dialogResult = civiliteWindow.ShowDialog();

            if (dialogResult.HasValue && dialogResult.Value == true)
            {
                //Si j'appuie sur le bouton Ok, je renvoi l'objet civilite se trouvant dans le datacontext de la fenêtre
                return (Civilite)civiliteWindow.DataContext;
            }
            else
            {
                try
                {
                    //On détache la commande
                    ((App)App.Current).mySitaffEntities.Detach((Civilite)civiliteWindow.DataContext);
                }
                catch (Exception)
                {
                }

                //Si j'appuie sur le bouton annuler, je préviens que j'annule mon ajout
                ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false;
                this.recalculMax();
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'une civilite annulée : " + this.mesCivilites.Count() + " / " + this.max;

                return null;
            }
        }
 public void LookCivilite(UIElement uIElement, Civilite civiliteToLook)
 {
     ((ParametreCiviliteControl)uIElement).Look(civiliteToLook);
 }
        //**************************************************************************************************
        private void btnModifierClient_Click(object sender, EventArgs e)
        {
            if ((clientSelectionne != null) && (txtBoxNomClient.Text.Trim() != ""))
            {
                try
                {
                    // On récupère Tous les attributs du client pour les persister en BDD
                    using (ClientManager clientManager = new ClientManager()) // appel automatique de la methode dispose qui ferme la connexion
                    {
                        clientSelectionne.Entreprise = txtBoxNomEntreprise.Text.Trim();
                        // récupération de la civilité du client via le comboBox civilité
                        Civilite laCiviliteSelectionnée = (Civilite)cbxCivilite.SelectedItem;
                        clientSelectionne.FkIdCivilite = laCiviliteSelectionnée.IdCivilite;

                        clientSelectionne.Prenom      = txtBoxPrenomClient.Text.Trim();
                        clientSelectionne.Nom         = txtBoxNomClient.Text.Trim();
                        clientSelectionne.Adresse     = txtBoxAdresse.Text.Trim();
                        clientSelectionne.CompAdresse = txtBoxAdresse2.Text.Trim();
                        clientSelectionne.Ville       = txtBoxVille.Text.Trim();
                        clientSelectionne.CodePostal  = mTxtBoxCodePostal.Text;
                        clientSelectionne.NumeroTel   = mTxtBoxTelephone.Text;
                        // Test validation Email
                        String reponseWsValidEmail = "";
                        String email = txtBoxEmail.Text.Trim();
                        if (email != string.Empty)
                        {
                            ValidEmail ValidEmail = new ValidEmail(txtBoxEmail.Text.Trim(), ref reponseWsValidEmail);
                            // MessageBox.Show(reponseWsValidEmail); // résultat envoyé par le service de vérification
                            MessageToast.Show(reponseWsValidEmail, "Message du Service Valide Email", 10); // résultat envoyé par le service de vérification
                        }
                        clientSelectionne.Email     = email;
                        clientSelectionne.Latitude  = mTxtBoxLatitude.Text;
                        clientSelectionne.Latitude  = clientSelectionne.Latitude.Replace(",", ".");
                        clientSelectionne.Longitude = mTxtBoxLongitude.Text;
                        clientSelectionne.Longitude = clientSelectionne.Longitude.Replace(",", ".");
                        // récupération image
                        if (pictureBoxImageClient.Image == null)
                        {
                            clientSelectionne.Photoent = new Byte[0];
                        }                                              // null
                        else
                        {
                            clientSelectionne.Photoent = Utils.imageToByteArray(pictureBoxImageClient.Image);
                        }

                        EtatClient etatClientSelectionné = (EtatClient)cbxEtatClient.SelectedItem;
                        clientSelectionne.FkIdEtatClient = etatClientSelectionné.IdEtatClient;

                        clientSelectionne.FkLoginE = UtilisateurConnecte.Login;
                        // On persiste les modifications
                        clientManager.insUpdateClient(clientSelectionne);
                        rafraichirIHM();
                        MessageToast.Show("Les modifications sont enregistrées");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }