public Books() { InitializeComponent(); db = new db_lab4Entities(); listGenre = new List<Genre>(); listAuthor = new List<Author>(); }
private void Search_Load(object sender, EventArgs e) { using (db_lab4Entities db = new db_lab4Entities()) { foreach (User user in db.Users) { bool flag = false; foreach (User u in listUser) { if (u.firstname.Equals(user.firstname)) { flag = true; break; } } if (!flag) { comboBox1.Items.Add(user.firstname); listUser.Add(user); } } } }
private void AddUser_Load(object sender, EventArgs e) { using (db_lab4Entities db = new db_lab4Entities()) { foreach (Book book in db.Books) { comboBox1.Items.Add(book.name); listBook.Add(book); } } }
private void AddBooks_Load(object sender, EventArgs e) { using (db_lab4Entities db = new db_lab4Entities()) { foreach (Genre genre in db.Genres) { comboBox1.Items.Add(genre.genre1); listGenre.Add(genre); } foreach (Author author in db.Authors) { comboBox2.Items.Add(author.firstname); listAuthor.Add(author); } } }
private void button1_Click(object sender, EventArgs e) { listBox1.Items.Clear(); using (db_lab4Entities db = new db_lab4Entities()) { foreach (User user in db.Users) { if (user.firstname == comboBox1.SelectedItem.ToString()) { foreach (Book book in db.Books) { if (user.id_book == book.id_book) listBox1.Items.Add(book.name); } } } } }
private void button1_Click(object sender, EventArgs e) { AddUser addUser = new AddUser(); DialogResult result = addUser.ShowDialog(this); User user = new User(); if (result == DialogResult.Cancel) Hide(); if (result == DialogResult.OK) { user.firstname = addUser.textBox1.Text; user.name = addUser.textBox2.Text; user.lastname = addUser.textBox3.Text; user.id_book = listBook.Find(ob => ob.name == addUser.comboBox1.Text).id_book; db_lab4Entities db = new db_lab4Entities(); db.Users.Add(user); db.SaveChanges(); dataGridView1.Refresh(); Refresh(); MessageBox.Show("Добавлена новая книга!"); } }
public Users() { InitializeComponent(); db = new db_lab4Entities(); listBook = new List<Book>(); }
public SettingsGenre() { InitializeComponent(); db = new db_lab4Entities(); }