private void btnCreateNew_Click(object sender, RoutedEventArgs e) { try { FrameworkElement fe = sender as FrameworkElement; if (fe == null) { MessageBox.Show("事件源不为:FrameworkElement"); return; } OrderReturnViewModel vm = fe.DataContext as OrderReturnViewModel; if (vm == null) { throw new Exception("对象数据为空"); } if (OperatorService.LoginOperator.Rights.Contains("创建订单") == false) { throw new Exception("你没有权限创建订单"); } if (vm.Source.Type != OrderReturnType.EXCHANGE) { if (MessageBox.Show("该退货不是换货,确认需要创建?", "警告", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } } var window = new OrderEditWindow { SourceOrder = vm.Order }; window.ShowDialog(); if (window.Order == null) { return; } vm.Source.NewOrderId = window.Order.Id; ServiceContainer.GetService <OrderReturnService>().Update(vm.Source); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnEditOrder_Click(object sender, RoutedEventArgs e) { try { var or = (sender as Button).Tag as OrderViewModel; if (or == null) { throw new Exception("订单对象为空"); } var win = new OrderEditWindow { Order = or.Source }; win.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }