Esempio n. 1
0
        /// <summary>
        /// Pour ajouter un client dans la BD.
        /// </summary>
        /// <param name="p_Client">Objet à ajouter</param>
        public void Ajouter(comptes p_compte)
        {
            Debug.Assert(p_compte != null, "p_Client doit être différent de null");


            this.m_BaseDeDonnees.comptes.InsertOnSubmit(p_compte);
        }
Esempio n. 2
0
        public async static Task <comptes> SelectCompte(string nomUtilisateur)
        {
            using (var ctx = new Connexion420())
            {
                var query = from c in ctx.comptes
                            where c.nomUtilisateur == nomUtilisateur
                            select c;
                comptes obj = await query.SingleOrDefaultAsync();

                return(obj);
            }
        }
Esempio n. 3
0
        public async static Task <comptes> SelectAsyncMatriculeCompte(string matricule)
        {
            using (var ctx = new Connexion420())
            {
                var query = from c in ctx.comptes
                            where c.matricule == matricule
                            select c;
                comptes obj = await query.SingleOrDefaultAsync();

                return(obj);
            }
        }
Esempio n. 4
0
        public static async Task <bool> UpdateAsync(comptes obj)
        {
            using (var ctx = new Connexion420())
            {
                ctx.comptes.Attach(obj);
                ctx.Entry(obj).State = EntityState.Modified;
                try
                {
                    await ctx.SaveChangesAsync();
                }
                catch (Exception exct)
                {
                    Console.WriteLine(exct.Message);
                    return(false);
                }

                return(true);
            }
        }
Esempio n. 5
0
        public static async Task <bool> InsertAsync(comptes obj)
        {
            using (var ctx = new Connexion420())
            {
                ctx.comptes.Add(obj);

                try
                {
                    await ctx.SaveChangesAsync();
                }
                catch (Exception exct)
                {
                    Console.WriteLine(exct.Message);
                    return(false);
                }

                return(true);
            }
        }
Esempio n. 6
0
        public static async Task <comptes> SelectByIDAsync(string id)
        {
            int num;

            bool success = int.TryParse(id, out num);

            if (!success)
            {
                return(null);
            }

            using (var ctx = new Connexion420())
            {
                var query = from c in ctx.comptes
                            where c.idCompte == num
                            select c;
                comptes obj = await query.SingleOrDefaultAsync();

                return(obj);
            }
        }