コード例 #1
0
        private void UpdateDoneNumber(ProduceFinish dmo)
        {
            var ids    = dmo.Details.Select(x => x.ProductNotice_Detail_ID).ToList();
            var detail = new JoinAlias(typeof(ProduceFinish_Detail));
            var bill   = new JoinAlias(typeof(ProduceFinish));
            var dom    = new DQueryDom(detail);

            dom.From.AddJoin(JoinType.Inner, new DQDmoSource(bill), DQCondition.EQ(bill, "ID", detail, "ProduceFinish_ID"));
            dom.EAddCheckedCondition(bill);
            dom.Where.Conditions.EFieldInList(DQExpression.Field(detail, "ProductNotice_Detail_ID"), ids);

            dom.Columns.Add(DQSelectColumn.Sum(detail, "Number"));
            dom.Columns.Add(DQSelectColumn.Field("ProductNotice_Detail_ID", detail));
            dom.GroupBy.Expressions.Add(DQExpression.Field(detail, "ProductNotice_Detail_ID"));

            var tupleList = dom.EExecuteList <Money <decimal>?, long>(Session);

            foreach (var id in ids)
            {
                var number = tupleList.Where(x => x.Item2 == id).Sum(x => ((x.Item1 ?? 0).Value));

                var update = new DQUpdateDom(typeof(ProductNotice_Detail));
                update.Columns.Add(new DQUpdateColumn("DoneNumber", number));
                update.Where.Conditions.Add(DQCondition.EQ("ID", id));
                Session.ExecuteNonQuery(update);
            }
        }
コード例 #2
0
        public static List <GoodsInfoDto> GetTodayGoodsByStore(long accountUnitId, long departId, long storeId, long productPlanId)
        {
            var list   = new List <GoodsInfoDto>();
            var bill   = new JoinAlias(typeof(ProduceOutput));
            var detail = new JoinAlias(typeof(ProduceOutput_Detail));
            var query  = new DQueryDom(bill);

            query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "ProduceOutput_ID"));
            query.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", accountUnitId));

            //query.Where.Conditions.Add(DQCondition.EQ("Department_ID", departId));
            //DQCondition.EQ(string.Format("Department_TreeDeep{0}ID", context.Department_Depth), context.Department_ID)

            query.Where.Conditions.Add(DQCondition.EQ(bill, "Domain_ID", DomainContext.Current.ID));
            query.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核));
            query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual(bill, "Time", DateTime.Today.AddDays(-3)), DQCondition.LessThanOrEqual(bill, "Time", DateTime.Today.AddDays(1))));
            //query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(bill, "Time", DateTime.Today));
            //query.Where.Conditions.Add(DQCondition.LessThan(bill, "Time", DateTime.Today.AddDays(1)));
            query.Where.Conditions.Add(DQCondition.EQ("FrozenStore_ID", storeId));
            query.Where.Conditions.Add(DQCondition.EQ("PlanNumber_ID", productPlanId));
            query.Where.Conditions.Add(DQCondition.NotInSubQuery(DQExpression.Field(detail, "Goods_ID"), GetTodayGoodsByStoreSubQuery(accountUnitId, departId, storeId, productPlanId)));
            query.Where.Conditions.EFieldInList(DQExpression.Field(bill, "PlanNumber_ID"), GetProductPlan().Select(x => x.ID).ToArray());

            OrganizationUtil.AddOrganizationLimit(query, typeof(ProduceOutput));

            query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail));
            query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail));
            //query.Columns.Add(DQSelectColumn.Field("Goods_InnerPackingPer", detail));
            query.Columns.Add(DQSelectColumn.Sum(detail, "Number"));
            query.Columns.Add(DQSelectColumn.Create(DQExpression.Divide(DQExpression.Sum(DQExpression.Field(detail, "Number")), DQExpression.Field(detail, "Goods_InnerPackingPer")), "InnerPackingPer"));
            query.Columns.Add(DQSelectColumn.Field("Goods_InnerPackingPer", detail));
            //query.Columns.Add(DQSelectColumn.Create(DQExpression.Divide(DQExpression.Field(detail,"Number"),DQExpression.Field(detail, "Goods_InnerPackingPer")),"包装数"));


            query.GroupBy.Expressions.Add(DQExpression.Field(detail, "Goods_ID"));
            query.GroupBy.Expressions.Add(DQExpression.Field(detail, "Goods_Name"));
            query.GroupBy.Expressions.Add(DQExpression.Field(detail, "Goods_InnerPackingPer"));

            using (var session = Dmo.NewSession())
            {
                using (var reader = session.ExecuteReader(query))
                {
                    while (reader.Read())
                    {
                        var goods = new GoodsInfoDto
                        {
                            Goods_ID              = (long)reader[0],
                            Goods_Name            = (string)reader[1],
                            Number                = (decimal?)(Money <decimal>?)reader[2],
                            InnerPackingPer       = (decimal?)reader[3],
                            Goods_InnerPackingPer = (decimal?)reader[4]
                        };
                        list.Add(goods);
                    }
                }
            }
            return(list);
        }
コード例 #3
0
        protected override DQueryDom GetQueryDom()
        {
            var query = base.GetQueryDom();

            OrganizationUtil.AddOrganizationLimit <Department>(query, "Department_ID");
            var detail     = JoinAlias.Create("detail");
            var goodsAlias = new JoinAlias(typeof(Goods));

            query.From.AddJoin(JoinType.Left, new DQDmoSource(goodsAlias), DQCondition.EQ(detail, "Goods_ID", goodsAlias, "ID"));
            foreach (ListItem field in checkbox.Items)
            {
                if (field.Selected)
                {
                    if (sumFileds.Contains(field.Value))
                    {
                        query.Columns.Add(DQSelectColumn.Sum(detail, field.Value));
                        SumColumnIndexs.Add(query.Columns.Count - 1);
                    }
                    else if (goodsFields.Contains(field.Value))
                    {
                        query.Columns.Add(DQSelectColumn.Field(field.Value, goodsAlias));
                        query.GroupBy.Expressions.Add(DQExpression.Field(goodsAlias, field.Value));
                    }
                    else
                    {
                        query.Columns.Add(DQSelectColumn.Field(field.Value));
                        query.GroupBy.Expressions.Add(DQExpression.Field(field.Value));
                    }
                }
            }
            if (!string.IsNullOrEmpty(goodsName.Text))
            {
                query.Where.Conditions.Add(DQCondition.Or(DQCondition.Like(goodsAlias, "Name", goodsName.Text), DQCondition.Like(goodsAlias, "Spell", goodsName.Text)));
            }
            if (!string.IsNullOrEmpty(goodsCode.Text))
            {
                query.Where.Conditions.Add(DQCondition.Like(goodsAlias, "Code", goodsCode.Text));
            }
            if (sd.Value.HasValue)
            {
                query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("Date", sd.Value.Value));
            }
            if (ed.Value.HasValue)
            {
                query.Where.Conditions.Add(DQCondition.LessThanOrEqual("Date", ed.Value.Value));
            }

            query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("BillState", 单据状态.已审核), DQCondition.EQ("Domain_ID", DomainContext.Current.ID)));
            if (query.Columns.Count == 0)
            {
                throw new Exception("至少选择一条显示列");
            }
            return(query);
        }
コード例 #4
0
        //载入存货列表
        public List <ProductPlanOrLinkOutput> GetGoodsList(ProduceOutput dmo)
        {
            var       planBill         = new JoinAlias(typeof(ProductPlan));
            var       outputPlanDetail = new JoinAlias(typeof(ProductPlan_OutputDetail));
            var       linkDetail       = new JoinAlias(typeof(ProductLinks_OutputDetail));
            DQueryDom query            = new DQueryDom(outputPlanDetail);

            query.From.AddJoin(JoinType.Inner, new DQDmoSource(planBill), DQCondition.EQ(planBill, "ID", outputPlanDetail, "ProductPlan_ID"));
            query.From.AddJoin(JoinType.Inner, new DQDmoSource(linkDetail), DQCondition.EQ(linkDetail, "Goods_ID", outputPlanDetail, "Goods_ID"));

            query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(planBill, "BillState", 单据状态.已审核),
                                                       DQCondition.EQ(planBill, "PlanNumber", dmo.PlanNumber_Name),
                                                       DQCondition.EQ(linkDetail, "ProductLinks_ID", dmo.ProductLinks_ID)));

            query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Code"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Spec"));
            query.Columns.Add(DQSelectColumn.Field("Goods_MainUnit"));
            query.Columns.Add(DQSelectColumn.Field("Goods_SecondUnit"));
            query.Columns.Add(DQSelectColumn.Sum("PlanNumber"));
            query.Columns.Add(DQSelectColumn.Sum("PlanSecondNumber"));

            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_ID"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Name"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Code"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Spec"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_MainUnit"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_SecondUnit"));

            var list = new List <ProductPlanOrLinkOutput>();

            using (var context = new TransactionContext())
            {
                using (var reader = context.Session.ExecuteReader(query))
                {
                    while (reader.Read())
                    {
                        var goodsList = new ProductPlanOrLinkOutput();
                        goodsList.Goods_ID         = (long)reader[0];
                        goodsList.Goods_Name       = (string)reader[1];
                        goodsList.Goods_Code       = (string)reader[2];
                        goodsList.Goods_Spec       = (string)reader[3];
                        goodsList.Goods_MainUnit   = (string)reader[4];
                        goodsList.Goods_SecondUnit = (string)reader[5];
                        goodsList.Number           = (Money <decimal>?)reader[6];
                        goodsList.SecondNumber     = (Money <decimal>?)reader[7];
                        list.Add(goodsList);
                    }
                }
            }

            return(list);
        }
コード例 #5
0
        protected override DQueryDom GetQueryDom()
        {
            var alias = new JoinAlias(typeof(tempClass));
            var query = new DQueryDom(alias);

            query.RegisterQueryTable(typeof(tempClass), new string[] { "Department_ID", "AccountingUnit_ID", "PlanNumber_ID", "AccountingUnit_Name", "PlanNumber_Name", "Name", "Code", "OutputNumber", "InStoreNumber" }, tempClass.GetQueryDom(mQueryContainer, sd, ed));
            foreach (ListItem field in checkbox.Items)
            {
                if (field.Selected)
                {
                    if (field.Value == "OutputNumber" || field.Value == "InStoreNumber")
                    {
                        query.Columns.Add(DQSelectColumn.Sum(field.Value));
                        SumColumnIndexs.Add(query.Columns.Count - 1);
                    }
                    else if (field.Value == "DiffNumber")
                    {
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Subtract(DQExpression.IfNull(DQExpression.Field("OutputNumber"), DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Field("InStoreNumber"), DQExpression.Value(0)))), field.Text));
                        SumColumnIndexs.Add(query.Columns.Count - 1);
                    }
                    else
                    {
                        query.Columns.Add(DQSelectColumn.Field(field.Value));
                        query.GroupBy.Expressions.Add(DQExpression.Field(field.Value));
                    }
                }
            }
            var accids = mQueryContainer.GetControl <DFChoiceBox>("AccountingUnit_ID").Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            var pnumberids = mQueryContainer.GetControl <DFChoiceBox>("PlanNumber_ID").Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            if (accids.Length > 0)
            {
                query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("AccountingUnit_ID"), accids.Select(x => DQExpression.Value(long.Parse(x))).ToArray()));
            }

            if (pnumberids.Length > 0)
            {
                query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("PlanNumber_ID"), pnumberids.Select(x => DQExpression.Value(long.Parse(x))).ToArray()));
            }

            OrganizationUtil.AddOrganizationLimit <Department>(query, "Department_ID");

            if (query.Columns.Count == 0)
            {
                throw new Exception("至少选择一条显示列");
            }
            return(query);
        }
コード例 #6
0
        void LoadOutputDetail()
        {
            Dmo.OutputDetails.Clear();
            var main   = new JoinAlias(typeof(ProductInStore));
            var detail = new JoinAlias(typeof(ProductInStore_Detail));
            var referencePirceAlias = new JoinAlias(typeof(GoodsReferencePrice));
            var query = new DQueryDom(detail);

            query.From.AddJoin(JoinType.Left, new DQDmoSource(main), DQCondition.EQ(main, "ID", detail, "ProductInStore_ID"));
            query.From.AddJoin(JoinType.Left, new DQDmoSource(referencePirceAlias), DQCondition.EQ(detail, "Goods_ID", referencePirceAlias, "Goods_ID"));
            query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Code"));
            query.Columns.Add(DQSelectColumn.Sum("Number"));
            query.Columns.Add(DQSelectColumn.Field("ReferencePrice", referencePirceAlias));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_ID"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Name"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Code"));
            query.GroupBy.Expressions.Add(DQExpression.Field(referencePirceAlias, "ReferencePrice"));
            query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(main, "AccountingUnit_ID", Dmo.AccountingUnit_ID), DQCondition.EQ(main, "Department_ID", Dmo.Department_ID), DQCondition.EQ(detail, "ProductPlan_ID", Dmo.PlanNumber_ID), DQCondition.EQ(main, "BillState", 单据状态.已审核)));
            using (var session = Forks.EnterpriseServices.DomainObjects2.Dmo.NewSession())
            {
                using (var reader = session.ExecuteReader(query))
                {
                    var inputSum = Dmo.InputDetails.Sum(x => x.Weight ?? 0);
                    while (reader.Read())
                    {
                        var d = new DailyProductReport_OutputDetail
                        {
                            Goods_ID   = (long?)reader[0],
                            Goods_Name = (string)reader[1],
                            Goods_Code = (string)reader[2],
                            Number     = ((Money <decimal>?)reader[3]).EToDecimal(),
                            Price      = ((decimal?)reader[4] ?? 0)
                        };
                        d.Money = d.Price * d.Number;
                        if (inputSum != 0)
                        {
                            d.OutputPrecent = d.Number / inputSum;
                        }
                        Dmo.OutputDetails.Add(d);
                    }
                }
            }
            outputGrid.DataBind();
        }
コード例 #7
0
            //        产出辅数量


            private static DQueryDom GetDom(DateTime?date)
            {
                var main = new JoinAlias("__produMain", typeof(ProduceOutput));

                var detail = new JoinAlias("__prodDetail", typeof(ProduceOutput_Detail));
                var dom    = new DQueryDom(main);

                dom.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(detail, "ProduceOutput_ID", main, "ID"));

                dom.Columns.Add(DQSelectColumn.Field("AccountingUnit_ID", main));
                dom.Columns.Add(DQSelectColumn.Field("ProductionUnit_ID", main));
                dom.Columns.Add(DQSelectColumn.Field("AccountingUnit_Name", main));
                dom.Columns.Add(DQSelectColumn.Field("Department_Name", main));
                var exp = DQExpression.Snippet(" (CONVERT(varchar(10), [__produMain].[Time], 23))");

                dom.Columns.Add(DQSelectColumn.Create(exp, "Time"));
                dom.Columns.Add(DQSelectColumn.Field("Goods_ID", detail));


                dom.Columns.Add(DQSelectColumn.Field("Goods_Name", detail));
                dom.Columns.Add(DQSelectColumn.Field("GoodsCategory_ID", detail));
                dom.Columns.Add(DQSelectColumn.Sum(detail, "Number"));
                dom.Columns.Add(DQSelectColumn.Sum(detail, "SecondNumber2"));



                dom.GroupBy.Expressions.Add(exp);
                dom.GroupBy.Expressions.Add(DQExpression.Field(main, "AccountingUnit_ID"));
                dom.GroupBy.Expressions.Add(DQExpression.Field(main, "ProductionUnit_ID"));
                dom.GroupBy.Expressions.Add(DQExpression.Field(main, "AccountingUnit_Name"));
                dom.GroupBy.Expressions.Add(DQExpression.Field(main, "Department_Name"));
                dom.GroupBy.Expressions.Add(DQExpression.Field(detail, "Goods_ID"));
                dom.GroupBy.Expressions.Add(DQExpression.Field(detail, "Goods_Name"));
                dom.GroupBy.Expressions.Add(DQExpression.Field(detail, "GoodsCategory_ID"));

                if (date != null)
                {
                    var c2 = DQCondition.LessThanOrEqual(main, "Time", date.Value.AddDays(1).AddSeconds(-1));
                    var c1 = DQCondition.GreaterThanOrEqual(main, "Time", date.Value);
                    dom.Where.Conditions.Add(DQCondition.And(c1, c2));
                }

                dom.Where.Conditions.Add(DQCondition.EQ(main, "BillState", 单据状态.已审核));
                return(dom);
            }
コード例 #8
0
        void LoadInputDetail()
        {
            Dmo.InputDetails.Clear();
            var main               = new JoinAlias(typeof(ProduceInput));
            var detail             = new JoinAlias(typeof(ProduceInput_Detail));
            var productLinksDetail = new JoinAlias(typeof(ProductLinks_InputDetail));
            var query              = new DQueryDom(detail);

            query.From.AddJoin(JoinType.Left, new DQDmoSource(main), DQCondition.EQ(main, "ID", detail, "ProduceInput_ID"));
            query.From.AddJoin(JoinType.Left, new DQDmoSource(productLinksDetail), DQCondition.And(DQCondition.EQ(main, "ProductLinks_ID", productLinksDetail, "ProductLinks_ID"), DQCondition.EQ(detail, "Goods_ID", productLinksDetail, "Goods_ID")));
            query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Code"));
            query.Columns.Add(DQSelectColumn.Sum("Number"));
            query.Columns.Add(DQSelectColumn.Sum("SecondNumber"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_ID"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Name"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Code"));
            query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(main, "Time", Dmo.Date), DQCondition.EQ(main, "AccountingUnit_ID", Dmo.AccountingUnit_ID), DQCondition.EQ(main, "Department_ID", Dmo.Department_ID), DQCondition.EQ(main, "PlanNumber_ID", Dmo.PlanNumber_ID), DQCondition.EQ(main, "BillState", 单据状态.已审核), DQCondition.EQ(productLinksDetail, "LivingBodyMark", true)));
            using (var session = Forks.EnterpriseServices.DomainObjects2.Dmo.NewSession())
            {
                using (var reader = session.ExecuteReader(query))
                {
                    while (reader.Read())
                    {
                        var d = new DailyProductReport_InputDetail
                        {
                            Goods_ID   = (long?)reader[0],
                            Goods_Name = (string)reader[1],
                            Goods_Code = (string)reader[2],
                            Weight     = ((Money <decimal>?)reader[3]).EToDecimal(),
                            Number     = ((Money <decimal>?)reader[4]).EToDecimal()
                        };
                        Dmo.InputDetails.Add(d);
                    }
                }
            }
            inputGrid.DataBind();
        }
コード例 #9
0
        protected override DQueryDom GetQueryDom()
        {
            mBrowseGrid.EnableRowsGroup = _showTypeList.Items.FindByText("合并单元格").Selected;
            var query = base.GetQueryDom();

            OrganizationUtil.AddOrganizationLimit <Department>(query, "Department_ID");
            OrganizationUtil.AddOrganizationLimit <Store>(query, "Store_ID");
            var bill            = query.From.RootSource.Alias;
            var detail          = JoinAlias.Create("detail");
            var goodsAlias      = new JoinAlias(typeof(Goods));
            var goodsProperty   = new JoinAlias(typeof(GoodsProperty));
            var propertyCatalog = new JoinAlias(typeof(GoodsPropertyCatalog));

            query.From.AddJoin(JoinType.Left, new DQDmoSource(goodsAlias), DQCondition.EQ(detail, "Goods_ID", goodsAlias, "ID"));
            query.From.AddJoin(JoinType.Left, new DQDmoSource(goodsProperty), DQCondition.EQ(goodsAlias, "GoodsProperty_ID", goodsProperty, "ID"));
            query.From.AddJoin(JoinType.Left, new DQDmoSource(propertyCatalog), DQCondition.EQ(goodsProperty, "GoodsPropertyCatalog_ID", propertyCatalog, "ID"));

            foreach (ListItem field in checkbox.Items)
            {
                if (field.Selected)
                {
                    SetQueryResult(query, field);
                    if (sumFileds.Contains(field.Value))
                    {
                        query.Columns.Add(DQSelectColumn.Sum(detail, field.Value));
                        SumColumnIndexs.Add(query.Columns.Count - 1);
                    }
                    else if (goodsFields.Contains(field.Value))
                    {
                        query.Columns.Add(DQSelectColumn.Field(field.Value, goodsAlias));
                        query.GroupBy.Expressions.Add(DQExpression.Field(goodsAlias, field.Value));
                    }
                    else if (mainFields.Contains(field.Value))
                    {
                        query.Columns.Add(DQSelectColumn.Field(field.Value));
                        query.GroupBy.Expressions.Add(DQExpression.Field(field.Value));
                    }
                    else if (field.Text == "每日")
                    {
                        var snippetDay = DQExpression.Snippet <DateTime?>("(Convert(nvarchar(10),[bill].[InStoreDate], 23))");
                        query.Columns.Add(DQSelectColumn.Create(snippetDay, "每日"));
                        query.GroupBy.Expressions.Add(snippetDay);
                    }
                    else if (field.Text == "每月")
                    {
                        var snippetMonth = DQExpression.Snippet <string>("Left(Convert(nvarchar(10),[bill].[InStoreDate], 23),7)");
                        query.Columns.Add(DQSelectColumn.Create(snippetMonth, "每月"));
                        query.GroupBy.Expressions.Add(snippetMonth);
                    }
                    else if (field.Text == "每年")
                    {
                        var snippetMonth = DQExpression.Snippet <string>("Left(Convert(nvarchar(10),[bill].[InStoreDate], 23),4)");
                        query.Columns.Add(DQSelectColumn.Create(snippetMonth, "每月"));
                        query.GroupBy.Expressions.Add(snippetMonth);
                    }
                    else if (field.Text == "标签")
                    {
                        var tarName = new JoinAlias(typeof(Dmo_TagNames));
                        query.From.AddJoin(JoinType.Left, new DQDmoSource(tarName), DQCondition.And(DQCondition.EQ(tarName, "DmoID", query.From.RootSource.Alias, "ID"), DQCondition.EQ(tarName, "DmoTypeID", mDmoTypeID)));
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(tarName, "Names"), "标签"));
                        query.GroupBy.Expressions.Add(DQExpression.Field(tarName, "Names"));
                    }
                    else if (field.Text == "存货属性")
                    {
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goodsProperty, "Name"), field.Text));
                        query.GroupBy.Expressions.Add(DQExpression.Field(goodsProperty, "Name"));
                    }
                    else if (field.Text == "属性分类")
                    {
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(propertyCatalog, "Name"), field.Text));
                        query.GroupBy.Expressions.Add(DQExpression.Field(propertyCatalog, "Name"));
                        var v = 0;
                        if (!depth.IsEmpty && int.TryParse(depth.Text, out v))
                        {
                            if (v < 0)
                            {
                                v = 0;
                            }
                            if (v > 8)
                            {
                                v = 8;
                            }
                            for (var i = 1; i <= v; i++)
                            {
                                var p = new JoinAlias("_p" + i, typeof(GoodsPropertyCatalog));
                                query.From.AddJoin(JoinType.Left, new DQDmoSource(p), DQCondition.EQ(p, "ID", propertyCatalog, string.Format("TreeDeep{0}ID", i)));
                                query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(p, "Name"), i + "级分类"));
                                query.GroupBy.Expressions.Add(DQExpression.Field(p, "Name"));
                            }
                        }
                    }
                    else if (field.Text == "货位")
                    {
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(detail, "CargoSpace_Name"), field.Text));
                        query.GroupBy.Expressions.Add(DQExpression.Field(detail, "CargoSpace_Name"));
                    }
                    else if (field.Text == "产品线")
                    {
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goodsAlias, field.Value), field.Text));
                        query.GroupBy.Expressions.Add(DQExpression.Field(goodsAlias, field.Value));
                    }
                    else
                    {
                        //用户自定义模块的字段 比如永达
                        if (field.Value.StartsWith(CustomMainFieldBegin))
                        {
                            continue;
                        }
                        var s = field.Value;
                        if (field.Value == "DRemark")
                        {
                            s = "Remark";
                            query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(detail, s), "备注"));
                        }
                        else
                        {
                            query.Columns.Add(DQSelectColumn.Field(s, detail));
                        }
                        query.GroupBy.Expressions.Add(DQExpression.Field(detail, s));
                    }
                }
            }
            if (!string.IsNullOrEmpty(goodsOrigin.Text))
            {
                query.Where.Conditions.Add(DQCondition.Like(goodsAlias, "Origin", goodsOrigin.Text));
            }
            if (!goodsName.IsEmpty)
            {
                var nameList     = goodsName.Text.Split(' ');
                var conditonList = new List <IDQExpression>();
                foreach (var n in nameList)
                {
                    conditonList.Add(DQCondition.Like(goodsAlias, "Name", n));
                }
                query.Where.Conditions.Add(DQCondition.Or(conditonList));
            }
            query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Domain_ID", DomainContext.Current.ID)));
            var brand = mQueryContainer.GetControl <DFChoiceBox>("Goods_Brand");

            if (!brand.IsEmpty)
            {
                query.Where.Conditions.Add(DQCondition.EQ(goodsAlias, "Brand", brand.Value));
            }
            var gProperty = mQueryContainer.GetControl <DFChoiceBox>("GoodsProperty_ID");

            if (!gProperty.IsEmpty)
            {
                query.Where.Conditions.Add(DQCondition.EQ(goodsProperty, "ID", gProperty.Value));
            }

            if (!_productLine.IsEmpty)
            {
                query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(goodsAlias, "ProductLine_ID"), _productLine.GetValues().Select(x => DQExpression.Value(x)).ToArray()));
            }
            if (!_producttypeLine.IsEmpty)
            {
                query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(goodsAlias, "ProductLineCategory_ID"), _producttypeLine.GetValues().Select(x => DQExpression.Value(x)).ToArray()));
            }
            TreeUtil.AddTreeCondition <GoodsPropertyCatalog>(query, mQueryContainer, "PropertyCatalog_ID", propertyCatalog);
            TagWebUtil.AddTagQueryCondition(mDmoTypeID, query, bill, mQueryContainer);
            if (query.Columns.Count == 0)
            {
                throw new Exception("至少选择一条显示列");
            }
            return(query);
        }
コード例 #10
0
        protected override DQueryDom GetQueryDom()
        {
            var query = base.GetQueryDom();

            OrganizationUtil.AddOrganizationLimit <Department>(query, "Department_ID");
            var detail               = JoinAlias.Create("detail");
            var goodsAlias           = new JoinAlias(typeof(Goods));
            var alias                = query.From.RootSource.Alias;
            var goodsPropertyCatalog = new JoinAlias(typeof(GoodsPropertyCatalog));
            var goodsProperty        = new JoinAlias(typeof(GoodsProperty));

            query.From.AddJoin(JoinType.Left, new DQDmoSource(goodsAlias), DQCondition.EQ(detail, "Goods_ID", goodsAlias, "ID"));
            query.From.AddJoin(JoinType.Left, new DQDmoSource(goodsProperty), DQCondition.EQ(goodsProperty, "ID", goodsAlias, "GoodsProperty_ID"));
            query.From.AddJoin(JoinType.Left, new DQDmoSource(goodsPropertyCatalog), DQCondition.EQ(goodsProperty, "GoodsPropertyCatalog_ID", goodsPropertyCatalog, "ID"));
            foreach (ListItem field in _checkbox.Items)
            {
                if (field.Selected)
                {
                    if (sumFileds.Contains(field.Value))
                    {
                        query.Columns.Add(DQSelectColumn.Sum(detail, field.Value));
                        SumColumnIndexs.Add(query.Columns.Count - 1);
                    }
                    else if (goodsFields.Contains(field.Value))
                    {
                        query.Columns.Add(DQSelectColumn.Field(field.Value, goodsAlias));
                        query.GroupBy.Expressions.Add(DQExpression.Field(goodsAlias, field.Value));
                    }

                    else if (mainFields.Contains(field.Value))
                    {
                        TakeValueCustomer(query, field, detail);//耘垦客户要求客户字段取值明细表中的客户字段
                    }
                    else if (detailFields.Contains(field.Value))
                    {
                        query.Columns.Add(DQSelectColumn.Field(field.Value, detail));
                        query.GroupBy.Expressions.Add(DQExpression.Field(detail, field.Value));
                    }
                    else if (field.Value == "摘要")
                    {
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(alias, "Remark"), "摘要"));
                        query.GroupBy.Expressions.Add(DQExpression.Field(alias, "Remark"));
                    }
                    else if (field.Value == "GoodsPropertyCatalog_Name")
                    {
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goodsPropertyCatalog, "Name"), "属性分类"));
                        query.GroupBy.Expressions.Add(DQExpression.Field(goodsPropertyCatalog, "Name"));
                    }
                    else if (field.Value == "GoodsProperty_Name")
                    {
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goodsProperty, "Name"), "存货属性"));
                        query.GroupBy.Expressions.Add(DQExpression.Field(goodsProperty, "Name"));
                    }

                    else
                    {
                        query.Columns.Add(DQSelectColumn.Field(field.Value, detail));
                        query.GroupBy.Expressions.Add(DQExpression.Field(detail, field.Value));
                    }
                }
            }
            query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID));
            if (!摘要.IsEmpty)
            {
                query.Where.Conditions.Add(DQCondition.And(DQCondition.Like(alias, "Remark", 摘要.Text)));
            }

            if (!备注.IsEmpty)
            {
                query.Where.Conditions.Add(DQCondition.And(DQCondition.Like(detail, "Remark", 备注.Text)));
            }

            if (query.Columns.Count == 0)
            {
                throw new Exception("至少选择一条显示列");
            }
            return(query);
        }