コード例 #1
0
ファイル: PriceFloatVM.cs プロジェクト: almutama/fashionDRP
        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());
        }
コード例 #2
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);
                }
            }
        }
コード例 #3
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());
        }
コード例 #4
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());
        }
コード例 #5
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());
        }
コード例 #6
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());
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        private OPResult Update(ProStyleBO style)
        {
            SetStyleBYQ(style);
            ProStyle       orginStyle    = LinqOP.GetById <ProStyle>(style.ID);
            List <Product> productsExist = LinqOP.Search <Product>(p => p.StyleID == style.ID).ToList();
            List <Product> products      = new List <Product>();

            foreach (var color in style.Colors)
            {
                foreach (var size in style.Sizes)
                {
                    var     pcode   = style.Code + color.Code + size.Code;
                    Product product = productsExist.FirstOrDefault(p => p.ColorID == color.ID && p.SizeID == size.ID);
                    if (product != null)
                    {
                        if (orginStyle.Code != style.Code)
                        {
                            product.Code = pcode;
                            products.Add(product);
                        }
                    }
                    else
                    {
                        product = new Product
                        {
                            Code      = pcode,
                            StyleID   = style.ID,
                            ColorID   = color.ID,
                            SizeID    = size.ID,
                            CreatorID = VMGlobal.CurrentUser.ID
                        };
                        products.Add(product);
                    }
                }
            }

            string changeMsg = "";

            if (orginStyle.Price != style.Price)
            {
                changeMsg += string.Format("单价从{0}变动为{1},", orginStyle.Price, style.Price);
            }
            if (orginStyle.Code != style.Code)
            {
                changeMsg += string.Format("款号从{0}变动为{1},", orginStyle.Code, style.Code);
            }
            if (products.Count > 0)
            {
                changeMsg += "增加了SKU码:";
                products.ForEach(o =>
                {
                    changeMsg += (o.Code + ",");
                });
            }
            changeMsg = changeMsg.TrimEnd(',');

            OPResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    LinqOP.Update <ProStyle>(style);
                    LinqOP.AddOrUpdate <Product>(products);
                    if (!string.IsNullOrEmpty(changeMsg))
                    {
                        ProStyleChange change = new ProStyleChange
                        {
                            CreateTime  = DateTime.Now,
                            CreatorID   = VMGlobal.CurrentUser.ID,
                            Description = changeMsg,
                            StyleID     = style.ID
                        };
                        LinqOP.Add <ProStyleChange>(change);
                        style.Changes.Insert(0, change);
                    }
                    result = new OPResult {
                        IsSucceed = true, Message = "更新成功!"
                    };
                    scope.Complete();
                }
                catch (Exception e)
                {
                    result = new OPResult {
                        IsSucceed = false, Message = "更新失败,失败原因:\n" + e.Message
                    };
                }
            }
            if (result.IsSucceed && !string.IsNullOrEmpty(changeMsg))
            {
                IMHelper.AsyncSendMessageTo(IMHelper.OnlineUsers, new IMessage
                {
                    Message = changeMsg
                }, IMReceiveAccessEnum.成品资料变动);
            }
            return(result);
        }
コード例 #9
0
 public ShopExpenseKindSetVM()
     : base(VMGlobal.DistributionQuery.LinqOP)
 {
     Entities = LinqOP.Search <ShopExpenseKind>(o => o.OrganizationID == VMGlobal.CurrentUser.OrganizationID).Select(o => new ShopExpenseKindBO(o)).ToList();
 }
コード例 #10
0
 public RetailShiftVM()
     : base(VMGlobal.DistributionQuery.LinqOP)
 {
     Entities = LinqOP.Search <RetailShift>(o => o.OrganizationID == VMGlobal.CurrentUser.OrganizationID).Select(o => new RetailShiftBO(o)).ToList();
 }
コード例 #11
0
 public ShopExpenseSetVM() : base(VMGlobal.DistributionQuery.LinqOP)
 {
     ExpenseKinds = LinqOP.Search <ShopExpenseKind>(o => o.OrganizationID == VMGlobal.CurrentUser.OrganizationID).ToList();
     Entities     = new List <ShopExpense>();
 }
コード例 #12
0
        protected override IEnumerable <RetailMonthTaget> SearchData()
        {
            var oids = OrganizationListVM.CurrentAndChildrenOrganizations.Select(o => o.ID).ToArray();

            return(LinqOP.Search <RetailMonthTaget>(o => oids.Contains(o.OrganizationID)).Select(o => new RetailMonthTagetBO(o)).ToList());
        }
コード例 #13
0
 protected override IEnumerable <Storage> SearchData()
 {
     return(LinqOP.Search <Storage>(o => o.OrganizationID == VMGlobal.CurrentUser.OrganizationID).Select(o => new StorageBO(o)).ToList());
 }
コード例 #14
0
        protected override IEnumerable <SysOrganizationType> SearchData()
        {
            var result = LinqOP.Search <SysOrganizationType>(o => o.OrganizationID == VMGlobal.CurrentUser.OrganizationID).ToList();

            return(result.Select(o => new SysOrganizationTypeBO(o)).ToList());
        }
コード例 #15
0
 public VoucherItemKindVM(int kind)
     : base(VMGlobal.DistributionQuery.LinqOP)
 {
     _kind    = kind;
     Entities = LinqOP.Search <VoucherItemKind>(o => o.OrganizationID == VMGlobal.CurrentUser.OrganizationID && o.Kind == kind).Select(o => new VoucherItemKindBO(o)).ToList();
 }
コード例 #16
0
ファイル: UserVM.cs プロジェクト: almutama/fashionDRP
        //用户对应的各种数据集合,避免在UI绑定时频繁操作数据库
        //private void RefreshAttachData()
        //{
        //    var users = (List<SysUser>)Users.SourceCollection;
        //    var uIDs = users.Select<SysUser, int>(u => u.ID);

        //    var urs = _query.QueryProvider.GetTable<SysUserRole>("SysUserRole");
        //    var queryUR = from ur in urs where uIDs.Contains(ur.UserId) select ur;
        //    UserRoles = queryUR.ToList();

        //    var ubs = _queryDistribution.QueryProvider.GetTable<UserBrand>("UserBrand");
        //    var queryUB = from ub in ubs where uIDs.Contains(ub.UserID) select ub;
        //    UserBrands = queryUB.ToList();

        //    var oIDs = users.Select<SysUser, int>(u => u.OrganizationID);
        //    Organizations = _query.LinqOP.Search<SysOrganization>(o => oIDs.Contains(o.ID)).ToList();
        //}

        private OPResult Add(SysUserBO user)
        {
            int?userpointlimit = null;

            try
            {
                userpointlimit = this.GetUserPointLimit();
                if (userpointlimit == null)
                {
                    return new OPResult {
                               IsSucceed = false, Message = "保存失败,失败原因:\n无法确认用户点数是否存在上限,请联系软件公司。"
                    }
                }
                ;
                if ((userpointlimit != -1) && userpointlimit <= LinqOP.Search <SysUser>().Count())
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "保存失败,失败原因:\n超过用户点数限制,若要增加用户点数,请联系软件公司。"
                    });
                }
            }
            catch (Exception e)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "保存失败,失败原因:\n" + e.Message
                });
            }
            string oginalPWD = user.Password;

            user.CreatorID = VMGlobal.CurrentUser.ID;
            user.Password  = oginalPWD.ToMD5String();
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    int id = LinqOP.Add <SysUser, int>(user, r => r.ID);
                    user.ID = id;
                    List <SysUserRole> urs = new List <SysUserRole>();
                    foreach (var r in user.Roles)
                    {
                        SysUserRole ur = new SysUserRole
                        {
                            UserId    = id,
                            RoleId    = r.ID,
                            CreatorID = VMGlobal.CurrentUser.ID
                        };
                        urs.Add(ur);
                    }
                    LinqOP.Add <SysUserRole>(urs);

                    List <UserBrand> ubs = new List <UserBrand>();
                    foreach (var b in user.Brands)
                    {
                        UserBrand ub = new UserBrand
                        {
                            UserID    = id,
                            BrandID   = b.ID,
                            CreatorID = VMGlobal.CurrentUser.ID
                        };
                        ubs.Add(ub);
                    }
                    VMGlobal.SysProcessQuery.LinqOP.Add <UserBrand>(ubs);
                    scope.Complete();
                    return(new OPResult {
                        IsSucceed = true, Message = "保存成功."
                    });
                }
                catch (Exception e)
                {
                    user.ID       = default(int);
                    user.Password = oginalPWD;
                    return(new OPResult {
                        IsSucceed = false, Message = "保存失败,失败原因:\n" + e.Message
                    });
                }
            }
        }