Ejemplo n.º 1
0
        public List <BaiViet> GetList(string TieuDe, string NgayDangMin, string NgayDangMax, byte ChuDeID, int LopHocID)
        {
            SqlConnection  con       = db.getConnection();
            List <BaiViet> l_BaiViet = new List <BaiViet>();

            try
            {
                SqlCommand cmd = new SqlCommand("BaiViet_timkiem");
                cmd.Connection = con;
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@TieuDe", TieuDe));
                cmd.Parameters.Add(new SqlParameter("@NgayDangMin", NgayDangMin));
                cmd.Parameters.Add(new SqlParameter("@NgayDangMax", NgayDangMax));
                cmd.Parameters.Add(new SqlParameter("@ChuDeID", ChuDeID));
                cmd.Parameters.Add(new SqlParameter("@lophocid", LopHocID));
                SqlDataReader   reader      = cmd.ExecuteReader();
                SmartDataReader smartReader = new SmartDataReader(reader);
                while (smartReader.Read())
                {
                    BaiViet bv = new BaiViet();
                    bv.ID       = smartReader.GetInt32("ID");
                    bv.TieuDe   = smartReader.GetString("TieuDe");
                    bv.NgayDang = smartReader.GetString("NgayDang");
                    bv.LuotXem  = smartReader.GetInt32("LuotXem");
                    bv.TenChuDe = smartReader.GetString("TenChuDe");
                    bv.URL      = smartReader.GetString("URL");
                    bv.IP       = smartReader.GetString("IP");
                    bv.LopHocID = smartReader.GetInt32("lophocid");
                    l_BaiViet.Add(bv);
                }
                smartReader.disposeReader(reader);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.closeConnection(con);
            }
            return(l_BaiViet);
        }
Ejemplo n.º 2
0
        public BaiViet FindByID(int ID)
        {
            BaiViet       bv  = new BaiViet();
            SqlConnection con = db.getConnection();

            try
            {
                SqlCommand cmd = new SqlCommand("BaiViet_chitiet");
                cmd.Connection = con;
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@ID", ID));
                SqlDataReader   reader      = cmd.ExecuteReader();
                SmartDataReader smartReader = new SmartDataReader(reader);
                while (smartReader.Read())
                {
                    bv.ID       = smartReader.GetInt32("ID");
                    bv.TieuDe   = smartReader.GetString("TieuDe");
                    bv.SoLuoc   = smartReader.GetString("SoLuoc");
                    bv.NoiDung  = smartReader.GetString("NoiDung");
                    bv.NgayDang = smartReader.GetString("NgayDang");
                    bv.IP       = smartReader.GetString("IP");
                    bv.LuotXem  = smartReader.GetInt32("LuotXem");
                    bv.TenChuDe = smartReader.GetString("TenChuDe");
                    bv.URL      = smartReader.GetString("URL");
                    bv.ChuDeID  = smartReader.GetByte("ChuDeID");
                    bv.AnhID    = smartReader.GetInt32("AnhID");
                    bv.LopHocID = smartReader.GetInt32("lophocid");
                }
                smartReader.disposeReader(reader);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.closeConnection(con);
            }
            return(bv);
        }
Ejemplo n.º 3
0
        public List <BaiViet> GetPaginationList(short pageNum, short limitPerPage, byte ChuDeID, int LopHocID)
        {
            SqlConnection  con       = db.getConnection();
            List <BaiViet> l_BaiViet = new List <BaiViet>();

            try
            {
                SqlCommand cmd = new SqlCommand("BaiViet_timKiemPhanTrang");
                cmd.Connection = con;
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Page", pageNum));
                cmd.Parameters.Add(new SqlParameter("@Limit", limitPerPage));
                cmd.Parameters.Add(new SqlParameter("@ChuDeID", ChuDeID));
                cmd.Parameters.Add(new SqlParameter("@lophocid", LopHocID));
                SqlDataReader   reader      = cmd.ExecuteReader();
                SmartDataReader smartReader = new SmartDataReader(reader);
                while (smartReader.Read())
                {
                    BaiViet bv = new BaiViet();
                    bv.ID       = smartReader.GetInt32("ID");
                    bv.TieuDe   = smartReader.GetString("TieuDe");
                    bv.SoLuoc   = smartReader.GetString("SoLuoc");
                    bv.URL      = smartReader.GetString("URL");
                    bv.LopHocID = smartReader.GetInt32("lophocid");
                    l_BaiViet.Add(bv);
                }
                smartReader.disposeReader(reader);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.closeConnection(con);
            }
            return(l_BaiViet);
        }
Ejemplo n.º 4
0
        public List <BaiViet> GetRecentList()
        {
            SqlConnection  con       = db.getConnection();
            List <BaiViet> l_BaiViet = new List <BaiViet>();

            try
            {
                SqlCommand cmd = new SqlCommand("BaiViet_timKiemGanNhat");
                cmd.Connection = con;
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataReader   reader      = cmd.ExecuteReader();
                SmartDataReader smartReader = new SmartDataReader(reader);
                while (smartReader.Read())
                {
                    BaiViet bv = new BaiViet();
                    bv.ID       = smartReader.GetInt32("ID");
                    bv.TieuDe   = smartReader.GetString("TieuDe");
                    bv.NgayDang = smartReader.GetString("NgayDang");
                    bv.SoLuoc   = smartReader.GetString("SoLuoc");
                    bv.URL      = smartReader.GetString("URL");
                    bv.LopHocID = smartReader.GetInt32("lophocid");
                    l_BaiViet.Add(bv);
                }
                smartReader.disposeReader(reader);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.closeConnection(con);
            }
            return(l_BaiViet);
        }