public static List<BingoHistory> GetUserBingoHistory(int userID) { var list = new List<BingoHistory>(); var sql = "SELECT * FROM dbo.AcnClub_LogBingo WHERE UserID = @userID ORDER BY ActionDate DESC"; using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); com.Parameters.Add(new SqlParameter("@userID", userID)); var sda = new SqlDataAdapter(com); con.Open(); var dt = new DataTable(); sda.Fill(dt); //con.Close(); foreach (DataRow dr in dt.Rows) { var bh = new BingoHistory(dr); list.Add(bh); } } return list; }
public static List<BingoHistory> GetAllBingoHistory() { var list = new List<BingoHistory>(); var sql = "SELECT * FROM dbo.AcnClub_LogBingo WHERE Result IS NOT NULL ORDER BY ActionDate DESC"; using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); var sda = new SqlDataAdapter(com); con.Open(); var dt = new DataTable(); sda.Fill(dt); //con.Close(); foreach (DataRow dr in dt.Rows) { var bh = new BingoHistory(dr); list.Add(bh); } } return list; }