public List <CommandeDal> GetByLogin(string login) { List <CommandeDal> la = new List <CommandeDal>(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "select * from VueCommande where clientLogin=@login"; command.Parameters.AddWithValue("login", login); con.Open(); using (SqlDataReader read = command.ExecuteReader()) { while (read.Read()) { CommandeDal a = new CommandeDal(); a.commandeId = (int)read["commandeId"]; a.biereNom = (string)read["biereNom"]; a.commandeDate = (DateTime)read["commandeDate"]; a.clientLogin = (string)read["clientLogin"]; //a.clientPwd = (string)read["biereImage"]; a.commandeQuantite = (int)read["commandeQuantite"]; a.bierePrix = (decimal)read["bierePrix"]; la.Add(a); } } } } return(la); }
public CommandeDal GetOne(int id) { CommandeDal a = new CommandeDal(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "select * from VueCommande where commandeId=@id"; command.Parameters.AddWithValue("id", id); con.Open(); using (SqlDataReader read = command.ExecuteReader()) { while (read.Read()) { a.commandeId = (int)read["commandeId"]; a.biereNom = (string)read["biereNom"]; a.commandeDate = (DateTime)read["commandeDate"]; a.clientLogin = (string)read["clientLogin"]; //a.clientPwd = (string)read["biereImage"]; a.commandeQuantite = (int)read["commandeQuantite"]; a.bierePrix = (decimal)read["bierePrix"]; } } } } return(a); }
public int Create(CommandeDal parametre) { using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "AddCommandBis2"; SqlParameter pid = new SqlParameter(); pid.ParameterName = "ID"; pid.Value = 0; pid.Direction = System.Data.ParameterDirection.Output; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue(nameof(parametre.biereId), parametre.biereId); command.Parameters.AddWithValue(nameof(parametre.clientId), parametre.clientId); command.Parameters.AddWithValue(nameof(parametre.commandeDate), parametre.commandeDate); command.Parameters.AddWithValue(nameof(parametre.commandeQuantite), parametre.commandeQuantite); command.Parameters.Add(pid); con.Open(); command.ExecuteNonQuery(); int id = (int)command.Parameters["ID"].Value; return(id); } } }
public static CommandeDal GetCommandeDal(this CommandeWPF wpf) { CommandeDal dal = new CommandeDal(); dal.biereId = wpf.biereId; dal.clientId = wpf.clientId; dal.commandeDate = wpf.commandeDate; dal.commandeId = wpf.commandeId; dal.commandeQuantite = wpf.commandeQuantite; return(dal); }
public static CommandeWPF GetCommandeWPF(this CommandeDal dal) { CommandeWPF wpf = new CommandeWPF(); wpf.biereId = dal.biereId; wpf.clientId = dal.clientId; wpf.commandeDate = dal.commandeDate; wpf.commandeId = dal.commandeId; wpf.commandeQuantite = dal.commandeQuantite; return(wpf); }
public static CommandeAPI GetCommandeAPI(this CommandeDal commandeDal) { CommandeAPI commandeAPI = new CommandeAPI(); commandeAPI.biereNom = commandeDal.biereNom; commandeAPI.bierePrix = commandeDal.bierePrix; commandeAPI.clientLogin = commandeDal.clientLogin; commandeAPI.commandeDate = commandeDal.commandeDate; commandeAPI.commandeId = commandeDal.commandeId; commandeAPI.commandeQuantite = commandeDal.commandeQuantite; return(commandeAPI); }
public void Update(CommandeDal parametre) { using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "EditCommande"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue(nameof(parametre.commandeId), parametre.commandeId); command.Parameters.AddWithValue(nameof(parametre.commandeQuantite), parametre.commandeQuantite); command.Parameters.AddWithValue(nameof(parametre.biereId), parametre.biereId); con.Open(); command.ExecuteNonQuery(); } } }
public List <CommandeDal> GetAll() { List <CommandeDal> lb = new List <CommandeDal>(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "Select * from Commande"; con.Open(); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { CommandeDal b = new CommandeDal(); if (dataReader["biereId"] is DBNull) { b.biereId = null; } else { b.biereId = (int?)dataReader["biereId"]; } if (dataReader["clientId"] is DBNull) { b.clientId = null; } else { b.clientId = (int?)dataReader["clientId"]; } b.commandeDate = (DateTime)dataReader["commandeDate"]; b.commandeQuantite = (int)dataReader["commandeQuantite"]; b.commandeId = (int)dataReader["commandeId"]; lb.Add(b); } } } } return(lb); }
public CommandeDal GetOne(int id) { CommandeDal b = new CommandeDal(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "Select * from Commande where commandeId=@id"; command.Parameters.AddWithValue("id", id); con.Open(); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { if (dataReader["biereId"] is DBNull) { b.biereId = null; } else { b.biereId = (int?)dataReader["biereId"]; } if (dataReader["clientId"] is DBNull) { b.clientId = null; } else { b.clientId = (int?)dataReader["clientId"]; } b.commandeDate = (DateTime)dataReader["commandeDate"]; b.commandeQuantite = (int)dataReader["commandeQuantite"]; b.commandeId = (int)dataReader["commandeId"]; } } } } return(b); }