예제 #1
0
        static public ObservableCollection <GardenEvent> SelectGardenEvents(Section section, int month, int year)
        {
            ObservableCollection <GardenEvent> gardenEvents = new ObservableCollection <GardenEvent>();

            PSQL.Connect();
            using (NpgsqlCommand command = new NpgsqlCommand(string.Format("SELECT * FROM events WHERE id_section = {0} AND EXTRACT(MONTH FROM date) = {1} AND EXTRACT(YEAR FROM date) = {2} ORDER BY id", section.ID, month, year), PSQL.Connection))
            {
                NpgsqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    gardenEvents.Add(new GardenEvent((int)reader["ID"],
                                                     (int)reader["ID_section"],
                                                     (DateTime)reader["Date"],
                                                     (int[])reader["ID_children"]));
                }
            }
            PSQL.Disconnect();
            return(gardenEvents);
        }
예제 #2
0
        static public ObservableCollection <GardenEvent> SelectGardenEvents()
        {
            ObservableCollection <GardenEvent> gardenEvents = new ObservableCollection <GardenEvent>();

            PSQL.Connect();
            using (NpgsqlCommand command = new NpgsqlCommand("SELECT * FROM events ORDER BY id", PSQL.Connection))
            {
                NpgsqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    gardenEvents.Add(new GardenEvent((int)reader["ID"],
                                                     (int)reader["ID_section"],
                                                     (DateTime)reader["Date"],
                                                     (int[])reader["ID_children"]));
                }
            }
            PSQL.Disconnect();
            return(gardenEvents);
        }
예제 #3
0
        static public ObservableCollection <Child> SelectChildren()
        {
            ObservableCollection <Child> children = new ObservableCollection <Child>();

            PSQL.Connect();
            using (NpgsqlCommand command = new NpgsqlCommand("SELECT * FROM children WHERE status = 1 ORDER BY id", PSQL.Connection))
            {
                NpgsqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    children.Add(new Child((int)reader["ID"],
                                           (string)reader["LastName"],
                                           (string)reader["FirstName"],
                                           (string)reader["Patronymic"],
                                           (int)reader["Status"],
                                           (int[])reader["Presences"]));
                }
            }
            PSQL.Disconnect();
            return(children);
        }