protected static FR_L5SR_GFSRfT_1635 Execute(DbConnection Connection, DbTransaction Transaction, P_L5SR_GFSRfT_1635 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5SR_GFSRfT_1635();
            returnValue.Result = new L5SR_GFSRfT_1635();

            // if nothing has choosen then give nothing
            if (!Parameter.IsPriceConditionsManuallyCleared &&
                !Parameter.IsQualityControlPerformed &&
                !Parameter.IsReceiptForwardedToBookkeeping &&
                !Parameter.IsTakenIntoStock && !Parameter.IsErwartet)
            {
                returnValue.Result.StockReceipts = new L5ALSR_GSRfT_1016[0];
                return(returnValue);
            }

            #region NoStatus StockReceipts

            var parameterForAll = new P_L5ALSR_GSRfT_1016
            {
                SupplierName           = Parameter.SupplierName,
                ReceiptNumber          = Parameter.ReceiptNumber,
                ProcurementOrderNumber = Parameter.ProcurementOrderNumber,
                DateFrom       = Parameter.DateFrom,
                DateTo         = Parameter.DateTo,
                SupplierTypeID = Parameter.SupplierTypeID
            };

            var AllList = new List <L5ALSR_GSRfT_1016>();

            // if we choose only those hwo doesn't have any status
            if ((Parameter.IsPriceConditionsManuallyCleared == false &&
                 Parameter.IsQualityControlPerformed == false &&
                 Parameter.IsReceiptForwardedToBookkeeping == false &&
                 Parameter.IsTakenIntoStock == false) || Parameter.IsErwartet)
            {
                parameterForAll.IsPriceConditionsManuallyCleared = false;
                parameterForAll.IsQualityControlPerformed        = false;
                parameterForAll.IsReceiptForwardedToBookkeeping  = false;
                parameterForAll.IsTakenIntoStock = false;

                var listWithoutStatus =
                    cls_Get_StockReceipts_for_TenantID.Invoke(Connection, Transaction, parameterForAll, securityTicket)
                    .Result.ToList();
                // add distinct members
                AllList.AddRange(listWithoutStatus.Where(x => !AllList.Select(y => y.LOG_RCP_Receipt_HeaderID).Contains(x.LOG_RCP_Receipt_HeaderID)));
            }

            #endregion

            #region QualityControlPerformed StockReceipts

            if (Parameter.IsQualityControlPerformed)
            {
                parameterForAll.IsQualityControlPerformed        = true;
                parameterForAll.IsTakenIntoStock                 = false;
                parameterForAll.IsPriceConditionsManuallyCleared = false;
                parameterForAll.IsReceiptForwardedToBookkeeping  = false;

                var listQuantityControl = cls_Get_StockReceipts_for_TenantID.Invoke(Connection, Transaction, parameterForAll, securityTicket)
                                          .Result.ToList();
                if (listQuantityControl.Any())
                {
                    // add distinct members
                    AllList.AddRange(listQuantityControl.Where(x => !AllList.Select(y => y.LOG_RCP_Receipt_HeaderID).Contains(x.LOG_RCP_Receipt_HeaderID)));
                }
            }

            #endregion

            #region TakenIntoStock StockReceipts

            if (Parameter.IsTakenIntoStock)
            {
                parameterForAll.IsQualityControlPerformed        = null;
                parameterForAll.IsTakenIntoStock                 = true;
                parameterForAll.IsPriceConditionsManuallyCleared = false;
                parameterForAll.IsReceiptForwardedToBookkeeping  = false;

                var listTakenIntoStock = cls_Get_StockReceipts_for_TenantID.Invoke(Connection, Transaction, parameterForAll, securityTicket)
                                         .Result.ToList();
                if (listTakenIntoStock.Any())
                {
                    // add distinct members
                    AllList.AddRange(listTakenIntoStock.Where(x => !AllList.Select(y => y.LOG_RCP_Receipt_HeaderID).Contains(x.LOG_RCP_Receipt_HeaderID)));
                }
            }

            #endregion

            #region PriceConditionsManuallyCleared StockReceipts

            if (Parameter.IsPriceConditionsManuallyCleared)
            {
                parameterForAll.IsQualityControlPerformed        = null;
                parameterForAll.IsTakenIntoStock                 = null;
                parameterForAll.IsPriceConditionsManuallyCleared = true;
                parameterForAll.IsReceiptForwardedToBookkeeping  = true;

                var listPriceConditions = cls_Get_StockReceipts_for_TenantID.Invoke(Connection, Transaction, parameterForAll, securityTicket)
                                          .Result.ToList();
                if (listPriceConditions.Any())
                {
                    // add distinct members
                    AllList.AddRange(listPriceConditions.Where(x => !AllList.Select(y => y.LOG_RCP_Receipt_HeaderID).Contains(x.LOG_RCP_Receipt_HeaderID)));
                }
            }

            #endregion

            #region ForwardedToBookkeeping StockReceipts

            if (Parameter.IsReceiptForwardedToBookkeeping)
            {
                parameterForAll.IsQualityControlPerformed        = null;
                parameterForAll.IsTakenIntoStock                 = null;
                parameterForAll.IsPriceConditionsManuallyCleared = null;
                parameterForAll.IsReceiptForwardedToBookkeeping  = true;

                var listPriceConditions = cls_Get_StockReceipts_for_TenantID.Invoke(Connection, Transaction, parameterForAll, securityTicket)
                                          .Result.ToList();
                if (listPriceConditions.Any())
                {
                    // add distinct members
                    AllList.AddRange(listPriceConditions.Where(x => !AllList.Select(y => y.LOG_RCP_Receipt_HeaderID).Contains(x.LOG_RCP_Receipt_HeaderID)));
                }
            }

            #endregion

            returnValue.Result.StockReceipts = new L5ALSR_GSRfT_1016[AllList.Count];
            returnValue.Result.StockReceipts = AllList.ToArray();

            return(returnValue);

            #endregion UserCode
        }
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_L5SR_GFSRfT_1635 Invoke(DbConnection Connection, DbTransaction Transaction, P_L5SR_GFSRfT_1635 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5SR_GFSRfT_1635 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5SR_GFSRfT_1635 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5SR_GFSRfT_1635 functionReturn = new FR_L5SR_GFSRfT_1635();

            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_Get_Filter_StockReceipt_for_TenantID", ex);
            }
            return(functionReturn);
        }
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_L5SR_GFSRfT_1635 Invoke(string ConnectionString, P_L5SR_GFSRfT_1635 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }