Beispiel #1
0
        /// <summary>
        /// Called when [save changes button click]. Save the changes made on
        /// the book information.
        /// </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 OnSaveChangesButton_Click(object sender, EventArgs e)
        {
            var fileOutput = new OutputClass();

            var validate = new ValidationClass();

            var msgBox = new MyMessageBoxClass();


            msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var coll = new global::BookList.Collections.BookDataCollection();

            if (coll.GetItemsCount() < 1)
            {
                return;
            }
            if (string.IsNullOrEmpty(txtTitle.Text.Trim()))
            {
                return;
            }

            if (BookDataProperties.BookSeries)
            {
                if (!validate.ValidateBookSeriesIsFormatted(txtBookInfo.Text))
                {
                    return;
                }
                if (!fileOutput.WriteBookTitleSeriesVolumeNamesToAuthorsFile(BookListPathsProperties
                                                                             .PathToCurrentAuthorsFile))
                {
                    msgBox.Msg = "Failed to complete save. Check over data and try again.";

                    msgBox.ShowErrorMessageBox();

                    return;
                }
            }

            if (!validate.ValidateBookNotSeriesIsFormatted(txtBookInfo.Text))
            {
                return;
            }

            if (!fileOutput.WriteAuthorsTitlesToFile(BookListPathsProperties.PathToCurrentAuthorsFile))
            {
                msgBox.Msg = "Failed to complete save. Check over data and try again.";
                msgBox.ShowErrorMessageBox();
                return;
            }

            ControlsStateAfterSuccessfulSave();
        }
        /// <summary>Moves to last record.</summary>
        private void MoveToLastRecord()
        {
            var coll = new global::BookList.Collections.BookDataCollection();

            if (coll.GetItemsCount() == 0)
            {
                return;
            }

            if (BookDataProperties.NumberOfItems + 1 > coll.GetItemsCount())
            {
                return;
            }

            BookDataProperties.NumberOfItems = coll.GetItemsCount() - 1;

            this.txtData.Text = coll.GetItemAt(BookDataProperties.NumberOfItems);

            _position = coll.GetItemsCount();

            this.DisplayRecordCountAndPosition();
        }
        /// <summary>Loads the book titles and info for the selected artist to a collection.</summary>
        private void LoadUnformattedData()
        {
            var fileInput = new InputClass();

            this.GetUnformattedDataFrom();

            if (string.IsNullOrEmpty(BookListPathsProperties.PathToCurrentAuthorsFile))
            {
                return;
            }

            fileInput.ReadTitlesFromFileLoop(BookListPathsProperties.PathToCurrentAuthorsFile);

            var coll = new global::BookList.Collections.BookDataCollection();

            _totalCount = coll.GetItemsCount();
        }
Beispiel #4
0
        /// <summary>
        /// Called when [format book information button click].
        /// <see cref="DataFormats.Format"/> the book information for series or
        /// nto series.
        /// </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 OnFormatBookInformationButton_Click(object sender, EventArgs e)
        {
            var coll = new global::BookList.Collections.BookDataCollection();

            if (coll.GetItemsCount() < 1)
            {
                return;
            }

            if (string.IsNullOrEmpty(txtTitle.Text.Trim()))
            {
                return;
            }

            if (!BookDataProperties.BookSeries)
            {
                NotSeriesFormatTitleOnly();
                btnSave.Enabled = true;
                return;
            }

            IsSeriesFormatBookInformation();
            btnSave.Enabled = true;
        }