private async void ShowProduct(int?obj) { if (obj != null) { int index = (int)obj; var pro = await product_Repo.GetById(index); if (pro != null) { ProductID = pro.ProductID.ToString(); ProductName = pro.Name; Description = pro.Description; Price = pro.UnitPrice.ToString(); PriceSales = pro.UnitOnOrder.ToString(); ImgProduct = pro.Picture.LoadImage(); SelectedCate = ListCatelogys.SingleOrDefault(t => t.CatelogyID == pro.CategoryID); } else { ProductID = ProductName = Description = Price = PriceSales = null; ImgProduct = null; SelectedCate = null; } await DialogHost.Show(new ProductProfile(), DialogHostId); } }
private async void DeleteCategory(int?obj) { try { dc = new DialogContent() { Content = "Bạn muốn xóa loại này ?", Tilte = "Thông Báo" }; var dialogYS = new DialogYesNo() { DataContext = dc }; var result = (bool)await DialogHost.Show(dialogYS, DialogHostId); if (result) { if (obj != null) { if (await categories_Repo.Remove((int)obj)) { dc = new DialogContent() { Content = "Xóa Thành Công", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; await DialogHost.Show(dialog, DialogHostId); ListCatelogys.Remove(ListCatelogys.SingleOrDefault(t => t.CatelogyID == (int)obj)); } else { dc = new DialogContent() { Content = "Xóa Thất Bại", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; await DialogHost.Show(dialog, DialogHostId); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private async void ShowDataCagory(int?obj) { ProCateID = DesCate = NameCate = null; if (obj != null) { var item = ListCatelogys.SingleOrDefault(t => t.CatelogyID == obj); if (item != null) { ProCateID = item.CatelogyID.ToString(); DesCate = item.Description; NameCate = item.Name; } } await MaterialDesignThemes.Wpf.DialogHost.Show(new CategoryProfile(), DialogHostId); }