コード例 #1
0
        void LoadData()
        {
            List<TheLoai> _theLoai = new List<TheLoai>();
            TheLoaiBUS _busTheLoai = new TheLoaiBUS();

            _theLoai = _busTheLoai.GetList();

            dataGrid.Items.Clear();

            id = 1;
            foreach (TheLoai i in _theLoai)
            {
                ThongTinTheLoai _thongTinTheLoai = new ThongTinTheLoai();
                _thongTinTheLoai.MaTheLoai = i.MaTheLoai;
                _thongTinTheLoai.TenTheLoai = i.TenTheLoai;
                _thongTinTheLoai.GhiChu = i.GhiChu;

                dataGrid.IsReadOnly = true;
                dataGrid.Items.Add(_thongTinTheLoai);

                if (id < int.Parse(i.MaTheLoai))
                {
                    id = int.Parse(i.MaTheLoai);
                }
            }
        }
コード例 #2
0
        private void btSua_Click(object sender, RoutedEventArgs e)
        {
            TheLoai theLoai = new TheLoai() { MaTheLoai = tbMaTheLoai.Text, TenTheLoai = tbTenTheLoai.Text, GhiChu = tbGhiChu.Text };

            TheLoaiBUS bus = new TheLoaiBUS();

            try
            {
                bus.Update(theLoai);

                MessageBox.Show("Sửa thành công !");
            }
            catch (Exception)
            {
                MessageBox.Show("Sửa thất bại !");
            }
            
            LoadData();
        }
コード例 #3
0
        private void btThem_Click(object sender, RoutedEventArgs e)
        {
            TheLoai theLoai = new TheLoai() { MaTheLoai = (++id).ToString(), TenTheLoai = tbTenTheLoai.Text, GhiChu = tbGhiChu.Text };
          
            TheLoaiBUS bus = new TheLoaiBUS();

            try
            {
                bus.Insert(theLoai);

                MessageBox.Show("Thêm thành công !");
            }
            catch (Exception)
            {
                MessageBox.Show("Thêm thất bại !");
            }
           

            LoadData();
        }
コード例 #4
0
        private void btXoa_Click(object sender, RoutedEventArgs e)
        {
            TheLoaiBUS bus = new TheLoaiBUS();

            try
            {
                bus.Delete(tbMaTheLoai.Text);

                MessageBox.Show("Xóa thành công !");
            }
            catch (Exception)
            {
                MessageBox.Show("Xóa thất bại !");
            }

            LoadData();
        }
コード例 #5
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            List<Sach> _sach = new List<Sach>();
            SachBUS _busSach = new SachBUS();

            dataGrid.Items.Clear();

            _sach = _busSach.GetList();

            List<TacGia> _tacGia = new List<TacGia>();
            TacGiaBUS _busTacGia = new TacGiaBUS();
            _tacGia = _busTacGia.GetList();

            List<NhaXuatBan> _nhaXuatBan = new List<NhaXuatBan>();
            NhaXuatBanBUS _busNhaXuatBan = new NhaXuatBanBUS();
            _nhaXuatBan = _busNhaXuatBan.GetList();

            List<TheLoai> _theLoai = new List<TheLoai>();
            TheLoaiBUS _busTheLoai = new TheLoaiBUS();
            _theLoai = _busTheLoai.GetList();

            foreach (Sach i in _sach)
            {
                ThongTinSach _thongTinSach = new ThongTinSach();
                _thongTinSach.MaSach = i.MaSach;
                _thongTinSach.TenSach = i.TenSach;
                _thongTinSach.TheLoai = LayTenTheLoai(_theLoai, i.TheLoai);
                _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia);
                _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan);
                _thongTinSach.NamXuatBan = i.NamXuatBan;
                _thongTinSach.GiaBan = i.GiaBan.ToString();
                _thongTinSach.SoLuong = i.SoLuong;

                dataGrid.Items.Add(_thongTinSach);
            }
        }