public OPResult Delete(OrganizationGoodReturnRatePerQuarter entity)
        {
            if (entity.ID == default(int))
            {
                return new OPResult {
                           IsSucceed = true, Message = "删除成功!"
                }
            }
            ;
            try
            {
                LinqOP.Delete <OrganizationGoodReturnRatePerQuarter>(entity);

                return(new OPResult {
                    IsSucceed = true, Message = "删除成功!"
                });
            }
            catch (Exception e)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "删除失败,失败原因:\n" + e.Message
                });
            }
        }
    }
Exemplo 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));
        }
        public override OPResult AddOrUpdate(OrganizationAllocationGrade entity)
        {
            if (!VMGlobal.SysProcessQuery.LinqOP.Any <OrganizationBrand>(o => o.OrganizationID == entity.OrganizationID && o.BrandID == entity.BrandID))
            {
                return(new OPResult {
                    IsSucceed = false, Message = "选定的机构和品牌没有对应关系"
                });
            }
            bool isAdd = entity.ID == default(int);

            if (isAdd)
            {
                if (LinqOP.Any <OrganizationAllocationGrade>(o => o.OrganizationID == entity.OrganizationID && o.BrandID == entity.BrandID))
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "已为该机构指定了对应品牌的等级"
                    });
                }
            }
            else
            {
                if (LinqOP.Any <OrganizationAllocationGrade>(o => o.OrganizationID == entity.OrganizationID && o.ID != entity.ID && o.BrandID == entity.BrandID))
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "已为该机构指定了对应品牌的等级"
                    });
                }
            }
            return(base.AddOrUpdate(entity));
        }
Exemplo n.º 4
0
        protected override IEnumerable <OrganizationPriceFloat> SearchData()
        {
            var oids   = VMGlobal.ChildOrganizations.Select(o => o.ID);
            var opfs   = LinqOP.Search <OrganizationPriceFloat>(o => oids.Contains(o.OrganizationID));
            var byqs   = LinqOP.GetDataContext <ProBYQ>();
            var result = from opf in opfs
                         from byq in byqs
                         where opf.BYQID == byq.ID
                         select new OrganizationPriceFloatBO
            {
                BrandID        = byq.BrandID,
                Year           = byq.Year,
                Quarter        = byq.Quarter,
                BYQID          = byq.ID,
                ID             = opf.ID,
                CreateTime     = opf.CreateTime,
                CreatorID      = opf.CreatorID,
                FloatRate      = opf.FloatRate,
                LastNumber     = opf.LastNumber,
                OrganizationID = opf.OrganizationID
            };
            var filteredData = (IQueryable <OrganizationPriceFloatBO>)result.Where(FilterDescriptors);

            TotalCount = filteredData.Count();
            return(filteredData.OrderBy(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Exemplo n.º 5
0
        protected override IEnumerable <RetailTactic> SearchData()
        {
            var tactics = LinqOP.GetDataContext <RetailTactic>();
            //if (!FilterConditionHelper.IsConditionSetted(condition, "OrganizationID"))
            //{
            var ds    = VMGlobal.SysProcessQuery.DB.ExecuteDataSet("GetOrganizationHierarchy", VMGlobal.CurrentUser.OrganizationID);
            var table = ds.Tables[0];

            if (table.Rows.Count > 0)
            {
                IEnumerable <int> os = table.ToList <OrganizationHierarchy>().Select(o => o.OrganizationID);
                tactics = tactics.Where(o => os.Contains(o.OrganizationID));
            }
            //}
            //if (!FilterConditionHelper.IsConditionSetted(condition, "BrandID"))
            //{
            IEnumerable <int> bs = VMGlobal.PoweredBrands.Select(o => o.ID);

            tactics = tactics.Where(o => bs.Contains(o.BrandID));
            //}
            var filteredData = (IQueryable <RetailTactic>)tactics.Where(FilterDescriptors);

            TotalCount = filteredData.Count();
            return(filteredData.OrderByDescending(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).Select(o => new RetailTacticBO(o)).ToList());
        }
        public override OPResult Delete(OrganizationGoodReturnRate entity)
        {
            if (entity.ID == default(int))
            {
                return new OPResult {
                           IsSucceed = true, Message = "删除成功!"
                }
            }
            ;
            var bo = (OrganizationGoodReturnRateBO)entity;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    LinqOP.Delete <OrganizationGoodReturnRatePerQuarter>(o => o.RateID == entity.ID);
                    LinqOP.Delete <OrganizationGoodReturnRate>(entity);
                    scope.Complete();
                    return(new OPResult {
                        IsSucceed = true, Message = "删除成功!"
                    });
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "删除失败,失败原因:\n" + e.Message
                    });
                }
            }
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
0
 public override OPResult AddOrUpdate(VIPUpTactic kind)
 {
     if (kind.OnceConsume == 0 && (kind.DateSpan == 0 || kind.SpanConsume == 0))
     {
         return(new OPResult {
             IsSucceed = false, Message = "单次消费和累计消费至少设置其中一个.\n即单次消费金额不能设为0,或者累计消费时间和消费金额不能设为0."
         });
     }
     if (kind.ID == default(int))
     {
         if (LinqOP.Any <VIPUpTactic>(o => o.BrandID == kind.BrandID && o.FormerKindID == kind.FormerKindID && o.AfterKindID == kind.AfterKindID && o.IsEnabled))
         {
             return(new OPResult {
                 IsSucceed = false, Message = "已经设置了相应VIP卡类型升级策略"
             });
         }
     }
     else
     {
         if (LinqOP.Any <VIPUpTactic>(o => o.BrandID == kind.BrandID && o.FormerKindID == kind.FormerKindID && o.AfterKindID == kind.AfterKindID && o.IsEnabled && o.ID != kind.ID && kind.IsEnabled))
         {
             return(new OPResult {
                 IsSucceed = false, Message = "已经设置了相应VIP卡类型升级策略"
             });
         }
     }
     return(base.AddOrUpdate(kind));
 }
Exemplo n.º 9
0
        /// <summary>
        /// 删除角色,同时删除角色权限和用户角色映射关系
        /// </summary>
        /// <param name="rid">角色ID</param>
        /// <returns>删除是否成功</returns>
        public override OPResult Delete(SysRole entity)
        {
            int rid = entity.ID;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    LinqOP.Delete <SysRoleModule>(rm => rm.RoleId == rid);
                    VMGlobal.SysProcessQuery.DB.ExecuteNonQuery("CleanUpDirtyProcess", rid);
                    LinqOP.Delete <SysRole>(r => r.ID == rid);
                    LinqOP.Delete <SysUserRole>(ur => ur.RoleId == rid);
                    scope.Complete();
                    return(new OPResult {
                        IsSucceed = true, Message = "删除成功!"
                    });
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "删除失败,失败原因:\n" + e.Message
                    });
                }
            }
        }
        public OPResult AddOrUpdate(OrganizationGoodReturnRatePerQuarter entity)
        {
            if (RateIsExist(entity))
            {
                return(new OPResult {
                    IsSucceed = false, Message = "该机构已经设置了该品牌年份季度的退货率."
                });
            }
            var id = entity.ID;

            try
            {
                if (id == default(int))
                {
                    entity.ID = LinqOP.Add <OrganizationGoodReturnRatePerQuarter, int>(entity, o => o.ID);
                }
                else
                {
                    LinqOP.Update <OrganizationGoodReturnRatePerQuarter>(entity);
                }
            }
            catch (Exception e)
            {
                entity.ID = id;
                return(new OPResult {
                    IsSucceed = false, Message = "保存失败,失败原因:\n" + e.Message
                });
            }

            return(new OPResult {
                IsSucceed = true, Message = "保存成功."
            });
        }
Exemplo n.º 11
0
        private void SetStyleBYQ(ProStyleBO style)
        {
            var byq = VMGlobal.BYQs.Find(o => o.BrandID == style.BrandID && o.Year == style.Year && o.Quarter == style.Quarter);

            if (byq != null)
            {
                style.BYQID = byq.ID;
            }
            else
            {
                byq = LinqOP.Search <ProBYQ>(o => o.BrandID == style.BrandID && o.Year == style.Year && o.Quarter == style.Quarter).FirstOrDefault();
                if (byq != null)
                {
                    style.BYQID = byq.ID;
                    VMGlobal.BYQs.Add(byq);
                }
                else
                {
                    byq = new ProBYQ {
                        BrandID = style.BrandID, Year = style.Year, Quarter = style.Quarter
                    };
                    int byqID = LinqOP.Add <ProBYQ, int>(byq, o => o.ID);
                    style.BYQID = byqID;
                    byq.ID      = byqID;
                    VMGlobal.BYQs.Add(byq);
                }
            }
        }
Exemplo n.º 12
0
        private OPResult Update(SysOrganizationBO organization)
        {
            var brandIDs = CurrentOrganization.Brands.Select(o => o.ID);
            List <OrganizationBrand> obs = new List <OrganizationBrand>();

            foreach (var b in organization.Brands)
            {
                OrganizationBrand ob = new OrganizationBrand
                {
                    OrganizationID = organization.ID,
                    BrandID        = b.ID,
                    CreatorID      = VMGlobal.CurrentUser.ID,
                    CreateTime     = DateTime.Now
                };
                obs.Add(ob);
            }
            OPResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    LinqOP.Update <SysOrganization>(organization);
                    VMGlobal.SysProcessQuery.LinqOP.Delete <OrganizationBrand>(ob => brandIDs.Contains(ob.BrandID) && ob.OrganizationID == organization.ID);
                    VMGlobal.SysProcessQuery.LinqOP.Add <OrganizationBrand>(obs);
                    scope.Complete();
                    result = new OPResult {
                        IsSucceed = true, Message = "更新成功!"
                    };
                }
                catch (Exception e)
                {
                    result = new OPResult {
                        IsSucceed = false, Message = "更新失败,失败原因:\n" + e.Message
                    };
                }
            }
            if (result.IsSucceed)
            {
                int index = VMGlobal.ChildOrganizations.FindIndex(o => o.ID == organization.ID);
                if (organization.Flag)
                {
                    if (index == -1)
                    {
                        VMGlobal.ChildOrganizations.Add(organization);
                    }
                    else
                    {
                        VMGlobal.ChildOrganizations[index] = organization;
                    }
                }
                else if (index != -1)
                {
                    VMGlobal.ChildOrganizations.RemoveAt(index);
                }
                _currentAndChildrenOrganizations = null;
            }
            return(result);
        }
Exemplo n.º 13
0
        protected override IEnumerable <ShopExpense> SearchData()
        {
            var oids = OrganizationArray.Select(o => o.ID);
            var data = (IQueryable <ShopExpense>)LinqOP.Search <ShopExpense>(o => oids.Contains(o.OrganizationID)).Where(FilterDescriptors);

            TotalCount = data.Count();
            return(data.OrderByDescending(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Exemplo n.º 14
0
        protected override IEnumerable <TEntity> SearchData()
        {
            var all          = LinqOP.GetDataContext <TEntity>();
            var filteredData = (IQueryable <TEntity>)all.Where(FilterDescriptors);

            TotalCount = filteredData.Count();
            return(filteredData.OrderBy(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Exemplo n.º 15
0
        protected override IEnumerable <VoucherReceiveMoney> SearchData()
        {
            var oids = (OrganizationArray ?? OrganizationListVM.CurrentOrganization.ChildrenOrganizations).Select(o => o.ID);
            var data = (IQueryable <VoucherReceiveMoney>)LinqOP.Search <VoucherReceiveMoney>(o => oids.Contains(o.OrganizationID)).Where(FilterDescriptors);

            TotalCount = data.Count();
            return(data.OrderByDescending(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Exemplo n.º 16
0
        protected override IEnumerable <SysOrganization> SearchData()
        {
            var currentOID   = VMGlobal.CurrentUser.OrganizationID;
            var orgs         = LinqOP.Search <SysOrganization>(o => o.ParentID == currentOID || o.ID == currentOID);
            var filteredOrgs = (IQueryable <SysOrganization>)orgs.Where(FilterDescriptors);

            TotalCount = filteredOrgs.Count();
            return(filteredOrgs.OrderBy(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).Select(o => new SysOrganizationBO(o)).ToList());
        }
Exemplo n.º 17
0
        protected override IEnumerable <OrganizationCredit> SearchData()
        {
            var oids         = VMGlobal.ChildOrganizations.Select(o => o.ID);
            var all          = LinqOP.Search <OrganizationCredit>(o => oids.Contains(o.OrganizationID));
            var filteredData = (IQueryable <OrganizationCredit>)all.Where(FilterDescriptors);

            TotalCount = filteredData.Count();
            return(filteredData.OrderBy(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Exemplo n.º 18
0
 public override OPResult Delete(ShopExpenseKind entity)
 {
     if (LinqOP.Any <ShopExpense>(o => o.ExpenseKindID == entity.ID))
     {
         return(new OPResult {
             IsSucceed = false, Message = "该费用类别已经被使用,\n若以后不再使用,请将状态置为禁用。"
         });
     }
     return(base.Delete(entity));
 }
Exemplo n.º 19
0
 public override OPResult Delete(RetailShoppingGuide guide)
 {
     if (LinqOP.Any <BillRetail>(o => o.GuideID == guide.ID))
     {
         return(new OPResult {
             IsSucceed = false, Message = "该导购已经有销售记录,不可删除,\n若以后不再使用,请将状态置为禁用。"
         });
     }
     return(base.Delete(guide));
 }
Exemplo n.º 20
0
 public override OPResult Delete(Factory factory)
 {
     if (LinqOP.Any <BillSubcontract>(p => p.OuterFactoryID == factory.ID))
     {
         return(new OPResult {
             IsSucceed = false, Message = "该工厂已经被使用,无法删除。\n若以后不使用,请将状态置为禁用。"
         });
     }
     return(base.Delete(factory));
 }
Exemplo n.º 21
0
 public override OPResult Delete(VIPKind kind)
 {
     if (LinqOP.Any <VIPCardKindMapping>(o => o.KindID == kind.ID))
     {
         return(new OPResult {
             IsSucceed = false, Message = "该VIP类型已使用,不能被删除."
         });
     }
     return(base.Delete(kind));
 }
Exemplo n.º 22
0
 public override OPResult Delete(RetailShift shift)
 {
     if (LinqOP.Any <RetailShoppingGuide>(o => o.ShiftID == shift.ID) || LinqOP.Any <BillRetail>(o => o.ShiftID == shift.ID))
     {
         return(new OPResult {
             IsSucceed = false, Message = "该班次信息已使用,不能被删除,\n若以后不使用,请将状态置为禁用."
         });
     }
     return(base.Delete(shift));
 }
        protected override IEnumerable <OrganizationAllocationGrade> SearchData()
        {
            var organizations = OrganizationListVM.CurrentOrganization.ChildrenOrganizations;
            var oids          = organizations.Select(o => o.ID);
            var brands        = VMGlobal.PoweredBrands;
            var bids          = brands.Select(o => o.ID);
            var opfs          = LinqOP.Search <OrganizationAllocationGrade>(o => oids.Contains(o.OrganizationID) && bids.Contains(o.BrandID));
            var result        = opfs.Select(o => new OrganizationAllocationGradeBO(o)).ToList();

            return(result);
        }
 private bool RateIsExist(OrganizationGoodReturnRate rate)
 {
     if (rate.ID == default(int))
     {
         return(LinqOP.Any <OrganizationGoodReturnRate>(oc => oc.OrganizationID == rate.OrganizationID && oc.BrandID == rate.BrandID));
     }
     else
     {
         return(LinqOP.Any <OrganizationGoodReturnRate>(oc => oc.ID != rate.ID && oc.OrganizationID == rate.OrganizationID && oc.BrandID == rate.BrandID));
     }
 }
Exemplo n.º 25
0
 /// <summary>
 /// 查看机构特定品牌的资信是否已设置过
 /// </summary>
 private bool CreditIsExist(OrganizationCredit credit)
 {
     if (credit.ID == default(int))
     {
         return(LinqOP.Any <OrganizationCredit>(oc => oc.OrganizationID == credit.OrganizationID && oc.BrandID == credit.BrandID));
     }
     else
     {
         return(LinqOP.Any <OrganizationCredit>(oc => oc.ID != credit.ID && oc.OrganizationID == credit.OrganizationID && oc.BrandID == credit.BrandID));
     }
 }
 private bool RateIsExist(OrganizationGoodReturnRatePerQuarter rate)
 {
     if (rate.ID == default(int))
     {
         return(LinqOP.Any <OrganizationGoodReturnRatePerQuarter>(oc => oc.RateID == rate.RateID && oc.Year == rate.Year && oc.Quarter == rate.Quarter));
     }
     else
     {
         return(LinqOP.Any <OrganizationGoodReturnRatePerQuarter>(oc => oc.ID != rate.ID && oc.RateID == rate.RateID && oc.Year == rate.Year && oc.Quarter == rate.Quarter));
     }
 }
Exemplo n.º 27
0
        private OPResult Update(SysUserBO user)
        {
            var roleIDs            = RolesCurrentUserCover.Select(rs => rs.ID);//加上ToList()在下面执行时就抛出Contains不支持的异常,坑爹
            List <SysUserRole> urs = new List <SysUserRole>();

            foreach (var rs in user.Roles)
            {
                SysUserRole ur = new SysUserRole
                {
                    UserId    = user.ID,
                    RoleId    = rs.ID,
                    CreatorID = VMGlobal.CurrentUser.ID
                };
                urs.Add(ur);
            }

            var brandIDs         = VMGlobal.PoweredBrands.Select(bs => bs.ID);
            List <UserBrand> ubs = new List <UserBrand>();

            foreach (var bs in user.Brands)
            {
                UserBrand ub = new UserBrand
                {
                    UserID    = user.ID,
                    BrandID   = bs.ID,
                    CreatorID = VMGlobal.CurrentUser.ID
                };
                ubs.Add(ub);
            }

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    LinqOP.Update <SysUser>(user);
                    LinqOP.Delete <SysUserRole>(ur => roleIDs.Contains(ur.RoleId) && ur.UserId == user.ID);
                    VMGlobal.SysProcessQuery.LinqOP.Delete <UserBrand>(ub => brandIDs.Contains(ub.BrandID) && ub.UserID == user.ID);
                    LinqOP.Add <SysUserRole>(urs);
                    VMGlobal.SysProcessQuery.LinqOP.Add <UserBrand>(ubs);
                    scope.Complete();
                    return(new OPResult {
                        IsSucceed = true, Message = "更新成功."
                    });
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "更新失败,失败原因:\n" + e.Message
                    });
                }
            }
        }
Exemplo n.º 28
0
 public override OPResult AddOrUpdate(VIPBirthdayTactic entity)
 {
     if (entity.ID == default(int))
     {
         if (LinqOP.Any <VIPBirthdayTactic>(o => o.OrganizationID == VMGlobal.CurrentUser.OrganizationID))
         {
             return(new OPResult {
                 IsSucceed = false, Message = "一个机构职能设置一个VIP生日消费策略."
             });
         }
         entity.OrganizationID = VMGlobal.CurrentUser.OrganizationID;
     }
     return(base.AddOrUpdate(entity));
 }
Exemplo n.º 29
0
     public override OPResult Delete(CertCarriedStandard entity)
     {
         if (entity.ID != default(int))
         {
             if (LinqOP.Any <Certification>(o => o.CarriedStandard == entity.ID))
             {
                 return new OPResult {
                            IsSucceed = false, Message = "该执行标准已被使用,若不再使用请将状态置为禁用。"
                 }
             }
             ;
         }
         return(base.Delete(entity));
     }
 }
Exemplo n.º 30
0
     public override OPResult Delete(CertGrade entity)
     {
         if (entity.ID != default(int))
         {
             if (LinqOP.Any <Certification>(o => o.Grade == entity.ID))
             {
                 return new OPResult {
                            IsSucceed = false, Message = "该质量等级已被使用,若不再使用请将状态置为禁用。"
                 }
             }
             ;
         }
         return(base.Delete(entity));
     }
 }