///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_Bool Invoke(DbConnection Connection, DbTransaction Transaction, P_L6ED_SEoBPQA_0819 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
        protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L6ED_SEoBPQA_0819 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Bool();

            #region Get and Set 'Broken/Expired' Invertory Change Reason
            var brokenExpiredReason = ORM_LOG_WRH_InventoryChangeReason.Query.Search(
                Connection,
                Transaction,
                new ORM_LOG_WRH_InventoryChangeReason.Query()
            {
                GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDefaultContentAdjustmentsReason.BrokenExpired),
                Tenant_RefID             = securityTicket.TenantID,
                IsDeleted = false
            }).Single();
            if (brokenExpiredReason == null)
            {
                returnValue.Result = false;
                returnValue.Status = FR_Status.Error_Internal;
                return(returnValue);
            }
            foreach (var adjustment in Parameter.Adjustments.Adjustments)
            {
                adjustment.IfManualCorrection_InventoryChangeReason_RefID = brokenExpiredReason.LOG_WRH_InventoryChangeReasonID;
            }
            #endregion

            var resultAdjustments = cls_Save_Shelf_ContentAdjustments.Invoke(Connection, Transaction, Parameter.Adjustments, securityTicket);

            returnValue.Result = resultAdjustments.Result;
            returnValue.Status = resultAdjustments.Result ? FR_Status.Success : FR_Status.Error_Internal;

            return(returnValue);

            #endregion UserCode
        }
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Bool Invoke(string ConnectionString, P_L6ED_SEoBPQA_0819 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Bool Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L6ED_SEoBPQA_0819 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Bool functionReturn = new FR_Bool();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw new Exception("Exception occured in method cls_Save_Expired_or_Broken_Products_QuantityAdjustments", ex);
            }
            return(functionReturn);
        }