コード例 #1
0
 public Boolean add(Object o)
 {
     try
     {
         OleDbConnection cn = new OleDbConnection();
         cn.ConnectionString = Properties.Settings.Default.ch;
         OleDbCommand cmd      = new OleDbCommand();
         Utilisateur  u        = (Utilisateur)o;
         String       login    = u.compte.login;
         String       password = u.compte.password;
         String       nom      = u.nom;
         String       prenom   = u.prenom;
         String       mail     = u.mail;
         Cryptage     cr       = new Cryptage();
         string       req      = string.Format("Begin Inscrire('" + login + "','" + cr.Encrypt(password) + "','" + nom + "','" + prenom + "','" + mail + "'); end; ");
         cmd.Connection = cn;
         cn.Open();
         cmd.CommandText = req;
         cmd.ExecuteNonQuery();
         cn.Close();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #2
0
        public Boolean compteIsExist(String login, String password)
        {
            try
            {
                Cryptage cr = new Cryptage();

                string req = string.Format("SELECT * FROM Compte Where login='******'");
                cn.Open();
                OleDbCommand    cmd    = new OleDbCommand(req, cn);
                OleDbDataReader Reader = cmd.ExecuteReader();
                Boolean         test   = false;
                while (Reader.Read())
                {
                    if (password.Equals(cr.Descrypt(Reader.GetString(1))))
                    {
                        test = true;
                    }
                }
                Reader.Close();
                cn.Close();
                return(test);
            }
            catch (Exception)
            {
                return(false);
            }
        }