Exemplo n.º 1
0
        public static List<DanhSachGame_DTO> FindGame(String sTen)
        {
            try
            {
                SqlConnection connection = SQLDBConnection.CreateSQlConnection();
                String cmdStr = String.Format(@"SELECT * FROM TROCHOI WHERE TEN LIKE N'%{0}%'", sTen);
                SqlCommand cmd = new SqlCommand(cmdStr, connection);

                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = cmd;
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                connection.Close();

                List<DanhSachGame_DTO> lGame = new List<DanhSachGame_DTO>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DanhSachGame_DTO Game = new DanhSachGame_DTO();
                    Game.Ma = dt.Rows[i]["Ma"].ToString();
                    Game.Ten = dt.Rows[i]["Ten"].ToString();
                    Game.NguoiChoi = int.Parse(dt.Rows[i]["NguoiChoi"].ToString());
                    Game.TheLoai = dt.Rows[i]["TheLoai"].ToString();
                    Game.GhiChu = dt.Rows[i]["GhiChu"].ToString();

                    lGame.Add(Game);
                }
                return lGame;
            }
            catch
            {
                return null;
            }
        }
Exemplo n.º 2
0
        public static List<DanhSachGame_DTO> FindGameMay(String sTen, String sMaMay)
        {
            try
            {
                SqlConnection connection = SQLDBConnection.CreateSQlConnection();
                String cmdStr = String.Empty;
                if (sMaMay == "Tất cả")
                {
                    cmdStr = String.Format(@"SELECT * FROM TROCHOI TC, GAME_MAY GM WHERE TC.TEN LIKE N'%{0}%' AND GM.MAGAME = TC.MA", sTen);
                }
                else
                {
                    cmdStr = String.Format(@"SELECT * FROM TROCHOI TC, GAME_MAY GM WHERE TC.TEN LIKE N'%{0}%' AND GM.MAMAY = N'{1}' AND GM.MAGAME = TC.MA", sTen, sMaMay);
                }
                SqlCommand cmd = new SqlCommand(cmdStr, connection);

                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = cmd;
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                connection.Close();

                List<DanhSachGame_DTO> lGame = new List<DanhSachGame_DTO>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DanhSachGame_DTO Game = new DanhSachGame_DTO();
                    Game.Ten = dt.Rows[i]["Ten"].ToString();
                    Game.NguoiChoi = int.Parse(dt.Rows[i]["NguoiChoi"].ToString());
                    Game.TheLoai = dt.Rows[i]["TheLoai"].ToString();
                    Game.MaMay = dt.Rows[i]["MaMay"].ToString();
                    Game.GhiChu = dt.Rows[i]["GhiChu"].ToString();

                    lGame.Add(Game);
                }
                return lGame;
            }
            catch (Exception EX)
            {
                throw EX;
                return null;
            }
        }
Exemplo n.º 3
0
        public static List<DanhSachGame_DTO> SelectDanhSachGame_May(String sMaMay)
        {
            try
            {
                SqlConnection connection = SQLDBConnection.CreateSQlConnection();

                SqlCommand command = connection.CreateCommand();
                command.CommandText = String.Format("SELECT * FROM TROCHOI G, GAME_MAY GM WHERE G.MA = GM.MAGAME AND GM.MAMAY = {0}", sMaMay);
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = command;
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                connection.Close();

                List<DanhSachGame_DTO> lGame = new List<DanhSachGame_DTO>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DanhSachGame_DTO Game = new DanhSachGame_DTO();
                    Game.Ma = dt.Rows[i]["Ma"].ToString();
                    Game.Ten = dt.Rows[i]["Ten"].ToString();
                    Game.NguoiChoi = int.Parse(dt.Rows[i]["NguoiChoi"].ToString());
                    Game.TheLoai = dt.Rows[i]["TheLoai"].ToString();
                    Game.GhiChu = dt.Rows[i]["GhiChu"].ToString();

                    lGame.Add(Game);
                }
                return lGame;
            }
            catch
            {
                return null;
            }
        }
Exemplo n.º 4
0
        public static List<DanhSachGame_DTO> SelectDanhSachGame()
        {
            try
            {
                SqlConnection connection = SQLDBConnection.CreateSQlConnection();

                SqlCommand command = connection.CreateCommand();
                //int MaMay = int.Parse(this.cbMay.SelectedValue.ToString());
                command.CommandText = "SELECT * FROM TROCHOI";
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = command;
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                connection.Close();

                List<DanhSachGame_DTO> lGame = new List<DanhSachGame_DTO>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DanhSachGame_DTO Game = new DanhSachGame_DTO();
                    Game.Ma = dt.Rows[i]["Ma"].ToString();
                    Game.Ten = dt.Rows[i]["Ten"].ToString();
                    Game.NguoiChoi = int.Parse(dt.Rows[i]["NguoiChoi"].ToString());
                    Game.TheLoai = dt.Rows[i]["TheLoai"].ToString();
                    Game.GhiChu = dt.Rows[i]["GhiChu"].ToString();

                    lGame.Add(Game);
                }
                return lGame;
            }
            catch
            {
                return null;
            }
        }