/// <summary>
        ///     Called when [select all authors button clicked].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void OnSelectAllAuthorsButton_Clicked(object sender, EventArgs e)
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            BookDataProperties.SetAllAuthorsSearch   = true;
            BookDataProperties.SetSingleAuthorSearch = false;

            var searchStr = this.txtTitle.Text.Trim();

            if (!this._valid.ValidateStringIsNotNull(searchStr))
            {
                return;
            }
            if (!this._valid.ValidateStringHasLength(searchStr))
            {
                return;
            }

            searchStr = searchStr.ToLower();

            BookDataProperties.SetBookTitleSearchString = searchStr;

            var cls1 = new AuthorOperationsClass();

            cls1.FillListWithAuthorsNames();

            cls1.AllAuthorsLoop();
        }
        /// <summary>
        ///     Called when [title search button click].
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void OnTitleSearchSingleAuthorButton_Click(object sender, EventArgs e)
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var searchStr = this.txtTitle.Text.Trim();

            if (!this._valid.ValidateStringIsNotNull(searchStr))
            {
                return;
            }
            if (!this._valid.ValidateStringHasLength(searchStr))
            {
                return;
            }

            BookDataProperties.SetBookTitleSearchString = searchStr;

            var cls1 = new AuthorOperationsClass();

            if (BookDataProperties.SetSingleAuthorSearch)
            {
                cls1.SearchBookTitleBySingleAuthor();
            }
            else if (BookDataProperties.SetAllAuthorsSearch)

            {
                cls1.SearchBookAuthorAllTitles();
            }
        }
        /// <summary>Gets the name of the authors name.</summary>
        /// <param name="fileName">Name of the file.</param>
        private void GetAuthorsName(string fileName)
        {
            var author = new AuthorOperationsClass();

            var clsFile    = new FileClass();
            var authorName = clsFile.RemoveFileExtension(fileName);
        }
Exemple #4
0
        /// <summary>
        ///     <para>
        ///         Initializes a new instance of the <see cref="BookListMainWin" />
        ///     </para>
        ///     <para>class.</para>
        /// </summary>
        public BookListMainWin()
        {
            InitializeComponent();

            var declaringType = MethodBase.GetCurrentMethod().DeclaringType;

            if (declaringType != null)
            {
                _msgBox.NameOfClass = declaringType.Name;
            }

            var authorOp = new AuthorOperationsClass();

            var dirFile = new FileClass();

            var dirClass = new DirectoryClass();

            dirClass.InitializeDirectoryPath();
            dirFile.InitializeFilePaths();
            authorOp.UpdateAuthorsNamesWithFileNames();
        }
        /// <summary>
        ///     Called when [show all titles for author button clicked].
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void OnShowAllTitlesSingleAuthorButton_Clicked(object sender, EventArgs e)
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirAuthors = BookListPathsProperties.PathAuthorsDirectory;

            var cls1     = new CombinePathsClass();
            var filePath =
                cls1.CombineDirectoryPathWithFileName(dirAuthors, BookListPathsProperties.CurrentWorkingFileName);

            var cls2 = new BookDataCollection();

            cls2.ClearCollection();

            var cls3 = new InputClass();

            cls3.ReadTitlesFromFileLoop(filePath);

            var cls4 = new AuthorOperationsClass();

            cls4.ShowAllBookTitlesBySingleAuthorLoop();

            this.lstTiltes.Items.Clear();
        }
        /// <summary>
        ///     The OnSaveRecordButton_Clicked.
        /// </summary>
        /// <param name="sender">
        ///     The source of the event. <see cref="Object" /> The source of the
        ///     event.
        /// </param>
        /// <param name="e">
        ///     The e <see cref="EventArgs" /> Instance containing the event data.
        /// </param>
        private void OnSaveRecordButton_Clicked(object sender, EventArgs e)
        {
            _msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirFileOp = new FileClass();

            var dirAuthors = BookListPathsProperties.PathAuthorsDirectory;

            var authorOp = new AuthorOperationsClass();

            if (!_valid.ValidateStringIsNotNull(dirAuthors))
            {
                return;
            }
            if (!_valid.ValidateStringHasLength(dirAuthors))
            {
                return;
            }
            if (!_valid.ValidateStringHasLength(txtAuthor.Text.Trim()))
            {
                return;
            }
            if (!_valid.ValidateDirectoryExists(dirAuthors))
            {
                return;
            }


            var fileName = authorOp.AddDashBetweenAuthorsFirstMiddleLastName(txtAuthor.Text);

            if (!_valid.ValidateStringHasLength(fileName))
            {
                return;
            }

            var cls      = new CombinePathsClass();
            var filePath = cls.CombineDirectoryPathWithFileName(dirAuthors, fileName);

            if (!_valid.ValidateStringHasLength(filePath))
            {
                return;
            }

            if (_valid.ValidateFileExists(filePath, false))
            {
                _msgBox.Msg = "This file all ready exists.";
                _msgBox.ShowInformationMessageBox();
                return;
            }

            if (dirFileOp.CreateNewFile(filePath))
            {
                _msgBox.Msg = "Author file created successfully.";
                _msgBox.ShowInformationMessageBox();
                BookListPathsProperties.AuthorsNameCurrent       = fileName;
                BookListPathsProperties.PathOfCurrentWorkingFile = filePath;

                AddNewAuthorFileNameToAuthorsList(fileName);

                return;
            }

            BookListPathsProperties.AuthorsNameCurrent       = string.Empty;
            BookListPathsProperties.PathOfCurrentWorkingFile = string.Empty;

            _msgBox.Msg = "Failed to create the file for this author.";
            _msgBox.ShowErrorMessageBox();
        }