Esempio n. 1
0
        static Book GetBookByID(LibraryEntities context, int bookID)
        {
            Book book = context.Book.FirstOrDefault(
                p => p.ID == bookID);

            return(book);
        }
        private bool CreateClient()
        {
            int affectedRows = 0;

            using (LibraryEntities db = new LibraryEntities())
            {
                Models.Client newclient = new Models.Client
                {
                    Name    = txtName_Client.Text,
                    Surname = txtSurname_Client.Text,
                    Email   = txtEmail_Client.Text,
                    Phone   = txtPhone_Client.Text
                };
                db.Clients.Add(newclient);

                db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
 private void FormAuthors_Load(object sender, EventArgs e)
 {
     LibraryEntities context = new LibraryEntities();
     var authors = context.Author;
     //dataGridViewAuthors.AutoGenerateColumns = false;
     dataGridViewAuthors.DataSource = authors;
 }
 private void FormCategories_Load(object sender, EventArgs e)
 {
     LibraryEntities context = new LibraryEntities();
     var categories = context.Category;
     //dataGridViewLanguages.AutoGenerateColumns = false;
     dataGridViewCategories.DataSource = categories;
 }
        private void BookTable_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int bookId = Convert.ToInt32(bookTable.Rows[e.RowIndex].Cells[0].Value);

            using (LibraryEntities db = new LibraryEntities())
            {
                bookFound = db.Books.Where(b => b.Id == bookId).FirstOrDefault();
                List <Models.AuthorsBooks> abList = db.AuthorsBooks.ToList();

                if (bookFound != null)
                {
                    nameBox.Text = bookFound.Name;
                    //foreach(var y in abList)
                    //{
                    //    if(bookFound.Id == y.BookId)
                    //    {
                    //        authorDrop.SelectedText = y.Authors.Name;
                    //    }
                    //}
                    priceBox.Text             = Convert.ToString(bookFound.Price);
                    quantityBox.Text          = Convert.ToString(bookFound.Quantity);
                    categoryDrop.SelectedItem = bookFound.Categories.Name;
                }
                saveBtn.Text      = "Update";
                deleteBtn.Enabled = true;
            }
        }
Esempio n. 6
0
        private void buttonReserve_Click(object sender, EventArgs e)
        {
            LibraryEntities context = new LibraryEntities();

            List <int> books = new List <int>();

            foreach (DataGridViewRow row in dataGridViewBooks.SelectedRows)
            {
                if (row.Cells[0].Value != null)
                {
                    books.Add(Convert.ToInt32(row.Cells[0].Value));
                }
            }

            if (books.Count > 0)
            {
                var client = (from c in context.Clients
                              where c.ClientID == id
                              select c).SingleOrDefault();

                foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
                {
                    if (books.Contains(cBook.BookID))
                    {
                        cBook.Reservation = true;
                        MessageBox.Show("Резервирането е успешно!");
                    }
                }

                context.SaveChanges();
            }
        }
Esempio n. 7
0
        private void checkBoxRejection_CheckedChanged(object sender, EventArgs e)
        {
            LibraryEntities context = new LibraryEntities();
            Book            book    = GetBookByID(context, id);

            book.Rejection = true;
            context.SaveChanges();
        }
Esempio n. 8
0
        private void radioButtonAll_CheckedChanged(object sender, EventArgs e)
        {
            LibraryEntities context = new LibraryEntities();
            var             books   = context.Book;

            dataGridViewBooks.AutoGenerateColumns = false;
            dataGridViewBooks.DataSource          = books;
        }
Esempio n. 9
0
        private void FormAuthors_Load(object sender, EventArgs e)
        {
            LibraryEntities context = new LibraryEntities();
            var             authors = context.Author;

            //dataGridViewAuthors.AutoGenerateColumns = false;
            dataGridViewAuthors.DataSource = authors;
        }
Esempio n. 10
0
        private void FormCategories_Load(object sender, EventArgs e)
        {
            LibraryEntities context    = new LibraryEntities();
            var             categories = context.Category;

            //dataGridViewLanguages.AutoGenerateColumns = false;
            dataGridViewCategories.DataSource = categories;
        }
        private void AddAuthor(object sender, EventArgs e)
        {
            if (saveBtn.Text == "Save")
            {
                Regex letters      = new Regex(@"^[A-Za-z ]+$");
                Match nameMatch    = letters.Match(nameBox.Text);
                Match surnameMatch = letters.Match(surnameBox.Text);

                if (nameMatch.Success && surnameMatch.Success)
                {
                    Models.Authors a1 = new Models.Authors();
                    a1.Id      = ab.AuthorId;
                    a1.Name    = nameBox.Text;
                    a1.Surname = surnameBox.Text;


                    using (LibraryEntities db = new LibraryEntities())
                    {
                        db.Authors.Add(a1);
                        db.SaveChanges();
                    }

                    FillAuthors();
                    nameBox.Clear();
                    surnameBox.Clear();
                }
                else
                {
                    MessageBox.Show("Surname and name contain only letters");
                }
            }
            else
            {
                using (LibraryEntities db = new LibraryEntities())
                {
                    int authorId = Convert.ToInt32(authorTable.SelectedRows[0].Cells[0].Value);

                    Models.Authors newAuthor = db.Authors.Where(a => a.Id == authorFound.Id).FirstOrDefault();

                    newAuthor.Id = authorId;
                    Regex letters      = new Regex(@"^[A-Za-z ]+$");
                    Match nameMatch    = letters.Match(nameBox.Text);
                    Match surnameMatch = letters.Match(surnameBox.Text);

                    if (nameMatch.Success && surnameMatch.Success)
                    {
                        newAuthor.Name    = nameBox.Text;
                        newAuthor.Surname = surnameBox.Text;
                    }
                    else
                    {
                        MessageBox.Show("Surname and name contain only letters");
                    }
                    db.SaveChanges();
                    FillAuthors();
                }
            }
        }
Esempio n. 12
0
        private void BtnSearch_Books_Click(object sender, EventArgs e)
        {
            string searchText = txtBookSearch.Text.Trim().ToLower();

            using (LibraryEntities db = new LibraryEntities())
            {
                List <Book> bookList = db.Books.Where(b =>
                                                      b.Name.ToLower().Contains(searchText)).ToList();
            }
        }
Esempio n. 13
0
 private void buttonSearch_Click(object sender, EventArgs e)
 {
     LibraryEntities context = new LibraryEntities();
     string authorFName = textBoxAuthor.Text;
     Author author = context.Author.FirstOrDefault(p => p.FName == authorFName);
     var books =
         from book in context.Book
         where (book.Title == textBoxTitle.Text) || (book.Author.Contains(author)) || (book.Description.Contains(textBoxDescription.Text))
         select book;
     dataGridViewBooks.DataSource = books;
 }
Esempio n. 14
0
 private void checkBoxLanguage_CheckedChanged(object sender, EventArgs e)
 {
     comboBoxLanguage.Enabled = true;
     LibraryEntities context = new LibraryEntities();
     var languages =
         from lan in context.Language
         select lan;
     comboBoxLanguage.DataSource = languages;
     comboBoxLanguage.ValueMember = "ID";
     comboBoxLanguage.DisplayMember = "Name";
 }
Esempio n. 15
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     LibraryEntities context = new LibraryEntities();
     Author newAuthor = new Author()
     {
         FName = textBoxFName.Text,
         LName = textBoxLName.Text
     };
     context.Author.AddObject(newAuthor);
     context.SaveChanges();
 }
Esempio n. 16
0
 private void checkBox2_CheckedChanged(object sender, EventArgs e)
 {
     comboBoxCategory.Enabled = true;
     LibraryEntities context = new LibraryEntities();
     var categories =
         from cat in context.Category
         select cat;
     comboBoxCategory.DataSource = categories;
     comboBoxCategory.ValueMember = "ID";
     comboBoxCategory.DisplayMember = "Name";
 }
Esempio n. 17
0
        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            comboBoxCategory.Enabled = true;
            LibraryEntities context    = new LibraryEntities();
            var             categories =
                from cat in context.Category
                select cat;

            comboBoxCategory.DataSource    = categories;
            comboBoxCategory.ValueMember   = "ID";
            comboBoxCategory.DisplayMember = "Name";
        }
Esempio n. 18
0
        private void checkBoxLanguage_CheckedChanged(object sender, EventArgs e)
        {
            comboBoxLanguage.Enabled = true;
            LibraryEntities context   = new LibraryEntities();
            var             languages =
                from lan in context.Language
                select lan;

            comboBoxLanguage.DataSource    = languages;
            comboBoxLanguage.ValueMember   = "ID";
            comboBoxLanguage.DisplayMember = "Name";
        }
Esempio n. 19
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     int i = dataGridViewCategories.CurrentRow.Index;
     string cat = dataGridViewCategories.Rows[i].Cells[1].Value.ToString();
     LibraryEntities context = new LibraryEntities();
     Category newCategory = new Category()
     {
         Name = cat
     };
     context.Category.AddObject(newCategory);
     context.SaveChanges();
 }
Esempio n. 20
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            LibraryEntities context   = new LibraryEntities();
            Author          newAuthor = new Author()
            {
                FName = textBoxFName.Text,
                LName = textBoxLName.Text
            };

            context.Author.AddObject(newAuthor);
            context.SaveChanges();
        }
Esempio n. 21
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            LibraryEntities context     = new LibraryEntities();
            string          authorFName = textBoxAuthor.Text;
            Author          author      = context.Author.FirstOrDefault(p => p.FName == authorFName);
            var             books       =
                from book in context.Book
                where (book.Title == textBoxTitle.Text) || (book.Author.Contains(author)) || (book.Description.Contains(textBoxDescription.Text))
                select book;

            dataGridViewBooks.DataSource = books;
        }
 private void DeleteClient(object sender, EventArgs e)
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         int            clientId = Convert.ToInt32(clientTable.SelectedRows[0].Cells[0].Value);
         Models.Clients c1       = db.Clients.Where(c => c.Id == clientId).FirstOrDefault();
         db.Clients.Remove(c1);
         db.SaveChanges();
     }
     FIllClients();
     Reset();
 }
Esempio n. 23
0
        private void radioButtonAvailable_CheckedChanged(object sender, EventArgs e)
        {
            LibraryEntities context = new LibraryEntities();
            var             books   =
                from clientbook in context.ClientBooks
                join book in context.Book on clientbook.BookID equals book.ID
                where clientbook.Returned == true
                select book;

            dataGridViewBooks.AutoGenerateColumns = false;
            dataGridViewBooks.DataSource          = books;
        }
 private void DeleteAuthor(object sender, EventArgs e)
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         int            authorId = Convert.ToInt32(authorTable.SelectedRows[0].Cells[0].Value);
         Models.Authors a1       = db.Authors.Where(a => a.Id == authorId).FirstOrDefault();
         db.Authors.Remove(a1);
         db.SaveChanges();
     }
     FillAuthors();
     Reset();
 }
Esempio n. 25
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     int i = dataGridViewLanguages.CurrentRow.Index;
     string lang = dataGridViewLanguages.Rows[i].Cells[1].Value.ToString();
     LibraryEntities context = new LibraryEntities();
     Language newLanguage = new Language()
     {
         Name = lang
     };
     context.Language.AddObject(newLanguage);
     context.SaveChanges();
 }
        private void AddCategory(object sender, EventArgs e)
        {
            if (saveBtn.Text == "Save")
            {
                Regex letters           = new Regex(@"^[A-Za-z ]+$");
                Match categoryNameMatch = letters.Match(categoryBox.Text);

                if (!categoryNameMatch.Success)
                {
                    MessageBox.Show("Category  contains only letters");
                }
                else
                {
                    Models.Categories c1 = new Models.Categories();
                    c1.Name = categoryBox.Text;

                    using (LibraryEntities db = new LibraryEntities())
                    {
                        db.Categories.Add(c1);
                        db.SaveChanges();
                    }

                    FillCategories();
                    categoryBox.Clear();
                }
            }
            else
            {
                using (LibraryEntities db = new LibraryEntities())
                {
                    int categoryId = Convert.ToInt32(categoryTable.SelectedRows[0].Cells[0].Value);

                    Models.Categories newCat = db.Categories.Where(c => c.Id == categoryFound.Id).FirstOrDefault();

                    newCat.Id = categoryId;
                    Regex letters           = new Regex(@"^[A-Za-z ]+$");
                    Match categoryNameMatch = letters.Match(categoryBox.Text);

                    if (!categoryNameMatch.Success)
                    {
                        MessageBox.Show("Category contains only letters");
                    }
                    else
                    {
                        newCat.Name = categoryBox.Text;
                    }

                    db.SaveChanges();
                    FillCategories();
                }
            }
        }
        private void DeleteCategory(object sender, EventArgs e)
        {
            using (LibraryEntities db = new LibraryEntities())
            {
                int          bookId = Convert.ToInt32(bookTable.SelectedRows[0].Cells[0].Value);
                Models.Books b1     = db.Books.Where(b => b.Id == bookId).FirstOrDefault();
                db.Books.Remove(b1);
                db.SaveChanges();
            }

            FillBooks();
            Reset();
        }
Esempio n. 28
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int             i           = dataGridViewLanguages.CurrentRow.Index;
            string          lang        = dataGridViewLanguages.Rows[i].Cells[1].Value.ToString();
            LibraryEntities context     = new LibraryEntities();
            Language        newLanguage = new Language()
            {
                Name = lang
            };

            context.Language.AddObject(newLanguage);
            context.SaveChanges();
        }
Esempio n. 29
0
        private void BtnSeach_Client_Click(object sender, EventArgs e)
        {
            string searchText = txtClientsSearch.Text.Trim().ToLower();

            using (LibraryEntities db = new LibraryEntities())
            {
                List <Client> clientList = db.Clients.Where(c =>
                                                            c.Name.ToLower().Contains(searchText) ||
                                                            c.Surname.ToLower().Contains(searchText) ||
                                                            c.Email.ToLower().Contains(searchText) ||
                                                            c.Phone.ToLower().Contains(searchText)).ToList();
            }
        }
Esempio n. 30
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int             i           = dataGridViewCategories.CurrentRow.Index;
            string          cat         = dataGridViewCategories.Rows[i].Cells[1].Value.ToString();
            LibraryEntities context     = new LibraryEntities();
            Category        newCategory = new Category()
            {
                Name = cat
            };

            context.Category.AddObject(newCategory);
            context.SaveChanges();
        }
        private void FillCategories()
        {
            using (LibraryEntities db = new LibraryEntities())
            {
                categoryTable.Rows.Clear();

                List <Models.Categories> categoryList = db.Categories.ToList();

                foreach (var category in categoryList)
                {
                    categoryTable.Rows.Add(category.Id,
                                           category.Name);
                }
            }
        }
        private void FillAuthors()
        {
            using (LibraryEntities db = new LibraryEntities())
            {
                authorTable.Rows.Clear();
                List <Models.Authors> authorsList = db.Authors.ToList();

                foreach (var a in authorsList)
                {
                    authorTable.Rows.Add(a.Id,
                                         a.Name,
                                         a.Surname);
                }
            }
        }
        private void CategoriesDataGrid_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int categID = (int)CategoriesDataGrid.Rows[e.RowIndex].Cells[0].Value;

            using (LibraryEntities db = new LibraryEntities())
            {
                globalCateg = db.Categories.Where(a => a.Id == categID).FirstOrDefault();
                if (globalCateg != null)
                {
                    txtNameCategori.Text = globalCateg.Name;
                }
            }

            btnSaveCategori.Text      = "Update";
            btnDeleteCategori.Enabled = true;
        }
        private void GenerateCategories()
        {
            CategoriesDataGrid.Rows.Clear();

            using (LibraryEntities db = new LibraryEntities())
            {
                List <Category> categories = db.Categories.ToList();

                foreach (var category in categories)
                {
                    CategoriesDataGrid.Rows.Add(category.Id,
                                                category.Name
                                                );
                }
            }
        }
        private void GenerateAuthors()
        {
            AuthorsDataGrid.Rows.Clear();

            using (LibraryEntities db = new LibraryEntities())
            {
                List <Author> authors = db.Authors.ToList();

                foreach (var author in authors)
                {
                    AuthorsDataGrid.Rows.Add(author.Id,
                                             author.Name,
                                             author.Surname);
                }
            }
        }
        private void FillBooks()
        {
            using (LibraryEntities db = new LibraryEntities())
            {
                bookTable.Rows.Clear();
                List <Models.Books> booksList = db.Books.ToList();
                //List<Models.AuthorsBooks> abList = db.AuthorsBooks.ToList();
                foreach (var b in booksList)
                {
                    bookTable.Rows.Add(b.Id,
                                       b.Name,
                                       b.AuthorsBooks,
                                       b.Price,
                                       b.Categories.Name,
                                       b.Quantity);
                }



                //foreach (var y in abList)
                //{
                //    bookTable.Rows.Add(y.Authors.Name + " " + y.Authors.Surname);
                //}
                //foreach (var b in booksList)
                //{
                //    bookTable.Rows.Add(b.Price,
                //                b.Categories.Name,
                //                b.Quantity);
                //}

                //foreach (var b in booksList)
                //{
                //    foreach (DataGridViewRow row in bookTable.Rows)
                //    {
                //        row.Cells[0].Value = b.Id;
                //        row.Cells[1].Value = b.Name;
                //        foreach(var y in abList)
                //        {
                //            row.Cells[2].Value = y.Authors.Name;
                //        }
                //        row.Cells[3].Value = b.Price;
                //        row.Cells[4].Value = b.Categories.Name;
                //        row.Cells[5].Value = b.Quantity;
                //    }
                //}
            }
        }
        private void AuthorTable_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int authorId = Convert.ToInt32(authorTable.Rows[e.RowIndex].Cells[0].Value);

            using (LibraryEntities db = new LibraryEntities())
            {
                authorFound = db.Authors.Where(a => a.Id == authorId).FirstOrDefault();
                if (authorFound != null)
                {
                    nameBox.Text    = authorFound.Name;
                    surnameBox.Text = authorFound.Surname;
                }

                saveBtn.Text      = "Update";
                deleteBtn.Enabled = true;
            }
        }
        private void OrderBtn_Click(object sender, EventArgs e)
        {
            int clientID = Convert.ToInt32(userTable.SelectedRows[0].Cells[0].Value);
            int bookID   = Convert.ToInt32(bookTable.SelectedRows[0].Cells[0].Value);

            Models.Orders order = new Models.Orders();
            order.ClientId   = clientID;
            order.BookId     = bookID;
            order.OrderDate  = DateTime.Now;
            order.ReturnDate = DateTime.Now.AddMonths(1);

            using (LibraryEntities db = new LibraryEntities())
            {
                db.Orders.Add(order);
                db.SaveChanges();
            }
        }
Esempio n. 39
0
 private void comboBoxCategory_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (radioButtonAll.Checked == true)
     {
         LibraryEntities context = new LibraryEntities();
         var books =
             from book in context.Book
             where book.CategoryID == int.Parse(comboBoxCategory.SelectedValue.ToString())
             select book;
         dataGridViewBooks.AutoGenerateColumns = false;
         dataGridViewBooks.DataSource = books;
     }
     if (radioButtonAvailable.Checked == true)
     {
         LibraryEntities context = new LibraryEntities();
         var books =
             from clientbook in context.ClientBooks
             join book in context.Book on clientbook.BookID equals book.ID
             where (clientbook.Returned == true) && (book.CategoryID == int.Parse(comboBoxCategory.SelectedValue.ToString()))
             select book;
         dataGridViewBooks.AutoGenerateColumns = false;
         dataGridViewBooks.DataSource = books;
     }
     if (radioButtonTaken.Checked == true)
     {
         LibraryEntities context = new LibraryEntities();
         var books =
             from clientbook in context.ClientBooks
             join book in context.Book on clientbook.BookID equals book.ID
             where (clientbook.Returned == false) && (book.CategoryID == int.Parse(comboBoxCategory.SelectedValue.ToString()))
             select book;
         dataGridViewBooks.AutoGenerateColumns = false;
         dataGridViewBooks.DataSource = books;
     }
     if (radioButtonBooked.Checked == true)
     {
         LibraryEntities context = new LibraryEntities();
         var books =
             from clientbook in context.ClientBooks
             join book in context.Book on clientbook.BookID equals book.ID
             where (clientbook.Reservation == true) && (book.CategoryID == int.Parse(comboBoxCategory.SelectedValue.ToString()))
             select book;
         dataGridViewBooks.AutoGenerateColumns = false;
         dataGridViewBooks.DataSource = books;
     }
 }
Esempio n. 40
0
 static void CreateNewBook(string invn, string isbn, string title,int authorID, string descr, int categID,
 int yearpubl, int langID, int price)
 {
     LibraryEntities context = new LibraryEntities();
     Author author = context.Author.FirstOrDefault(p => p.ID == authorID);
     Book newBook = new Book()
     {
         InvNum = invn,
         ISBN = isbn,
         Title = title,
         Description = descr,
         CategoryID = categID,
         YearPubl = yearpubl,
         LanguageID = langID,
         Price = price,
         Rejection = false
     };
     newBook.Author.Add(author);
     context.Book.AddObject(newBook);
     context.SaveChanges();
     //return newBook.ID;
 }
Esempio n. 41
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     LibraryEntities context = new LibraryEntities();
     CreateNewBook(textBoxInvNum.Text, textBoxISBN.Text, textBoxTitle.Text,
         int.Parse(comboBoxAuthor.ValueMember), textBoxDescription.Text,
         int.Parse(comboBoxCategory.ValueMember), int.Parse(textBoxYearPubl.Text),
         int.Parse(comboBoxLanguage.ValueMember), int.Parse(textBoxPrice.Text));
     if (MessageBox.Show("Ще въвеждате ли още?", "Добавяне на проект",
        MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         textBoxInvNum.Clear();
         textBoxISBN.Clear();
         textBoxTitle.Clear();
         textBoxDescription.Clear();
         textBoxYearPubl.Clear();
         textBoxPrice.Clear();
         textBoxInvNum.Focus();
     }
     else
     {
         this.Close();
     }
 }
Esempio n. 42
0
 private void radioButtonAll_CheckedChanged(object sender, EventArgs e)
 {
     LibraryEntities context = new LibraryEntities();
     var books = context.Book;
     dataGridViewBooks.AutoGenerateColumns = false;
     dataGridViewBooks.DataSource = books;
 }
Esempio n. 43
0
 private void checkBoxRejection_CheckedChanged(object sender, EventArgs e)
 {
     LibraryEntities context = new LibraryEntities();
     Book book = GetBookByID(context, id);
     book.Rejection = true;
     context.SaveChanges();
 }
Esempio n. 44
0
 static Book GetBookByID(LibraryEntities context, int bookID)
 {
     Book book = context.Book.FirstOrDefault(
         p => p.ID == bookID);
     return book;
 }
Esempio n. 45
0
 private void FormBook_Load(object sender, EventArgs e)
 {
     if (id == 0)
     {
         LibraryEntities context = new LibraryEntities();
         //Book book = GetBookByID(context, id);
         var categories =
             from cat in context.Category
             select cat;
         comboBoxCategory.DataSource = categories;
         comboBoxCategory.ValueMember = "ID";
         comboBoxCategory.DisplayMember = "Name";
         var languages =
             from lan in context.Language
             select lan;
         comboBoxLanguage.DataSource = languages;
         comboBoxLanguage.ValueMember = "ID";
         comboBoxLanguage.DisplayMember = "Name";
         var authors =
             from author in context.Author
             select author;
         comboBoxAuthor.DataSource = authors;
         comboBoxAuthor.ValueMember = "ID";
         comboBoxAuthor.DisplayMember = "LName";
         textBoxInvNum.Text = "";
         textBoxISBN.Text = "";
         textBoxTitle.Text = "";
         textBoxDescription.Text = "";
         textBoxYearPubl.Text = "";
         textBoxPrice.Text = "";
     }
     else
     {
         LibraryEntities context = new LibraryEntities();
         Book book = GetBookByID(context, id);
         var categories =
             from cat in context.Category
             select cat;
         comboBoxCategory.DataSource = categories;
         comboBoxCategory.ValueMember = "ID";
         comboBoxCategory.DisplayMember = "Name";
         var languages =
             from lan in context.Language
             select lan;
         comboBoxLanguage.DataSource = languages;
         comboBoxLanguage.ValueMember = "ID";
         comboBoxLanguage.DisplayMember = "Name";
         var authors =
             from author in context.Author
             select author;
         comboBoxAuthor.DataSource = authors;
         comboBoxAuthor.ValueMember = "ID";
         comboBoxAuthor.DisplayMember = "FName" + " " + "LName";
         textBoxInvNum.Text = book.InvNum;
         textBoxISBN.Text = book.ISBN;
         textBoxTitle.Text = book.Title;
         textBoxDescription.Text = book.Description;
         comboBoxCategory.ValueMember = "book.CategoryID";
         textBoxYearPubl.Text = book.YearPubl.ToString();
         comboBoxLanguage.ValueMember = "book.LanguageID";
         textBoxPrice.Text = book.Price.ToString();
     }
 }
Esempio n. 46
0
 private void radioButtonTaken_CheckedChanged(object sender, EventArgs e)
 {
     LibraryEntities context = new LibraryEntities();
     var books =
         from clientbook in context.ClientBooks
         join book in context.Book on clientbook.BookID equals book.ID
         where clientbook.Returned == false
         select book;
     dataGridViewBooks.AutoGenerateColumns = false;
     dataGridViewBooks.DataSource = books;
 }