コード例 #1
0
        private void SearchBook(string key) // burada datagrid'e sorgu atıyor büyük küçük harf duyarlılığı var
        {
            BookDal bookDal = new BookDal();

            dgwBooks.DataSource = bookDal.GetAll().Where(p => p.name.Contains(key)).ToList(); //
            // datagrid'in datakaynağı = bookDal nesnesinin GetAll fonksiyonu olsun fakat bu fonksiyodan gelen dataya linq ile sorgu atıyoruz.Where p için(p istediğimiz bir değişken burada datadaki eleman) p.name -> p iteminin name propu contains -> içersin key-> verilen değeri ve sonunda bunu bir listeye atadık
        }
コード例 #2
0
        private void DgwBooks_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            BookDal     bookDal = new BookDal();
            List <Book> Books   = bookDal.GetByProp(Convert.ToInt32(dgwBooks.CurrentRow.Cells[0].Value));

            int i = 0;

            foreach (Book item in Books)                            // book türünde books listesinde döngü başlattık
            {
                dgwDeneme.Rows[i].Cells["ID"].Value    = item.id;   // 3. datagridin i'ninci(0) kolonuna ID dedik ve books listesindeki book item'in id'sini verdik
                dgwDeneme.Rows[i].Cells[1].Value       = item.name; // sadece kolon adı ile değil kolon numarası ile de veri ekleyebiliriz.
                dgwDeneme.Rows[i].Cells["Yazar"].Value = item.author;

                i++;
            }
        }
コード例 #3
0
 private void BtnDeleteBook_Click(object sender, EventArgs e)
 {
     try
     {
         BookDal bookDal = new BookDal();
         bookDal.Delete(new Book {
             id = Convert.ToInt32(dgwBooks.CurrentRow.Cells[0].Value)
         });
         MessageBox.Show("Seçili Kitap Başarıyla Silindi!");
         dgwBooks.DataSource = bookDal.GetAll();
     }
     catch (Exception a)
     {
         MessageBox.Show("Seçili Kitap Silinemedi!" + a.Message);
         throw;
     }
 }
コード例 #4
0
 private void BtnAddBook_Click(object sender, EventArgs e)
 {
     try
     {
         BookDal bookDal = new BookDal();
         bookDal.Add(new Book {
             name = tbxAddName.Text, page = Convert.ToInt32(tbxAddPage.Text), type = Convert.ToInt32(cbxAddType.SelectedValue), author = tbxAddAuthor.Text, content = rtbxAddContent.Text
         });
         MessageBox.Show("Kitap Başarıyla Eklendi!");
         this.Hide();
         Main main = new Main();
         main.Show();
     }
     catch (Exception a)
     {
         MessageBox.Show("Kitap Eklenirken Hata Oluştu Lütfen Tekrar Deneyiniz!" + a.Message);
     }
 }
コード例 #5
0
        private void BtnUpdateBook_Click(object sender, EventArgs e)
        {
            try
            {
                BookDal bookDal = new BookDal();
                bookDal.Update(new Book {
                    id = this.id, name = tbxUpdateName.Text, author = tbxUpdateAuthor.Text, content = rtbxUpdateContent.Text, page = Convert.ToInt32(tbxUpdatePage.Text), type = Convert.ToInt32(cbxUpdateType.SelectedValue)
                });
                MessageBox.Show(String.Format("{0} id'li kitap başarıyla güncellendi!", this.id.ToString()));
                this.Hide();
                Main main = new Main();
                main.Show();
            }
            catch (Exception a)
            {
                MessageBox.Show("Kitap güncellenemedi! Hata Kodu :\n" + a.Message);

                throw;
            }
        }
コード例 #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            BookTypeDal bookTypeDal = new BookTypeDal();

            dgwBookType.DataSource = bookTypeDal.GetAll();
            BookDal bookDal = new BookDal();

            dgwBooks.DataSource            = bookDal.GetAll();
            dgwBooks.Columns[0].HeaderText = "Id"; // dgwBook datagridview'in columns listesinin 0. elemanının user tarafından görüntüsünü değiştirdik.
            dgwBooks.Columns[1].HeaderText = "Kitap Adı";
            dgwBooks.Columns[2].HeaderText = "Sayfa Sayısı";
            dgwBooks.Columns[3].HeaderText = "Yazar Adı";
            dgwBooks.Columns[4].HeaderText = "Konusu";
            dgwBooks.Columns[5].HeaderText = "Tür Id";
            dgwDeneme.Columns.Add("ID", "ID"); // ilk parametre kolon adı , ikinci parametre user'İn gördüğü kolon adı -> kolon ekledik
            dgwDeneme.Columns.Add("Kitap", "Kitap");
            dgwDeneme.Columns.Add("Yazar", "Yazar");

            //dgwDeneme.Columns[1].HeaderText = "ID";
            //dgwDeneme.Columns[2].HeaderText = "Kitap";
            //dgwDeneme.Columns[3].HeaderText = "Yazar";
        }
コード例 #7
0
        private void DgwBookType_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            BookDal bookDal = new BookDal();

            dgwBooks.DataSource = bookDal.GetByType(Convert.ToInt32(dgwBookType.CurrentRow.Cells[0].Value.ToString()));
        }
コード例 #8
0
        private void SearchBook2() // fakat burada direkt database'e sorgu atıyor ve küçük büyük harf duyarlılığı yok
        {
            BookDal bookDal = new BookDal();

            dgwBooks.DataSource = bookDal.GetByName(tbxSearchBook.Text);
        }
コード例 #9
0
        private void BtnRefreshData_Click(object sender, EventArgs e)
        {
            BookDal bookDal = new BookDal();

            dgwBooks.DataSource = bookDal.GetAll();
        }