コード例 #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();
        }
コード例 #2
0
        /// <summary>Called when [format book information 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 OnFormatBookInformationButton_Click(object sender, EventArgs e)
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;
            var validate = new ValidationClass();

            if (!this.rbtnIsSeries.Checked && !this.rbtnNotSeries.Checked)
            {
                this._msgBox.Msg = "You must select if book is series or not series.";
                this._msgBox.ShowErrorMessageBox();
                return;
            }

            var temp = this.txtData.Text.Trim();

            if (string.IsNullOrEmpty(temp))
            {
                return;
            }

            if (BookDataProperties.BookSeries)
            {
                if (validate.ValidateBookSeriesIsFormatted(this.txtData.Text))
                {
                    return;
                }
            }
            else if (!BookDataProperties.BookSeries &&
                     validate.ValidateBookNotSeriesIsFormatted(this.txtData.Text))
            {
                return;
            }

            BookDataProperties.UnformattedBookInformation = temp;

            using (var dlg = new UnformattedBookDataWin())
            {
                this._result = dlg.ShowDialog();
            }

            if (this._result == DialogResult.OK)
            {
                this.ReloadBookTitles();
            }
            this.btnFirst.PerformClick();
        }