예제 #1
0
        private void btnRemoveProduct_Click(object sender, RoutedEventArgs e)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;
            List <SaleGift_RuleSettingViewModel> needRemoveList = new List <SaleGift_RuleSettingViewModel>();

            if (vm.ProductScopeList.Count > 0)
            {
                foreach (SaleGift_RuleSettingViewModel setting in vm.ProductScopeList)
                {
                    if (setting.IsChecked)
                    {
                        needRemoveList.Add(setting);
                    }
                }

                #region
                //非整网规则,不能单独添加排斥类
                string errorStr = ValidateDataForRemove();
                if (!string.IsNullOrEmpty(errorStr))
                {
                    CPApplication.Current.CurrentPage.Context.Window.Alert(errorStr);
                    return;
                }
                #endregion

                needRemoveList.ForEach(f => vm.ProductScopeList.Remove(f));
                dgProduct.ItemsSource = vm.ProductScopeList;
                dgProduct.Bind();
            }
        }
예제 #2
0
        private void cmbType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;

            if (vm.Type.Value == SaleGiftType.Full)
            //vm.Type.Value == SaleGiftType.FirstOrder || vm.Type.Value == SaleGiftType.Additional)
            {
                tbMinAmount.SetReadOnly(false);
            }
            else
            {
                tbMinAmount.SetReadOnly(true);
            }

            if (vm.SysNo.HasValue)
            {
                cmbType.IsEnabled = false;
            }
            else
            {
                cmbType.IsEnabled = true;
                if (vm.Type == SaleGiftType.Full || vm.Type == SaleGiftType.Vendor)
                ////|| vm.Type.Value == SaleGiftType.FirstOrder || vm.Type.Value == SaleGiftType.Additional)
                {
                    vendorPicker.IsEnabled = true;
                }
                else
                {
                    vendorPicker.IsEnabled = false;
                }
            }
        }
예제 #3
0
        public void SaveMaster(SaleGiftInfoViewModel viewModel, EventHandler <RestClientEventArgs <SaleGiftInfoViewModel> > callback)
        {
            if (!viewModel.SysNo.HasValue)
            {
                string relativeUrl = "/MKTService/SaleGift/CreateMaster";
                viewModel.CompanyCode = CPApplication.Current.CompanyCode;
                restClient.Create <int?>(relativeUrl, VtoE(viewModel), (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    viewModel.SysNo           = args.Result;
                    viewModel.Status          = SaleGiftStatus.Init;
                    viewModel.IsGlobalProduct = false;
                    callback(obj, new RestClientEventArgs <SaleGiftInfoViewModel>(viewModel, restClient.Page));
                });
            }
            else
            {
                string relativeUrl = "/MKTService/SaleGift/UpdateMaster";

                restClient.Update <CouponsInfo>(relativeUrl, VtoE(viewModel), (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }

                    callback(obj, new RestClientEventArgs <SaleGiftInfoViewModel>(viewModel, restClient.Page));
                });
            }
        }
예제 #4
0
        void UCSaleGiftRule_Loaded(object sender, RoutedEventArgs e)
        {
            if (isLoaded)
            {
                return;
            }

            chkGiftComboType.IsEnabled = true;
            tbItemGiftCount.IsEnabled  = true;

            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;

            if (vm.Type == SaleGiftType.Vendor)
            {
                chkGiftComboType.IsEnabled = false;
                chkGiftComboType.IsChecked = true;
                tbItemGiftCount.IsEnabled  = false;
            }
            //if (vm.Type == SaleGiftType.Additional)
            //{
            //    chkGiftComboType.IsEnabled = false;
            //    chkGiftComboType.IsChecked = false;
            //}

            this.dgGiftProduct.ItemsSource = vm.GiftItemList;
            this.dgGiftProduct.Bind();

            if (vm.GiftComboType.Value == SaleGiftGiftItemType.GiftPool)
            {
                dgGiftProduct.Columns[dgGiftProduct.Columns.Count - 2].Visibility = System.Windows.Visibility.Collapsed;

                tbItemGiftCount.SetReadOnly(false);
            }
            else
            {
                dgGiftProduct.Columns[dgGiftProduct.Columns.Count - 2].Visibility = System.Windows.Visibility.Visible;

                tbItemGiftCount.SetReadOnly(true);
                tbItemGiftCount.Text = "";
            }

            //如果是满额加购,需要设置加购价格
            //if (vm.Type == SaleGiftType.Additional)
            //{
            //    tbItemGiftCount.Text = "1";
            //    gridGiftType.RowDefinitions[0].Height = new GridLength(0);
            //    dgGiftProduct.Columns[dgGiftProduct.Columns.Count - 3].Visibility = System.Windows.Visibility.Visible;
            //}
            //else
            //{
            //    dgGiftProduct.Columns[dgGiftProduct.Columns.Count - 3].Visibility = System.Windows.Visibility.Collapsed;
            //}

            if (vm.IsOnlyViewMode)
            {
                OperationControlStatusHelper.SetControlsStatus(this.gridLayout, true);
            }

            isLoaded = true;
        }
예제 #5
0
        private void chkGiftProductCheckBoxAll_Click(object sender, RoutedEventArgs e)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;
            CheckBox chk             = (CheckBox)sender;

            vm.GiftItemList.ForEach(f => f.IsChecked = chk.IsChecked.Value);
        }
예제 #6
0
        private void SaleGiftProcess(PSOperationType opt, string optname, SaleGiftStatus targetStatus)
        {
            List <int?> sysNoList = new List <int?>();

            sysNoList.Add(_saleGiftInfoVM.SysNo);

            _facade.BatchProcessSaleGift(sysNoList, opt, (obj, args) =>
            {
                if (args.Result.FailureRecords.Count == 0)
                {
                    if (opt == PSOperationType.SubmitAudit)
                    {
                        _facade.Load(_saleGiftInfoVM.SysNo, _saleGiftInfoVM, (obj1, args1) =>
                        {
                            _saleGiftInfoVM  = args1.Result;
                            this.DataContext = _saleGiftInfoVM;
                            SetControlByOperation();
                        });
                    }
                    else
                    {
                        _saleGiftInfoVM.Status = targetStatus;
                        SetControlByOperation();
                    }
                    //Window.Alert(string.Format("赠品活动-{0}成功!", optname));
                    Window.Alert(string.Format(ResSaleGiftMaitain.Msg_DealSuccess, optname));
                }
                else
                {
                    string msg = args.Result.FailureRecords.Join("\r\n") + Environment.NewLine;
                    Window.Alert(msg);
                }
            });
        }
예제 #7
0
        private void chkDGBrandC3CheckBoxAll_Click(object sender, RoutedEventArgs e)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;
            CheckBox chk             = (CheckBox)sender;

            vm.BrandC3ScopeList.ForEach(f => f.IsChecked = chk.IsChecked.Value);
            dgBrandC3.ItemsSource = vm.BrandC3ScopeList;
            dgBrandC3.Bind();
        }
        private void chkDGProductCheckBoxAll_Click(object sender, RoutedEventArgs e)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;
            CheckBox chk             = (CheckBox)sender;

            foreach (var item in vm.ProductOnlyList)
            {
                item.IsChecked = chk.IsChecked.Value;
            }
            //dgProductOnly.ItemsSource = vm.ProductOnlyList;
        }
예제 #9
0
        public void SetSaleGiftGiftItemRules(SaleGiftInfoViewModel viewModel, EventHandler <RestClientEventArgs <object> > callback)
        {
            string relativeUrl = "/MKTService/SaleGift/SetGiftItemRules";

            restClient.Update(relativeUrl, VtoE(viewModel), (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }
                callback(obj, args);
            });
        }
예제 #10
0
        private void chkIsGlobalProduct_Click(object sender, RoutedEventArgs e)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;

            if ((vm.ProductScopeList != null && vm.ProductScopeList.Count > 0) ||
                (vm.BrandC3ScopeList != null && vm.BrandC3ScopeList.Count > 0))
            {
                CurrentWindow.Confirm("当前已有设置的数据,改变\"整网商品\"的选择后,现有设置将清除!请确认是否要清除?", (obj, args) =>
                {
                    if (args.DialogResult == DialogResultType.OK)
                    {
                        vm.ProductScopeList   = new ObservableCollection <SaleGift_RuleSettingViewModel>();
                        vm.BrandC3ScopeList   = new ObservableCollection <SaleGift_RuleSettingViewModel>();
                        dgBrandC3.ItemsSource = vm.BrandC3ScopeList;
                        dgBrandC3.Bind();
                        dgProduct.ItemsSource = vm.ProductScopeList;
                        dgProduct.Bind();
                    }
                    else
                    {
                        if (chkIsGlobalProduct.IsChecked.Value)
                        {
                            chkIsGlobalProduct.IsChecked = false;
                        }
                        else
                        {
                            chkIsGlobalProduct.IsChecked = true;
                        }
                    }
                });
            }

            if (chkIsGlobalProduct.IsChecked.Value)
            {
                cmbRelation.SelectedValue   = PSRelationType.Exclude;
                cmbRelation.IsEnabled       = false;
                rdoProductExclude.IsEnabled = false;
                rdoProductExclude.IsChecked = true;
                rdoProductInclude.IsEnabled = false;
                rdoProductInclude.IsChecked = false;
            }
            else
            {
                cmbRelation.SelectedValue   = PSRelationType.Include;
                cmbRelation.IsEnabled       = true;
                rdoProductExclude.IsEnabled = true;
                rdoProductExclude.IsChecked = false;
                rdoProductInclude.IsEnabled = true;
                rdoProductInclude.IsChecked = true;
            }
        }
예제 #11
0
        private void btnRemoveProduct_Click(object sender, RoutedEventArgs e)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;
            List <SaleGift_RuleSettingViewModel> needRemoveList = new List <SaleGift_RuleSettingViewModel>();

            if (vm.ProductOnlyList.Count > 0)
            {
                foreach (SaleGift_RuleSettingViewModel setting in vm.ProductOnlyList)
                {
                    if (setting.IsChecked)
                    {
                        needRemoveList.Add(setting);
                    }
                }
                needRemoveList.ForEach(f => vm.ProductOnlyList.Remove(f));
                dgProductOnly.ItemsSource = vm.ProductOnlyList;
                dgProductOnly.Bind();
            }
        }
예제 #12
0
        public override void OnPageLoad(object sender, EventArgs e)
        {
            base.OnPageLoad(sender, e);

            _facade = new SaleGiftFacade(this);

            int tempsysNo = -1;

            if (this.Request.QueryString != null &&
                this.Request.QueryString.ContainsKey("sysno") &&
                int.TryParse(this.Request.QueryString["sysno"].ToString().Trim(), out tempsysNo))
            {
                currentSysNo = tempsysNo;
                if (this.Request.QueryString.ContainsKey("operation") &&
                    !string.IsNullOrEmpty(this.Request.QueryString["operation"].ToString().Trim()))
                {
                    _operationType = this.Request.QueryString["operation"].ToString().ToLower();
                }
            }

            if (_operationType == "edit")
            {
                //TODO:判断是否有编辑的权限,如果没有,则将自动变为view权限
            }
            else if (_operationType == "mgt")
            {
            }
            else
            {
            }

            _saleGiftInfoVM.BeginDate = DateTime.Now;
            _saleGiftInfoVM.EndDate   = DateTime.Now.AddDays(1);

            _facade.Load(currentSysNo, _saleGiftInfoVM, (obj, args) =>
            {
                _saleGiftInfoVM  = args.Result;
                this.DataContext = _saleGiftInfoVM;
                SetControlByOperation();
                SetCanelAuditByRequest();
                _discountBelongSnap = _saleGiftInfoVM.DisCountType;
            });
        }
예제 #13
0
        private string ValidateDataForRemove()
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;
            bool isGlobalProduct     = vm.IsGlobalProduct;


            ObservableCollection <SaleGift_RuleSettingViewModel> dataList = new ObservableCollection <SaleGift_RuleSettingViewModel>();

            vm.BrandC3ScopeList.ForEach(x => dataList.Add(x));
            vm.ProductScopeList.ForEach(x => dataList.Add(x));

            string errorStr = string.Empty;
            ObservableCollection <SaleGift_RuleSettingViewModel> tempData = dataList.DeepCopy();
            List <SaleGift_RuleSettingViewModel> tempDataRemove           = new List <SaleGift_RuleSettingViewModel>();

            foreach (SaleGift_RuleSettingViewModel item in tempData)
            {
                if (item.IsChecked)
                {
                    tempDataRemove.Add(item);
                }
            }
            tempDataRemove.ForEach(x => tempData.Remove(x));

            if (isGlobalProduct == false && tempData.Count > 0)
            {
                bool isPass = false;
                tempData.ForEach(x =>
                {
                    if (x.ComboType != AndOrType.Not)
                    {
                        isPass = true;
                    }
                    ;
                });
                if (isPass == false)
                {
                    errorStr = "未勾选“整网商品”时,请确保列表中存在“包含”类型的销售规则!";
                }
            }

            return(errorStr);
        }
예제 #14
0
        private SaleGiftInfo VtoE(SaleGiftInfoViewModel viewModel)
        {
            viewModel.ProductCondition = new ObservableCollection <SaleGift_RuleSettingViewModel>();
            if (viewModel.ProductOnlyList != null)
            {
                viewModel.ProductOnlyList.ForEach(p =>
                {
                    viewModel.ProductCondition.Add(p);
                });
            }
            if (viewModel.BrandC3ScopeList != null)
            {
                viewModel.BrandC3ScopeList.ForEach(p =>
                {
                    viewModel.ProductCondition.Add(p);
                });
            }
            if (viewModel.ProductScopeList != null)
            {
                viewModel.ProductScopeList.ForEach(p =>
                {
                    viewModel.ProductCondition.Add(p);
                });
            }
            if (viewModel.GiftItemList != null)
            {
                if (viewModel.GiftComboType == SaleGiftGiftItemType.GiftPool)
                {
                    foreach (SaleGift_GiftItemViewModel giftitem in viewModel.GiftItemList)
                    {
                        giftitem.Count = null;
                    }
                }
            }

            SaleGiftInfo entity = viewModel.ConvertVM <SaleGiftInfoViewModel, SaleGiftInfo>();

            entity.Title       = new BizEntity.LanguageContent(viewModel.Title);
            entity.Description = new BizEntity.LanguageContent(viewModel.Description);

            return(entity);
        }
예제 #15
0
        public void Load(int?sysNo, SaleGiftInfoViewModel viewModel, EventHandler <RestClientEventArgs <SaleGiftInfoViewModel> > callback)
        {
            if (!sysNo.HasValue)
            {
                callback(new Object(), new RestClientEventArgs <SaleGiftInfoViewModel>(viewModel, restClient.Page));
                return;
            }
            string relativeUrl = string.Format("/MKTService/SaleGift/{0}", sysNo.Value);

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

                SaleGiftInfo entity = args.Result;
                viewModel           = EtoV(entity);

                callback(obj, new RestClientEventArgs <SaleGiftInfoViewModel>(viewModel, restClient.Page));
            });
        }
예제 #16
0
        private void btnSaveProductRange_Click(object sender, RoutedEventArgs e)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;

            ValidationManager.Validate(this.ucLimitProduct.dgProductOnly);

            foreach (SaleGift_RuleSettingViewModel rowVM in vm.ProductCondition)
            {
                if (rowVM.HasValidationErrors)
                {
                    return;
                }

                if (rowVM.RelProduct != null && rowVM.RelProduct.HasValidationErrors)
                {
                    return;
                }
            }

            foreach (SaleGift_RuleSettingViewModel rm in vm.ProductOnlyList)
            {
                if (rm.HasValidationErrors)
                {
                    return;
                }

                if (rm.RelProduct != null && rm.RelProduct.HasValidationErrors)
                {
                    return;
                }
            }

            SaleGiftFacade facade = new SaleGiftFacade(CPApplication.Current.CurrentPage);

            facade.SetSaleGiftSaleRules(vm, (obj, args) =>
            {
                CurrentWindow.Alert("主商品规则保存成功!");
            });
        }
예제 #17
0
        void UCSaleGiftLimitScope_Loaded(object sender, RoutedEventArgs e)
        {
            if (isLoaded)
            {
                return;
            }

            List <KeyValuePair <PSRelationType?, string> > statusList = EnumConverter.GetKeyValuePairs <PSRelationType>();

            cmbRelation.ItemsSource   = statusList;
            cmbRelation.SelectedIndex = 0;

            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;

            dgBrandC3.ItemsSource = vm.BrandC3ScopeList;
            dgBrandC3.Bind();
            dgProduct.ItemsSource = vm.ProductScopeList;
            dgProduct.Bind();
            if (vm.IsGlobalProduct)
            {
                cmbRelation.SelectedValue   = PSRelationType.Exclude;
                cmbRelation.IsEnabled       = false;
                rdoProductExclude.IsEnabled = false;
                rdoProductExclude.IsChecked = true;
                rdoProductInclude.IsEnabled = false;
                rdoProductInclude.IsChecked = false;
            }
            else
            {
                cmbRelation.IsEnabled       = true;
                rdoProductExclude.IsEnabled = true;
                rdoProductExclude.IsChecked = false;
                rdoProductInclude.IsEnabled = true;
                rdoProductInclude.IsChecked = true;
            }

            isLoaded = true;
        }
예제 #18
0
        void UCSaleGiftLimitProduct_Loaded(object sender, RoutedEventArgs e)
        {
            if (isLoaded)
            {
                return;
            }

            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;

            if (vm.Type.Value == SaleGiftType.Vendor || vm.Type.Value == SaleGiftType.Single)
            {
                dgProductOnly.Columns[9].Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                dgProductOnly.Columns[9].Visibility = System.Windows.Visibility.Visible;
            }

            dgProductOnly.ItemsSource = vm.ProductOnlyList;
            dgProductOnly.Bind();

            isLoaded = true;
        }
예제 #19
0
        private string ValidateDataForAdd(SaleGift_RuleSettingViewModel addData)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;
            bool isGlobalProduct     = vm.IsGlobalProduct;


            ObservableCollection <SaleGift_RuleSettingViewModel> dataList = new ObservableCollection <SaleGift_RuleSettingViewModel>();

            vm.BrandC3ScopeList.ForEach(x => dataList.Add(x));
            vm.ProductScopeList.ForEach(x => dataList.Add(x));

            string errorStr = string.Empty;
            //非整网规则,不能单独添加排斥类
            ObservableCollection <SaleGift_RuleSettingViewModel> tempData = dataList.DeepCopy();

            tempData.Add(addData);

            if (isGlobalProduct == false && tempData.Count > 0)
            {
                bool isPass = false;
                tempData.ForEach(x =>
                {
                    if (x.ComboType != AndOrType.Not)
                    {
                        isPass = true;
                    }
                    ;
                });
                if (isPass == false)
                {
                    errorStr = "未勾选“整网商品”时,请确保列表中存在“包含”类型的销售规则!";
                }
            }

            return(errorStr);
        }
예제 #20
0
        void UCSaleGiftProductRange_Loaded(object sender, RoutedEventArgs e)
        {
            if (isLoaded)
            {
                return;
            }

            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;

            if (vm.IsOnlyViewMode)
            {
                OperationControlStatusHelper.SetControlsStatus(this.ucLimitScope, true);
                OperationControlStatusHelper.SetControlsStatus(this.ucLimitProduct, true);
            }


            //if (vm.Type == SaleGiftType.Full)
            //{
            //    this.ucLimitProduct.dgProductOnly.Columns[8].Visibility = System.Windows.Visibility.Collapsed;
            //}


            isLoaded = true;
        }
예제 #21
0
        private void btnSaveBasic_Click(object sender, RoutedEventArgs e)
        {
            CPApplication.Current.CurrentPage.Context.Window.MessageBox.Clear();

            ValidationManager.Validate(this.ucBasic.gridBasic);
            if (_saleGiftInfoVM.HasValidationErrors)
            {
                return;
            }

            if (_saleGiftInfoVM.Type != SaleGiftType.Vendor)
            {
                if (string.IsNullOrEmpty(_saleGiftInfoVM.Title))
                {
                    _saleGiftInfoVM.ValidationErrors.Add(new ValidationResult(ResSaleGiftMaitain.Msg_RequireTitle, new List <string> {
                        "Title"
                    }));
                }
            }

            if (_saleGiftInfoVM.Type == SaleGiftType.Full)
            //|| _saleGiftInfoVM.Type == SaleGiftType.FirstOrder || _saleGiftInfoVM.Type == SaleGiftType.Additional)
            {
                if (string.IsNullOrEmpty(_saleGiftInfoVM.Description))
                {
                    _saleGiftInfoVM.ValidationErrors.Add(new ValidationResult(ResSaleGiftMaitain.Msg_RequireDescription, new List <string> {
                        "Description"
                    }));
                }

                if (string.IsNullOrEmpty(_saleGiftInfoVM.OrderCondition.OrderMinAmount))
                {
                    _saleGiftInfoVM.ValidationErrors.Add(new ValidationResult(ResSaleGiftMaitain.Msg_RequireOrderMinAmount, new List <string> {
                        "OrderMinAmount"
                    }));
                }
            }
            if (_saleGiftInfoVM.HasValidationErrors)
            {
                return;
            }

            _saleGiftInfoVM.ValidationErrors.Clear();

            bool needReload = false;

            if (_saleGiftInfoVM.SysNo.HasValue && _saleGiftInfoVM.DisCountType != _discountBelongSnap)
            {
                needReload = true;
            }

            _facade.SaveMaster(_saleGiftInfoVM, (obj, args) =>
            {
                _saleGiftInfoVM = args.Result;

                if (needReload)
                {
                    _facade.Load(_saleGiftInfoVM.SysNo, _saleGiftInfoVM, (obj1, args1) =>
                    {
                        _saleGiftInfoVM  = args1.Result;
                        this.DataContext = _saleGiftInfoVM;
                        if (_saleGiftInfoVM.ProductOnlyList != null && _saleGiftInfoVM.ProductOnlyList.Count > 0)
                        {
                            this.ucProductRange.ucLimitProduct.dgProductOnly.ItemsSource = _saleGiftInfoVM.ProductOnlyList;
                        }

                        if (_saleGiftInfoVM.GiftItemList != null && _saleGiftInfoVM.GiftItemList.Count > 0)
                        {
                            this.ucGiftRule.dgGiftProduct.ItemsSource = _saleGiftInfoVM.GiftItemList;
                        }
                        _discountBelongSnap = _saleGiftInfoVM.DisCountType;
                        //Window.Alert("保存成功!");
                        Window.Alert(ResSaleGiftMaitain.Msg_SaveSuccess);
                    });
                }
                else
                {
                    _operationType = "edit";

                    SetControlByOperation();
                    //Window.Alert("保存成功!");
                    Window.Alert(ResSaleGiftMaitain.Msg_SaveSuccess);
                }
            });
        }
예제 #22
0
        private SaleGiftInfoViewModel EtoV(SaleGiftInfo entity)
        {
            SaleGiftInfoViewModel viewmodel = entity.Convert <SaleGiftInfo, SaleGiftInfoViewModel>((en, vm) =>
            {
                vm.Title       = entity.Title.Content;
                vm.Description = entity.Description.Content;
            });

            if (entity.WebChannel != null)
            {
                viewmodel.WebChannel = new Basic.Components.Models.WebChannelVM()
                {
                    ChannelID = entity.WebChannel.ChannelID, ChannelName = entity.WebChannel.ChannelName
                };
            }
            else
            {
                viewmodel.WebChannel = viewmodel.WebChennelList[0];
            }
            //目前只有买满即送才有复杂的主商品范围规则
            viewmodel.BrandC3ScopeList = new ObservableCollection <SaleGift_RuleSettingViewModel>();
            viewmodel.ProductScopeList = new ObservableCollection <SaleGift_RuleSettingViewModel>();
            viewmodel.ProductOnlyList  = new ObservableCollection <SaleGift_RuleSettingViewModel>();

            //modified by poseidon.y.tong at 2013-08-22 10:36:48
            //新增赠品类型:首次下单、满额加购都有复杂的商品范围规则
            if (viewmodel.Type.Value == SaleGiftType.Full)
            //||  viewmodel.Type.Value == SaleGiftType.FirstOrder  || viewmodel.Type.Value == SaleGiftType.Additional)
            {
                foreach (SaleGift_RuleSettingViewModel rule in viewmodel.ProductCondition)
                {
                    if (rule.Type.Value != SaleGiftSaleRuleType.Item)
                    {
                        viewmodel.BrandC3ScopeList.Add(rule);
                    }
                    else
                    {
                        viewmodel.ProductScopeList.Add(rule);
                    }
                }
            }
            else
            {
                viewmodel.ProductOnlyList = viewmodel.ProductCondition;
            }

            if (viewmodel.GiftItemList == null)
            {
                viewmodel.GiftItemList = new List <SaleGift_GiftItemViewModel>();
            }
            else
            {
                if (viewmodel.GiftComboType == SaleGiftGiftItemType.GiftPool)
                {
                    foreach (SaleGift_GiftItemViewModel giftitem in viewmodel.GiftItemList)
                    {
                        giftitem.Count = "0";
                    }
                }
            }

            return(viewmodel);
        }
예제 #23
0
        /// <summary>
        /// 有高级权限时
        /// step1 在服务器端去检查主商品是否有货
        /// step2 主商品有货时在检查赠品和主商品在同一个仓库是否都有货
        /// step3 前两个条件任何一个为否 将抛出异常 提示是否继续添加(高级权限可继续,一般权限则不能进行保存)
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="callback"></param>
        public void CheckGiftStockResult(SaleGiftInfoViewModel viewModel, EventHandler <RestClientEventArgs <string> > callback)
        {
            string relativeUrl = "/MKTService/SaleGift/CheckGiftStockResult";

            restClient.Query(relativeUrl, VtoE(viewModel), callback);
        }
예제 #24
0
        private void btnSaveGiftSetting_Click(object sender, RoutedEventArgs e)
        {
            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;

            if (vm.GiftComboType == SaleGiftGiftItemType.GiftPool)
            {
                foreach (SaleGift_GiftItemViewModel giftitem in vm.GiftItemList)
                {
                    giftitem.Count = "0";
                    if (string.IsNullOrEmpty(giftitem.PlusPrice))
                    {
                        giftitem.PlusPrice = giftitem.CurrentPrice.GetValueOrDefault().ToString("f2");
                    }
                }
                int count = 0;
                int.TryParse(vm.ItemGiftCount, out count);
                if (string.IsNullOrEmpty(vm.ItemGiftCount) || count < 1)
                {
                    tbItemGiftCount.Validation("赠品池任选总数量不能为空并且必须为大于0的整数!", vm, this.gridGiftType);
                    return;
                }
                else
                {
                    tbItemGiftCount.ClearValidationError();
                }
            }
            else
            {
                tbItemGiftCount.ClearValidationError();
            }

            List <SaleGift_GiftItemViewModel> list = dgGiftProduct.ItemsSource as List <SaleGift_GiftItemViewModel>;

            if (list == null || list.Count == 0)
            {
                CurrentWindow.Alert("请至少设置1个赠品!");
                return;
            }

            if (vm.GiftComboType.Value == SaleGiftGiftItemType.AssignGift)
            {
                foreach (SaleGift_GiftItemViewModel item in list)
                {
                    if (string.IsNullOrEmpty(item.Count) || item.Count.Equals("0"))
                    {
                        CurrentWindow.Alert("赠品数量必须大于0!");
                        return;
                    }
                }
            }

            ValidationManager.Validate(this.dgGiftProduct);
            foreach (SaleGift_GiftItemViewModel rowVM in list)
            {
                if (rowVM.HasValidationErrors)
                {
                    return;
                }
            }


            SaleGiftFacade facade = new SaleGiftFacade(CPApplication.Current.CurrentPage);

            if (vm.IsAccess) //有高级权限
            {
                facade.CheckGiftStockResult(vm, (obj, arg) =>
                {
                    if (arg.FaultsHandle())
                    {
                        return;
                    }
                    if (arg.Result.Length > 0)
                    {
                        CPApplication.Current.CurrentPage.Context.Window.Confirm(arg.Result + ";是否继续保存?", (objs, args) =>
                        {
                            if (args.DialogResult == Newegg.Oversea.Silverlight.Controls.Components.DialogResultType.OK)
                            {
                                facade.SetSaleGiftGiftItemRules(vm, (o, a) =>
                                {
                                    if (a.FaultsHandle())
                                    {
                                        return;
                                    }
                                    CurrentWindow.Alert("赠品规则保存成功!");
                                });
                            }
                        });
                    }
                    else
                    {
                        facade.SetSaleGiftGiftItemRules(vm, (o, a) =>
                        {
                            if (a.FaultsHandle())
                            {
                                return;
                            }
                            CurrentWindow.Alert("赠品规则保存成功!");
                        });
                    }
                });
            }
            else
            {
                facade.SetSaleGiftGiftItemRules(vm, (o, a) =>
                {
                    if (a.FaultsHandle())
                    {
                        return;
                    }
                    CurrentWindow.Alert("赠品规则保存成功!");
                });
            }
        }
예제 #25
0
        private void btnAddBrandC3_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(ucBrand.SelectedBrandSysNo) && !ucCategory.ChooseCategory3SysNo.HasValue)
            {
                CurrentWindow.Alert("品牌和分类至少选择一项且分类至少是三级分类!");
                return;
            }

            SaleGiftInfoViewModel vm = this.DataContext as SaleGiftInfoViewModel;

            SaleGift_RuleSettingViewModel settingVM = new SaleGift_RuleSettingViewModel();

            if (vm.IsGlobalProduct)
            {
                settingVM.ComboType = AndOrType.Not;
            }
            else
            {
                settingVM.ComboType = ((PSRelationType)cmbRelation.SelectedValue) == PSRelationType.Include ? AndOrType.Or : AndOrType.Not;
            }

            if (!string.IsNullOrEmpty(ucBrand.SelectedBrandSysNo))
            {
                settingVM.RelBrand.SysNo = int.Parse(ucBrand.SelectedBrandSysNo);
                settingVM.RelBrand.Name  = ucBrand.SelectedBrandName;
            }
            if (ucCategory.ChooseCategory3SysNo.HasValue)
            {
                settingVM.RelC3.SysNo = ucCategory.ChooseCategory3SysNo;
                settingVM.RelC3.Name  = ucCategory.Category3Name;
            }

            if (!string.IsNullOrEmpty(ucBrand.SelectedBrandSysNo) && ucCategory.ChooseCategory3SysNo.HasValue)
            {
                if (vm.BrandC3ScopeList.FirstOrDefault(f => f.RelBrand.SysNo == settingVM.RelBrand.SysNo && f.RelC3.SysNo == settingVM.RelC3.SysNo) != null)
                {
                    CPApplication.Current.CurrentPage.Context.Window.Alert("相同的数据已经存在!");
                    return;
                }

                settingVM.Type = SaleGiftSaleRuleType.BrandC3Combo;
            }
            else
            {
                if (!string.IsNullOrEmpty(ucBrand.SelectedBrandSysNo))
                {
                    if (vm.BrandC3ScopeList.FirstOrDefault(f => f.RelBrand.SysNo == settingVM.RelBrand.SysNo && f.RelC3.SysNo == null) != null)
                    {
                        CPApplication.Current.CurrentPage.Context.Window.Alert("相同的数据已经存在!");
                        return;
                    }
                    settingVM.Type = SaleGiftSaleRuleType.Brand;
                }
                else if (ucCategory.ChooseCategory3SysNo.HasValue)
                {
                    if (vm.BrandC3ScopeList.FirstOrDefault(f => f.RelC3.SysNo == settingVM.RelC3.SysNo && f.RelBrand.SysNo == null) != null)
                    {
                        CPApplication.Current.CurrentPage.Context.Window.Alert("相同的数据已经存在!");
                        return;
                    }
                    settingVM.Type = SaleGiftSaleRuleType.C3;
                }
            }
            settingVM.IsChecked = false;



            #region
            //非整网规则,不能单独添加排斥类
            string errorStr = ValidateDataForAdd(settingVM);
            if (!string.IsNullOrEmpty(errorStr))
            {
                CPApplication.Current.CurrentPage.Context.Window.Alert(errorStr);
                return;
            }
            #endregion


            vm.BrandC3ScopeList.Add(settingVM);

            dgBrandC3.ItemsSource = vm.BrandC3ScopeList;
            dgBrandC3.Bind();
        }
예제 #26
0
        private void btnAddProduct_Click(object sender, RoutedEventArgs e)
        {
            UCProductSearch ucPicker = new UCProductSearch();

            ucPicker.SelectionMode = SelectionMode.Multiple;
            ucPicker.DialogHandler = CurrentWindow.ShowDialog("选择商品", ucPicker, (obj, args) =>
            {
                if (args.DialogResult == DialogResultType.OK)
                {
                    if (args.Data == null)
                    {
                        return;
                    }
                    SaleGiftInfoViewModel vm      = this.DataContext as SaleGiftInfoViewModel;
                    List <ProductVM> selectedList = args.Data as List <ProductVM>;

                    StringBuilder message = new StringBuilder();

                    foreach (ProductVM product in selectedList)
                    {
                        //if (product.Status.Value != BizEntity.IM.ProductStatus.Active)
                        //{
                        //    message.AppendLine(string.Format("商品{0}必须为上架商品!",product.ProductID));
                        //    continue;
                        //}

                        SaleGift_RuleSettingViewModel settingVM = new SaleGift_RuleSettingViewModel();
                        settingVM.IsChecked = false;

                        settingVM.RelProduct.ProductSysNo = product.SysNo;
                        settingVM.RelProduct.ProductID    = product.ProductID;
                        settingVM.RelProduct.ProductName  = product.ProductName;
                        settingVM.RelProduct.AvailableQty = product.AvailableQty;
                        settingVM.RelProduct.ConsignQty   = product.ConsignQty;
                        settingVM.RelProduct.VirtualQty   = product.OnlineQty - (product.AvailableQty + product.ConsignQty);
                        settingVM.RelProduct.UnitCost     = product.UnitCost;
                        settingVM.RelProduct.CurrentPrice = product.CurrentPrice;
                        //获取商品的毛利
                        //new CouponsFacade(CPApplication.Current.CurrentPage).GetCouponGrossMarginRate(product.SysNo.Value, (s, a) =>
                        //{
                        //    settingVM.RelProduct.GrossMarginRate = a.Result;
                        //});
                        settingVM.RelProduct.MinQty = "1";

                        if (vm.ProductOnlyList.FirstOrDefault(f => f.RelProduct.ProductSysNo == settingVM.RelProduct.ProductSysNo) != null)
                        {
                            message.AppendLine(string.Format("商品{0}已经存在!", product.ProductID));
                            continue;
                        }

                        settingVM.Type      = SaleGiftSaleRuleType.Item;
                        settingVM.ComboType = AndOrType.And;

                        vm.ProductOnlyList.Add(settingVM);
                    }

                    if (message.Length > 0)
                    {
                        CPApplication.Current.CurrentPage.Context.Window.Alert(message.ToString(), MessageType.Warning);
                    }

                    dgProductOnly.ItemsSource = vm.ProductOnlyList;
                }
            });
        }
예제 #27
0
        private void btnAddGift_Click(object sender, RoutedEventArgs e)
        {
            UCProductSearch ucPicker = new UCProductSearch();

            ucPicker.SelectionMode = SelectionMode.Multiple;
            ucPicker.DialogHandler = CurrentWindow.ShowDialog("选择商品", ucPicker, (obj, args) =>
            {
                if (args.DialogResult == DialogResultType.OK)
                {
                    SaleGiftInfoViewModel vm      = this.DataContext as SaleGiftInfoViewModel;
                    List <ProductVM> selectedList = args.Data as List <ProductVM>;

                    StringBuilder message = new StringBuilder();

                    foreach (ProductVM product in selectedList)
                    {
                        //赠品必须是非展示状态
                        if (product.Status != BizEntity.IM.ProductStatus.InActive_Show)
                        {
                            message.AppendLine(string.Format("赠品{0}必须是非展示状态!", product.ProductID));
                            continue;
                        }


                        SaleGift_GiftItemViewModel giftVM = new SaleGift_GiftItemViewModel();
                        giftVM.IsChecked = false;

                        giftVM.ProductSysNo = product.SysNo;
                        giftVM.ProductID    = product.ProductID;
                        giftVM.ProductName  = product.ProductName;
                        giftVM.AvailableQty = product.AvailableQty;
                        giftVM.ConsignQty   = product.ConsignQty;
                        giftVM.VirtualQty   = product.OnlineQty - (product.AvailableQty + product.ConsignQty);
                        giftVM.UnitCost     = product.UnitCost;
                        giftVM.CurrentPrice = product.CurrentPrice;

                        if (vm.GiftItemList.FirstOrDefault(f => f.ProductSysNo == giftVM.ProductSysNo) != null)
                        {
                            message.AppendLine(string.Format("商品{0}已经存在!", product.ProductID));
                            continue;
                        }

                        //获取商品的毛利
                        new CouponsFacade(CPApplication.Current.CurrentPage).GetCouponGrossMarginRate(product.SysNo.Value, (s, a) =>
                        {
                            giftVM.GrossMarginRate = a.Result;
                        });

                        giftVM.Priority = (vm.GiftItemList.Count + 1).ToString();
                        if (vm.GiftComboType.Value == SaleGiftGiftItemType.AssignGift)
                        {
                            giftVM.Count = "1";
                        }
                        else
                        {
                            giftVM.Count     = "0";
                            giftVM.PlusPrice = giftVM.CurrentPrice.GetValueOrDefault().ToString("f2");
                        }

                        vm.GiftItemList.Add(giftVM);
                    }

                    if (message.Length > 0)
                    {
                        CPApplication.Current.CurrentPage.Context.Window.Alert(message.ToString(), MessageType.Warning);
                    }

                    dgGiftProduct.ItemsSource = vm.GiftItemList;
                    dgGiftProduct.Bind();
                }
            });
        }
예제 #28
0
        private void btnAddProduct_Click(object sender, RoutedEventArgs e)
        {
            UCProductSearch ucPicker = new UCProductSearch();

            ucPicker.SelectionMode = SelectionMode.Multiple;
            ucPicker.DialogHandler = CurrentWindow.ShowDialog("选择商品", ucPicker, (obj, args) =>
            {
                if (args.DialogResult == DialogResultType.OK)
                {
                    SaleGiftInfoViewModel vm      = this.DataContext as SaleGiftInfoViewModel;
                    List <ProductVM> selectedList = args.Data as List <ProductVM>;
                    StringBuilder message         = new StringBuilder();

                    foreach (ProductVM product in selectedList)
                    {
                        //if (product.Status.Value != BizEntity.IM.ProductStatus.Active)
                        //{
                        //    message.AppendLine(string.Format("商品{0}必须为上架商品!", product.ProductID));
                        //    continue;
                        //}

                        SaleGift_RuleSettingViewModel settingVM = new SaleGift_RuleSettingViewModel();
                        settingVM.IsChecked = false;

                        settingVM.RelProduct.ProductSysNo = product.SysNo;
                        settingVM.RelProduct.ProductID    = product.ProductID;
                        settingVM.RelProduct.ProductName  = product.ProductName;
                        settingVM.RelProduct.AvailableQty = product.AvailableQty;
                        settingVM.RelProduct.ConsignQty   = product.ConsignQty;
                        settingVM.RelProduct.UnitCost     = product.UnitCost;
                        settingVM.RelProduct.CurrentPrice = product.CurrentPrice;

                        if (vm.ProductScopeList.FirstOrDefault(f => f.RelProduct.ProductSysNo == settingVM.RelProduct.ProductSysNo) != null)
                        {
                            message.AppendLine(string.Format("商品{0}已经存在!", product.ProductID));
                            continue;
                        }

                        //获取商品的毛利
                        //new CouponsFacade(CPApplication.Current.CurrentPage).GetCouponGrossMarginRate(product.SysNo.Value, (s, a) =>
                        //{
                        //    settingVM.RelProduct.GrossMarginRate = a.Result;
                        //});

                        settingVM.Type = SaleGiftSaleRuleType.Item;
                        if (vm.IsGlobalProduct)
                        {
                            settingVM.ComboType = AndOrType.Not;
                        }
                        else
                        {
                            if (rdoProductInclude.IsChecked.HasValue && rdoProductInclude.IsChecked.Value)
                            {
                                settingVM.ComboType = AndOrType.Or;
                            }
                            else
                            {
                                settingVM.ComboType = AndOrType.Not;
                            }
                        }

                        #region
                        //非整网规则,不能单独添加排斥类
                        string errorStr = ValidateDataForAdd(settingVM);
                        if (!string.IsNullOrEmpty(errorStr))
                        {
                            CPApplication.Current.CurrentPage.Context.Window.Alert(errorStr);
                            return;
                        }
                        #endregion

                        vm.ProductScopeList.Add(settingVM);
                    }

                    if (message.Length > 0)
                    {
                        CPApplication.Current.CurrentPage.Context.Window.Alert(message.ToString(), MessageType.Warning);
                    }

                    dgProduct.ItemsSource = vm.ProductScopeList;
                }
            });
        }