Пример #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string keyWord = tbSearchBar.Text;

            if (!string.IsNullOrWhiteSpace(keyWord))
            {
                try
                {
                    listBoxShowLibrary.Items.Clear();
                    List <PaperWork> result = Helper.Search(keyWord, libraryInstance);
                    for (int i = 0; i < result.Count; i++)
                    {
                        if (result[i] is Fiction)
                        {
                            Fiction fiction = (Fiction)result[i];
                            listBoxShowLibrary.Items.Add(fiction);
                            //listBoxShowLibrary.Items.Add(fiction.Title + " by " + fiction.Authors + Environment.NewLine);
                        }
                        else if (result[i] is Newspaper)
                        {
                            Newspaper newspaper = (Newspaper)result[i];
                            listBoxShowLibrary.Items.Add(newspaper);
                            //listBoxShowLibrary.Items.Add(newspaper.Title + ", " + newspaper.Type + ", with topic " + Environment.NewLine);
                        }
                        else if (result[i] is Magazine)
                        {
                            Magazine magazine = (Magazine)result[i];
                            listBoxShowLibrary.Items.Add(magazine);
                            //listBoxShowLibrary.Items.Add(magazine.Title + " with topic " + magazine.Topic + Environment.NewLine);
                        }
                        else if (result[i] is ScientificArticle)
                        {
                            ScientificArticle sciArt = (ScientificArticle)result[i];
                            listBoxShowLibrary.Items.Add(sciArt);
                            //listBoxShowLibrary.Items.Add(sciArt.Title + " by " + sciArt.Authors + " with field " + sciArt.ScientificFiled + Environment.NewLine);
                        }
                        else if (result[i] is TechnicalLiterature)
                        {
                            TechnicalLiterature techLit = (TechnicalLiterature)result[i];
                            listBoxShowLibrary.Items.Add(techLit);
                            //listBoxShowLibrary.Items.Add(techLit.Title + " by " + techLit.Authors + " with field " + techLit.ScientificField + Environment.NewLine);
                        }
                    }
                }
                catch (NullReferenceException)
                {
                    MessageBox.Show("There isn't any library loaded yet!");
                    tbSearchBar.Clear();
                }
                catch (ArgumentNullException)
                {
                    MessageBox.Show("There were no results");
                }
            }
            else
            {
                MessageBox.Show("The search bar is empty!");
            }
        }
Пример #2
0
        private void listBoxShowLibrary_MouseDoubleClick(object sender, EventArgs e)
        {
            if (listBoxShowLibrary.SelectedItem is Fiction)
            {
                Fiction        fiction = (Fiction)listBoxShowLibrary.SelectedItem;
                AddFictionForm aff     = new AddFictionForm()
                {
                    ISBNValue            = fiction.ISBN,
                    TitleValue           = fiction.Title,
                    LanguageValue        = fiction.Language,
                    PublisherValue       = fiction.Publishers,
                    ReleaseDateValue     = fiction.ReleaseDate.ToString(),
                    AuthorValue          = fiction.Authors,
                    PageCountValue       = fiction.PageCount.ToString(),
                    EditionNumberValue   = fiction.EditionNumber.ToString(),
                    CoverTypeValue       = fiction.CoverType,
                    GenreValue           = fiction.Genre,
                    AudienceValue        = fiction.Audience,
                    CopiesAvailableValue = fiction.CopiesAvailable.ToString()
                };
                aff.btnAddArticle.Hide();
                aff.Show();
            }
            else if (listBoxShowLibrary.SelectedItem is Newspaper)
            {
                Newspaper        newspaper = (Newspaper)listBoxShowLibrary.SelectedItem;
                AddNewspaperForm anf       = new AddNewspaperForm()
                {
                    ISBNValue            = newspaper.ISBN,
                    TitleValue           = newspaper.Title,
                    LanguageValue        = newspaper.Language,
                    PublisherValue       = newspaper.Publishers,
                    YearPublishedValue   = newspaper.Year.ToString(),
                    EditionNumberValue   = newspaper.EditionNumber.ToString(),
                    TypeValue            = newspaper.Type,
                    EditorValue          = newspaper.Editor,
                    TopicValue           = newspaper.MainTopicForTheEdition,
                    CopiesAvailableValue = newspaper.CopiesAvailable.ToString()
                };
                anf.btnAddNewspaper.Hide();
                anf.Show();
            }
            else if (listBoxShowLibrary.SelectedItem is Magazine)
            {
                Magazine magazine = (Magazine)listBoxShowLibrary.SelectedItem;

                AddMagazineForm amf = new AddMagazineForm()
                {
                    ISBNValue             = magazine.ISBN,
                    TitleValue            = magazine.Title,
                    LanguageValue         = magazine.Language,
                    PublisherValue        = magazine.Publishers,
                    YearPublishedValue    = magazine.Year.ToString(),
                    EditionNumberValue    = magazine.EditionNumber.ToString(),
                    TopicValue            = magazine.Topic,
                    AuthorValue           = magazine.Authors,
                    CoverDescriptionValue = magazine.FrontCoverDescription,
                    CopiesAvailableValue  = magazine.CopiesAvailable.ToString()
                };
                amf.btnAddMagazine.Hide();
                amf.Show();
            }
            else if (listBoxShowLibrary.SelectedItem is ScientificArticle)
            {
                ScientificArticle article = (ScientificArticle)listBoxShowLibrary.SelectedItem;

                AddScientificArticleForm asaf = new AddScientificArticleForm()
                {
                    ISBNValue                 = article.ISBN,
                    TitleValue                = article.Title,
                    LanguageValue             = article.Language,
                    PublisherValue            = article.Publishers,
                    ReleaseDateValue          = article.ReleaseDate.ToString(),
                    AuthorValue               = article.Authors,
                    PageCountValue            = article.PageCount.ToString(),
                    ScientificFieldValue      = article.ScientificFiled,
                    RecomendedLiteratureValue = article.RecomendedLiterature,
                    CopiesAvailableValue      = article.CopiesAvailable.ToString()
                };
                asaf.btnAddArticle.Hide();
                asaf.Show();
            }
            else if (listBoxShowLibrary.SelectedItem is TechnicalLiterature)
            {
                TechnicalLiterature techLit = (TechnicalLiterature)listBoxShowLibrary.SelectedItem;

                AddTechnicalLiteratureForm atlf = new AddTechnicalLiteratureForm()
                {
                    ISBNValue            = techLit.ISBN,
                    TitleValue           = techLit.Title,
                    LanguageValue        = techLit.Language,
                    PublisherValue       = techLit.Publishers,
                    ReleaseDateValue     = techLit.ReleaseDate.ToString(),
                    AuthorValue          = techLit.Authors,
                    PageCountValue       = techLit.PageCount.ToString(),
                    EditionNumberValue   = techLit.EditionNumber.ToString(),
                    CoverTypeValue       = techLit.CoverType,
                    ScientificFieldValue = techLit.ScientificField,
                    AudienceLevelValue   = techLit.AudienceLevel,
                    CopiesAvailableValue = techLit.CopiesAvailable.ToString()
                };
                atlf.btnAddTechLit.Hide();
                atlf.Show();
            }
        }