public void Action_Connexion() { try { if (vide()) { Afficher_Msg_Erreur("Champ(s) vide(s), tous les champs sont obligatoires"); } else { profile prof = new profile(TBLogin.Text, TBMDP.Password); int id = profilC.authentification(prof); prof.ID = id; if (id == -1) { Afficher_Msg_Erreur("Erreur de connexion! veuillez contacter le service technique"); } else { if (id == 0) { Afficher_Msg_Erreur("La combinaison login et mot de passe est incorrecte."); } else { Principale p = new Principale(id); //p.WindowState = WindowState.Maximized; DateTime localDate = DateTime.Now; fsg_gpao.Acteurs.JournalP journal = new fsg_gpao.Acteurs.JournalP(id, localDate.ToString("F"), "Connexion", ""); fsg_gpao.Connecteurs.JournalPC.ajouterJournal(journal); p.Show(); this.Close(); } } } } catch (Exception e) { MessageBox.Show(e.Message); } }
private void BTConfirmer_Click(object sender, RoutedEventArgs e) { //ActionDemander = ""; if (ChampVide()) { Afficher_Msg_Confirmation("Erreur : champ(s) vide(s)"); } else { String solId; if (TBId.Text.Equals("")) { solId = "0"; } else { solId = TBId.Text; } fsg_gpao.Acteurs.profile adminx = new fsg_gpao.Acteurs.profile(Int16.Parse(solId), TBLogin.Text, TBMotdepasse.Text, TBEmail.Text, CBService.Text, CHEtat.IsChecked.Value); //MessageBox.Show(" "+CHEtat.IsChecked.Value); if (ActionDemander.Equals("Modifier")) { if (!TBId.Text.Equals("")) { if (fsg_gpao.Connecteurs.profilC.LogExiste(TBLogin.Text, Int16.Parse(TBId.Text)) == -1) { Afficher_Msg_Erreur("Erreur de connexion à la base de données"); } else { if (fsg_gpao.Connecteurs.profilC.LogExiste(TBLogin.Text, Int16.Parse(TBId.Text)) != 0) { Afficher_Msg_Erreur("Ce login est déja utilisé."); } else { if (!IsValidEmail(TBEmail.Text)) { Afficher_Msg_Erreur("Erreur : E-mail invalide"); } else { int res = fsg_gpao.Connecteurs.profilC.ModifierProfile(adminx); if (res == 1) { Afficher_Msg_Confirmation("L'administrateur est bien modifier"); DateTime localDate = DateTime.Now; fsg_gpao.Acteurs.JournalP journal = new fsg_gpao.Acteurs.JournalP(this.prod.ID, localDate.ToString("F"), "Modification de : " + adminx.SERVICE + " " + adminx.LOGIN, ""); fsg_gpao.Connecteurs.JournalPC.ajouterJournal(journal); } else { Afficher_Msg_Erreur("Erreur de connexion à la base de données"); } } } } } else { Afficher_Msg_Erreur("Veuillez sélctionnez un Adminitrateur"); } CacherGroupeB(); LoadAllProfiles(); } else { if (ActionDemander.Equals("Supprimer")) { if (!TBId.Text.Equals("")) { if (fsg_gpao.Connecteurs.profilC.IdExisteJournal(Int16.Parse(TBId.Text)) == -1) { Afficher_Msg_Erreur("Erreur de connexion à la base de données"); } else { if (fsg_gpao.Connecteurs.profilC.IdExisteJournal(Int16.Parse(TBId.Text)) != 0) { Afficher_Msg_Erreur("Impossible de supprimer cet utilisateur, il a réalisé un/des tache(s) dans le journal."); } else { int res = fsg_gpao.Connecteurs.profilC.SupprimerProfile(adminx.ID); if (res == 1) { Afficher_Msg_Confirmation("Le profil est bien supprimer"); DateTime localDate = DateTime.Now; fsg_gpao.Acteurs.JournalP journal = new fsg_gpao.Acteurs.JournalP(this.prod.ID, localDate.ToString("F"), "supprission de : " + adminx.SERVICE + " " + adminx.LOGIN, ""); fsg_gpao.Connecteurs.JournalPC.ajouterJournal(journal); } else { Afficher_Msg_Erreur("Erreur de connexion à la base de données"); } } } } else { Afficher_Msg_Erreur("Veuillez sélctionnez un Adminitrateur"); } } } } CacherGroupeB(); LoadAllProfiles(); }