private async void ShowInfo(int?obj) { try { if (obj != null) { var index = (int)obj; var objsup = ListSupplier.SingleOrDefault(t => t.SupID == index); Name = objsup.Name; Delegate = objsup.Delegate; Phone = objsup.Phone; Email = objsup.Email; SupID = obj.ToString(); SupImg = objsup.Avatar.LoadImage(); DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(new SupplierProfile(), DialogHostId); } } catch { dc.Content = "Có Lỗi"; dc.Tilte = "Thông Báo"; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } }
private async void DeleteSup(int?obj) { try { dc = new DialogContent() { Content = "Bạn muốn xóa nhà cung cấp 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 supplier_repo.Remove((int)obj)) { ListSupplier.Remove(ListSupplier.SingleOrDefault(t => t.SupID == (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); } 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) { dc.Content = "Có Lỗi"; dc.Tilte = "Thông Báo"; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } }