Пример #1
0
 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;
 }
Пример #2
0
 public Verse getVerse(ref Chapter tmp_chapter, int verse)
 {
     return (Verse)tmp_chapter.getVerse(verse);
 }
Пример #3
0
        /*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();

            }
        }
Пример #4
0
 public void addChapter(ref Chapter chapter)
 {
     chapters.Add(chapter.chapter_id, chapter);
 }
Пример #5
0
        /*this adds the verses to the chapter*/
        public static void addChapterVerses(ref Chapter chapter, ref Translation translation)
        {
            Testament book_test = chapter.testament;
            Book book = chapter.book;
            string sqlQuery = "SELECT Verse, VerseText"
            + " FROM bible WHERE translation = '" + translation.translation_id+ "' AND book ='" + book.id + "'"
            + " AND Chapter = '"+chapter.chapter_id+"' ORDER BY Verse";
            MySqlConnection conn = DBManager.getConnection();
            try
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand(sqlQuery, conn);
                MySqlDataReader rdr = cmd.ExecuteReader();

                Verse prev_verse = null;
                Verse next_verse = null;
                if (rdr.HasRows)
                {
                    rdr.Read();

                    Verse curr_verse = new Verse(
                                            Int32.Parse((rdr[0]).ToString()),
                                            (rdr[1]).ToString(),
                                            ref book_test,
                                            ref book,
                                            ref chapter,
                                            ref translation);

                    while (curr_verse != null)
                    {
                        //curr_chapter.prev_chapter = prev_chapter;
                        if (rdr.Read())
                        {

                            next_verse = new Verse(
                                            Int32.Parse((rdr[0]).ToString()),
                                            (rdr[1]).ToString(),
                                            ref book_test,
                                            ref book,
                                            ref chapter,
                                            ref translation
                                            );
                            curr_verse.prev_verse = prev_verse;
                            curr_verse.next_verse = next_verse;
                            chapter.addVerse(ref curr_verse);
                            prev_verse = curr_verse;
                            curr_verse = next_verse;
                        }
                        else
                        {
                            curr_verse.prev_verse = prev_verse;
                            curr_verse.next_verse = null;
                            curr_verse.is_last_verse_of_chapter = true;
                            chapter.addVerse(ref curr_verse);
                            break;
                        }

                    }
                }
                rdr.Close();
                conn.Close();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                conn.Close();

            }
        }