/*this adds the chapters to the book*/ public static void addBookChapters(ref Book book) { string sqlQuery = "SELECT DISTINCT Chapter" + " FROM bible WHERE translation = 1 AND book ='" + book.id + "'"; MySqlConnection conn = DBManager.getConnection(); try { conn.Open(); MySqlCommand cmd = new MySqlCommand(sqlQuery, conn); MySqlDataReader rdr = cmd.ExecuteReader(); Chapter prev_chapter = null; Chapter next_chapter = null; if (rdr.HasRows) { rdr.Read(); Testament book_test = book.testament; Chapter curr_chapter = new Chapter( Int32.Parse((rdr[0]).ToString()), ref book_test, ref book); while (curr_chapter != null) { //curr_chapter.prev_chapter = prev_chapter; if (rdr.Read()) { next_chapter = new Chapter( Int32.Parse((rdr[0]).ToString()), ref book_test, ref book); curr_chapter.prev_chapter = prev_chapter; curr_chapter.next_chapter = next_chapter; book.addChapter(ref curr_chapter); prev_chapter = curr_chapter; curr_chapter = next_chapter; } else { curr_chapter.prev_chapter = prev_chapter; curr_chapter.next_chapter = null; book.addChapter(ref curr_chapter); break; } } } rdr.Close(); conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); conn.Close(); } }
private int num_verses = 0; //we set this once so we dont have to calculate it everytime #endregion Fields #region Constructors public Chapter( int chapter_id, ref Testament testament, ref Book book) { this.chapter_id = chapter_id; this.testament = testament; this.book = book; verses = new Hashtable(); }
public Verse( int verse_id, string text, ref Testament testament, ref Book book, ref Chapter chapter, ref Translation translation ) { this.verse_id = verse_id; this.text = text; this.book = book; this.chapter = chapter; this.next_verse = null; this.prev_verse = null; this.translation = translation; is_last_verse_of_chapter = false; }
public Chapter getChapter(ref Book tmp_book, int chapter) { return (Chapter) tmp_book.getChapter(chapter); }
/*this adds the books to the testament*/ public static void addTestamentBooks(ref Testament testament) { string sqlQuery = "Select id, abbr, testament, name From books WHERE " +" testament ='"+ testament.testament_id+"' Order by id"; MySqlConnection conn = DBManager.getConnection(); try { conn.Open(); MySqlCommand cmd = new MySqlCommand(sqlQuery, conn); MySqlDataReader rdr = cmd.ExecuteReader(); Book prev_book = null; Book next_book = null; if (rdr.HasRows) { rdr.Read(); Book curr_book = new Book( Int32.Parse((rdr[0]).ToString()), rdr[3].ToString(), ((rdr[1]).ToString()), ref testament); while (curr_book != null) { //curr_chapter.prev_chapter = prev_chapter; if (rdr.Read()) { next_book = new Book( Int32.Parse((rdr[0]).ToString()), rdr[3].ToString(), ((rdr[1]).ToString()), ref testament); curr_book.prev_book = prev_book; curr_book.next_book = next_book; testament.addBook(ref curr_book); prev_book = curr_book; curr_book = next_book; } else { curr_book.prev_book = prev_book; curr_book.next_book = null; testament.addBook(ref curr_book); break; } } } /*while (rdr.Read()) { Book aBook = new Book( Int32.Parse((rdr[0]).ToString()), rdr[3].ToString(), ((rdr[1]).ToString()), ref testament); testament.addBook(ref aBook); }*/ rdr.Close(); conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); conn.Close(); } }