1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
   | public static bool ajout_transaction(int Id, String Type, int Montant, int id_compte)
        {
            try
            {
                using (Entities2 m = new Entities2())
                {
 
                    TRANSACTION t = new TRANSACTION();
                    t.ID_TRANS = Id;
                    t.TYPE = Type;
                    t.MONTANT = Montant;
                    IEnumerable<KeyValuePair<string, object>> entityKeyValues =new KeyValuePair<string, object>[] {
                    new KeyValuePair<string, object>("ID_COMP",id_compte) };
                    EntityKey key = new EntityKey("Model1.TRANSACTION", entityKeyValues);
                    t.COMPTEReference.EntityKey = key;
                    m.AddToTRANSACTION(t);
                    m.SaveChanges();
 
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                succes = true;
            }
            return succes;
        } | 
Partager