private static IDQExpression GetNumber(JoinAlias bill, string title) { return(DQExpression.IfNull(DQExpression.Field(bill, title), DQExpression.ConstValue(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); }
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); }