private void tbConfirm_Click(object sender, EventArgs e)
 {
     foreach (Book book in Books)
     {
         LibrarySnapshot.EditBook(book);
     }
     this.Close();
 }
Exemple #2
0
 private void btnReturnBook_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in gvMyBooks.SelectedRows)
     {
         int id = Convert.ToInt32(row.Cells["Id"].Value);
         LibrarySnapshot.ReturnBook(id);
     }
     RefreshBookTables();
 }
Exemple #3
0
        private void btnReserveBook_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in gvAvailBooks.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells["Id"].Value);
                LibrarySnapshot.BorrowBook(id, CurrentUser);
            }

            RefreshBookTables();
        }
Exemple #4
0
        private void menuBtnExportLib_Click(object sender, EventArgs e)
        {
            var saveDialog = new SaveFileDialog();

            saveDialog.Filter = "Datový súbor knižnice(*.xml)|*.xml";
            saveDialog.ShowDialog();
            if (saveDialog.FileName != "")
            {
                LibrarySnapshot.SaveSnapshotToFile(saveDialog.FileName);// save library from snapshot to file
            }
        }
Exemple #5
0
        private void btnDeleteBooks_Click(object sender, EventArgs e)
        {
            List <int> idsToRemove = new List <int>();

            foreach (DataGridViewRow row in gvAllBooks.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells["Id"].Value);
                //LibrarySnapshot.RemoveBookFromSnapshot(id);
                idsToRemove.Add(id);
            }

            LibrarySnapshot.RemoveBooksFromSnapshot(idsToRemove);
            RefreshBookTables();
        }
Exemple #6
0
        private void manuBtnImportLib_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Datový súbor knižnice(*.xml)|*.xml";
            openFileDialog.ShowDialog();
            if (openFileDialog.FileName != "")//basic file presence protection
            {
                try
                {
                    LibrarySnapshot.LoadSnapshot(openFileDialog.FileName);
                }
                catch
                {
                    MessageBox.Show("Nebolo možné načítať súbor");
                }
                RefreshBookTables();
            }
        }
Exemple #7
0
        private void btnBookAdd_Click(object sender, EventArgs e)
        {
            if (tbAuthor.Text.Length > 0 && tbBookName.Text.Length > 0)
            {
                Book newBook = new Book
                {
                    Author = tbAuthor.Text,
                    Name   = tbBookName.Text
                };

                MessageBox.Show("Hotovo");
                tbAuthor.Text   = "";
                tbBookName.Text = "";
                LibrarySnapshot.AddBookToSnapshot(newBook);
                SetUnsavedState();
                RefreshBookTables();
            }
            else
            {
                MessageBox.Show("Všetky polia sú povinné");
            }
        }
Exemple #8
0
        private void btnEditBooks_Click(object sender, EventArgs e)
        {
            List <int> booksIds = new List <int>();//extract Identifiers

            foreach (DataGridViewRow row in gvAllBooks.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells["Id"].Value);
                booksIds.Add(id);
            }
            var books = LibrarySnapshot.GetAllBooks(UsersSnapshot);

            List <Book> selectedBooks = (from b in books where booksIds.Contains(b.Id) select b).ToList();


            bookEditor = new WindowEditBook
            {
                LibrarySnapshot = LibrarySnapshot,
                Books           = selectedBooks
            };
            bookEditor.ShowDialog();
            SetUnsavedState();
            RefreshBookTables();
        }