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 => { 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))); } if (!string.IsNullOrEmpty(argu.InputArgument)) dom.Where.Conditions.Add(DQCondition.Like("ID", argu.InputArgument)); OrganizationUtil.AddOrganizationLimit(dom, typeof(WeightBill)); dom.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID)); return Query(dom); }); } private static IEnumerable 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(); } } } }