|
|
|
@ -22,7 +22,7 @@ namespace BWP.B3_YunKen.BLActions |
|
|
|
public void Execute(Forks.EnterpriseServices.BusinessInterfaces.IDmoContext context, object dmo, object parameter) |
|
|
|
{ |
|
|
|
var customer = dmo as Customer; |
|
|
|
if (customer != null && customer.CreditPolicy_ID != null) { |
|
|
|
if (customer.AccountCustomer_ID != null && customer.CreditPolicy_ID != null) { |
|
|
|
Tuple<long?, long> tuple = null; |
|
|
|
var detail = new JoinAlias(typeof(SaleCreditPolicy_Detail)); |
|
|
|
var saleCreditPolicy = new JoinAlias(typeof(SaleCreditPolicy)); |
|
|
|
@ -30,7 +30,7 @@ namespace BWP.B3_YunKen.BLActions |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(saleCreditPolicy), DQCondition.EQ(detail, "SaleCreditPolicy_ID", saleCreditPolicy, "ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("CreditPolicy_ID", saleCreditPolicy)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", saleCreditPolicy)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Customer_ID", customer.ID)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Customer_ID", customer.AccountCustomer_ID)); |
|
|
|
using (var reader = context.Session.ExecuteReader(query)) { |
|
|
|
while (reader.Read()) { |
|
|
|
tuple = new Tuple<long?, long>((long?)reader[0], (long)reader[1]); |
|
|
|
@ -41,7 +41,7 @@ namespace BWP.B3_YunKen.BLActions |
|
|
|
|
|
|
|
if (tuple != null && tuple.Item1 != null) { |
|
|
|
var del = new DQDeleteDom(typeof(SaleCreditPolicy_Detail)); |
|
|
|
del.Where.Conditions.Add(DQCondition.EQ("Customer_ID", customer.ID)); |
|
|
|
del.Where.Conditions.Add(DQCondition.EQ("Customer_ID", customer.AccountCustomer_ID)); |
|
|
|
context.Session.ExecuteNonQuery(del); |
|
|
|
|
|
|
|
var update = new DQUpdateDom(typeof(SaleCreditPolicy)); |
|
|
|
@ -64,10 +64,10 @@ namespace BWP.B3_YunKen.BLActions |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (list.Count() > 0 && !list.Any(x => x.Item1 == customer.ID)) { |
|
|
|
if (list.Count() > 0 && !list.Any(x => x.Item1 == customer.AccountCustomer_ID)) { |
|
|
|
var first = list.First(); |
|
|
|
var customerDetail = new SaleCreditPolicy_Detail(); |
|
|
|
customerDetail.Customer_ID = customer.ID; |
|
|
|
customerDetail.Customer_ID = customer.AccountCustomer_ID.Value; |
|
|
|
customerDetail.SaleCreditPolicy_ID = first.Item2; |
|
|
|
context.Session.Insert(customerDetail); |
|
|
|
var update = new DQUpdateDom(typeof(SaleCreditPolicy)); |
|
|
|
|