示例#1
0
        public List <qlbhDTO> GetNhanVien(string sql)
        {
            List <qlbhDTO> list = new List <qlbhDTO>();


            int    maLoaiSp;
            string tenLoaiSp;

            dp.Connect();
            try
            {
                SqlDataReader dr = dp.executeReader(sql);
                while (dr.Read())
                {
                    maLoaiSp  = dr.GetInt32(0);
                    tenLoaiSp = dr.GetString(1);

                    qlbhDTO ql = new qlbhDTO(maLoaiSp, tenLoaiSp);//-> gọi DTO, DTO lấy dữ liệu từ Data
                    list.Add(ql);
                }
                dr.Close();
                return(list);// trả về List đã có dữ liệu
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                dp.DisConnect();
            }
        }