예제 #1
0
        public void Add(KategoriUrun2 kategoriUrun)
        {
            ConnectionControl();
            SqlCommand command = new SqlCommand("insert into KategoriUrun values (@UrunKategoriAd)", _connection);

            command.Parameters.AddWithValue("UrunKategoriAd", kategoriUrun.UrunKategoriAd);
            command.ExecuteNonQuery();
            _connection.Close();
        }
예제 #2
0
        public void Update(KategoriUrun2 kategoriUrun)
        {
            ConnectionControl();
            SqlCommand command = new SqlCommand("Update KategoriUrun set UrunKategoriAd=@UrunKategoriAd where UrunKategoriId=@UrunKategoriId", _connection);

            command.Parameters.AddWithValue("UrunKategoriId", kategoriUrun.UrunKategoriId);
            command.Parameters.AddWithValue("UrunKategoriAd", kategoriUrun.UrunKategoriAd);
            command.ExecuteNonQuery();

            _connection.Close();
        }
예제 #3
0
        public List <KategoriUrun2> GetAll()
        {
            ConnectionControl();
            SqlCommand command = new SqlCommand("Select * from KategoriUrun", _connection);

            SqlDataReader        reader          = command.ExecuteReader();
            List <KategoriUrun2> kategoriUrunler = new List <KategoriUrun2>();

            while (reader.Read())
            {
                KategoriUrun2 kategoriUrun = new KategoriUrun2
                {
                    UrunKategoriAd = reader["UrunKategoriAd"].ToString(),
                    UrunKategoriId = Convert.ToInt32(reader["UrunKategoriId"])
                };
                kategoriUrunler.Add(kategoriUrun);
            }
            reader.Close();
            _connection.Close();
            return(kategoriUrunler);
        }