diff --git a/BWP.B3ButcherManageExport.Web/Pages/B3ButcherManageExport/NC_/PayToNc_/PayToNcList.cs b/BWP.B3ButcherManageExport.Web/Pages/B3ButcherManageExport/NC_/PayToNc_/PayToNcList.cs index 36da04b..fd55152 100644 --- a/BWP.B3ButcherManageExport.Web/Pages/B3ButcherManageExport/NC_/PayToNc_/PayToNcList.cs +++ b/BWP.B3ButcherManageExport.Web/Pages/B3ButcherManageExport/NC_/PayToNc_/PayToNcList.cs @@ -1,20 +1,14 @@ using System; using System.Collections.Generic; -using System.Web.UI; -using System.Web.UI.WebControls; using BWP.B3ButcherManage.BO; using BWP.B3ButcherManageExport.BL; using BWP.B3ExportBase; -using BWP.B3ExportBase.BO; using BWP.B3ExportBase.Utils; using BWP.B3Frameworks; using BWP.Web.Pages.B3ExportBase; using Forks.EnterpriseServices.BusinessInterfaces; -using Forks.EnterpriseServices.DataForm; -using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using TSingSoft.WebControls2; -using TSingSoft.WebPluginFramework; namespace BWP.Web.Pages.B3ButcherManageExport.NC_.PayToNc_ { diff --git a/BWP.B3ButcherManageExport/BL/NC/PayToNcBL_/PayToNcBL.cs b/BWP.B3ButcherManageExport/BL/NC/PayToNcBL_/PayToNcBL.cs index 65940fd..048c35b 100644 --- a/BWP.B3ButcherManageExport/BL/NC/PayToNcBL_/PayToNcBL.cs +++ b/BWP.B3ButcherManageExport/BL/NC/PayToNcBL_/PayToNcBL.cs @@ -8,6 +8,8 @@ using BWP.B3ExportBase.BO; using BWP.B3Frameworks; using Forks.EnterpriseServices; using Forks.EnterpriseServices.BusinessInterfaces; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; using TSingSoft.WebPluginFramework; using TSingSoft.WebPluginFramework.BIPlugins.BLEvents; @@ -24,6 +26,7 @@ namespace BWP.B3ButcherManageExport.BL [ExportID(B3FrameworksConsts.DmoTypeIDBases.B3ButcherManageExport, B3ButcherManageExportConsts.ExportIDOffsets.PayToNc)] public class PayToNcBL : NcBL, IPayToNcBL { + public readonly List MinPreDetailProperties = new List(); protected override NcUfinterface CreateUfinterface(IList dmos) { var scriptHelper = new PythonScriptHelper(string.Empty, Config.Script, this); @@ -58,7 +61,7 @@ namespace BWP.B3ButcherManageExport.BL Export(dmoIDs, extSystemID); } - public void CheckAccountingUnit(IEnumerable dmos) + public void CheckAccountingUnit(IEnumerable dmos) { var groups = dmos.GroupBy(x => x.AccountingUnit_Name); var count = groups.Count(); @@ -84,5 +87,110 @@ namespace BWP.B3ButcherManageExport.BL return string.Empty; return GetDateTime(dmo.Details[0].StatPay_Date, format); } + + public string GetSumMoney(IEnumerable details) + { + return details.Sum(x => (x.Money ?? 0).Value).ToString(); + } + + public string GetSumPreMoney(IEnumerable details) + { + return details.Sum(x => (x.AdvancePay_Money ?? 0).Value).ToString(); + } + + protected override void BeforeExport(List dmoIDs) + { + base.BeforeExport(dmoIDs); + var dmoType = typeof(Pay_AdvanceDetail); + var dom = new DQueryDom(new JoinAlias(dmoType)); + dom.Columns.Add(DQSelectColumn.Field("ID")); + foreach (string property in MinPreDetailProperties) + { + dom.Columns.Add(DQSelectColumn.Field(property)); + } + var expressionList = new List(); + foreach (var dmo in Dmos) + expressionList.Add(DQExpression.Value(dmo.ID)); + dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("Pay_ID"), expressionList.ToArray())); + var details = new List(); + using (IDQDataReader reader = Session.ExecuteReader(dom)) + { + while (reader.Read()) + { + var detail = new Pay_AdvanceDetail + { + ID = (long)reader[0] + }; + int i = 1; + foreach (var property in MinPreDetailProperties) + { + var propertyInfo = dmoType.GetProperty(property); + if (propertyInfo != null) + propertyInfo.SetValue(detail, reader[i++], null); + } + details.Add(detail); + } + } + var groups = details.GroupBy(x => x.Pay_ID); + foreach (var gDetail in groups) + { + var firstDmo = Dmos.FirstOrDefault(x => x.ID == gDetail.Key); + if (firstDmo == null) + continue; + foreach (var billDetail in gDetail) + { + firstDmo.AdvanceDetails.Add(billDetail); + } + } + } + + protected override Action> FillDetail + { + get + { + return dmos => + { + var dmoType = typeof(Pay_Detail); + var dom = new DQueryDom(new JoinAlias(dmoType)); + dom.Columns.Add(DQSelectColumn.Field("ID")); + foreach (string property in MinDetailProperties) + { + dom.Columns.Add(DQSelectColumn.Field(property)); + } + var expressionList = new List(); + foreach (var dmo in dmos) + expressionList.Add(DQExpression.Value(dmo.ID)); + dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("Pay_ID"), expressionList.ToArray())); + var details = new List(); + using (IDQDataReader reader = Session.ExecuteReader(dom)) + { + while (reader.Read()) + { + var detail = new Pay_Detail + { + ID = (long)reader[0] + }; + int i = 1; + foreach (var property in MinDetailProperties) + { + dmoType.GetProperty(property).SetValue(detail, reader[i++], null); + } + details.Add(detail); + } + } + var groups = details.GroupBy(x => x.Pay_ID); + foreach (var gDetail in groups) + { + var firstDmo = dmos.FirstOrDefault(x => x.ID == gDetail.Key); + if (firstDmo == null) + continue; + foreach (var billDetail in gDetail) + { + firstDmo.Details.Add(billDetail); + } + } + }; + } + } } }