Ejemplo n.º 1
0
        public List <ClassKhachHang> GetKhachHang()
        {
            using (CSDLQuanLyQuanAoDataContext db = new CSDLQuanLyQuanAoDataContext())
            {
                List <ClassKhachHang> lstKH = new List <ClassKhachHang>();

                db.DeferredLoadingEnabled = false;
                var ttKH = from k in db.KhachHangs
                           join l in db.LoaiKhachHangs on k.LoaiKhachHang equals l.MaLoaiKhachHang

                           select new
                {
                    KhachHang     = k,
                    LoaiKhachHang = l
                };

                foreach (var i in ttKH)
                {
                    //  MessageBox.Show(""+i);
                    ClassKhachHang KHNew = new ClassKhachHang();
                    KHNew.MaKhachHang   = i.KhachHang.MaKhachHang;
                    KHNew.TenKhachHang  = i.KhachHang.TenKhachHang;
                    KHNew.Ngaysinh      = i.KhachHang.Ngaysinh;
                    KHNew.GioiTinh      = i.KhachHang.GioiTinh;
                    KHNew.Email         = i.KhachHang.Email;
                    KHNew.DiaChi        = i.KhachHang.DiaChi;
                    KHNew.SDT           = i.KhachHang.SDT;
                    KHNew.LoaiKhachHang = i.LoaiKhachHang.TenLoaiKhachHang;
                    KHNew.GhiChu        = i.KhachHang.GhiChu;
                    if (i.KhachHang.Image != null)
                    {
                        KHNew.Image = ByteArrayToImage(i.KhachHang.Image.ToArray());
                    }
                    lstKH.Add(KHNew);
                }
                classKH = lstKH;
                return(lstKH);
            }
        }