public ProductAccessoriesQueryConditionValueSet() { InitializeComponent(); cboCondition.SelectionChanged += new SelectionChangedEventHandler(cboCondition_SelectionChanged); this.Loaded += (sender, e) => { facade = new ProductAccessoriesFacade(); if (IsEdit) //编辑 { this.DataContext = Data; var con = (from p in Data.ConditionList where p.SysNo == ConditionSysNo select p).FirstOrDefault(); this.cboCondition.SelectedValue = con; this.cboCondition.IsEnabled = false; } else { model = new ProductAccessoriesConditionValueVM() { ConditionList = ConditionList }; this.DataContext = model; if (model.ConditionList.Count > 0) { cboCondition.SelectedIndex = 0; } } }; }
private void BtnSave_Click(object sender, RoutedEventArgs e) { if (!ValidationManager.Validate(this)) { return; } if (txtValue.IsEnabled == false) { CPApplication.Current.CurrentPage.Context.Window.Alert("设置错误,无法保存!", MessageType.Error); return; } ProductAccessoriesConditionValueVM vm = this.DataContext as ProductAccessoriesConditionValueVM; vm.MasterSysNo = MaterSysNo; if (IsEdit) //更新 { vm.SysNo = SysNo; facade.UpdateProductAccessoriesQueryConditionValue(vm, (obj, arg) => { if (arg.FaultsHandle()) { return; } CPApplication.Current.CurrentPage.Context.Window.Alert("更新成功!"); CloseDialog(DialogResultType.OK); }); } else { facade.CreateProductAccessoriesQueryConditionValue(vm, (obj, arg) => { if (arg.FaultsHandle()) { return; } CPApplication.Current.CurrentPage.Context.Window.Alert("创建成功!"); CloseDialog(DialogResultType.OK); }); } }
/// <summary> /// 选项值model转换 /// </summary> /// <param name="data"></param> /// <returns></returns> private ProductAccessoriesQueryConditionValueInfo ConvertConditionValueEntity(ProductAccessoriesConditionValueVM data) { ProductAccessoriesQueryConditionValueInfo info = new ProductAccessoriesQueryConditionValueInfo() { ConditionSysNo = data.Condition.SysNo, ConditionValue = data.ConditionValue.ConditionValue, MasterSysNo = data.MasterSysNo, SysNo = data.SysNo }; info.ConditionValueParentSysNo = data.ParentConditionValue == null ? 0 : data.ParentConditionValue.SysNo; return(info); }
/// <summary> /// 更新选项值 /// </summary> /// <param name="model"></param> /// <param name="callback"></param> public void UpdateProductAccessoriesQueryConditionValue(ProductAccessoriesConditionValueVM model, EventHandler <RestClientEventArgs <dynamic> > callback) { restClient.Update(UpdateProductAccessoriesQueryConditionValueUrl, ConvertConditionValueEntity(model), callback); }