예제 #1
0
        private void dgvInfoClient_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            int    col          = dgvInfoClient.CurrentCell.OwningColumn.Index;
            string nomcol       = dgvInfoClient.CurrentCell.OwningColumn.Name;
            string id_Table     = dgvInfoClient.Rows[e.RowIndex].Cells[0].Value.ToString();
            string donnee_Table = dgvInfoClient.CurrentCell.Value.ToString();

            donnee_Table = donnee_Table.Replace("'", "''");

            // Cryptage mot de passe
            if (dgvInfoClient.Rows[0].Cells[4].Value.ToString() != "")
            {
                if (nomcol == "MotDePasse")
                {
                    /*byte[] bytes = Encoding.UTF8.GetBytes(donnee_Table);
                     * byte[] protectedBytes = ProtectedData.Protect(bytes, null, DataProtectionScope.CurrentUser);
                     * donnee_Table = Convert.ToBase64String(protectedBytes);*/
                }
                Requete_Sql = "update utilisateur set " + nomcol + " = '" + donnee_Table + "' where id = '" + PageAcceuil.NumUtilisateur + "'";
                sc.AjoutSupModifUtilisateurSql(Requete_Sql);
            }
        }
예제 #2
0
        private void btValidationCompte_Click(object sender, EventArgs e)
        {
            Int16 ValCompte = 0;
            //int numUtilisateur = 0;
            string LoginUtilisateur  = textBoxChoixLogin.Text;
            string MotDePasse        = textBoxChoixMotDePasse.Text;
            string nomUtilisateur    = textBoxNom.Text;
            string prenomUtilisateur = textBoxPrenom.Text;
            string mailUtilisateur   = textBoxMail.Text;
            string service           = comboBoxService.Text;

            switch (Id_Statut)
            {
            case 2:
                if (service == "")
                {
                    ;
                }
                break;

            case 3:
                service = "";
                break;

            default:
                service = "";
                break;
            }

            Requete_Sql = "";

            for (Int16 i = 0; i < 7; i++)
            {
                if (ValidationCompte[i] == true)
                {
                    ValCompte++;
                }
            }

            if (ValCompte == 7)
            {
                // Cryptage mot de passe
                string cryptmotDePasse;

                /*byte[] bytes = Encoding.UTF8.GetBytes(MotDePasse);
                 * byte[] protectedBytes = ProtectedData.Protect(bytes, null, DataProtectionScope.CurrentUser);
                 * cryptmotDePasse = Convert.ToBase64String(protectedBytes);*/
                cryptmotDePasse = MotDePasse;

                Requete_Sql = @"insert into utilisateur values (null,'" + LoginUtilisateur + "', '"
                              + cryptmotDePasse + "', '"
                              + nomUtilisateur + "', '"
                              + prenomUtilisateur + "', '"
                              + mailUtilisateur + "', "
                              + Id_Statut + ", '', '"
                              + service + "')";

                sc.AjoutSupModifUtilisateurSql(Requete_Sql);
                // préparation à la connection du nouvel utilisateur
                //LoginUtilisateur = loginUtilisateur;
                textBoxLogin.Text = LoginUtilisateur;
                //MotDePasse = cryptmotDePasse;
                textBoxMotDePasse.Text = MotDePasse;
                //lbBienvenu.Text = "Bonjour " + LoginUtilisateur + " ! Votre compte est validé.";
                //lbNumUtilisateur.Text = numUtilisateur.ToString();

                // récupération du n°utilisateur (id)
                Requete_Sql = "select * from utilisateur where login = '******'";
                List <ServiceWCF.ClsUtilisateur> TableUtilisateur = new List <ServiceWCF.ClsUtilisateur>();
                TableUtilisateur.AddRange(sc.LireTableUtilisateurSql(Requete_Sql));
                ServiceWCF.ClsUtilisateur[] tabUtil = TableUtilisateur.ToArray();
                NumUtilisateur        = tabUtil[0].Id;
                lbNumUtilisateur.Text = NumUtilisateur.ToString();
                lbBienvenu.Text       = "Bonjour " + tabUtil[0].Prenom + ". Votre compte est validé.";
            }
        }