private void showChapterView_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e) { LibraryDataSet.ChapterRow chapterRow = viewChapters.GetFocusedDataRow() as LibraryDataSet.ChapterRow; if (chapterRow == null) { return; } chapterRow.BookRow = bkr; }
private LibraryDataSet.ChapterRow MakeChapterRow(LibraryDataSet.ChapterRow chr, int bkId) { LibraryDataSet.ChapterRow nchr = lds.Chapter.NewChapterRow(); nchr.Title = chr.Title; nchr.StartPage = chr.StartPage; nchr.EndPage = chr.EndPage; nchr.BookRow = lds.Book.FindById(bkId) as LibraryDataSet.BookRow; nchr.IdBook = bkId; return(nchr); }
public static Boolean checkChapterData(LibraryDataSet.ChapterRow chapter) { try { if (!checkChapterTitle(chapter.Title) || !checkChapterPages(chapter.StartPage.ToString(), chapter.EndPage.ToString())) { MessageBox.Show("Chapter " + chapter.Title + " is not valid"); return(false); } } catch (StrongTypingException) { MessageBox.Show("Chapter is not valid"); return(false); } return(true); }
private void Ok_Click_1(object sender, EventArgs e) { if (!CheckData.checkBookData(txtTitle.Text, txtPublisher.Text, txtYear.Text, lookUpAuthor.Text)) { return; } else { LibraryDataSet.BookRow bookRow = AddBookRow(); foreach (LibraryDataSet.ChapterRow chr in ds.Chapter.Rows) { if (CheckData.checkChapterData(chr)) { LibraryDataSet.ChapterRow nchr = MakeChapterRow(chr, bookRow.Id); lds.Chapter.AddChapterRow(nchr); } } } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }