|
|
|
@ -3,13 +3,16 @@ using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using BWP.B3Frameworks; |
|
|
|
using BWP.B3Frameworks.Utils; |
|
|
|
using BWP.B3Sale.BO; |
|
|
|
using BWP.Web.Layout; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
|
using Forks.Utils; |
|
|
|
using TSingSoft.WebControls2; |
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
|
|
|
|
namespace BWP.Web.Pages.B3YunKen.Overlays |
|
|
|
{ |
|
|
|
@ -40,32 +43,39 @@ namespace BWP.Web.Pages.B3YunKen.Overlays |
|
|
|
List<SaleForecast_Detail> LoadList() |
|
|
|
{ |
|
|
|
var list=new List<SaleForecast_Detail>(); |
|
|
|
|
|
|
|
var bill = new JoinAlias(typeof(CustomerGoodsTable)); |
|
|
|
var detail = new JoinAlias(typeof(CustomerGoodsTable_Detail)); |
|
|
|
var query = new DQueryDom(bill); |
|
|
|
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "CustomerGoodsTable_ID")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", Dmo.AccountingUnit_ID)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Customer_ID", Dmo.Customer_ID)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("SaleGoods_ID", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Brand", detail)); |
|
|
|
using (var session=Forks.EnterpriseServices.DomainObjects2.Dmo.NewSession()) |
|
|
|
{ |
|
|
|
using (var reader=session.ExecuteReader(query)) |
|
|
|
{ |
|
|
|
while (reader.Read()) |
|
|
|
var maxid = GetMaxId(session); |
|
|
|
var bill = new JoinAlias(typeof(CustomerGoodsTable)); |
|
|
|
var detail = new JoinAlias(typeof(CustomerGoodsTable_Detail)); |
|
|
|
var query = new DQueryDom(bill); |
|
|
|
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "CustomerGoodsTable_ID")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("ID", maxid)); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("SaleGoods_ID", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BrandItem_ID", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BrandItem_Name", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Unit", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("UnitNum ", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("SecondNumber ", detail)); |
|
|
|
|
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
{ |
|
|
|
var dmodetail = new SaleForecast_Detail() |
|
|
|
while (reader.Read()) |
|
|
|
{ |
|
|
|
SaleGoods_ID = (long) reader[0], |
|
|
|
Goods_Name = (string) reader[1], |
|
|
|
Goods_Brand = (string) reader[2] |
|
|
|
}; |
|
|
|
list.Add(dmodetail); |
|
|
|
var dmodetail = new SaleForecast_Detail() |
|
|
|
{ |
|
|
|
SaleGoods_ID = (long)reader[0], |
|
|
|
BrandItem_ID = (long?)reader[1], |
|
|
|
BrandItem_Name = (string)reader[2], |
|
|
|
Unit = (string)reader[3], |
|
|
|
UnitNum = (Money<decimal>?)reader[4], |
|
|
|
SecondNumber = (Money<decimal>?)reader[5], |
|
|
|
}; |
|
|
|
list.Add(dmodetail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foreach (SaleForecast_Detail forecastDetail in list) |
|
|
|
{ |
|
|
|
@ -75,5 +85,19 @@ namespace BWP.Web.Pages.B3YunKen.Overlays |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
private long? GetMaxId(IDmoSession session) |
|
|
|
{ |
|
|
|
var bill = new JoinAlias(typeof(CustomerGoodsTable)); |
|
|
|
var query = new DQueryDom(bill); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", Dmo.AccountingUnit_ID)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Customer_ID", Dmo.Customer_ID)); |
|
|
|
query.EAddCheckedCondition(bill); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Domain_ID",DomainContext.Current.ID)); |
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID",true)); |
|
|
|
query.Range=SelectRange.Top(1); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
return query.EExecuteScalar<long?>(session); |
|
|
|
} |
|
|
|
} |
|
|
|
} |