Exemplo n.º 1
0
        public CategoryItem GetCategoryItem(int catNo)
        {
            // Construct and execute the query
            SQLiteCommand query = new SQLiteCommand();
            query.CommandText = "SELECT category_no, category_name, timed FROM [" + Year +
                "_category] WHERE category_no = @noparam;";
            query.CommandType = System.Data.CommandType.Text;
            query.Parameters.Add(new SQLiteParameter("@noparam", catNo));
            query.Connection = ClubConn;
            SQLiteDataReader reader = DoTheReader(query);

            // Read the results
            CategoryItem item = new CategoryItem();
            while (reader.Read())
            {
                item.No = reader.GetInt32(0);
                item.Name = reader.GetString(1);
                item.Timed = (bool)IntToBool(reader.GetInt32(2));
            }
            reader.Close();
            ClubConn.Close();
            return item;
        }
Exemplo n.º 2
0
        // Optional: sort (default is category_no)
        public List<CategoryItem> GetCategoryItemList(string database, int year, string sort)
        {
            MySqlDataReader reader;
            CategoryItem item;
            List<CategoryItem> CatItemList = new List<CategoryItem>();

            if (sort == String.Empty)
                sort = "category_no";

            reader = GetReader(database, year + "_category", "category_no, category_name, timed", String.Empty, sort);
            while (reader.Read())
            {
                item = new CategoryItem();
                item.no = reader.GetInt32(0);
                item.name = reader.GetString(1);
                item.timed = reader.GetBoolean(2);
                CatItemList.Add(item);
            }
            reader.Close();
            connection.Close();
            return CatItemList;
        }
Exemplo n.º 3
0
        public CategoryItem GetCategoryItem(string database, int year, int catNo)
        {
            MySqlDataReader reader;
            CategoryItem item = new CategoryItem();

            reader = GetReader(database, year + "_category", "category_no, category_name, timed", "category_no=" + catNo, "category_no");
            while (reader.Read())
            {
                item.no = reader.GetInt32(0);
                item.name = reader.GetString(1);
                item.timed = reader.GetBoolean(2);
            }
            reader.Close();
            connection.Close();
            return item;
        }
Exemplo n.º 4
0
        // Optional: sort (default is category_no)
        public List<CategoryItem> GetCategoryItemList(CategorySort sort = CategorySort.Default)
        {
            // Case statment for sort column
            string sortString;
            switch (sort)
            {
                case CategorySort.Name: sortString = "category_name"; break;
                case CategorySort.Timed: sortString = "timed"; break;
                default: sortString = "category_no"; break;
            }

            // Construct and execute the query
            string query = "SELECT category_no, category_name, timed FROM [" + Year +
                "_category] ORDER BY " + sortString + ";";
            SQLiteDataReader reader = DoTheReader(ClubConn, query);
            List<CategoryItem> catItemList = new List<CategoryItem>();
            CategoryItem item;

            // Read the results
            while (reader.Read())
            {
                item = new CategoryItem();
                item.No = reader.GetInt32(0);
                item.Name = reader.GetString(1);
                item.Timed = (bool)IntToBool(reader.GetInt32(2));
                catItemList.Add(item);
            }
            reader.Close();
            ClubConn.Close();
            return catItemList;
        }