예제 #1
0
 private void btnModifyDeliveryInfo_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         FrameworkElement btn = sender as FrameworkElement;
         if (btn == null)
         {
             MessageBox.Show("事件源对不是 btnSetPrice_Click FrameworkElement");
             return;
         }
         var order = btn.Tag as Order;
         if (order == null)
         {
             throw new Exception("绑定信息不是Order对象");
         }
         OrderModifyDeliveryInfoWindow win = new OrderModifyDeliveryInfoWindow {
             DeliveryCompany = order.DeliveryCompany, DeliveryNumber = order.DeliveryNumber
         };
         if (win.ShowDialog().Value == true)
         {
             this.orderService.UpdateDelivery(order.Id, 0, win.DeliveryCompany, win.DeliveryNumber, DateTime.Now);
             order.DeliveryCompany = win.DeliveryCompany;
             order.DeliveryNumber  = win.DeliveryNumber;
             MessageBox.Show("更新成功");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
        private void btnModify_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FrameworkElement fe = sender as FrameworkElement;
                if (fe == null)
                {
                    MessageBox.Show("事件源不为:FrameworkElement");
                    return;
                }
                var vm = fe.DataContext as OrderReturnViewModel;

                if (vm == null)
                {
                    MessageBox.Show("没有要修改退换货记录");
                    return;
                }

                var window = new OrderModifyDeliveryInfoWindow
                {
                    DeliveryCompany = vm.Source.DeliveryCompany,
                    DeliveryNumber  = vm.Source.DeliveryNumber,
                };
                bool?ret = window.ShowDialog();
                if (ret != null && ret.Value)
                {
                    vm.Source.DeliveryCompany = window.DeliveryCompany;
                    vm.Source.DeliveryNumber  = window.DeliveryNumber;
                    ServiceContainer.GetService <OrderReturnService>().Update(vm.Source);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }