Пример #1
0
        public List <NhanVien> LoadData()
        {
            List <NhanVien> list = new List <NhanVien>();

            try
            {
                dp.Connect();
                string        sql = "Select * from NhanVien";
                SqlDataReader dr  = dp.ExcuteReader(sql);

                while (dr.Read())
                {
                    NhanVien nv = new NhanVien();
                    nv.maNV   = dr.GetInt32(0);
                    nv.hoNV   = dr.GetString(1);
                    nv.ten    = dr.GetString(2);
                    nv.diaChi = dr.GetString(3);
                    nv.sdt    = dr.GetString(4);
                    list.Add(nv);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (InvalidOperationException ex)
            {
                throw ex;
            }
            finally
            {
                dp.DisConnect();
            }
            return(list);
        }