Exemple #1
0
        public static Person Load(BdDatabase database, int id)
        {
            string query = PulpBirthday.Resources.Queries.Person.Load;
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("id", id);

            using (FbDataReader reader = database.ExecuteReader(query, parameters))
            {
                Person person = null;
                if (reader.Read())
                {
                    person = new Classes.Person(reader);
                }

                reader.Close();

                if (person == null)
                {
                    throw new ArgumentOutOfRangeException(PulpBirthday.Resources.Message.IdentifierNotFoundError);
                }

                return(person);
            }
        }
Exemple #2
0
        public static List <Person> LoadList(BdDatabase database, DateTime dateFrom, DateTime dateTo,
                                             bool forList, int sortingOrder, string mask)
        {
            string query = PulpBirthday.Resources.Queries.Person.LoadListSortedByName;

            if (sortingOrder == 1)
            {
                query = PulpBirthday.Resources.Queries.Person.LoadListSortedByBirthday;
            }

            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("dateFrom", dateFrom);
            parameters.Add("dateTo", dateTo);
            parameters.Add("isList", forList);
            parameters.Add("mask", mask);

            List <Person> personList = new List <Person>();

            using (FbDataReader reader = database.ExecuteReader(query, parameters))
            {
                while (reader.Read())
                {
                    personList.Add(new Person(reader));
                }

                reader.Close();
            }

            return(personList);
        }