public static void AjoutCommande2(Commande commande, Client client, Adresse adresse) { using (SqlConnection conx = ConnectionDB.getConnection()) { using (SqlCommand cmd = conx.CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "insertion_commande2"; SqlParameter nom_client = new SqlParameter("@nom", SqlDbType.NVarChar); nom_client.Direction = ParameterDirection.Input; nom_client.Value = client.nom; cmd.Parameters.Add(nom_client); SqlParameter adresse_client = new SqlParameter("@adresse", SqlDbType.NVarChar); adresse_client.Direction = ParameterDirection.Input; adresse_client.Value = adresse.adresse; cmd.Parameters.Add(adresse_client); SqlParameter cp_client = new SqlParameter("@codepostal", SqlDbType.NVarChar); cp_client.Direction = ParameterDirection.Input; cp_client.Value = adresse.code_postal; cmd.Parameters.Add(cp_client); SqlParameter ville_client = new SqlParameter("@ville", SqlDbType.NVarChar); ville_client.Direction = ParameterDirection.Input; ville_client.Value = adresse.ville; cmd.Parameters.Add(ville_client); SqlParameter date_commande = new SqlParameter("@date", SqlDbType.DateTime); date_commande.Direction = ParameterDirection.Input; date_commande.Value = commande.date; cmd.Parameters.Add(date_commande); cmd.Connection = conx; cmd.ExecuteNonQuery(); } } }
public static Client lectureClient(string client) { Client clients = new Client(); using (SqlConnection conx = ConnectionDB.getConnection()) { using (SqlCommand cmd = conx.CreateCommand()) { cmd.CommandText = "select * from client where no_client=@cli "; cmd.Parameters.Add(new SqlParameter("@cli", SqlDbType.Int)).Value = client; cmd.Connection = conx; SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { clients.code_client = (int)dr["NO_CLIENT"]; clients.nom= dr["NOM"].ToString(); clients.prenom= dr["PRENOM"].ToString(); } } } } return clients; }
public static Client lireNomClient(string cli) { Client client = new Client(); client = CrudeClient.lectureClient(cli); return client; }
public static void ajoutclient(Client client,Adresse adresse) { DataLayer.CrudeClient.AjoutClient(client, adresse); }
public static void ajoutCommande2(Commande commande, Client client, Adresse adresse) { DataLayer.CrudCommande.AjoutCommande2(commande, client, adresse); }
public static List<Client> listClient() { List<Client> listeClient = new List<Client>(); Client client; using (SqlConnection conx = ConnectionDB.getConnection()) { using (SqlCommand cmd = conx.CreateCommand()) { cmd.CommandText = "select * from select_client"; SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { client = new Client(); client.id_adresse = (int)dr["no_client"]; client.nom = dr["nom"].ToString(); client.prenom = dr["prenom"].ToString(); listeClient.Add(client); } } } } return listeClient; }