diff --git a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Bills/CostRecord_/CostRecordEdit.cs b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Bills/CostRecord_/CostRecordEdit.cs index a8b5dad..41204c6 100644 --- a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Bills/CostRecord_/CostRecordEdit.cs +++ b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Bills/CostRecord_/CostRecordEdit.cs @@ -85,15 +85,18 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Bills.CostRecord_ { using (var reader = session.ExecuteReader(query)) { - var detail = new CostRecord_Detail() + while (reader.Read()) { - WeightBill_ID = (long)reader[0], - Supplier_Name = (string)reader[1], - Employee_Name = (string)reader[2], - Car_Name = (string)reader[3], - BuyNum = (int?)reader[4] - }; - Dmo.Details.Add(detail); + var detail = new CostRecord_Detail() + { + WeightBill_ID = (long)reader[0], + Supplier_Name = (string)reader[1], + Employee_Name = (string)reader[2], + Car_Name = (string)reader[3], + BuyNum = (int?)reader[4] + }; + Dmo.Details.Add(detail); + } } } _detailGrid.DataBind(); diff --git a/B3QingDaoWanFu/TypeIOCs/StatPayBLTypeIoc.cs b/B3QingDaoWanFu/TypeIOCs/StatPayBLTypeIoc.cs index 1b92a0a..9fbdbff 100644 --- a/B3QingDaoWanFu/TypeIOCs/StatPayBLTypeIoc.cs +++ b/B3QingDaoWanFu/TypeIOCs/StatPayBLTypeIoc.cs @@ -10,6 +10,12 @@ using BWP.B3Frameworks; using Forks.EnterpriseServices.BusinessInterfaces; using Forks.Utils; using TSingSoft.WebPluginFramework; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.DomainObjects2; +using BWP.B3QingDaoWanFu.BO; +using Forks.EnterpriseServices.SqlDoms; +using BWP.B3Frameworks.BO.NamedValueTemplate; +using BWP.B3Frameworks.BO.MoneyTemplate; namespace BWP.B3QingDaoWanFu.TypeIOCs { @@ -19,7 +25,7 @@ namespace BWP.B3QingDaoWanFu.TypeIOCs //{ // public void Invoke(IDmoContext context, StatPay dmo) // { - + // } //} @@ -51,7 +57,24 @@ namespace BWP.B3QingDaoWanFu.TypeIOCs dmo.ActualPrice = decimal.Round(dmo.ActualMoney.EToDecimal() ?? 0, 2) / we; if (dmo.ActualPrice.HasValue) dmo.ActualPrice = decimal.Round(dmo.ActualPrice.Value.Value, 2); + if (dmo.Weigh_ID.HasValue) + dmo.Money = dmo.Money - GetCostRecordMoney(dmo.Weigh_ID.Value, context.Session); } } + + decimal GetCostRecordMoney(long weightID, IDmoSession session) + { + var main = new JoinAlias("_Main",typeof(CostRecord)); + var detail = new JoinAlias(typeof(CostRecord_Detail)); + var query = new DQueryDom(main); + query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "CostRecord_ID")); + query.Columns.Add(DQSelectColumn.Sum(detail, "JingJiFee")); + query.Columns.Add(DQSelectColumn.Sum(detail, "TransferFee")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.EQ(detail, "WeightBill_ID", weightID))); + var result = query.EExecuteScalar?, Money<金额>?>(session); + if (result == null) + return 0; + return (result.Item1 ?? 0) + (result.Item2 ?? 0); + } } }