public CarteBancaire(int id, int numero, DateTime dateExpi, int crypto, TypeCarte type, Banque hisBank)
 {
     bankCardId = id;
     number = numero;
     experationDate = dateExpi;
     cryctogramme = crypto;
     typeCard = type;
     banque = hisBank;
 }
Beispiel #2
0
 public static void Update(Banque bank)
 {
     SqlCommand cmd = new SqlCommand();
     const string query = "UPDATE BANQUE set NOM = '{0}' where ID_BANQUE='{1}'";
     cmd.CommandText = string.Format(query, bank.BankName , bank.BankId.ToString());
     cmd.CommandType = CommandType.Text;
     cmd.Connection = BDDConnexion.Conn;
     try
     {
         cmd.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         throw (e);
     }
     finally
     {
         cmd.Dispose();
         cmd = null;
     }
 }
Beispiel #3
0
 public static void Insert(Banque bank)
 {
     SqlCommand cmd = new SqlCommand();
     const string query = "INSERT INTO BANQUE VALUES ('{0}','{1}')";
     cmd.CommandText = string.Format(query, GenerateId().ToString(), bank.BankName);
     cmd.CommandType = CommandType.Text;
     cmd.Connection = BDDConnexion.Conn;
     try
     {
         cmd.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         throw (e);
     }
     finally
     {
         cmd.Dispose();
         cmd = null;
     }
 }
        public string NewBank(int idAdmin, string bank)
        {
            String msg = string.Empty;
            try
            {
                Administrateur adminDB = AdministrateurDAO.Read(idAdmin);

                if (adminDB == null)
                {
                    throw new Exception ("Authentification impossible: les identifiants sont incorrects.");
                }
                else
                {
                    List<Banque> bankDB = BanqueDAO.Search("NOM = '" + bank + "'");
                    if (bankDB.Any())
                    {
                        throw new Exception ("Action impossible. Le type de carte " + bank + " est déjà présent dans la base.");
                    }
                    else
                    {
                        Banque newBank = new Banque(bank);
                        BanqueDAO.Insert(newBank);
                        msg = "Le type de carte " + bank + " a été ajouté dans la base.";
                    }
                }

                BDDConnexion.CloseConnection();
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            return msg;
        }
Beispiel #5
0
        private static List<Banque> ExecuteReader(SqlCommand cmd)
        {
            SqlDataReader reader;

            List<Banque> result = new List<Banque>();
            try
            {
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Banque currentBanque = new Banque(Convert.ToInt32(reader["ID_BANQUE"]), reader["NOM"].ToString());
                    result.Add(currentBanque);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }

            reader.Close();
            reader.Dispose();
            reader = null;
            return result;
        }