示例#1
0
        /// <summary>
        /// If this is a Patient class record, find and return all the Active daily tasks associated with this record.
        /// </summary>
        /// <returns>A list of DailyTaskDAOs which represent the patient's active daily tasks. If the patient was not found, then an empty list is returned. If there was an error, null is returned. Note, the objects in the list will be derived classes of DailyTaskDAO and not DailyTaskDAO objects.</returns>
        public List <DailyTaskDAO> GetActiveTasks()
        {
            List <DailyTaskDAO> results = new List <DailyTaskDAO>();

            string myQueryStr = "select DailyTaskClass, idDailyTask from DailyTask where active=true and idPatient=" + m_idNumber;

            OdbcConnection myConnection = GetConnection();
            OdbcCommand    myCommand    = new OdbcCommand(myQueryStr, myConnection);

            myConnection.Open();

            OdbcDataReader myReader;

            myReader = myCommand.ExecuteReader();
            try
            {
                while (myReader.Read())
                {
                    DailyTaskDAO temp = null;

                    WalkingTaskDAO wtd        = new WalkingTaskDAO();
                    Type           typeofTask = Type.GetType("Server." + myReader.GetString(0) + "DAO", true);
                    temp = (DailyTaskDAO)(Activator.CreateInstance(typeofTask));

                    temp.idDailyTask = myReader.GetInt32(1);

                    if (temp == null)
                    {
                        return(null);
                    }

                    temp.Find();

                    results.Add(temp);
                }
            }
            finally
            {
                myReader.Close();
                myConnection.Close();
            }

            return(results);
        }