Beispiel #1
0
        public List <DailyTaskDAO> GetActiveTasks(UserDAO patient)
        {
            List <DailyTaskDAO> results = new List <DailyTaskDAO>();

            patient.Find();

            if (!patient.UserClass.Equals("Patient"))
            {
                return(null);
            }

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

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

            myConnection.Open();

            OdbcDataReader myReader;

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

                    if (myReader.GetString(0).Equals("WalkingTask"))
                    {
                        temp = new WalkingTaskDAO();
                        temp.m_idDailyTask = myReader.GetInt32(1);
                    }

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

                    temp.Find();

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

            return(results);
        }
Beispiel #2
0
        // Main begins program execution.
        static void Main()
        {
            // Write to console
            Console.WriteLine("Welcome to the C# Station Tutorial!");


            //Check to see if the user "bh673" exists in the database.
            UserDAO u = new UserDAO();

            u.Username = "******";
            if (u.Find())
            {
                //The record was found.
                Console.WriteLine("User's record was found.");
            }

            if (u.Password.Equals("password"))
            {
                //Check to see if the user's password equals the provided password: "******"
                Console.WriteLine("Password was Correct!");
            }


            //Obtain a list of daily tasks, for the user "bh673".
            DailyTaskDAO        dtd = new DailyTaskDAO();
            List <DailyTaskDAO> res = dtd.GetActiveTasks(u);

            //List the number of steps for each of the walking tasks.
            List <DailyTaskDAO> .Enumerator t = res.GetEnumerator();
            while (t.MoveNext())
            {
                Console.WriteLine("Steps: " + (t.Current as WalkingTaskDAO).Steps);
            }

            //Add a Statistics record to the database.
            WalkingStatsDAO s = new WalkingStatsDAO();

            s.idDailyTask   = 1;
            s.StartDateTime = new DateTime(2007, 12, 25);
            s.EndDateTime   = new DateTime(2008, 1, 1);
            s.Steps         = 550;
            Console.WriteLine("Insert: " + s.Insert());

            //Pause
            Console.WriteLine("I executed.");
        }
Beispiel #3
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);
        }
        // Main begins program execution.
        static void Main()
        {
            // Write to console
            Console.WriteLine("Welcome to the C# Station Tutorial!");

            //Check to see if the user "bh673" exists in the database.
            UserDAO u = new UserDAO();
            u.Username = "******";
            if (u.Find())
                //The record was found.
                Console.WriteLine("User's record was found.");

            if (u.Password.Equals("password"))
                //Check to see if the user's password equals the provided password: "******"
                Console.WriteLine("Password was Correct!");

            //Obtain a list of daily tasks, for the user "bh673".
            DailyTaskDAO dtd = new DailyTaskDAO();
            List<DailyTaskDAO> res = dtd.GetActiveTasks(u);

            //List the number of steps for each of the walking tasks.
            List<DailyTaskDAO>.Enumerator t = res.GetEnumerator();
            while (t.MoveNext())
                Console.WriteLine("Steps: " + (t.Current as WalkingTaskDAO).Steps);

            //Add a Statistics record to the database.
            WalkingStatsDAO s = new WalkingStatsDAO();
            s.idDailyTask = 1;
            s.StartDateTime = new DateTime(2007, 12, 25);
            s.EndDateTime = new DateTime(2008, 1, 1);
            s.Steps = 550;
            Console.WriteLine("Insert: " + s.Insert());

            //Pause
            Console.WriteLine("I executed.");
        }