private void HyperlinkButton_Click(object sender, RoutedEventArgs e) { BrandAuthorizedVM vm = this.DataContext as BrandAuthorizedVM; if (string.IsNullOrEmpty(vm.ImageName)) { CPApplication.Current.CurrentPage.Context.Window.Alert("图片路径不能为空!", Newegg.Oversea.Silverlight.Controls.Components.MessageType.Error); return; } //Ocean.20130514, Move to ControlPanelPConfiguration string urlFormat = CPApplication.Current.CurrentPage.Context.Window.Configuration.GetConfigValue(ConstValue.DomainName_ExternalSYS, ConstValue.ConfigKey_External_BrandAuthorizedImageUrl); string url = string.Format(urlFormat, vm.ImageName); facade.UrlIsExist(url, (obj, arg) => { if (arg.FaultsHandle()) { return; } if (arg.Result) { this.spImage.Visibility = Visibility.Visible; this.img.Source = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute)); } else { CPApplication.Current.CurrentPage.Context.Window.Alert("获取图片失败!", Newegg.Oversea.Silverlight.Controls.Components.MessageType.Error); } }); }
private void Button_Click(object sender, RoutedEventArgs e) { BrandAuthorizedList = new List <BrandAuthorizedVM>(); BrandAuthorizedVM vm = this.DataContext as BrandAuthorizedVM; if (!ValidationManager.Validate(this)) { return; } if (vm.StartActiveTime != null && vm.EndActiveTime != null) { if (vm.EndActiveTime.Value.CompareTo(vm.StartActiveTime) < 0) { CPApplication.Current.CurrentPage.Context.Window.Alert(ResBrandAuthorizedMaintain.EndTimeNotLessStartTime, Newegg.Oversea.Silverlight.Controls.Components.MessageType.Error); return; } } if (vm.Category2SysNo == null) { CPApplication.Current.CurrentPage.Context.Window.Alert("授权限制最低为二级类别!", Newegg.Oversea.Silverlight.Controls.Components.MessageType.Error); return; } if (vm.Category2SysNo > 0 && vm.Category3SysNo == null) //只选择了二级类别 { //找到选择的二级类别 var category = (from p in myUCCategoryPicker.Category2List where p.SysNo == vm.Category2SysNo select p).FirstOrDefault(); //将二级类别放在list中 然后一起处理 BrandAuthorizedList.Add(GetBrandAuthorizedVM(2, vm.Category2SysNo, vm, category.CategoryName.Content)); CPApplication.Current.CurrentPage.Context.Window.Confirm("是否批量保存到二级类别下相关的三级类别授权牌!", (obj, arg) => { if (arg.DialogResult == Newegg.Oversea.Silverlight.Controls.Components.DialogResultType.OK) { var list = from p in myUCCategoryPicker.Category3List where p.ParentSysNumber == vm.Category2SysNo select p; //找到该2级类别下所有的3级类别 //将所有三级类别放在list中 foreach (var item in list) { BrandAuthorizedList.Add(GetBrandAuthorizedVM(3, item.SysNo, vm, item.CategoryName.Content)); } ExecAuthorized(0); } }); } if (vm.Category2SysNo > 0 && vm.Category3SysNo > 0) { //找到选择的三级类别 var category = (from p in myUCCategoryPicker.Category3List where p.SysNo == vm.Category3SysNo select p).FirstOrDefault(); //在将选择的三级类放在list中 BrandAuthorizedList.Add(GetBrandAuthorizedVM(3, vm.Category3SysNo, vm, category.CategoryName.Content)); ExecAuthorized(0); } }
private bool isExist = false; //图片地址是否存在 public BrandAuthorizedMaintain() { InitializeComponent(); this.BrandAuthorizedResult.LoadingDataSource += new EventHandler <LoadingDataEventArgs>(BrandAuthorizedResult_LoadingDataSource); this.Loaded += (e, sender) => { facade = new BrandFacade(); model = new BrandAuthorizedVM(); this.DataContext = model; this.BrandAuthorizedResult.Bind(); }; }
/// <summary> /// 得到VM /// </summary> /// <param name="type">三级类或二级类</param> /// <param name="ReferenceSysNo">关联类别的SysNo</param> /// <returns></returns> private BrandAuthorizedVM GetBrandAuthorizedVM(int type, int?ReferenceSysNo, BrandAuthorizedVM vm, string name) { return(new BrandAuthorizedVM() { AuthorizedAcive = vm.AuthorizedAcive, AuthorizedDeAcive = vm.AuthorizedDeAcive, BrandSysNo = BrandSysNo, EndActiveTime = vm.EndActiveTime, ImageName = vm.ImageName, ReferenceSysNo = ReferenceSysNo, StartActiveTime = vm.StartActiveTime, SysNo = vm.SysNo, Type = type, ReferenceName = name }); }
/// <summary> /// 是否存在该授权信息 /// </summary> /// <param name="info"></param> /// <returns></returns> public void IsExistBrandAuthorized(BrandAuthorizedVM model, EventHandler <RestClientEventArgs <bool> > callback) { BrandAuthorizedInfo info = new BrandAuthorizedInfo() { AuthorizedStatus = model.AuthorizedAcive == true ? AuthorizedStatus.Active : AuthorizedStatus.DeActive, BrandSysNo = model.BrandSysNo, ReferenceSysNo = model.ReferenceSysNo, ImageName = model.ImageName, EndActiveTime = model.EndActiveTime, StartActiveTime = model.StartActiveTime, SysNo = model.SysNo, Type = model.Type, }; _restClient.Query(IsExistBrandAuthorizedUrl, info, callback); }
/// <summary> /// 插入授权信息 /// </summary> /// <param name="info"></param> public void InsertBrandAuthorized(BrandAuthorizedVM model, EventHandler <RestClientEventArgs <dynamic> > callback) { BrandAuthorizedInfo info = new BrandAuthorizedInfo() { AuthorizedStatus = model.AuthorizedAcive == true ? AuthorizedStatus.Active : AuthorizedStatus.DeActive, BrandSysNo = model.BrandSysNo, ReferenceSysNo = model.ReferenceSysNo, ImageName = model.ImageName, EndActiveTime = model.EndActiveTime, StartActiveTime = model.StartActiveTime, SysNo = model.SysNo, Type = model.Type, IsExist = model.IsExist, LanguageCode = CPApplication.Current.LanguageCode, CompanyCode = CPApplication.Current.CompanyCode, User = new BizEntity.Common.UserInfo() { UserName = CPApplication.Current.LoginUser.LoginName, SysNo = CPApplication.Current.LoginUser.UserSysNo } }; _restClient.Create(InsertBrandAuthorizedUrl, info, callback); }