Ejemplo n.º 1
0
        public List <PhanHoi> GetList(string IP, string HienThi)
        {
            SqlConnection  con       = db.getConnection();
            List <PhanHoi> l_PhanHoi = new List <PhanHoi>();

            try
            {
                SqlCommand cmd = new SqlCommand("PhanHoi_timkiem");
                cmd.Connection = con;
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@IP", IP));
                cmd.Parameters.Add(new SqlParameter("@HienThi", HienThi));
                SqlDataReader   reader      = cmd.ExecuteReader();
                SmartDataReader smartReader = new SmartDataReader(reader);
                while (smartReader.Read())
                {
                    PhanHoi ph = new PhanHoi();
                    ph.ID       = smartReader.GetInt32("ID");
                    ph.HoTen    = smartReader.GetString("HoTen");
                    ph.Tuoi     = smartReader.GetByte("Tuoi");
                    ph.DiaChi   = smartReader.GetString("DiaChi");
                    ph.TieuDe   = smartReader.GetString("TieuDe");
                    ph.NoiDung  = smartReader.GetString("NoiDung");
                    ph.HienThi  = smartReader.GetBoolean("HienThi");
                    ph.IP       = smartReader.GetString("IP");
                    ph.NgayDang = smartReader.GetString("NgayDang");
                    l_PhanHoi.Add(ph);
                }
                smartReader.disposeReader(reader);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.closeConnection(con);
            }
            return(l_PhanHoi);
        }
Ejemplo n.º 2
0
        public PhanHoi FindByID(int ID)
        {
            PhanHoi       ph  = new PhanHoi();
            SqlConnection con = db.getConnection();

            try
            {
                SqlCommand cmd = new SqlCommand("PhanHoi_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())
                {
                    ph.ID       = smartReader.GetInt32("ID");
                    ph.HoTen    = smartReader.GetString("HoTen");
                    ph.Tuoi     = smartReader.GetByte("Tuoi");
                    ph.DiaChi   = smartReader.GetString("DiaChi");
                    ph.TieuDe   = smartReader.GetString("TieuDe");
                    ph.NoiDung  = smartReader.GetString("NoiDung");
                    ph.HienThi  = smartReader.GetBoolean("HienThi");
                    ph.IP       = smartReader.GetString("IP");
                    ph.NgayDang = smartReader.GetString("NgayDang");
                }
                smartReader.disposeReader(reader);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.closeConnection(con);
            }
            return(ph);
        }