Exemple #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 first record.</summary>
        private void MoveToFirstRecord()
        {
            var coll = new global::BookList.Collections.BookDataCollection();

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

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

            _position = BookDataProperties.NumberOfItems + 1;

            this.DisplayRecordCountAndPosition();
        }
Exemple #3
0
        /// <summary>
        /// Book not series format title and replace original title with new
        /// title.
        /// </summary>
        private void NotSeriesFormatTitleOnly()
        {
            var sb = new StringBuilder();

            sb.Append(BookDataProperties.BookTitleName);
            sb.Append("*");

            txtBookInfo.Text = BookDataProperties.BookTitleName;

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

            coll.RemoveItemAt(BookDataProperties.NumberOfItems);
            coll.AddItem(sb.ToString());
            coll.SortCollection();

            txtTitle.Text = string.Empty;
        }
        /// <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();
        }
Exemple #5
0
        /// <summary>
        /// Are the series format book information.
        /// <see cref="DataFormats.Format"/> the series name of the book by
        /// surrounding it with parentheses.
        /// </summary>
        private void IsSeriesFormatBookInformation()
        {
            var sb = new StringBuilder();

            sb.Append(BookDataProperties.BookTitleName);
            sb.Append(" ");
            sb.Append("(");
            sb.Append(BookDataProperties.NameOfBookSeries);
            sb.Append(")");
            sb.Append(" ");
            sb.Append(BookDataProperties.BookSeriesVolumeNumber);

            txtBookInfo.Text = sb.ToString();

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

            coll.RemoveItemAt(BookDataProperties.NumberOfItems);
            coll.AddItem(sb.ToString());

            BookDataProperties.NameOfBookSeries = string.Empty;
            BookDataProperties.BookTitleName    = string.Empty;
        }
Exemple #6
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;
        }