private void AddBook_Load(object sender, EventArgs e) { BookTypeDal bookTypeDal = new BookTypeDal(); cbxAddType.DataSource = bookTypeDal.GetAll(); cbxAddType.DisplayMember = "name"; cbxAddType.ValueMember = "id"; }
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"; }
private void BtnAddType_Click(object sender, EventArgs e) { try { BookTypeDal bookTypeDal = new BookTypeDal(); bookTypeDal.Add(new BookType { name = tbxAddType.Text }); MessageBox.Show("Kitap Türü Başarıyla Eklendi!"); this.Hide(); Main main = new Main(); main.Show(); } catch { MessageBox.Show("Kitap Türü Eklenemedi!"); } }
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"; }