private void ButtonNew_Click(object sender, RoutedEventArgs e) { this.ButtonSave.IsEnabled = true; _currentVM = new BannerLocationVM(); this.Grid.DataContext = _currentVM; _isEditing = false; }
public void Update(BannerLocationVM vm, EventHandler <RestClientEventArgs <object> > callback) { var model = vm.ConvertVM <BannerLocationVM, BannerLocation>((v, entity) => { entity.Infos = v.Infos.ConvertVM <BannerInfoVM, BannerInfo>(); });; model.CompanyCode = CPApplication.Current.CompanyCode; model.WebChannel = new BizEntity.Common.WebChannel { ChannelID = vm.ChannelID }; string relativeUrl = "/MKTService/Banner/Update"; restClient.Update(relativeUrl, model, callback); }
public override void OnPageLoad(object sender, EventArgs e) { base.OnPageLoad(sender, e); //页面加载后固定跨列的文本框的宽度 this.txtBannerResourceUrl.Width = this.txtBannerResourceUrl.ActualWidth; this.txtBannerLink.Width = this.txtBannerLink.ActualWidth; this.txtBannerOnClick.Width = this.txtBannerOnClick.ActualWidth; this.rbInvalid.Content = EnumConverter.GetDescription(ADStatus.Deactive, typeof(ADStatus)); this.rbValid.Content = EnumConverter.GetDescription(ADStatus.Active, typeof(ADStatus)); this.lstBannerType.ItemsSource = EnumConverter.GetKeyValuePairs <BannerType>(); //初始化页面数据 this.lstChannel.ItemsSource = CPApplication.Current.CurrentWebChannelList.ToList <UIWebChannel>(); //初始化DataContext _isEditing = !string.IsNullOrWhiteSpace(this.Request.Param); if (_isEditing) { new BannerFacade(this).Load(this.Request.Param, (s, args) => { if (args.FaultsHandle()) { return; } _currentVM = args.Result.Convert <BannerLocation, BannerLocationVM>(); _currentVM.Infos = args.Result.Infos.Convert <BannerInfo, BannerInfoVM>(); _currentVM.BannerDimension = args.Result.BannerDimension.Convert <BannerDimension, BannerDimensionVM>(); if (args.Result.WebChannel != null) { _currentVM.ChannelID = args.Result.WebChannel.ChannelID; } //绑定数据时不触发位置改变事件。 this.lstPosition.SelectionChanged -= new SelectionChangedEventHandler(lstPosition_SelectionChanged); this.lstBannerType.SelectionChanged -= new SelectionChangedEventHandler(lstBannerType_SelectionChanged); this.Grid.DataContext = _currentVM; this.SetBannerTypeInfo(); this.ucPageType.PageTypeLoadCompleted += new EventHandler(ucPageType_PageTypeLoadCompleted); this.ucPageType.PageLoadCompleted += new EventHandler(ucPageType_PageLoadCompleted); this.lstBannerType.SelectionChanged += new SelectionChangedEventHandler(lstBannerType_SelectionChanged); this.lstPosition.SelectionChanged += new SelectionChangedEventHandler(lstPosition_SelectionChanged); }); } else { _currentVM = new BannerLocationVM(); this.Grid.DataContext = _currentVM; this.lstChannel.SelectedIndex = 0; this.lstPosition.SelectedIndex = 0; //创建时默认选中所有区域 //this.ucDisplayArea.LoadAreaCompleted += (o, a) => //{ // //创建时默认选中所有区域 // this.ucDisplayArea.SetAllAreaSelected(); //}; //this.ucDisplayArea.SetAllAreaSelected(); this.ucPageType.ExtendC3Visibility = System.Windows.Visibility.Visible; } }