Exemplo n.º 1
0
        // Optional: sort (default is rider_last)
        public List<RiderItem> GetRiderItemList(RiderSort sort = RiderSort.Default)
        {
            // Case statment for sort column
            string sortString;
            switch (sort)
            {
                case RiderSort.Number: sortString = "rider_no"; break;
                case RiderSort.FirstName: sortString = "rider_first, rider_last"; break;
                case RiderSort.BirthDate: sortString = "rider_dob, rider_last"; break;
                default: sortString = "rider_last, rider_first"; break;
            }

            string query = "SELECT rider_no, rider_first, rider_last, rider_dob, phone, email, member, rider_comment FROM [" +
                Year + "_rider] ORDER BY " + sortString + ";";
            SQLiteDataReader reader = DoTheReader(ClubConn, query);
            List<RiderItem> riderItemList = new List<RiderItem>();
            RiderItem item;

            reader = DoTheReader(ClubConn, query);
            while (reader.Read())
            {
                item = new RiderItem();
                item.No = reader.GetInt32(0);
                item.FirstName = reader.GetString(1);
                item.LastName = reader.GetString(2);
                item.Birthdate = StringToDate(reader.GetString(3));
                item.Phone = reader.GetString(4);
                item.Email = reader.GetString(5);
                item.Member = (bool)IntToBool(reader.GetInt32(6));
                item.Comments = reader.GetString(7);
                riderItemList.Add(item);
            }
            reader.Close();
            ClubConn.Close();
            return riderItemList;
        }
Exemplo n.º 2
0
 public void SortRiders(RiderSort sort)
 {
     RiderList = Database.GetRiderItemList(sort);
 }