Example #1
0
        public IList <PlanHistory> getHistory()
        {
            string connectionString = "Data Source=FORLOGIC357;Initial Catalog=PLANNER;" +
                                      "Integrated Security=True";

            string sqlQuery = "SELECT * FROM plan_history";

            PlanStatusDAO psDAO   = new PlanStatusDAO();
            PlanDAO       planDAO = new PlanDAO();

            using (SqlConnection connection =
                       new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(sqlQuery, connection);

                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        Plan       p  = planDAO.getOnePlan((int)reader[1]);
                        PlanStatus ps = psDAO.getOneStatus((int)reader[2]);

                        PlanHistory ph = new PlanHistory((int)reader[0], p, ps, (DateTime)reader[3]);

                        this.planHistoryList.Add(ph);
                    }
                    reader.Close();
                    return(this.planHistoryList);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return(this.planHistoryList);
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Example #2
0
        public IList <PlanStakeholder> getByPlanId(int id)
        {
            string connectionString = "Data Source=FORLOGIC357;Initial Catalog=PLANNER;" +
                                      "Integrated Security=True";

            string sqlQuery = "SELECT * FROM plan_interested_user WHERE id_plan = @id";


            PlanStakeholder psk     = null;
            UserDAO         userDAO = new UserDAO();
            PlanDAO         planDAO = new PlanDAO();

            using (SqlConnection connection =
                       new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(sqlQuery, connection);
                command.Parameters.AddWithValue("@id", id);

                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        psk = new PlanStakeholder((int)reader[0], planDAO.getOnePlan((int)reader[1]), userDAO.getResponsible((int)reader[2]));
                        planStakeList.Add(psk);
                    }
                    reader.Close();
                    return(this.planStakeList);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return(this.planStakeList);
                }
                finally
                {
                    connection.Close();
                }
            }
        }