示例#1
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5SH_GSHDaCOwPDfS_1128 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5SH_GSHDaCOwPDfS_1128 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5SH_GSHDaCOwPDfS_1128 functionReturn = new FR_L5SH_GSHDaCOwPDfS_1128();

            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_ShippmentHeaderDetails_and_CustomerOrder_with_PositionDetails_for_ShipmentID", ex);
            }
            return(functionReturn);
        }
示例#2
0
        protected static FR_L5SH_GSHDaCOwPDfS_1128 Execute(DbConnection Connection, DbTransaction Transaction, P_L5SH_GSHDaCOwPDfS_1128 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_L5SH_GSHDaCOwPDfS_1128();

            //Put your code here
            if (Parameter.ShipmentHeaderID == null || Parameter.ShipmentHeaderID == Guid.Empty)
            {
                return(null);
            }

            L5SH_GSHDaCOwPDfS_1128 retVal = new L5SH_GSHDaCOwPDfS_1128();

            P_L5PP_GSHDaCOwPfS_1125 param = new P_L5PP_GSHDaCOwPfS_1125();
            param.ShipmentHeaderID = Parameter.ShipmentHeaderID;
            var shipmentHeaderDetailsWithPositions = cls_Get_ShippmentHeaderDetails_and_CustomerOrder_with_Positions_for_ShipmentID.Invoke(Connection, Transaction, param, securityTicket).Result;

            if (shipmentHeaderDetailsWithPositions == null || shipmentHeaderDetailsWithPositions.Count() == 0)
            {
                return(null);
            }

            #region Retrieve shipment header details
            var shipmentDetails = shipmentHeaderDetailsWithPositions.FirstOrDefault(i => i.LOG_SHP_Shipment_HeaderID == Parameter.ShipmentHeaderID);
            L5SH_GSHDaCOwPDfS_1128_ShipmentDetailHeader shipmentDetailHeaderRetVal = new L5SH_GSHDaCOwPDfS_1128_ShipmentDetailHeader();
            shipmentDetailHeaderRetVal.ORD_CUO_CustomerOrder_HeaderID = shipmentDetails.ORD_CUO_CustomerOrder_HeaderID;
            shipmentDetailHeaderRetVal.CustomerOrderNumber            = shipmentDetails.CustomerOrder_Number;
            shipmentDetailHeaderRetVal.CustomerOrderDate     = shipmentDetails.CustomerOrder_Date;
            shipmentDetailHeaderRetVal.ShipmentHeader_Number = shipmentDetails.ShipmentHeader_Number;
            shipmentDetailHeaderRetVal.ShipmentCreationDate  = shipmentDetails.ShipmentCreationDate;
            shipmentDetailHeaderRetVal.Customer = shipmentDetails.DisplayName;
            #endregion

            #region Retrieve shipment positions
            List <L5SH_GSHDaCOwPDfS_1128_ShipmentPositions> positionsRetVal = new List <L5SH_GSHDaCOwPDfS_1128_ShipmentPositions>();
            L5SH_GSHDaCOwPDfS_1128_ShipmentPositions        positionItemRetVal;
            int quantity;
            foreach (var position in shipmentHeaderDetailsWithPositions)
            {
                if (!Int32.TryParse(position.Position_Quantity, out quantity))
                {
                    quantity = 0;
                }

                #region Get product quantities
                P_L2SH_GQiSCfPV_1654 quantitiesParam = new P_L2SH_GQiSCfPV_1654();
                quantitiesParam.ProductID        = position.CMN_PRO_ProductID;
                quantitiesParam.ProductVariantID = position.CMN_PRO_Product_VariantID;
                var productQuantities = cls_Get_Quantities_in_ShelfContents_for_ProductVariantID.Invoke(Connection, Transaction, quantitiesParam, securityTicket).Result;
                #endregion

                positionItemRetVal = new L5SH_GSHDaCOwPDfS_1128_ShipmentPositions();
                positionItemRetVal.LOG_SHP_Shipment_PositionID = position.LOG_SHP_Shipment_PositionID;
                positionItemRetVal.CMN_PRO_ProductID           = position.CMN_PRO_ProductID;
                positionItemRetVal.CMN_PRO_Product_VariantID   = position.CMN_PRO_Product_VariantID;
                positionItemRetVal.Product_Number   = position.Product_Number;
                positionItemRetVal.Product_Name     = position.Product_Name;
                positionItemRetVal.VariantName      = position.VariantName;
                positionItemRetVal.QuantityOnOrder  = quantity;
                positionItemRetVal.QuantityReserved = productQuantities != null ? productQuantities.ReservedQuantity : 0;
                positionItemRetVal.QuantityOnStock  = productQuantities != null ? productQuantities.CurrentQuantity : 0;
                positionItemRetVal.FreeQuantity     = productQuantities != null ? productQuantities.FreeQuantity : 0;

                positionsRetVal.Add(positionItemRetVal);
            }
            #endregion

            retVal.ShipmentDetailHeader = shipmentDetailHeaderRetVal;
            retVal.ShipmentPositions    = positionsRetVal.ToArray();

            returnValue.Result = retVal;
            return(returnValue);

            #endregion UserCode
        }