Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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);
         }
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 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();
         }
     }
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }