123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OUP
- {
- class ClassMain : BaseViewModel
- {
- private ObservableCollection<Product> _products;
- private ObservableCollection<CashRegister> _cashRegisters;
- private RelayCommand _updateOpenWindow;
- private Product _selectedProduct;
- private CashRegister _cashRegister;
- private RelayCommand _update;
- public RelayCommand UpdateOpenWindow
- {
- get
- {
- return _updateOpenWindow ??
- (_updateOpenWindow = new RelayCommand((x) =>
- {
- if (x is CashRegister xx)
- {
- }
- }));
- }
- }
- public ObservableCollection<Product> Products
- {
- get
- {
- return _products;
- }
- set
- {
- _products = value;
- OnPropertyChanged();
- }
- }
- public Product SelectedProduct
- {
- get
- {
- return _selectedProduct;
- }
- set
- {
- _selectedProduct = value;
- OnPropertyChanged();
- }
- }
- public CashRegister SelectedCashRegister
- {
- get
- {
- return _cashRegister;
- }
- set
- {
- _cashRegister = value;
- OnPropertyChanged();
- }
- }
- public ObservableCollection<CashRegister> CashRegister
- {
- get
- {
- return _cashRegisters;
- }
- set
- {
- _cashRegisters = value;
- OnPropertyChanged();
- }
- }
- private void LoadCollection()
- {
- Products.Clear();
- Products = new ObservableCollection<Product>(Helper.GetContext().Product);
- }
- public ClassMain()
- {
- _products = new ObservableCollection<Product>(Helper.GetContext().Product);
- _cashRegisters = new ObservableCollection<CashRegister>(Helper.GetContext().CashRegister);
- }
- public RelayCommand Update
- {
- get
- {
- return _update ??
- (_update = new RelayCommand((x) =>
- {
- SelectedProduct.CashRegister = CashRegister;
- Helper.GetContext().SaveChanges();
- LoadCollection();
- }));
- }
- }
- }
- }
|