Ejemplo n.º 1
0
 private void filter_tb_TextChanged(object sender, EventArgs e)
 {
     using (PublishingHouseEntities db = new PublishingHouseEntities())
     {
         if (fn_radio.Checked)
         {
             var           filtered = db.Books.Where(b => b.Authors.FirstName.Contains(filter_tb.Text)).ToList();
             BindingSource bs       = new BindingSource();
             bs.DataSource            = filtered.Select(b => new { b.ID_Book, b.NameBook, b.Authors.FirstName, b.Authors.LastName, b.Price }).ToList();
             dataGridView1.DataSource = bs;
         }
         else if (ln_radio.Checked)
         {
             var           filtered = db.Books.Where(b => b.Authors.LastName.Contains(filter_tb.Text)).ToList();
             BindingSource bs       = new BindingSource();
             bs.DataSource            = filtered.Select(b => new { b.ID_Book, b.NameBook, b.Authors.FirstName, b.Authors.LastName, b.Price }).ToList();
             dataGridView1.DataSource = bs;
         }
         else if (nb_radio.Checked)
         {
             var           filtered = db.Books.Where(b => b.NameBook.Contains(filter_tb.Text)).ToList();
             BindingSource bs       = new BindingSource();
             bs.DataSource            = filtered.Select(b => new { b.ID_Book, b.NameBook, b.Authors.FirstName, b.Authors.LastName, b.Price }).ToList();
             dataGridView1.DataSource = bs;
         }
     }
 }
Ejemplo n.º 2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     using (PublishingHouseEntities db = new PublishingHouseEntities())
     {
         BindingSource bs = new BindingSource();
         bs.DataSource            = db.Books.Select(b => new { b.ID_Book, b.NameBook, b.Authors.FirstName, b.Authors.LastName, b.Price }).ToList();
         dataGridView1.DataSource = bs;
     }
 }
Ejemplo n.º 3
0
 private void trackBar1_Scroll(object sender, EventArgs e)
 {
     using (PublishingHouseEntities db = new PublishingHouseEntities())
     {
         var           filtered = db.Books.Where(b => b.Price < trackBar1.Value).ToList();
         BindingSource bs       = new BindingSource();
         bs.DataSource            = filtered.Select(b => new { b.ID_Book, b.NameBook, b.Authors.FirstName, b.Authors.LastName, b.Price }).ToList();
         dataGridView1.DataSource = bs;
     }
 }