コード例 #1
0
ファイル: ClassDb.cs プロジェクト: kbrimm/TrotTrax
        public ClassItem GetClassItem(int classNo)
        {
            // Construct and execute the query
            SQLiteCommand query = new SQLiteCommand();
            query.CommandText = "SELECT class_no, category_no, class_name, fee FROM [" + Year +
                "_class] WHERE class_no = @noparam;";
            query.CommandType = System.Data.CommandType.Text;
            query.Parameters.Add(new SQLiteParameter("@noparam", classNo));
            query.Connection = ClubConn;
            SQLiteDataReader reader = DoTheReader(query);

            // Read the results
            ClassItem item = new ClassItem();
            while (reader.Read())
            {
                item.No = reader.GetInt32(0);
                item.CatNo = reader.GetInt32(1);
                item.Name = reader.GetString(2);
                item.Fee = reader.GetDecimal(3);
            }
            reader.Close();
            ClubConn.Close();
            return item;
        }
コード例 #2
0
ファイル: DbDriver.cs プロジェクト: kbrimm/TrotTrax
        //Optional: sort (default is class_name)
        public List<ClassItem> GetClassItemList(string database, int year, string sort)
        {
            MySqlDataReader reader;
            ClassItem item;
            List<ClassItem> classItemList = new List<ClassItem>();

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

            reader = GetReader(database, year + "_class", "class_no, category_no, class_name, fee", String.Empty, sort);
            while (reader.Read())
            {
                item = new ClassItem();
                item.no = reader.GetInt32(0);
                item.catNo = reader.GetInt32(1);
                item.name = reader.GetString(2);
                item.fee = reader.GetDecimal(3);

                classItemList.Add(item);
            }
            reader.Close();
            connection.Close();
            return classItemList;
        }
コード例 #3
0
ファイル: DbDriver.cs プロジェクト: kbrimm/TrotTrax
        public ClassItem GetClassItem(string database, int year, int classNo)
        {
            MySqlDataReader reader;
            ClassItem item = new ClassItem();

            reader = GetReader(database, year + "_class", "class_no, category_no, class_name, fee", "class_no=" + classNo, "class_no");
            while(reader.Read())
            {
                item.no = reader.GetInt32(0);
                item.catNo = reader.GetInt32(1);
                item.name = reader.GetString(2);
                item.fee = reader.GetDecimal(3);
            }
            reader.Close();
            connection.Close();
            return item;
        }
コード例 #4
0
ファイル: ClassDb.cs プロジェクト: kbrimm/TrotTrax
        //Optional: sort (default is class_no)
        public List<ClassItem> GetClassItemList(ClassSort sort = ClassSort.Default)
        {
            // Case statment for sort column
            string sortString;
            switch (sort)
            {
                case ClassSort.Name: sortString = "class_name"; break;
                case ClassSort.Category: sortString = "category_no"; break;
                default: sortString = "class_no"; break;
            }

            // Construct and execute the query
            string query = "SELECT class_no, category_no, class_name, fee FROM [" + Year +
                "_class] ORDER BY " + sortString + ";";
            SQLiteDataReader reader = DoTheReader(ClubConn, query);
            List<ClassItem> classItemList = new List<ClassItem>();
            ClassItem item;

            // Read the results
            reader = DoTheReader(ClubConn, query);
            while (reader.Read())
            {
                item = new ClassItem();

                item.No = reader.GetInt32(0);
                item.CatNo = reader.GetInt32(1);
                item.Name = reader.GetString(2);
                item.Fee = reader.GetDecimal(3);

                classItemList.Add(item);
            }
            reader.Close();
            ClubConn.Close();
            return classItemList;
        }