Beispiel #1
0
        public IEnumerable <Persist> fnSelect(string campagneID, short cibleEnqueteID, short status)
        {
            List <Enquete> mListe = new List <Enquete>();

            db.definirProcedureStockee("Enquete_Lister");
            db.ajouterParametreEntree("@Campagne", 8, SqlDbType.VarChar, campagneID);
            db.ajouterParametreEntree("@CibleEnqueteID", 8, SqlDbType.SmallInt, cibleEnqueteID);
            db.ajouterParametreEntree("@Status", 8, SqlDbType.SmallInt, status);

            IDataReader reader = db.executeReader();

            while (reader.Read())
            {
                Enquete mClass = new Enquete();

                mapFromDataReaderToObject(reader, mClass);

                mListe.Add(mClass);
            }
            reader.Close();
            return(mListe);
        }
Beispiel #2
0
        private void mapFromDataReaderToObject(IDataReader reader, Enquete mClass)
        {
            if (reader != null)
            {
                if (!Convert.IsDBNull(reader["ID"]))
                {
                    mClass.ID = (int)reader["ID"];
                }

                if (!Convert.IsDBNull(reader["Titre"]))
                {
                    mClass.Titre = reader["Titre"].ToString();
                }

                if (!Convert.IsDBNull(reader["Campagne"]))
                {
                    mClass.Campagne = reader["Campagne"].ToString();
                }

                mClass.Cible = new CibleEnquete();

                if (!Convert.IsDBNull(reader["CibleID"]))
                {
                    mClass.Cible.ID = short.Parse(reader["CibleID"].ToString());
                }

                if (!Convert.IsDBNull(reader["CibleNom"]))
                {
                    mClass.Cible.Nom = reader["CibleNom"].ToString();
                }


                if (!Convert.IsDBNull(reader["DateDebut"]))
                {
                    mClass.DateDebut = DateTime.Parse(reader["DateDebut"].ToString());
                }

                if (!Convert.IsDBNull(reader["DateFin"]))
                {
                    mClass.DateDebut = DateTime.Parse(reader["DateFin"].ToString());
                }

                if (!Convert.IsDBNull(reader["CreationDate"]))
                {
                    mClass.CreationDate = DateTime.Parse(reader["CreationDate"].ToString());
                }

                if (!Convert.IsDBNull(reader["CreationUtilisateur"]))
                {
                    mClass.CreationUtilisateur = reader["CreationUtilisateur"].ToString();
                }

                if (!Convert.IsDBNull(reader["ModificationUtilisateur"]))
                {
                    mClass.ModificationUtilisateur = reader["ModificationUtilisateur"].ToString();
                }


                if (!Convert.IsDBNull(reader["ModificationDate"]))
                {
                    mClass.ModificationDate = DateTime.Parse(reader["ModificationDate"].ToString());
                }

                if (!Convert.IsDBNull(reader["Rowversion"]))
                {
                    mClass.RowVersion = (byte[])reader["RowVersion"];
                }

                if (!Convert.IsDBNull(reader["Statut"]))
                {
                    mClass.Statut = (bool)reader["Statut"];
                }
            }
        }