コード例 #1
0
ファイル: BiereDalService.cs プロジェクト: Nathan2503/Test3
        public List <BiereDal> GetAll()
        {
            List <BiereDal> la = new List <BiereDal>();

            using (SqlConnection con = new SqlConnection())
            {
                con.ConnectionString = connectionString;
                using (SqlCommand command = con.CreateCommand())
                {
                    command.CommandText = "select * from VueBiere";
                    con.Open();
                    using (SqlDataReader read = command.ExecuteReader())
                    {
                        while (read.Read())
                        {
                            BiereDal a = new BiereDal();
                            a.biereId          = (int)read["biereId"];
                            a.nomBrasserie     = (string)read["nomBrasserie"];
                            a.biereDescription = (string)read["biereDescription"];
                            a.biereNom         = (string)read["biereNom"];
                            a.biereImage       = (string)read["biereImage"];
                            //Decimal test = (Decimal)read["bierePrix"];
                            a.bierePrix         = (Decimal)read["bierePrix"];
                            a.biereRobe         = (string)read["biereRobe"];
                            a.pourcentageAlcool = (Decimal)read["pourcentageAlcool"];
                            a.typeBiereNom      = (string)read["typeBiereNom"];
                            la.Add(a);
                        }
                    }
                }
            }
            return(la);
        }
コード例 #2
0
ファイル: BiereDalService.cs プロジェクト: Nathan2503/Test3
        public BiereDal GetOne(int id)
        {
            BiereDal a = new BiereDal();

            using (SqlConnection con = new SqlConnection())
            {
                con.ConnectionString = connectionString;
                using (SqlCommand command = con.CreateCommand())
                {
                    command.CommandText = "select * from VueBiere where biereId=@id";
                    command.Parameters.AddWithValue("id", id);
                    con.Open();
                    using (SqlDataReader read = command.ExecuteReader())
                    {
                        while (read.Read())
                        {
                            a.biereId           = (int)read["biereId"];
                            a.nomBrasserie      = (string)read["nomBrasserie"];
                            a.biereDescription  = (string)read["biereDescription"];
                            a.biereNom          = (string)read["biereNom"];
                            a.biereImage        = (string)read["biereImage"];
                            a.bierePrix         = (decimal)read["bierePrix"];
                            a.biereRobe         = (string)read["biereRobe"];
                            a.pourcentageAlcool = (decimal)read["pourcentageAlcool"];
                            a.typeBiereNom      = (string)read["typeBiereNom"];
                        }
                    }
                }
            }
            return(a);
        }
コード例 #3
0
ファイル: BiereDalService.cs プロジェクト: Nathan2503/Test4
 public int Create(BiereDal parametre)
 {
     using (SqlConnection con = new SqlConnection())
     {
         con.ConnectionString = connectionString;
         using (SqlCommand command = con.CreateCommand())
         {
             command.CommandText = "AddBiereBis";
             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.biereDescription), parametre.biereDescription);
             command.Parameters.AddWithValue(nameof(parametre.biereImage), parametre.biereImage);
             command.Parameters.AddWithValue(nameof(parametre.biereNom), parametre.biereNom);
             command.Parameters.AddWithValue(nameof(parametre.bierePrix), parametre.bierePrix);
             command.Parameters.AddWithValue(nameof(parametre.pourcentageAlcool), parametre.pourcentageAlcool);
             command.Parameters.AddWithValue(nameof(parametre.biereRobe), parametre.biereRobe);
             command.Parameters.AddWithValue(nameof(parametre.typeBiereId), parametre.typeBiereId);
             command.Parameters.Add(pid);
             con.Open();
             command.ExecuteNonQuery();
             int id = (int)command.Parameters["ID"].Value;
             return(id);
         }
     }
 }
コード例 #4
0
ファイル: Mapper.cs プロジェクト: Nathan2503/Test3
        public static BiereDal GetBiereDal(this BiereAPI biereAPI)
        {
            BiereDal biereDal = new BiereDal();

            biereDal.biereDescription  = biereAPI.biereDescription;
            biereDal.biereId           = biereAPI.biereId;
            biereDal.biereImage        = biereAPI.biereImage;
            biereDal.biereNom          = biereAPI.biereNom;
            biereDal.bierePrix         = biereAPI.bierePrix;
            biereDal.biereRobe         = biereAPI.biereRobe;
            biereDal.nomBrasserie      = biereAPI.nomBrasserie;
            biereDal.pourcentageAlcool = biereAPI.pourcentageAlcool;
            biereDal.typeBiereNom      = biereAPI.typeBiereNom;
            return(biereDal);
        }
コード例 #5
0
        public static BiereDal GetBiereDal(this BiereWPF wpf)
        {
            BiereDal dal = new BiereDal();

            dal.biereDescription  = wpf.biereDescription;
            dal.biereId           = wpf.biereId;
            dal.biereImage        = wpf.biereImage;
            dal.biereIsDispo      = wpf.biereIsDispo;
            dal.biereNom          = wpf.biereNom;
            dal.bierePrix         = wpf.bierePrix;
            dal.biereRobe         = wpf.biereRobe;
            dal.brasserieId       = wpf.brasserieId;
            dal.pourcentageAlcool = wpf.pourcentageAlcool;
            dal.typeBiereId       = wpf.typeBiereId;
            return(dal);
        }
コード例 #6
0
        public static BiereWPF GetBiereWPF(this BiereDal dal)
        {
            BiereWPF wpf = new BiereWPF();

            wpf.biereDescription  = dal.biereDescription;
            wpf.biereId           = dal.biereId;
            wpf.biereImage        = dal.biereImage;
            wpf.biereIsDispo      = dal.biereIsDispo;
            wpf.biereNom          = dal.biereNom;
            wpf.bierePrix         = dal.bierePrix;
            wpf.biereRobe         = dal.biereRobe;
            wpf.brasserieId       = dal.brasserieId;
            wpf.pourcentageAlcool = dal.pourcentageAlcool;
            wpf.typeBiereId       = dal.typeBiereId;
            return(wpf);
        }
コード例 #7
0
ファイル: BiereDalService.cs プロジェクト: Nathan2503/Test4
        public List <BiereDal> GetAll()
        {
            List <BiereDal> lb = new List <BiereDal>();

            using (SqlConnection con = new SqlConnection())
            {
                con.ConnectionString = connectionString;
                using (SqlCommand command = con.CreateCommand())
                {
                    command.CommandText = "Select * from Biere";
                    con.Open();
                    using (SqlDataReader dataReader = command.ExecuteReader())
                    {
                        while (dataReader.Read())
                        {
                            BiereDal b = new BiereDal();
                            b.biereDescription  = (string)dataReader["biereDescription"];
                            b.biereId           = (int)dataReader["biereId"];
                            b.biereImage        = (string)dataReader["biereImage"];
                            b.biereIsDispo      = (bool)dataReader["biereIsDispo"];
                            b.biereNom          = (string)dataReader["biereNom"];
                            b.bierePrix         = (decimal)dataReader["bierePrix"];
                            b.biereRobe         = (string)dataReader["biereRobe"];
                            b.brasserieId       = (int?)dataReader["brasserieId"];
                            b.pourcentageAlcool = (decimal)dataReader["pourcentageAlcool"];
                            if (dataReader["typeBiereId"] is DBNull)
                            {
                                b.typeBiereId = null;
                            }
                            else
                            {
                                b.typeBiereId = (int?)dataReader["typeBiereId"];
                            }
                            lb.Add(b);
                        }
                    }
                }
            }
            return(lb);
        }
コード例 #8
0
ファイル: BiereDalService.cs プロジェクト: Nathan2503/Test4
 public void Update(BiereDal parametre)
 {
     using (SqlConnection con = new SqlConnection())
     {
         con.ConnectionString = connectionString;
         using (SqlCommand command = con.CreateCommand())
         {
             command.CommandText = "EditBiere";
             command.CommandType = System.Data.CommandType.StoredProcedure;
             command.Parameters.AddWithValue(nameof(parametre.biereId), parametre.biereId);
             command.Parameters.AddWithValue(nameof(parametre.biereDescription), parametre.biereDescription);
             command.Parameters.AddWithValue(nameof(parametre.biereImage), parametre.biereImage);
             command.Parameters.AddWithValue(nameof(parametre.biereNom), parametre.biereNom);
             command.Parameters.AddWithValue(nameof(parametre.bierePrix), parametre.bierePrix);
             command.Parameters.AddWithValue(nameof(parametre.pourcentageAlcool), parametre.pourcentageAlcool);
             command.Parameters.AddWithValue(nameof(parametre.biereRobe), parametre.biereRobe);
             command.Parameters.AddWithValue(nameof(parametre.typeBiereId), parametre.typeBiereId);
             con.Open();
             command.ExecuteNonQuery();
         }
     }
 }
コード例 #9
0
ファイル: BiereDalService.cs プロジェクト: Nathan2503/Test4
        public BiereDal GetOne(int id)
        {
            BiereDal b = new BiereDal();

            using (SqlConnection con = new SqlConnection())
            {
                con.ConnectionString = connectionString;
                using (SqlCommand command = con.CreateCommand())
                {
                    command.CommandText = "Select * from Biere where biereId=@id";
                    command.Parameters.AddWithValue("id", id);
                    con.Open();
                    using (SqlDataReader dataReader = command.ExecuteReader())
                    {
                        while (dataReader.Read())
                        {
                            b.biereDescription  = (string)dataReader["biereDescription"];
                            b.biereId           = (int)dataReader["biereId"];
                            b.biereImage        = (string)dataReader["biereImage"];
                            b.biereIsDispo      = (bool)dataReader["biereIsDispo"];
                            b.biereNom          = (string)dataReader["biereNom"];
                            b.bierePrix         = (decimal)dataReader["bierePrix"];
                            b.biereRobe         = (string)dataReader["biereRobe"];
                            b.brasserieId       = (int?)dataReader["brasserieId"];
                            b.pourcentageAlcool = (decimal)dataReader["pourcentageAlcool"];
                            if (dataReader["typeBiereId"] is DBNull)
                            {
                                b.typeBiereId = null;
                            }
                            else
                            {
                                b.typeBiereId = (int?)dataReader["typeBiereId"];
                            }
                        }
                    }
                }
            }
            return(b);
        }