Exemplo n.º 1
0
        public ISqlDom CreateView()
        {
            var main        = new JoinAlias(typeof(DailyProductReport));
            var inputdetail = new JoinAlias(typeof(DailyProductReport_InputDetail));
            var dom         = new DQueryDom(main);

            dom.From.AddJoin(JoinType.Inner, new DQDmoSource(inputdetail), DQCondition.EQ(main, "ID", inputdetail, "DailyProductReport_ID"));

            dom.Columns.Add(DQSelectColumn.Field("Domain_ID"));
            dom.Columns.Add(DQSelectColumn.Field("AccountingUnit_ID"));
            dom.Columns.Add(DQSelectColumn.Field("Department_ID"));
            dom.Columns.Add(DQSelectColumn.Field("Date"));
            dom.Columns.Add(DQSelectColumn.Field("PlanNumber_ID"));
            dom.Columns.Add(DQSelectColumn.Field("Goods_ID", inputdetail));
            dom.Columns.Add(DQSelectColumn.Field("Number", inputdetail));
            dom.Columns.Add(DQSelectColumn.Field("Weight", inputdetail));
            dom.Columns.Add(DQSelectColumn.Create(DQExpression.Value <decimal?>(null), "OutputPrecent"));
            dom.Columns.Add(DQSelectColumn.Create(DQExpression.Value <decimal>(0), "Price"));
            dom.Columns.Add(DQSelectColumn.Create(DQExpression.Value <bool>(false), "DetailType"));
            dom.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核));
            SelectDom selectDom = (SelectDom)dom.Build(DbProviderType.SqlClient, DbmsType.SqlServer2005);

            UnionDom  unionDom          = new UnionDom();
            UnionItem inputDetailUnion  = new UnionItem(selectDom, UnionType.Default);
            UnionItem outputDetailUnion = new UnionItem(GetOutputDetailDom(), UnionType.All);

            unionDom.Items.Add(inputDetailUnion);
            unionDom.Items.Add(outputDetailUnion);
            return(unionDom);
        }
Exemplo n.º 2
0
            public static void AddJoin(DQueryDom mainDom, JoinAlias selfAlias)
            {
                var root     = mainDom.From.RootSource.Alias;
                var datediff =
                    DQExpression.DateDiff(DQExpression.Field(selfAlias, "Date"), DQExpression.Field(root, "Time"));

                mainDom.From.AddJoin(JoinType.Left, new DQDmoSource(selfAlias), DQCondition.And(
                                         DQCondition.EQ(DQExpression.Value(-1), datediff),
                                         DQCondition.EQ(selfAlias, "Goods_ID", root, "Goods_ID")));
            }
Exemplo n.º 3
0
        public static DQueryDom GetQueryDom(string planNumber)
        {
            var query = new DQueryDom(new JoinAlias(typeof(ProductInStore_Detail)));

            query.Columns.Add(DQSelectColumn.Field("ProductInStore_ID", "MainID"));
            if (!string.IsNullOrEmpty(planNumber))
            {
                var expression = new List <IDQExpression>();
                foreach (var item in planNumber.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    expression.Add(DQExpression.Value(long.Parse(item)));
                }
                if (expression.Count > 0)
                {
                    query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ProductPlan_ID"), expression.ToArray()));
                }
            }
            query.Distinct = true;
            return(query);
        }
Exemplo n.º 4
0
        static DQueryDom GetOutputQuery(long domainID, QueryContainer mQueryContainer, DateInput sd, DateInput ed)
        {
            var main       = new JoinAlias(typeof(ProduceOutput));
            var detail     = new JoinAlias(typeof(ProduceOutput_Detail));
            var goodsAlias = new JoinAlias("g1", typeof(Goods));
            var query      = new DQueryDom(detail);

            query.From.AddJoin(JoinType.Left, new DQDmoSource(main), DQCondition.EQ(main, "ID", detail, "ProduceOutput_ID"));
            query.From.AddJoin(JoinType.Left, new DQDmoSource(goodsAlias), DQCondition.EQ(detail, "Goods_ID", goodsAlias, "ID"));
            query.Columns.Add(DQSelectColumn.Field("Department_ID", main));
            query.Columns.Add(DQSelectColumn.Field("AccountingUnit_ID", main));
            query.Columns.Add(DQSelectColumn.Field("PlanNumber_ID", main));
            query.Columns.Add(DQSelectColumn.Field("AccountingUnit_Name", main));
            query.Columns.Add(DQSelectColumn.Field("PlanNumber_Name", main));
            query.Columns.Add(DQSelectColumn.Field("Name", goodsAlias));
            query.Columns.Add(DQSelectColumn.Field("Code", goodsAlias));
            query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(detail, "Number"), "OutputNumber"));
            query.Columns.Add(DQSelectColumn.Create(DQExpression.Value <Money <decimal> >(0m), "InStoreNumber"));
            query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(main, "BillState", 单据状态.已审核), DQCondition.EQ(main, "Domain_ID", domainID)));
            AddCondition(main, goodsAlias, query, "Time", mQueryContainer, sd, ed);
            return(query);
        }
Exemplo n.º 5
0
        private SelectDom GetOutputDetailDom()
        {
            var main         = new JoinAlias(typeof(DailyProductReport));
            var outputdetail = new JoinAlias(typeof(DailyProductReport_OutputDetail));
            var dom          = new DQueryDom(main);

            dom.From.AddJoin(JoinType.Inner, new DQDmoSource(outputdetail), DQCondition.EQ(main, "ID", outputdetail, "DailyProductReport_ID"));
            dom.Columns.Add(DQSelectColumn.Field("Domain_ID"));
            dom.Columns.Add(DQSelectColumn.Field("AccountingUnit_ID"));
            dom.Columns.Add(DQSelectColumn.Field("Department_ID"));
            dom.Columns.Add(DQSelectColumn.Field("Date"));
            dom.Columns.Add(DQSelectColumn.Field("PlanNumber_ID"));
            dom.Columns.Add(DQSelectColumn.Field("Goods_ID", outputdetail));
            dom.Columns.Add(DQSelectColumn.Field("Number", outputdetail));
            dom.Columns.Add(DQSelectColumn.Create(DQExpression.Value <decimal?>(null), "Weight"));
            dom.Columns.Add(DQSelectColumn.Field("OutputPrecent", outputdetail));
            dom.Columns.Add(DQSelectColumn.Field("Price", outputdetail));
            dom.Columns.Add(DQSelectColumn.Create(DQExpression.Value <bool>(true), "DetailType"));
            dom.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核));
            SelectDom selectDom = (SelectDom)dom.Build(DbProviderType.SqlClient, DbmsType.SqlServer2005);

            return(selectDom);
        }
Exemplo n.º 6
0
        private void AddQueryResult(VLayoutPanel vPanel)
        {
            var btn = vPanel.Add(new DialogButton {
                Text = "增加记录", Url = "AddSettingDialog.aspx"
            }, new VLayoutOption(HorizontalAlign.Left));

            btn.Click += delegate { StartQuery(); };


            _mGrid = vPanel.Add(new DFBrowseGrid(new DFDataTableEditor())
            {
                Width = Unit.Percentage(100)
            });
            _mGrid.Columns.Add(new DFBrowseGridCustomExtColumn(delegate(DFDataRow row, HtmlTableCell cell, int rowIndex)
            {
                var delBtn = new LinkButton
                {
                    Text = "x"
                };
                delBtn.Click += delegate
                {
                    var id  = (long?)_mGrid.CurrentData.Data.Rows[rowIndex]["ID"];
                    var dom = new DQDeleteDom(typeof(Goods_Accounting_Store));
                    dom.Where.Conditions.Add(DQExpression.EQ(DQExpression.Field("ID"), DQExpression.Value(id)));
                    using (var session = Dmo.NewSession())
                    {
                        session.ExecuteNonQuery(dom);
                        session.Commit();
                    }
                    StartQuery();
                };
                delBtn.OnClientClick = "return confirm('确定删除吗?')";
                cell.Controls.Add(delBtn);
            }));
            _mGrid.Columns.Add(new DFBrowseGridAutoColumn());
        }
Exemplo n.º 7
0
        protected override DQueryDom GetQueryDom()
        {
            var dom  = base.GetQueryDom();
            var bill = dom.From.RootSource.Alias;

            mDisplayHelper.AddAlias("bill", JoinAlias.Create("bill"));
            var detail      = new JoinAlias("detail", typeof(ProduceFinish_Detail));
            var noticDetail = new JoinAlias("noticDetail", typeof(ProductNotice_Detail));
            var goods       = new JoinAlias("goods", typeof(Goods));

            mDisplayHelper.AddAlias("detail", JoinAlias.Create("detail"));
            mDisplayHelper.AddAlias("noticDetail", JoinAlias.Create("noticDetail"));
            mDisplayHelper.AddAlias("goods", JoinAlias.Create("goods"));
            dom.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "ProduceFinish_ID"));
            dom.From.AddJoin(JoinType.Left, new DQDmoSource(noticDetail), DQCondition.EQ(detail, "ProductNotice_Detail_ID", noticDetail, "ID"));
            dom.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(detail, "Goods_ID", goods, "ID"));
            var goodsChb = mQueryContainer.GetControl <DFChoiceBox>("Goods_ID");
            var proChb   = mQueryContainer.GetControl <DFChoiceBox>("GoodsProperty_ID");
            var brandChb = mQueryContainer.GetControl <DFChoiceBox>("BrandItem_ID");
            var lineChb  = mQueryContainer.GetControl <DFChoiceBox>("ProductLine_ID");

            if (!goodsChb.IsEmpty)
            {
                dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(detail, "Goods_ID"), goodsChb.GetValues().Select(x => DQExpression.Value(x)).ToArray()));
            }
            if (!proChb.IsEmpty)
            {
                dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(detail, "GoodsProperty_ID"), proChb.GetValues().Select(x => DQExpression.Value(x)).ToArray()));
            }
            if (!brandChb.IsEmpty)
            {
                dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(detail, "BrandItem_ID"), brandChb.GetValues().Select(x => DQExpression.Value(x)).ToArray()));
            }
            if (!lineChb.IsEmpty)
            {
                dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(goods, "ProductLine_ID"), lineChb.GetValues().Select(x => DQExpression.Value(x)).ToArray()));
            }
            mDisplayHelper.AddSelectColumns(dom, (name) => OptionIsSelected("选项", name), SumColumnIndexs);
            return(dom);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public static IList <ProductInStoreTemplate> GetProductInStoreTemplate(long[] id)
        {
            if (id.Length == 0)
            {
                return(new List <ProductInStoreTemplate>());
            }
            var query = new DmoQuery(typeof(ProductInStoreTemplate));

            query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
            query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), id.Select(x => DQExpression.Value(x)).ToArray()));
            return(query.EExecuteList().Cast <ProductInStoreTemplate>().ToList());
        }
Exemplo n.º 10
0
        protected override DQueryDom GetQueryDom()
        {
            var main  = new JoinAlias(typeof(ProductOutTemp));
            var query = new DQueryDom(main);

            ProductOutTemp.Register(query, dateInput.Date);
            var frozen = new JoinAlias("tempFrozen", typeof(FrozenOutTemp));

            var frozenNum = new JoinAlias("tempFrozenAllNumber", typeof(FrozeTemp));

            FrozenOutTemp.Register(query, dateInput.Value);
            FrozenOutTemp.AddJoin(query, frozen);

            FrozeTemp.Register(query, dateInput.Value);
            FrozeTemp.AddJoin(query, frozenNum);

            var 速冻出库重量Exp = DQExpression.Field(frozenNum, "AllNumber");
            var 速冻出库袋数Exp = DQExpression.Field(frozenNum, "AllSecondNumber2");

            foreach (ListItem item in _checkbox.Items)
            {
                if (item.Selected)
                {
                    var field = item.Value;
                    if (field.StartsWith("_"))
                    {
                        field = field.Substring(4);
                    }

                    switch (item.Text)
                    {
                    case "会计单位":
                    case "部门":
                    case "经办人":
                    case "产出单品名":
                    case "速冻出库品名":
                    case "产出数量":
                    case "产出辅数量":

                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(main, field), item.Text));
                        query.GroupBy.Expressions.Add(DQExpression.Field(main, field));
                        break;

                    case "速冻出库数量":

                        query.Columns.Add(DQSelectColumn.Create(速冻出库重量Exp, item.Text));
                        query.GroupBy.Expressions.Add(速冻出库重量Exp);
                        break;

                    case "速冻出库辅数量":
                        query.Columns.Add(DQSelectColumn.Create(速冻出库袋数Exp, item.Text));
                        query.GroupBy.Expressions.Add(速冻出库袋数Exp);

                        break;

                    case "包装品名":
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(frozen, field), item.Text));
                        query.GroupBy.Expressions.Add(DQExpression.Field(frozen, field));
                        break;

                    case "包装数量":
                    case "包装辅数量":
                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Field(frozen, field)), item.Text));
                        SumColumnIndexs.Add(query.Columns.Count - 1);

                        break;

                    case  "产出单差异(重量)":

                        var 产出重量Exp = DQExpression.Field(main, "Number");

                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Subtract(产出重量Exp, 速冻出库重量Exp), item.Text));

                        query.GroupBy.Expressions.Add(DQExpression.Subtract(产出重量Exp, 速冻出库重量Exp));
                        break;

                    case "产出单差异(袋数)":

                        var 产出袋数Exp = DQExpression.Field(main, "SecondNumber2");

                        query.Columns.Add(DQSelectColumn.Create(DQExpression.Subtract(产出袋数Exp, 速冻出库袋数Exp), item.Text));

                        query.GroupBy.Expressions.Add(DQExpression.Subtract(产出袋数Exp, 速冻出库袋数Exp));
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty(auuInput.Value))
            {
                query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "AccountingUnit_Name"), auuInput.GetValues().Select(x => DQExpression.Value(x)).ToArray()));
            }

            if (!string.IsNullOrEmpty(departInput.Value))
            {
                query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "Department_Name"), departInput.GetValues().Select(x => DQExpression.Value(x)).ToArray()));
            }
            if (!string.IsNullOrEmpty(goodInput.Value))
            {
                query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "Goods_ID"), goodInput.GetValues().Select(x => DQExpression.Value(x)).ToArray()));
            }


            return(query);
        }
Exemplo n.º 11
0
        protected override DQueryDom GetQueryDom()
        {
            var dom    = base.GetQueryDom();
            var detail = JoinAlias.Create("detail");
            var alias  = dom.From.RootSource.Alias;

            dom.Columns.Add(DQSelectColumn.Field("ID", alias));
            dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(detail, "ID"), "DetailID"));
            dom.Columns.Add(DQSelectColumn.Field("AccountingUnit_Name"));
            dom.Columns.Add(DQSelectColumn.Field("Customer_Name"));
            dom.Columns.Add(DQSelectColumn.Field("Detail_Customer_Name", detail));
            dom.Columns.Add(DQSelectColumn.Field("ProductionUnit_ID"));
            dom.Columns.Add(DQSelectColumn.Field("ProductionUnit_Name"));
            dom.Columns.Add(DQSelectColumn.Field("Date", "单据日期"));
            dom.Columns.Add(DQSelectColumn.Field("ProduceDate", detail));
            dom.Columns.Add(DQSelectColumn.Field("DeliveryDate", detail));
            dom.Columns.Add(DQSelectColumn.Field("ProduceRequest", detail, "工艺描述"));
            dom.Columns.Add(DQSelectColumn.Field("Goods_Name", detail));
            dom.Columns.Add(DQSelectColumn.Field("Goods_MainUnit", detail));
            dom.Columns.Add(DQSelectColumn.Field("Goods_SecondUnit", detail));
            dom.Columns.Add(DQSelectColumn.Field("Goods_ID", detail));
            dom.Columns.Add(DQSelectColumn.Field("Number", detail));
            dom.Columns.Add(DQSelectColumn.Field("SecondNumber", detail));
            dom.Columns.Add(DQSelectColumn.Field("DoneNumber", detail));
            dom.Columns.Add(DQSelectColumn.Field("BrandItem_Name", detail));
            dom.Columns.Add(DQSelectColumn.Field("BrandItem_ID", detail));
            dom.EAddCheckedCondition(alias);
            dom.Where.Conditions.Add(DQCondition.EQ(alias, "Domain_ID", DomainContext.Current.ID));
            if (_hideFinishedBill.Checked)
            {
                dom.Where.Conditions.Add(DQCondition.GreaterThan(DQExpression.Field(detail, "Number"), DQExpression.IfNull(DQExpression.Field(detail, "DoneNumber"), DQExpression.Value(0))));
            }
            return(dom);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public static List <ProductPlanInfo> GetProductPlanInfo(long[] id)
        {
            if (id.Length == 0)
            {
                return(new List <ProductPlanInfo>());
            }
            var query = new DQueryDom(new JoinAlias(typeof(ProductPlan)));

            query.Columns.Add(DQSelectColumn.Field("ID"));
            query.Columns.Add(DQSelectColumn.Field("PlanNumber"));
            query.Columns.Add(DQSelectColumn.Field("Date"));
            query.Columns.Add(DQSelectColumn.Field("RowVersion"));
            query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), id.Select(x => DQExpression.Value(x)).ToArray()));
            query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
            var result = query.EExecuteList <long, string, DateTime, int>();
            var rst    = new List <ProductPlanInfo>();

            foreach (var item in result)
            {
                rst.Add(new ProductPlanInfo {
                    ID = item.Item1, PlanNumber = item.Item2, PlanDate = item.Item3, RowVersion = item.Item4
                });
            }
            return(rst);
        }