private void btnAddOrder_Click_1(object sender, RoutedEventArgs e) { AddWindow win = new AddWindow(); AddOrder addOrderUc = new AddOrder(); win.Title = "Orders: " + WorkerId; addOrderUc.ParentWin = win; win.AddGrid.Children.Add(addOrderUc); win.SizeToContent = SizeToContent.WidthAndHeight; bool? resDiag = win.ShowDialog(); if (resDiag.HasValue && resDiag.Value) { Order toAdd = addOrderUc.newOrder; toAdd.WorkerId = WorkerId; try { MainWindow._repo.AddOrders(toAdd); } catch (Exception ex) { MessageBox.Show(ex.Message , "Show Orders"); } MainWindow._orders = MainWindow._repo.GetOrder(WorkerId); dgShowOrders.ItemsSource = MainWindow._orders; dgShowOrders.Items.Refresh(); } }
private void AddOrderMI_Click_1(object sender, RoutedEventArgs e) { AddWindow addWin = new AddWindow(); AddOrder addOrder = new AddOrder(); addWin.SizeToContent = SizeToContent.WidthAndHeight; addOrder.ParentWin = addWin; addWin.AddGrid.Children.Add(addOrder); addWin.ShowDialog(); bool? resDiag = addWin.DialogResult; if (resDiag.HasValue && resDiag.Value) { _repo.AddOrders(addOrder.newOrder); } }