Ejemplo n.º 1
0
        public override OPResult AddOrUpdate(OrganizationContractDiscount entity)
        {
            OrganizationContractDiscountBO contractdiscount = (OrganizationContractDiscountBO)entity;
            var byq = ProductLogic.GetBYQ(contractdiscount.BrandID, contractdiscount.Year, contractdiscount.Quarter);

            if (byq == null)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "未找到相应的品牌年份季度信息"
                });
            }
            contractdiscount.BYQID = byq.ID;
            bool isAdd = contractdiscount.ID == default(int);

            if (isAdd)
            {
                if (LinqOP.Any <OrganizationContractDiscount>(o => o.OrganizationID == contractdiscount.OrganizationID && o.BYQID == contractdiscount.BYQID))
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "已为该机构指定了对应款式的合同折扣"
                    });
                }
            }
            else
            {
                if (LinqOP.Any <OrganizationContractDiscount>(o => o.OrganizationID == contractdiscount.OrganizationID && o.ID != contractdiscount.ID && o.BYQID == contractdiscount.BYQID))
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "已为该机构指定了对应款式的合同折扣"
                    });
                }
            }
            return(base.AddOrUpdate(entity));
        }
Ejemplo n.º 2
0
        public override OPResult AddOrUpdate(OrganizationPriceFloat entity)
        {
            OrganizationPriceFloatBO pricefloat = (OrganizationPriceFloatBO)entity;
            var byq = ProductLogic.GetBYQ(pricefloat.BrandID, pricefloat.Year, pricefloat.Quarter);

            if (byq == null)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "未找到相应的品牌年份季度信息."
                });
            }
            pricefloat.BYQID = byq.ID;
            if (pricefloat.ID == default(int))
            {
                if (IsSetted(pricefloat.OrganizationID, byq.ID))
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "已为该机构指定了对应款式的价格上浮策略."
                    });
                }
            }
            else
            {
                if (LinqOP.Any <OrganizationPriceFloat>(o => o.OrganizationID == pricefloat.OrganizationID && o.ID != pricefloat.ID && o.BYQID == byq.ID))
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "已为该机构指定了对应款式的价格上浮策略."
                    });
                }
            }
            return(base.AddOrUpdate(entity));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取折扣
        /// </summary>
        public decimal GetDiscount(int brandID, int year, int quarter, int organizationID)
        {
            var byq = ProductLogic.GetBYQ(brandID, year, quarter);

            if (byq == null)
            {
                throw new Exception("没有对应品牌年份季度信息");
            }
            return(GetDiscount(byq.ID, organizationID));
        }
Ejemplo n.º 4
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!View.Extension.UIHelper.IsValid(this))
            {
                return;
            }
            if (lbxRight.Items.Count == 0)
            {
                MessageBox.Show("未选择机构");
                return;
            }
            BatchPriceFloat bcd = (BatchPriceFloat)this.DataContext;
            var             byq = ProductLogic.GetBYQ(bcd.BrandID, bcd.Year, bcd.Quarter);

            if (byq == null)
            {
                MessageBox.Show("未找到相应的品牌年份季度信息");
                return;
            }
            bcd.OrganizationIDs = new List <int>();
            foreach (var item in lbxRight.Items)
            {
                bcd.OrganizationIDs.Add(((SysOrganization)item).ID);
            }
            List <OrganizationPriceFloat> ocds = new List <OrganizationPriceFloat>();

            bcd.OrganizationIDs.ForEach(oid => ocds.Add(new OrganizationPriceFloat
            {
                BYQID          = byq.ID,
                FloatRate      = bcd.FloatRate,
                LastNumber     = bcd.LastNumber,
                OrganizationID = oid,
                CreatorID      = VMGlobal.CurrentUser.ID,
                CreateTime     = DateTime.Now
            }));
            try
            {
                OrganizationLogic.BatchSavePriceFloat(ocds);
                MessageBox.Show("设置成功");
                if (SetCompleted != null)
                {
                    SetCompleted();
                }
                InitContext();
            }
            catch (Exception ex)
            {
                MessageBox.Show("设置失败\n失败原因:" + ex.Message);
            }
        }