Exemplo n.º 1
0
        public void Load(string sysNo, EventHandler <RestClientEventArgs <GroupBuyingMaintainVM> > callback)
        {
            string relativeUrl = "/MKTService/GroupBuying/" + sysNo;

            restClient.Query <GroupBuyingInfo>(relativeUrl, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }

                GroupBuyingInfo entity           = args.Result;
                GroupBuyingMaintainVM _viewModel = null;
                if (entity == null)
                {
                    _viewModel = new GroupBuyingMaintainVM();
                }
                else
                {
                    _viewModel = EtoV(entity);
                }

                callback(obj, new RestClientEventArgs <GroupBuyingMaintainVM>(_viewModel, restClient.Page));
            });
        }
Exemplo n.º 2
0
        private GroupBuyingInfo VtoE(GroupBuyingMaintainVM vm)
        {
            var entity = vm.ConvertVM <GroupBuyingMaintainVM, GroupBuyingInfo>((v, en) =>
            {
                en.GroupBuyingDesc         = new BizEntity.LanguageContent(vm.GroupBuyingDesc);
                en.GroupBuyingDescLong     = new BizEntity.LanguageContent(vm.GroupBuyingDescLong);
                en.GroupBuyingPicUrl       = new BizEntity.LanguageContent(vm.GroupBuyingPicUrl);
                en.GroupBuyingMiddlePicUrl = new BizEntity.LanguageContent(vm.GroupBuyingMiddlePicUrl);
                en.GroupBuyingSmallPicUrl  = new BizEntity.LanguageContent(vm.GroupBuyingSmallPicUrl);
                en.GroupBuyingTitle        = new BizEntity.LanguageContent(vm.GroupBuyingTitle);
                en.GroupBuyingRules        = new BizEntity.LanguageContent(vm.GroupBuyingRules);
            });

            entity.VendorStoreSysNoList = new List <int>();
            if (vm.VendorStoreList != null)
            {
                foreach (var item in vm.VendorStoreList)
                {
                    if (item.IsChecked)
                    {
                        entity.VendorStoreSysNoList.Add(item.SysNo.Value);
                    }
                }
            }
            entity.PriceRankList = vm.ConvertPriceRank();
            return(entity);
        }
Exemplo n.º 3
0
        public void Update(GroupBuyingMaintainVM vm, EventHandler <RestClientEventArgs <GroupBuyingInfo> > callback)
        {
            GroupBuyingInfo entity      = VtoE(vm);
            string          relativeUrl = "/MKTService/GroupBuying/Update";

            restClient.Update(relativeUrl, entity, callback);
        }
Exemplo n.º 4
0
        public void Create(GroupBuyingMaintainVM vm, EventHandler <RestClientEventArgs <GroupBuyingInfo> > callback)
        {
            vm.CompanyCode = CPApplication.Current.CompanyCode;
            GroupBuyingInfo entity = VtoE(vm);

            string relativeUrl = "/MKTService/GroupBuying/Create";

            restClient.Create(relativeUrl, entity, callback);
        }
Exemplo n.º 5
0
        private GroupBuyingMaintainVM EtoV(GroupBuyingInfo entity)
        {
            GroupBuyingMaintainVM viewmodel = entity.Convert <GroupBuyingInfo, GroupBuyingMaintainVM>((en, vm) =>
            {
                if (en.PriceRankList.Count == 1)
                {
                    vm.SysNo1            = en.PriceRankList[0].ProductSysNo.Value;
                    vm.SellCount1        = en.PriceRankList[0].MinQty.ToString();
                    vm.GroupBuyingPrice1 = en.PriceRankList[0].DiscountValue.ToString();
                    //显示第一个阶梯价格
                    vm.Price = vm.GroupBuyingPrice1;
                }
                if (en.PriceRankList.Count == 2)
                {
                    vm.SysNo1            = en.PriceRankList[0].ProductSysNo.Value;
                    vm.SellCount1        = en.PriceRankList[0].MinQty.ToString();
                    vm.GroupBuyingPrice1 = en.PriceRankList[0].DiscountValue.ToString();

                    vm.SysNo2            = en.PriceRankList[1].ProductSysNo.Value;
                    vm.SellCount2        = en.PriceRankList[1].MinQty.ToString();
                    vm.GroupBuyingPrice2 = en.PriceRankList[1].DiscountValue.ToString();
                }
                if (en.PriceRankList.Count == 3)
                {
                    vm.SysNo1            = en.PriceRankList[0].ProductSysNo.Value;
                    vm.SellCount1        = en.PriceRankList[0].MinQty.ToString();
                    vm.GroupBuyingPrice1 = en.PriceRankList[0].DiscountValue.ToString();

                    vm.SysNo2            = en.PriceRankList[1].ProductSysNo.Value;
                    vm.SellCount2        = en.PriceRankList[1].MinQty.ToString();
                    vm.GroupBuyingPrice2 = en.PriceRankList[1].DiscountValue.ToString();

                    vm.SysNo3            = en.PriceRankList[2].ProductSysNo.Value;
                    vm.SellCount3        = en.PriceRankList[2].MinQty.ToString();
                    vm.GroupBuyingPrice3 = en.PriceRankList[2].DiscountValue.ToString();
                }

                vm.GroupBuyingReason = en.Reasons;
            });

            return(viewmodel);
        }
Exemplo n.º 6
0
        public void LoadMarginRateInfo(GroupBuyingMaintainVM vm, EventHandler <RestClientEventArgs <List <GroupBuySaveInfoVM> > > callback)
        {
            GroupBuyingInfo entity = VtoE(vm);

            string relativeUrl = "/MKTService/GroupBuying/LoadMarginRateInfo";

            restClient.Query <List <GroupBuySaveInfo> >(relativeUrl, entity, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }

                List <GroupBuySaveInfoVM> infoVMList = new List <GroupBuySaveInfoVM>();
                foreach (GroupBuySaveInfo info in args.Result)
                {
                    infoVMList.Add(EntityConverter <GroupBuySaveInfo, GroupBuySaveInfoVM> .Convert(info));
                }
                callback(obj, new RestClientEventArgs <List <GroupBuySaveInfoVM> >(infoVMList, _Page));
            });
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取随心配在团购中的毛利率
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="callback"></param>
        public void GetProductPromotionMargionByGroupBuying(GroupBuyingMaintainVM vm, EventHandler <RestClientEventArgs <string> > callback)
        {
            string relativeUrl = "/MKTService/GroupBuying/GetProductPromotionMarginByGroupBuying";

            restClient.Query(relativeUrl, VtoE(vm), callback);
        }
Exemplo n.º 8
0
        public override void OnPageLoad(object sender, EventArgs e)
        {
            base.OnPageLoad(sender, e);
            this.ucItemMaster.ProductSelected += new EventHandler <ProductSelectedEventArgs>(ucItemMaster_ProductSelected);

            _Facade    = new GroupBuyingFacade(this);
            _viewModel = new GroupBuyingMaintainVM();

            if (this.Request.QueryString.ContainsKey("op"))
            {
                _op = this.Request.QueryString["op"];
            }
            if (this.Request.QueryString.ContainsKey("sysNo"))
            {
                sysNo = this.Request.QueryString["sysNo"];
                _Facade.Load(sysNo, (s, args) =>
                {
                    _viewModel       = args.Result;
                    this.DataContext = _viewModel;
                    _viewModel.ValidationErrors.Clear();

                    if (_viewModel.CategoryType == GroupBuyingCategoryType.Virtual)
                    {
                        new ExternalServiceFacade(this).QueryVendorStoreList(this._viewModel.GroupBuyingVendorSysNo, (se, a) =>
                        {
                            if (a.FaultsHandle())
                            {
                                return;
                            }
                            List <VendorStoreVM> list = DynamicConverter <VendorStoreVM> .ConvertToVMList(a.Result.Rows);
                            _viewModel.VendorStoreList.Clear();
                            list.ForEach(p =>
                            {
                                _viewModel.VendorStoreList.Add(p);
                            });
                            foreach (var item in _viewModel.VendorStoreList)
                            {
                                var re = _viewModel.VendorStoreSysNoList.FirstOrDefault(p => p == item.SysNo.Value);
                                if (re > 0)
                                {
                                    item.IsChecked = true;
                                }
                            }
                        });
                    }

                    InitPage(sysNo);

                    new GroupBuyingFacade(this).GetProductOriginalPrice(int.Parse(_viewModel.ProductSysNo), _viewModel.IsByGroup ? "Y" : "N", (obj, a) =>
                    {
                        //_viewModel.OriginalPrice = (a.Result == null || a.Result[0] == null ? 0m : decimal.Round(decimal.Parse(a.Result[0].ToString()), 2));
                        if (a.Result.Count > 4)
                        {
                            _viewModel.GroupBuyingVendorSysNo = int.Parse(a.Result[3].ToString());
                            _viewModel.GroupBuyingVendorName  = a.Result[4].ToString();
                        }
                    });
                });
            }
            else
            {
                _Facade.GetGroupBuyingTypes((s, args) =>
                {
                    if (!args.FaultsHandle())
                    {
                        // _viewModel.GroupBuyingTypeList.Add(0, ECCentral.BizEntity.Enum.Resources.ResCommonEnum.Enum_All);
                        foreach (var gbt in args.Result)
                        {
                            _viewModel.GroupBuyingTypeList.Add(gbt.Key, gbt.Value);
                        }
                        _Facade.GetGroupBuyingAreas((s1, args1) =>
                        {
                            if (!args1.FaultsHandle())
                            {
                                //_viewModel.GroupBuyingAreaList.Add(0, ECCentral.BizEntity.Enum.Resources.ResCommonEnum.Enum_All);
                                foreach (var gba in args1.Result)
                                {
                                    _viewModel.GroupBuyingAreaList.Add(gba.Key, gba.Value);
                                }
                                this.DataContext = _viewModel;

                                InitPage(sysNo);
                            }
                        });
                    }
                });
            }
            //this.DataContext = _viewModel;
        }