diff --git a/BWP.B3_YunKen/BLActions/CustomerCreditPolicyBLAction.cs b/BWP.B3_YunKen/BLActions/CustomerCreditPolicyBLAction.cs index 0797f78..14a29ca 100644 --- a/BWP.B3_YunKen/BLActions/CustomerCreditPolicyBLAction.cs +++ b/BWP.B3_YunKen/BLActions/CustomerCreditPolicyBLAction.cs @@ -49,18 +49,19 @@ namespace BWP.B3_YunKen.BLActions update.Where.Conditions.Add(DQCondition.EQ("ID", tuple.Item2)); context.Session.ExecuteNonQuery(update); } - - List> list = new List>(); + + List> list = new List>(); var scp = new JoinAlias(typeof(SaleCreditPolicy)); var scp_detail = new JoinAlias(typeof(SaleCreditPolicy_Detail)); var main = new DQueryDom(saleCreditPolicy); main.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(detail, "SaleCreditPolicy_ID", saleCreditPolicy, "ID")); main.Columns.Add(DQSelectColumn.Field("Customer_ID", detail)); main.Columns.Add(DQSelectColumn.Field("ID", saleCreditPolicy)); + main.Columns.Add(DQSelectColumn.Field("AccountingUnit_ID", saleCreditPolicy)); main.Where.Conditions.Add(DQCondition.EQ("CreditPolicy_ID", customer.CreditPolicy_ID)); using (var reader = context.Session.ExecuteReader(main)) { while (reader.Read()) { - list.Add(new Tuple((long?)reader[0], (long?)reader[1])); + list.Add(new Tuple((long?)reader[0], (long?)reader[1], (long?)reader[2])); } } @@ -74,10 +75,25 @@ namespace BWP.B3_YunKen.BLActions update.Columns.Add(new DQUpdateColumn("RowVersion", DQExpression.Add(DQExpression.Field("RowVersion"), DQExpression.Value(1)))); update.Where.Conditions.Add(DQCondition.EQ("ID", first.Item2)); context.Session.ExecuteNonQuery(update); + DeleteHeadOfficeCreditPolicyToday(context, customer.AccountCustomer_ID, first.Item3); + context.Session.AddInsertOrUpdate(new CustomerCreditPolicyToday { + Customer_ID = customer.AccountCustomer_ID.Value, + SaleCreditPolicy_ID = first.Item2.Value, + AccountingUnit_ID = first.Item3 ?? 0 + }); } } } + private void DeleteHeadOfficeCreditPolicyToday(IDmoContext context, long? customer_ID, long? accountingUnit_ID) + { + var type = typeof(CustomerCreditPolicyToday); + var deldom = new DQDeleteDom(type); + deldom.Where.Conditions.Add(DQCondition.EQ("Customer_ID", customer_ID)); + deldom.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", accountingUnit_ID ?? 0)); + context.Session.ExecuteNonQuery(deldom); + } + public IList Features { get { return new List(); }