Ejemplo n.º 1
0
        public Meaning findById(int id)
        {
            try
            {
                Program.conn.Open();    // Open new connection
                SQLiteCommand    cmd     = new SQLiteCommand("SELECT * FROM meaning WHERE id = " + id, Program.conn);
                SQLiteDataReader reader  = cmd.ExecuteReader();
                Meaning          meaning = new Meaning();
                IWordDAO         wordDao = new WordDAO();

                while (reader.Read())
                {
                    meaning = new Meaning(reader.GetInt32(0), reader.GetString(2), wordDao.findById(reader.GetInt32(1)));
                }

                return(meaning);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} Exception caught.", ex);
                return(null);
            }
            finally
            {
                Program.conn.Close();   // Close connection
            }
        }
Ejemplo n.º 2
0
        public StringBuilder getMeaningByID(int id)
        {
            IWordDAO      wordDao = new WordDAO();
            StringBuilder strb    = new StringBuilder();

            try
            {
                Program.conn.Open();    // Open new connection
                SQLiteCommand    cmd    = new SQLiteCommand("select * from meaning where word = " + id, Program.conn);
                SQLiteDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    strb.Append("- ").Append(reader.GetString(2) + "\r\n");
                }

                return(strb);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} Exception caught.", ex);
                return(null);
            }
            finally
            {
                Program.conn.Close();   // Close connection
            }
        }
Ejemplo n.º 3
0
        public ObservableCollection <Meaning> getAll()
        {
            IWordDAO wordDao = new WordDAO();
            ObservableCollection <Meaning> meanings = new ObservableCollection <Meaning>();

            try
            {
                Program.conn.Open();    // Open new connection
                SQLiteCommand    cmd    = new SQLiteCommand("SELECT * FROM meaning", Program.conn);
                SQLiteDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    meanings.Add(new Meaning(reader.GetInt32(0), reader.GetString(2), wordDao.findById(reader.GetInt32(1))));
                }

                return(meanings);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} Exception caught.", ex);
                return(null);
            }
            finally
            {
                Program.conn.Close();   // Close connection
            }
        }