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>
        ///     The OnSaveBookRecordButton_Clicked
        ///     If not series save book title.
        ///     If series save book title, book series name, book volume number.
        /// </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="System.EventArgs" />Instance containing the event data.</param>
        private void OnSaveBookRecordButton_Clicked(object sender, EventArgs e)
        {
            _msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var clsOutput = new OutputClass();

            var filePath = BookListPathsProperties.PathOfCurrentWorkingFile;

            if (!chkSeries.Checked)
            {
                clsOutput.WriteAuthorsTitlesToFile(filePath);
                return;
            }

            var seriesOp = new SeriesOperationsClass();

            var bookInfo = seriesOp.FormatBookSeriesData(txtSeries.Text, txtTitle.Text, txtVolume.Text);


            var bookTitle = txtTitle.Text.Trim();
            var retVal    = CheckThatAuthorsFileDoesNotContainThisBookTitle(filePath, bookTitle);


            if (retVal)
            {
                _msgBox.Msg = "This book title is all ready contained in the authors file.";
                _msgBox.ShowInformationMessageBox();
                return;
            }

            if (clsOutput.WriteAuthorsTitlesSeriesToFile(filePath, bookInfo))
            {
                _msgBox.Msg = "The book title and series information have been successfully saved. ";
                _msgBox.ShowInformationMessageBox();
            }
        }