|
|
using BWP.B3Frameworks;
|
|
|
using BWP.B3Frameworks.BO.NamedValueTemplate;
|
|
|
using BWP.B3Frameworks.Utils;
|
|
|
using BWP.B3SheepButcherManage;
|
|
|
using BWP.B3SheepButcherManage.BO;
|
|
|
using BWP.B3UnitedInfos.BO;
|
|
|
using Forks.EnterpriseServices.DomainObjects2;
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery;
|
|
|
using Forks.EnterpriseServices.SqlDoms;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using TSingSoft.WebControls2;
|
|
|
using TSingSoft.WebPluginFramework;
|
|
|
|
|
|
namespace BWP.Web.Utils
|
|
|
{
|
|
|
public static class B3SheepButcherManageChoiceBoxProvider
|
|
|
{
|
|
|
public static void Register()
|
|
|
{
|
|
|
ChoiceBoxSettings.Register(B3SheepButcherManageConsts.DataSources.可屠宰存货属性, (argu) =>
|
|
|
new ChoiceBoxQueryHelper<GoodsProperty>(argu, true)
|
|
|
{
|
|
|
BeforeQuery = query =>
|
|
|
{
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("IsButchery", true));
|
|
|
DomainUtil.AddDomainPermissionLimit(query);
|
|
|
}
|
|
|
}.GetData());
|
|
|
|
|
|
ChoiceBoxSettings.Register(B3SheepButcherManageConsts.DataSources.活体级别, argu =>
|
|
|
{
|
|
|
var goods = new JoinAlias(typeof(Livestock));
|
|
|
var goodsProperty = new JoinAlias(typeof(GoodsProperty));
|
|
|
var dom = new DQueryDom(goods);
|
|
|
dom.From.AddJoin(JoinType.Left, new DQDmoSource(goodsProperty), DQCondition.EQ(goods, "GoodsProperty_ID", goodsProperty, "ID"));
|
|
|
dom.Columns.Add(DQSelectColumn.Field("Name", goods));
|
|
|
dom.Columns.Add(DQSelectColumn.Field("ID", goods));
|
|
|
dom.Where.Conditions.Add(DQCondition.EQ(goodsProperty, "IsButchery", true));
|
|
|
dom.Where.Conditions.Add(DQCondition.EQ("Stopped", false));
|
|
|
DomainUtil.AddDomainPermissionLimit(dom, typeof(GoodsProperty), goodsProperty);
|
|
|
if (!string.IsNullOrEmpty(argu.InputArgument))
|
|
|
{
|
|
|
dom.Where.Conditions.Add(DQCondition.Or(DQCondition.Like("Name", argu.InputArgument), DQCondition.Like("Spell", argu.InputArgument), DQCondition.Like("Code", argu.InputArgument)));
|
|
|
}
|
|
|
return dom.EExecuteList<string, long>().Select(x => new WordPair(x.Item1.ToString(), x.Item2.ToString()));
|
|
|
});
|
|
|
|
|
|
ChoiceBoxSettings.Register(B3SheepButcherManageConsts.DataSources.已审核过磅单, argu =>
|
|
|
{
|
|
|
var weightBill = new JoinAlias(typeof(WeightBill));
|
|
|
var dom = new DQueryDom(weightBill);
|
|
|
dom.Columns.Add(DQSelectColumn.Field("ID", weightBill));
|
|
|
dom.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
|
|
|
dom.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核));
|
|
|
if (!string.IsNullOrWhiteSpace(argu.CodeArgument))
|
|
|
{
|
|
|
dom.Where.Conditions.Add(DQCondition.EQ("Supplier_ID", long.Parse(argu.CodeArgument)));
|
|
|
}
|
|
|
OrganizationUtil.AddOrganizationLimit(dom, typeof(WeightBill));
|
|
|
dom.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID));
|
|
|
return Query(dom);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
private static IEnumerable<WordPair> Query(DQueryDom query)
|
|
|
{
|
|
|
query.Range = SelectRange.Top(100);
|
|
|
using (var session = Dmo.NewSession())
|
|
|
{
|
|
|
using (IDQDataReader reader = session.ExecuteReader(query))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (query.Columns.Count == 3)
|
|
|
yield return new WordPair(TreeUtil.GetTreePrefix(Convert.ToInt32(reader[2])) + reader[0], reader[1].ToString());
|
|
|
if (query.Columns.Count == 2)
|
|
|
yield return new WordPair(reader[0].ToString(), reader[1].ToString());
|
|
|
if (query.Columns.Count == 1)
|
|
|
yield return new WordPair(reader[0].ToString());
|
|
|
}
|
|
|
}
|
|
|
session.Commit();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|