Exemplo n.º 1
0
        private void btnChooseBrand_Click(object sender, MouseButtonEventArgs e)
        {
            UCBrandQuery selectDialog = new UCBrandQuery()
            {
                SelectionMode = SelectionMode.Multiple
            };

            selectDialog.Dialog = CPApplication.Current.CurrentPage.Context.Window.ShowDialog("供应商查询", selectDialog, (obj, args) =>
            {
                if (args.DialogResult == Newegg.Oversea.Silverlight.Controls.Components.DialogResultType.OK)
                {
                    List <string> vendorList            = new List <string>();
                    List <DynamicXml> getSelectedBrands = args.Data as List <DynamicXml>;
                    if (null != getSelectedBrands)
                    {
                        foreach (DynamicXml getSelectedBrand in getSelectedBrands)
                        {
                            vendorList.Add(getSelectedBrand["BrandName_Ch"].ToString());
                            PageQueryView.BrandSysNoList.Add(Convert.ToInt32(getSelectedBrand["SysNo"]));
                        }
                        this.txtBrandName.Text = vendorList.Join(",");
                    }
                }
            }, new Size(750, 650));
        }
Exemplo n.º 2
0
        private void btnAddBrand_Click(object sender, RoutedEventArgs e)
        {
            UCBrandQuery selectDialog = new UCBrandQuery();

            selectDialog.Dialog = CPApplication.Current.CurrentPage.Context.Window.ShowDialog("查询品牌", selectDialog, (obj, args) =>
            {
                if (args.DialogResult == Newegg.Oversea.Silverlight.Controls.Components.DialogResultType.OK)
                {
                    DynamicXml getSelectedBrand = args.Data as DynamicXml;
                    if (null != getSelectedBrand)
                    {
                        //验证品牌是否有效
                        var status = getSelectedBrand["Status"].ToString();
                        if (status != "Active")
                        {
                            CPApplication.Current.CurrentPage.Context.Window.Alert("只能添加有效的品牌!");
                            return;
                        }
                        CouponsInfoViewModel vm = (CouponsInfoViewModel)this.DataContext;
                        if (vm.ProductCondition == null)
                        {
                            vm.ProductCondition = new PSProductConditionViewModel();
                        }
                        if (vm.ProductCondition.RelBrands == null)
                        {
                            vm.ProductCondition.RelBrands = new RelBrandViewModel();
                        }
                        if (vm.ProductCondition.RelBrands.BrandList == null)
                        {
                            vm.ProductCondition.RelBrands.BrandList = new List <SimpleObjectViewModel>();
                        }

                        if (vm.ProductCondition.RelBrands.BrandList.FirstOrDefault(f => f.SysNo.ToString() == getSelectedBrand["SysNo"].ToString()) == null)
                        {
                            vm.ProductCondition.RelBrands.BrandList.Add(new SimpleObjectViewModel()
                            {
                                SysNo     = int.Parse(getSelectedBrand["SysNo"].ToString()),
                                Name      = getSelectedBrand["BrandName_Ch"].ToString(),
                                Relation  = vm.ProductCondition.RelBrands.IsIncludeRelation.Value ? PSRelationType.Include : PSRelationType.Exclude,
                                IsChecked = false
                            });
                        }

                        dgBrand.ItemsSource = vm.ProductCondition.RelBrands.BrandList;
                    }
                }
            });
        }