Exemple #1
0
        private void menuBtnExport_Click(object sender, EventArgs e)
        {
            var saveDialog = new SaveFileDialog();

            saveDialog.Filter = "Datový súbor(*.xml)|*.xml";
            saveDialog.ShowDialog();
            if (saveDialog.FileName != "")
            {
                UsersSnapshot.SaveSnapshotToFile(saveDialog.FileName);
            }
        }
Exemple #2
0
        private void RefreshBookTables()
        {
            List <pBook> books     = null;
            List <pBook> freeBooks = null;
            List <pBook> myBooks   = null;

            UsersSnapshot.LoadFromSnapshot();

            try
            {
                books = pBook.GetBooks(LibrarySnapshot, UsersSnapshot);
                gvAllBooks.AutoGenerateColumns = true;
                gvAllBooks.DataSource          = books;
                gvAllBooks.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

                gvAllBooks.CellContentClick += AllBooksGridClick;

                freeBooks = pBook.GetAvailableBooks(LibrarySnapshot, UsersSnapshot);
                gvAvailBooks.AutoGenerateColumns = true;
                gvAvailBooks.DataSource          = freeBooks;


                myBooks = pBook.GetBookByBorrow(CurrentUser, LibrarySnapshot, UsersSnapshot);
                gvMyBooks.AutoGenerateColumns = true;
                gvMyBooks.DataSource          = myBooks;
            }
            catch (Exception e)
            {
                var result = MessageBox.Show("Databáza kníh je nedostupná. Prajete si vytvoriť novú?", "Chyba", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    Book.InitLibrary();
                }
                else
                {
                    Application.Exit();
                }
            }
        }
Exemple #3
0
        private void menuBtnImport_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Datový súbor(*.xml)|*.xml";
            openFileDialog.ShowDialog();
            if (openFileDialog.FileName != "")
            {
                try
                {
                    UsersSnapshot.LoadXmlStreamSnapshot(openFileDialog.FileName); // load users from file to snapshot memory
                    UsersSnapshot.GetUsers();
                }
                catch
                {
                    MessageBox.Show("Nebolo možné načítať súbor");
                }
            }


            RefreshBookTables();
        }