/// <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> /// Called when [series button click]. Set the is series property to /// <see langword="true"/> for series or <see langword="false"/> for not /// a 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 OnSeriesButton_Click(object sender, EventArgs e) { var validate = new ValidationClass(); var len = txtSeries.SelectionLength; if (len <= 0) { return; } GetSelectedSeriesText(); if (string.IsNullOrEmpty(BookDataProperties.NameOfBookSeries)) { return; } txtSeries.Enabled = true; txtSeries.Text = BookDataProperties.NameOfBookSeries; // If the title and series name match then exit operation. if (validate.ValidateTitleSeriesTextDoesNotMatch()) { var msgBox = new MyMessageBoxClass(); msgBox.Msg = "The book title name can not be the same as the book series name."; msgBox.ShowErrorMessageBox(); return; } lblInfo.Text = "SelectVolumeNumber"; btnVolume.Enabled = true; }
/// <summary>Called when [ok 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 OnOKButton_Clicked(object sender, EventArgs e) { var coll = new BookDataCollection(); BookListPathsProperties.AuthorsNameCurrent = lblAuthor.Text; var clsComb = new CombinePathsClass(); var filePath = clsComb.CombineDirectoryPathWithFileName(BookListPathsProperties.PathAuthorsDirectory, BookListPathsProperties.AuthorsNameCurrent); var valid = new ValidationClass(); var msgBox = new MyMessageBoxClass(); if (!valid.ValidateStringHasLength(filePath)) { msgBox.Msg = "Unable to complete the operation."; msgBox.ShowErrorMessageBox(); return; } BookListPathsProperties.PathOfCurrentWorkingFile = filePath; coll.ClearCollection(); Close(); }
/// <summary>Called when [volume number button click]. /// Check that volume test does not match title or series text. Place volume name and or number into text box.</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 OnVolumeNumberButton_Click(object sender, EventArgs e) { var validate = new ValidationClass(); var len = txtVolume.SelectionLength; if (len <= 0) { return; } GetSelectedBookVolumeText(); if (string.IsNullOrEmpty(BookDataProperties.BookSeriesVolumeNumber)) { return; } txtVolume.Enabled = true; txtVolume.Text = BookDataProperties.BookSeriesVolumeNumber; if (validate.ValidateTitleVolumeTextDoesNotMatch()) { var msgBox = new MyMessageBoxClass(); msgBox.Msg = "The book title name can not be the same as the book volume."; msgBox.ShowErrorMessageBox(); return; } if (validate.ValidateSeriesVolumeTextDoesNotMatch()) { var msgBox = new MyMessageBoxClass(); msgBox.Msg = "The book series name can not be the same as the book volume."; msgBox.ShowErrorMessageBox(); return; } btnFormat.Enabled = true; }
/// <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(); }