示例#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
        }
        private void UpdateBook_Load(object sender, EventArgs e)
        {
            BookTypeDal bookTypeDal = new BookTypeDal();
            List <Book> bookItem    = bookDal.GetAll().Where(w => w.id == id).ToList(); // linq ile sorgu attık.

            tbxUpdateName.Text          = bookItem[0].name;
            tbxUpdateAuthor.Text        = bookItem[0].author;
            tbxUpdatePage.Text          = Convert.ToString(bookItem[0].page);
            cbxUpdateType.Text          = bookItem[0].type.ToString();
            rtbxUpdateContent.Text      = bookItem[0].content;
            cbxUpdateType.DataSource    = bookTypeDal.GetAll();
            cbxUpdateType.DisplayMember = "name";
            cbxUpdateType.ValueMember   = "id";
        }
示例#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 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";
        }
示例#5
0
        private void BtnRefreshData_Click(object sender, EventArgs e)
        {
            BookDal bookDal = new BookDal();

            dgwBooks.DataSource = bookDal.GetAll();
        }