private void BtnSaveClick(object sender, RoutedEventArgs e)
        {
            var vm = DataContext as CategoryAccessoriesVM;

            if (vm == null)
            {
                return;
            }
            if (vm.CategoryInfo == null || vm.CategoryInfo.SysNo == null)
            {
                CPApplication.Current.CurrentPage.Context.Window.Alert("请选择三级分类.");
                return;
            }
            if (vm.Accessory == null || String.IsNullOrEmpty(vm.Accessory.AccessoryName))
            {
                CPApplication.Current.CurrentPage.Context.Window.Alert("请填写配件.");
                return;
            }
            if (vm.Priority == null || vm.Priority.Value <= 0)
            {
                CPApplication.Current.CurrentPage.Context.Window.Alert("请填写正确的配件顺序.");
                return;
            }
            _facade  = new CategoryAccessoriesFacade();
            vm.SysNo = SysNo;
            if (vm.SysNo == null || vm.SysNo.Value <= 0)
            {
                _facade.CreateCategoryAccessory(vm, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    vm.SysNo = args.Result.SysNo;
                    CPApplication.Current.CurrentPage.Context.Window.Alert(ResBrandMaintain.Info_SaveSuccessfully);
                    CloseDialog(DialogResultType.OK);
                });
            }
            else
            {
                _facade.UpdateCategoryAccessory(vm, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    CPApplication.Current.CurrentPage.Context.Window.Alert(ResBrandMaintain.Info_SaveSuccessfully);
                    CloseDialog(DialogResultType.OK);
                });
            }
        }
 private void BindPage()
 {
     if (SysNo != null)
     {
         _facade = new CategoryAccessoriesFacade();
         _facade.GetCategoryAccessoryBySysNo(SysNo.Value, (obj, args) =>
         {
             if (args.FaultsHandle())
             {
                 return;
             }
             if (args.Result == null)
             {
                 CPApplication.Current.CurrentPage.Context.Window.MessageBox.Show("没有获得分类配件信息.", MessageBoxType.Warning);
                 return;
             }
             var vm          = args.Result.Convert <CategoryAccessory, CategoryAccessoriesVM>();
             vm.CategoryInfo = args.Result.CategoryInfo.Convert <CategoryInfo, CategoryVM>
                                   ((v, t) =>
             {
                 t.CategoryName = v.CategoryName.Content;
             });
             vm.Accessory = args.Result.Accessory.Convert <AccessoryInfo, AccessoryVM>
                                ((v, t) =>
             {
                 t.AccessoryName = v.AccessoryName.Content;
             });
             DataContext = vm;
         });
     }
     else
     {
         var brand = new CategoryAccessoriesVM {
             Accessory = new AccessoryVM(), CategoryInfo = new CategoryVM()
         };
         DataContext = brand;
         dplistStatus.SelectedIndex = 0;
     }
 }