/// <summary> /// 获取比赛列表 /// </summary> /// <param name="playId"></param> /// <returns></returns> public List <RemotingInterface.GameInfo> GetGameList(int playId) { SqlConnection sqlConn = new SqlConnection(Common.strConn); if (sqlConn.State == ConnectionState.Closed) { sqlConn.Open(); } try { if (playId == 0) { return(null); } SqlCommand sqlCmd = new SqlCommand("SELECT * FROM [Game] where playId=" + playId + " ORDER BY GameID", sqlConn); SqlDataReader sqlReader = sqlCmd.ExecuteReader(); List <RemotingInterface.GameInfo> listGame = new List <RemotingInterface.GameInfo>(); RemotingInterface.GameInfo gameInfo = new RemotingInterface.GameInfo(); gameInfo.Clear(); while (sqlReader.Read()) { gameInfo.GameId = Convert.ToInt32(sqlReader["GameId"]); gameInfo.PlayId = Convert.ToInt32(sqlReader["PlayId"]); gameInfo.GameName = sqlReader["GameName"].ToString(); gameInfo.GameType = Convert.ToByte(sqlReader["GameType"]); gameInfo.RegDateStart = Convert.ToDateTime(sqlReader["RegDateStart"]); gameInfo.RegDateEnd = Convert.ToDateTime(sqlReader["RegDateEnd"]); gameInfo.GameDateStart = Convert.ToDateTime(sqlReader["GameDateStart"]); gameInfo.GameDateEnd = Convert.ToDateTime(sqlReader["GameDateEnd"]); gameInfo.GameLevel = Convert.ToByte(sqlReader["GameLevel"]); gameInfo.GameState = Convert.ToByte(sqlReader["GameState"]); gameInfo.Description = sqlReader["Description"].ToString(); listGame.Add(gameInfo); Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": Load the Game list : PlayId = " + gameInfo.PlayId + "\t GameId = " + gameInfo.GameId + " \t GameName = " + gameInfo.GameName); } return(listGame); } catch (Exception ex) { Loger.Debug(ex.ToString()); return(null); } finally { if (sqlConn.State != ConnectionState.Closed) { sqlConn.Close(); } } }
/// <summary> /// 获取比赛列表 /// </summary> /// <param name="playId"></param> /// <returns></returns> public List<RemotingInterface.GameInfo> GetGameList(int playId) { SqlConnection sqlConn = new SqlConnection(Common.strConn); if (sqlConn.State == ConnectionState.Closed) sqlConn.Open(); try { if (playId == 0) return null; SqlCommand sqlCmd = new SqlCommand("SELECT * FROM [Game] where playId=" + playId + " ORDER BY GameID", sqlConn); SqlDataReader sqlReader = sqlCmd.ExecuteReader(); List<RemotingInterface.GameInfo> listGame = new List<RemotingInterface.GameInfo>(); RemotingInterface.GameInfo gameInfo = new RemotingInterface.GameInfo(); gameInfo.Clear(); while (sqlReader.Read()) { gameInfo.GameId = Convert.ToInt32(sqlReader["GameId"]); gameInfo.PlayId = Convert.ToInt32(sqlReader["PlayId"]); gameInfo.GameName = sqlReader["GameName"].ToString(); gameInfo.GameType = Convert.ToByte(sqlReader["GameType"]); gameInfo.RegDateStart = Convert.ToDateTime(sqlReader["RegDateStart"]); gameInfo.RegDateEnd = Convert.ToDateTime(sqlReader["RegDateEnd"]); gameInfo.GameDateStart = Convert.ToDateTime(sqlReader["GameDateStart"]); gameInfo.GameDateEnd = Convert.ToDateTime(sqlReader["GameDateEnd"]); gameInfo.GameLevel = Convert.ToByte(sqlReader["GameLevel"]); gameInfo.GameState = Convert.ToByte(sqlReader["GameState"]); gameInfo.Description = sqlReader["Description"].ToString(); listGame.Add(gameInfo); Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+": Load the Game list : PlayId = " + gameInfo.PlayId + "\t GameId = " + gameInfo.GameId + " \t GameName = " + gameInfo.GameName); } return listGame; } catch (Exception ex) { Loger.Debug(ex.ToString()); return null; } finally { if (sqlConn.State != ConnectionState.Closed) sqlConn.Close(); } }