Exemplo n.º 1
0
        public void C3SelectChangedClick(object sender, EventArgs e)
        {
            var cmbSelect = (Combox)sender;

            if (cmbSelect.SelectedValue != null)
            {
                var productGroupFacade = new ProductGroupFacade();
                productGroupFacade.GetCategorySetting((int)cmbSelect.SelectedValue, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }

                    var categoryPropertyList = productGroupFacade.ConvertCategoryPropertyListToPropertyVMList(
                        args.Result.CategoryProperties.Where(
                            property => property.PropertyType == PropertyType.Grouping));

                    categoryPropertyList.Insert(0, new PropertyVM
                    {
                        SysNo        = 0,
                        PropertyName = "请选择..."
                    });

                    var currentPage = (Views.ProductGroupMaintain)CPApplication.Current.CurrentPage;
                    currentPage.VM.PropertyVM.CategoryPropertyList = categoryPropertyList;
                    RefreshProductGroupSettingVM(currentPage.VM.PropertyVM.ProductGroupSettings[0]);
                    RefreshProductGroupSettingVM(currentPage.VM.PropertyVM.ProductGroupSettings[1]);
                });
            }
        }
Exemplo n.º 2
0
        public override void OnPageLoad(object sender, EventArgs e)
        {
            base.OnPageLoad(sender, e);

            int productGroupSysNo;

            _vm = new ProductGroupMaintainVM();

            if (Int32.TryParse(Request.Param, out productGroupSysNo))
            {
                _productGroupFacade = new ProductGroupFacade(this);

                _vm.CreateFlag = false;

                ucProductGroupMaintainBasicInfo.ucCategoryPicker
                .LoadCategoryCompleted += (s, arg)
                                          => _productGroupFacade.GetProductGroupInfoBySysNo(productGroupSysNo, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    if (args.Result == null || !args.Result.SysNo.HasValue || args.Result.ProductList.Count == 0)
                    {
                        Window.MessageBox.Show("无此商品组或商品组数据完整性有误,请联系管理员检查", MessageBoxType.Error);
                        return;
                    }
                    ucProductGroupMaintainBasicInfo.ucCategoryPicker.cmbCategory3SelectionChanged -= ucProductGroupMaintainBasicInfo.C3SelectChangedClick;
                    _vm.ProductGroupSysNo = args.Result.SysNo.Value;
                    _vm.BasicInfoVM       =
                        _productGroupFacade.ConvertProductGroupEntityToProductGroupMaintainBasicInfoVM(args.Result);
                    _vm.ProductListVM =
                        _productGroupFacade.ConvertProductGroupEntityToProductGroupMaintainProductListVM(args.Result);
                    var sysNo = args.Result.ProductList.First().ProductBasicInfo.ProductCategoryInfo.SysNo;
                    if (sysNo.HasValue)
                    {
                        _productGroupFacade.GetCategorySetting(sysNo.Value, (o, a) =>
                        {
                            if (a.FaultsHandle())
                            {
                                return;
                            }

                            var categoryPropertyList = _productGroupFacade.
                                                       ConvertCategoryPropertyListToPropertyVMList
                                                           (a.Result.CategoryProperties.Where(property => property.PropertyType == PropertyType.Grouping));

                            categoryPropertyList.Insert(0, new PropertyVM
                            {
                                SysNo        = 0,
                                PropertyName = "请选择..."
                            });

                            _vm.PropertyVM =
                                _productGroupFacade.ConvertProductGroupEntityToProductGroupMaintainPropertySettingVM(
                                    args.Result);

                            _vm.PropertyVM.CategoryPropertyList
                                = categoryPropertyList;

                            DataContext = _vm;
                            ucProductGroupMaintainProductList.dgProductGroupProductList.ItemsSource =
                                _vm.ProductListVM.ProductGroupProductVMList;
                        });
                    }
                });
            }
            else
            {
                _vm.CreateFlag = true;
                DataContext    = _vm;
            }
        }