private void Button_Click_1(object sender, RoutedEventArgs e) { //update switch (SelecterObj) { case Obj.Worker: foreach (var item in DG.SelectedItems) { WorkerWindow workerWindow = new WorkerWindow((WorkersDTO)item, BLL_); workerWindow.Show(); workerWindow.Closing += Window_Closed; } break; case Obj.Product: foreach (var item in DG.SelectedItems) { ProductWindow productWindow = new ProductWindow(ProductDG.ConvertToDTO((ProductDG)item), BLL_); productWindow.Show(); productWindow.Closing += Window_Closed; } break; case Obj.Director: foreach (var item in DG.SelectedItems) { DirectorWindow directorWindow = new DirectorWindow((DirectorsDTO)item, BLL_); directorWindow.Show(); directorWindow.Closing += Window_Closed; } break; case Obj.Shop: foreach (var item in DG.SelectedItems) { ShopWindow_ shopWindow = new ShopWindow_((ShopsDTO)item, BLL_); shopWindow.Show(); shopWindow.Closing += Window_Closed; } break; case Obj.NONE: MessageBox.Show("NoNe"); return; default: break; } }
private void LoadData(Obj SelecterObj_) { switch (SelecterObj_) { case Obj.Worker: ObservableCollection <WorkerDG> workerDGs = new ObservableCollection <WorkerDG>(); foreach (var item in BLL_.GetAllWorkers()) { workerDGs.Add(WorkerDG.Convert(item)); } DG.ItemsSource = workerDGs; break; case Obj.Product: ObservableCollection <ProductDG> productDGs = new ObservableCollection <ProductDG>(); foreach (var item in BLL_.GetAllProducts()) { productDGs.Add(ProductDG.Convert(item)); } DG.ItemsSource = productDGs; break; case Obj.Director: ObservableCollection <DirectorDG> directorDGs = new ObservableCollection <DirectorDG>(); foreach (var item in BLL_.GetAllDirectors()) { directorDGs.Add(DirectorDG.Convert(item)); } DG.ItemsSource = directorDGs; break; case Obj.Shop: ObservableCollection <ShopDG> shopDGs = new ObservableCollection <ShopDG>(); foreach (var item in BLL_.GetAllShops()) { shopDGs.Add(ShopDG.Convert(item)); } DG.ItemsSource = shopDGs; break; case Obj.NONE: MessageBox.Show("NoNe"); return; default: break; } }
public static ProductsDTO ConvertToDTO(ProductDG productsDTO) { return(new ProductsDTO(productsDTO.Id, productsDTO.FirstName, productsDTO.CategoryId, productsDTO.Price, productsDTO.Discount, productsDTO.IsInStook)); }