示例#1
0
文件: Verse.cs 项目: rowan84/BibleApp
 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
        /*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();

            }
        }
示例#3
0
文件: Bible.cs 项目: rowan84/BibleApp
 public Bible(Translation translation)
 {
     this.translation = translation;
     loadBible();
 }