private async void Addsuccess(PurchasingHeader obj) { try { if (obj != null) { var newobj = await oh_repo.GetById(obj.PurID); ListOrder.Add(newobj); dc = new DialogContent() { Content = "Thêm Thành Công", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } else { dc = new DialogContent() { Content = "Thêm Thất Bại", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, 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 CreateOrder() { try { if (ListOD.Count() > 0) { var newOrder = new PurchasingHeader(); if (SelectedCus != null) { newOrder.SuplierID = SelectedCus.SupID; } if (SelectedLog != null) { newOrder.LogID = SelectedLog.LogID; } newOrder.PurDate = DateTime.Now; foreach (var i in ListOD) { newOrder.PurchasingDetails.Add(new PurchasingDetail() { ProductId = i.ProductID, PurQty = i.OrderQty, UnitPrice = (decimal)i.UnitPrice, StoreID = i.StoreID, }); } var result = await oh_repo.Add(newOrder); MessengerInstance.Send <PurchasingHeader>(result); } } catch { MessageBox.Show("Có Lỗi"); } }