Ejemplo n.º 1
0
        private static List <Telephone> GetListNumero(int idCli)
        {
            var list = new List <Telephone>();
            // Demande de la liste des clients
            var cmd = new SqlCommand();

            cmd.CommandText = @"select  T.Numero
                                from Client C
                                inner join Adresse A on A.IdClient = C.Id
                                inner join Telephone T on T.IdClient = C.Id
                                where C.Id= @IdClient";
            cmd.Parameters.Add(new SqlParameter {
                SqlDbType = SqlDbType.Int, ParameterName = "@IdClient", Value = idCli
            });
            using (var conn = new SqlConnection(Settings1.Default.GrandHotelConnexion))
            {
                //Connection à la base de données
                cmd.Connection = conn;
                conn.Open();
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var item = new Telephone();
                        item.Numero = (string)reader["Numero"];

                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Ejemplo n.º 2
0
        /*--> Ajouter un numero de téléphone */
        public static void AjouterTelephone(Telephone t)
        {
            var cmd = new SqlCommand();

            cmd.CommandText = @"insert Telephone (IdClient, Numero, CodeType, Pro)
									values (@IdClient, @Numero, @CodeType, @Pro)"                                    ;

            cmd.Parameters.Add(new SqlParameter {
                SqlDbType = SqlDbType.Int, ParameterName = "@IdClient", Value = t.IdClient
            });
            cmd.Parameters.Add(new SqlParameter {
                SqlDbType = SqlDbType.NVarChar, ParameterName = "@Numero", Value = t.Numero
            });
            cmd.Parameters.Add(new SqlParameter {
                SqlDbType = SqlDbType.NVarChar, ParameterName = "@CodeType", Value = t.CodeType
            });
            cmd.Parameters.Add(new SqlParameter {
                SqlDbType = SqlDbType.Bit, ParameterName = "@Pro", Value = t.Pro
            });

            using (var cnx = new SqlConnection(Settings1.Default.GrandHotelConnexion))
            {
                cmd.Connection = cnx;
                cnx.Open();
                cmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 3
0
 public void AjouterTeleOuMail(Telephone tele, Email mail, bool?a)
 {
     // ajout Telephone
     if (a == true)
     {
         Telephones.Add(tele);
         SaveChanges();
     }
     // ajout email
     else
     {
         Emails.Add(mail);
         SaveChanges();
     }
 }