private void cmbdskh_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cmbdskh.SelectedIndex == -1)
     {
         dataGrid.DataContext = null;
     }
     if (cmbdskh.SelectedIndex == 0)
     {
         var db = this.FindResource("Caffein") as ViewModel.Caffein;
         db.CurPage            = 1;
         cmbdskh.SelectedIndex = 0;
         //dataGrid.DataContext = kh.LayViewKH();
         int totalPage;
         db.ViewKhachHang     = kh.LayViewKH(db.CurPage, ViewModel.Caffein.PageSize, out totalPage);
         dataGrid.DataContext = db.ViewKhachHang;
         db.TotalPage         = totalPage;
     }
     if (cmbdskh.SelectedIndex == 1)
     {
         var db = this.FindResource("Caffein") as ViewModel.Caffein;
         db.CurPage            = 1;
         cmbdskh.SelectedIndex = 1;
         int totalPage;
         db.ViewKhachHangXoa  = kh.LayViewKHXoa(db.CurPage, ViewModel.Caffein.PageSize, out totalPage);
         dataGrid.DataContext = db.ViewKhachHangXoa;
         db.TotalPage         = totalPage;
     }
     if (cmbdskh.SelectedIndex == 2)
     {
         var db = this.FindResource("Caffein") as ViewModel.Caffein;
         db.CurPage            = 1;
         cmbdskh.SelectedIndex = 2;
         int totalPage;
         db.ViewKhachHangAll  = kh.LayViewKHAll(db.CurPage, ViewModel.Caffein.PageSize, out totalPage);
         dataGrid.DataContext = db.ViewKhachHangAll;
         db.TotalPage         = totalPage;
     }
 }
Exemple #2
0
        private void btnfirst_Click(object sender, RoutedEventArgs e)
        {
            var db = this.FindResource("Caffein") as ViewModel.Caffein;
            int totalPage;

            if (db.TotalPage != 0)
            {
                if (db.CurPage > 1)
                {
                    db.CurPage = 1;
                    if (cmbdskh.SelectedIndex == 0)
                    {
                        db.ViewKhachHang     = kh.LayViewKH(db.CurPage, ViewModel.Caffein.PageSize, out totalPage);
                        dataGrid.DataContext = db.ViewKhachHang;
                    }
                    if (cmbdskh.SelectedIndex == 1)
                    {
                        db.ViewKhachHangXoa  = kh.LayViewKHXoa(db.CurPage, ViewModel.Caffein.PageSize, out totalPage);
                        dataGrid.DataContext = db.ViewKhachHangXoa;
                    }
                    if (cmbdskh.SelectedIndex == 2)
                    {
                        db.ViewKhachHangAll  = kh.LayViewKHAll(db.CurPage, ViewModel.Caffein.PageSize, out totalPage);
                        dataGrid.DataContext = db.ViewKhachHangAll;
                    }
                }
                else
                {
                    MessageBox.Show("Đã là trang đầu!");
                }
            }
            else
            {
                MessageBox.Show("Không có trang để thay đổi!");
            }
        }