Exemple #1
0
        public List <CalculatriceBean> ObtenirListeCalculatrice()
        {
            SqlConnection cnn             = null;
            var           connetionString = Properties.Settings.Default.dbConnectionString;
            var           calculatrices   = new List <CalculatriceBean>();

            cnn = new SqlConnection(connetionString);

            const string sql = "SELECT * FROM Calculatrice c ";

            try
            {
                cnn.Open();
                var command = new SqlCommand(sql, cnn);

                var dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    var calcu = new CalculatriceBean
                    {
                        NoCalculatrice = int.Parse(dataReader.GetValue(0).ToString()),
                        Modele         = dataReader.GetValue(1).ToString()
                    };

                    calculatrices.Add(calcu);
                }

                dataReader.Close();
                command.Dispose();
                cnn.Close();
            }
            catch (Exception ex)
            {
                // MessageBox.Show("Can not open connection ! ");
            }

            return(calculatrices);
        }
        public List<CalculatriceBean> ObtenirListeCalculatrice()
        {
            SqlConnection cnn = null;
            var connetionString = Properties.Settings.Default.dbConnectionString;
            var calculatrices = new List<CalculatriceBean>();
            cnn = new SqlConnection(connetionString);

            const string sql = "SELECT * FROM Calculatrice c ";
            try
            {
                cnn.Open();
                var command = new SqlCommand(sql, cnn);

                var dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    var calcu = new CalculatriceBean
                    {
                        NoCalculatrice = int.Parse(dataReader.GetValue(0).ToString()),
                        Modele = dataReader.GetValue(1).ToString()
                    };

                    calculatrices.Add(calcu);
                }

                dataReader.Close();
                command.Dispose();
                cnn.Close();
            }
            catch (Exception ex)
            {
                // MessageBox.Show("Can not open connection ! ");
            }

            return calculatrices;
        }