예제 #1
0
        public static List <Person> LoadList(BdDatabase database, string mask)
        {
            DateTime Jan1  = new DateTime(2017, 1, 1);
            DateTime Dec31 = new DateTime(2017, 12, 31);

            return(LoadList(database, Jan1, Dec31, false, 0, mask));
        }
예제 #2
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);
            }
        }
예제 #3
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);
        }
예제 #4
0
        public void Delete(BdDatabase database)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("id", Id);

            database.ExecuteQuery(DeleteQuery, parameters);
        }
예제 #5
0
 public void Save(BdDatabase database)
 {
     if (Id == 0)
     {
         InsertDataItem(database);
     }
     else
     {
         UpdateDataItem(database);
     }
 }
예제 #6
0
 private void InsertDataItem(BdDatabase database)
 {
     Id = (int)database.ExecuteScalar(InsertQuery, CreateParameterList());
 }
예제 #7
0
 private void UpdateDataItem(BdDatabase database)
 {
     database.ExecuteQuery(UpdateQuery, CreateParameterList());
 }