Пример #1
0
        public void DBRead(int gameId, bool readRoms = false)
        {
            if (_commandRvGameRead == null)
            {
                _commandRvGameRead = new SQLiteCommand(@"
                SELECT GameId, DatId, name, description, manufacturer, cloneof, romof, sourcefile, isbios, board, year, istrurip, publisher, developer, edition, version, type, media, language, players, ratings, genre, peripheral, barcode, mediacatalognumber
                    FROM GAME WHERE GameId=@GameId ORDER BY name", Program.db.Connection);
                _commandRvGameRead.Parameters.Add(new SQLiteParameter("GameId"));
            }

            _commandRvGameRead.Parameters["GameId"].Value = gameId;

            using (DbDataReader dr = _commandRvGameRead.ExecuteReader())
            {
                if (dr.Read())
                {
                    RvGameReadFromReader(dr, this);
                }

                dr.Close();
            }

            if (readRoms)
            {
                Roms = RvRom.ReadRoms(GameId);
            }
        }
Пример #2
0
        private void ReadFromReader(SQLiteDataReader dr, bool readRoms = false)
        {
            GameId             = Convert.ToUInt32(dr["GameId"]);
            DatId              = Convert.ToUInt32(dr["DatId"]);
            Name               = dr["name"].ToString();
            Description        = dr["description"].ToString();
            Manufacturer       = dr["manufacturer"].ToString();
            CloneOf            = dr["cloneOf"].ToString();
            RomOf              = dr["romof"].ToString();
            SourceFile         = dr["sourcefile"].ToString();
            IsBios             = dr["isbios"].ToString();
            Board              = dr["board"].ToString();
            Year               = dr["year"].ToString();
            IsTrurip           = Convert.ToBoolean(dr["istrurip"]);
            Publisher          = dr["publisher"].ToString();
            Developer          = dr["developer"].ToString();
            Edition            = dr["edition"].ToString();
            Version            = dr["version"].ToString();
            Type               = dr["type"].ToString();
            Media              = dr["media"].ToString();
            Language           = dr["language"].ToString();
            Players            = dr["players"].ToString();
            Ratings            = dr["ratings"].ToString();
            Genre              = dr["genre"].ToString();
            Peripheral         = dr["peripheral"].ToString();
            BarCode            = dr["barcode"].ToString();
            MediaCatalogNumber = dr["mediacatalognumber"].ToString();

            if (readRoms)
            {
                Roms = RvRom.ReadRoms(GameId);
            }
        }
Пример #3
0
        public static List <RvGame> ReadGames(uint datId, bool readRoms = false)
        {
            if (_commandRvGameReadDatGames == null)
            {
                _commandRvGameReadDatGames = new SQLiteCommand(@"
                SELECT GameId, DatId, name, description, manufacturer, cloneof, romof, sourcefile, isbios, board, year, istrurip, publisher, developer, edition, version, type, media, language, players, ratings, genre, peripheral, barcode, mediacatalognumber
                    FROM GAME WHERE DatId=@DatId ORDER BY name", Program.db.Connection);
                _commandRvGameReadDatGames.Parameters.Add(new SQLiteParameter("DatId"));
            }

            List <RvGame> games = new List <RvGame>();

            _commandRvGameReadDatGames.Parameters["DatId"].Value = datId;

            using (DbDataReader dr = _commandRvGameReadDatGames.ExecuteReader())
            {
                while (dr.Read())
                {
                    RvGame rvGame = new RvGame();
                    RvGameReadFromReader(dr, rvGame);
                    games.Add(rvGame);
                }
                dr.Close();
            }

            if (readRoms)
            {
                foreach (RvGame game in games)
                {
                    game.Roms = RvRom.ReadRoms(game.GameId);
                }
            }

            return(games);
        }