From 581034b08da8e2932651a96523769752507c0f9f Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 8 Oct 2019 21:05:49 +0000 Subject: [PATCH] --- .../AyaLib/GZTW.AyaNova.BLL/Client.cs | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/Client.cs b/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/Client.cs index b97943b..cd31f9b 100644 --- a/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/Client.cs +++ b/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/Client.cs @@ -2028,6 +2028,8 @@ namespace GZTW.AyaNova.BLL } return nm; } + + #endregion #region DAL Data Access @@ -2369,15 +2371,36 @@ namespace GZTW.AyaNova.BLL //case 3701 set pm's inactive if client is now inactive if (this.mActiveChanged && this.mActive == false) { - //here set all pm's for this client to inactive - DBCommandWrapper cmPM = DBUtil.GetCommandFromSQL( - "UPDATE AWORKORDERPREVENTIVEMAINTENANCE set aactive = 0 from AWORKORDERPREVENTIVEMAINTENANCE " + - "LEFT OUTER JOIN AWORKORDER ON (AWORKORDERPREVENTIVEMAINTENANCE.AWORKORDERID=AWORKORDER.AID) " + - "WHERE AWORKORDER.AWORKORDERTYPE='2' AND AWORKORDER.ACLIENTID=@CLIENTID " - ); - cmPM.AddInParameter("@CLIENTID", DbType.Guid, mID); - DBUtil.DB.ExecuteNonQuery(cmPM, transaction); + //because firebird doesn't support updating through a join statement + //Need to fetch as a list object first then update them all... + //Find all PM's for this client + string pmListCriteria = " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " "; + var wopm = WorkorderPMList.GetList(pmListCriteria); + if (wopm.Count > 0) + { + foreach (WorkorderPMList.WorkorderPMListInfo i in wopm) + { + if (i.LT_O_WorkorderPreventiveMaintenance.Value != Guid.Empty) + { + DBCommandWrapper cmPM = DBUtil.GetCommandFromSQL( + "UPDATE " + + " AWORKORDERPREVENTIVEMAINTENANCE " + + " SET " + + " AACTIVE=0 " + + " WHERE AWORKORDERID=@PMID " + ); + cmPM.AddInParameter("@PMID", DbType.Guid, i.LT_O_WorkorderPreventiveMaintenance.Value); + DBUtil.DB.ExecuteNonQuery(cmPM, transaction); + } + } + } }