Exemplo n.º 1
0
        protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5SG_SSCR_1048 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Bool();
            //Put your code here

            foreach (var adjustment in Parameter.Adjustments)
            {
                var currentShelfContetnAdjustment = new ORM_LOG_WRH_Shelf_ContentAdjustment();
                var currentshelfContent           = new ORM_LOG_WRH_Shelf_Content();
                var destinationShelfContent       = new ORM_LOG_WRH_Shelf_Content();
                var destinationShelf = new ORM_LOG_WRH_Shelf();

                currentshelfContent.Load(Connection, Transaction, adjustment.ShelfContentID);

                currentShelfContetnAdjustment = ORM_LOG_WRH_Shelf_ContentAdjustment.Query.Search(
                    Connection,
                    Transaction,
                    new ORM_LOG_WRH_Shelf_ContentAdjustment.Query()
                {
                    ShelfContent_RefID = currentshelfContent.LOG_WRH_Shelf_ContentID,
                    Tenant_RefID       = securityTicket.TenantID,
                    IsDeleted          = false
                }).FirstOrDefault();

                destinationShelfContent.Tenant_RefID            = securityTicket.TenantID;
                destinationShelfContent.Shelf_RefID             = adjustment.DestinationShelf;
                destinationShelfContent.Product_RefID           = adjustment.ProductID;
                destinationShelfContent.LOG_WRH_Shelf_ContentID = Guid.NewGuid();
                var destinationShelfContentID = new FR_Guid(destinationShelfContent.Save(Connection, Transaction),
                                                            destinationShelfContent.LOG_WRH_Shelf_ContentID).Result;

                var destinationShelfContentTrackingInstance = new ORM_LOG_ProductTrackingInstance();
                var sourceShelfContentTrackingInstance      = new ORM_LOG_ProductTrackingInstance();

                if (adjustment.TrackingInstanceID != null && adjustment.TrackingInstanceID != Guid.Empty)
                {
                    sourceShelfContentTrackingInstance.Load(Connection, Transaction, adjustment.TrackingInstanceID);

                    destinationShelfContentTrackingInstance.ExpirationDate                = sourceShelfContentTrackingInstance.ExpirationDate;
                    destinationShelfContentTrackingInstance.BatchNumber                   = sourceShelfContentTrackingInstance.BatchNumber;
                    destinationShelfContentTrackingInstance.Tenant_RefID                  = securityTicket.TenantID;
                    destinationShelfContentTrackingInstance.TrackingCode                  = String.Empty;
                    destinationShelfContentTrackingInstance.CMN_PRO_Product_RefID         = adjustment.ProductID;
                    destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID = Guid.NewGuid();
                    var destinationShelfContentTrackingInstanceID = new FR_Guid(destinationShelfContentTrackingInstance.Save(Connection, Transaction),
                                                                                destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID).Result;

                    var historyEntry = new ORM_LOG_ProductTrackingInstance_HistoryEntry();
                    historyEntry.LOG_ProductTrackingInstance_HistoryEntryID = Guid.NewGuid();
                    historyEntry.ProductTrackingInstance_RefID = destinationShelfContentTrackingInstanceID;
                    historyEntry.Tenant_RefID      = securityTicket.TenantID;
                    historyEntry.HistoryEntry_Text = "Transfered from other shelf content.";
                    historyEntry.Save(Connection, Transaction);

                    var assignment = new ORM_LOG_WRH_ShelfContent_2_TrackingInstance();
                    assignment.LOG_ProductTrackingInstance_RefID = destinationShelfContentTrackingInstanceID;
                    assignment.LOG_WRH_Shelf_Content_RefID       = destinationShelfContentID;
                    assignment.Tenant_RefID = securityTicket.TenantID;
                    assignment.AssignmentID = Guid.NewGuid();
                    var savedAssignment = new FR_Guid(assignment.Save(Connection, Transaction), assignment.AssignmentID);
                }
                else
                {
                    destinationShelfContentTrackingInstance.Tenant_RefID                  = securityTicket.TenantID;
                    destinationShelfContentTrackingInstance.CMN_PRO_Product_RefID         = adjustment.ProductID;
                    destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID = Guid.NewGuid();
                    var destinationShelfContentTrackingInstanceID = new FR_Guid(destinationShelfContentTrackingInstance.Save(Connection, Transaction),
                                                                                destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID).Result;

                    var historyEntry = new ORM_LOG_ProductTrackingInstance_HistoryEntry();
                    historyEntry.LOG_ProductTrackingInstance_HistoryEntryID = Guid.NewGuid();
                    historyEntry.ProductTrackingInstance_RefID = destinationShelfContentTrackingInstanceID;
                    historyEntry.Tenant_RefID      = securityTicket.TenantID;
                    historyEntry.HistoryEntry_Text = "Transfered from other shelf content.";
                    historyEntry.Save(Connection, Transaction);
                }

                var sourceAdjustmentSaveParameter = new P_L3WH_SSCA_1732();

                var adjustmentsList = new List <P_L3WH_SSCA_1732a>();

                var sourceAdjustment = new P_L3WH_SSCA_1732a();
                sourceAdjustment.AdjustedQuantity   = currentshelfContent.Quantity_Current - adjustment.AdjustedQuantity;
                sourceAdjustment.ProductID          = adjustment.ProductID;
                sourceAdjustment.ShelfContentID     = adjustment.ShelfContentID;
                sourceAdjustment.TrackingInstanceID = sourceShelfContentTrackingInstance.LOG_ProductTrackingInstanceID;
                sourceAdjustment.IsManualCorrection = true;
                sourceAdjustment.IfManualCorrection_InventoryChangeReason_RefID = Guid.Empty;
                sourceAdjustment.IsRelocation           = true;
                sourceAdjustment.RelocationAdjustmentID = Guid.NewGuid();

                var destinationAdjustment = new P_L3WH_SSCA_1732a();
                destinationAdjustment.AdjustedQuantity   = destinationShelfContent.Quantity_Current + adjustment.AdjustedQuantity;
                destinationAdjustment.IsManualCorrection = true;
                destinationAdjustment.ProductID          = adjustment.ProductID;
                destinationAdjustment.ShelfContentID     = destinationShelfContent.LOG_WRH_Shelf_ContentID;
                destinationAdjustment.TrackingInstanceID = destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID;
                destinationAdjustment.IfManualCorrection_InventoryChangeReason_RefID = Guid.Empty;
                destinationAdjustment.IsRelocation           = true;
                destinationAdjustment.RelocationAdjustmentID = Guid.NewGuid();

                sourceAdjustment.IfRelocation_CorrespondingAdjustment_RefID      = destinationAdjustment.RelocationAdjustmentID;
                destinationAdjustment.IfRelocation_CorrespondingAdjustment_RefID = sourceAdjustment.RelocationAdjustmentID;

                adjustmentsList.Add(sourceAdjustment);
                adjustmentsList.Add(destinationAdjustment);

                sourceAdjustmentSaveParameter.Adjustments = adjustmentsList.ToArray();

                var IsAdjustmentSaved = cls_Save_Shelf_ContentAdjustments.Invoke(Connection, Transaction, sourceAdjustmentSaveParameter, securityTicket).Result;
            }

            return(returnValue);

            #endregion UserCode
        }
Exemplo n.º 2
0
 ///<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_L5SG_SSCR_1048 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Exemplo n.º 3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Bool Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5SG_SSCR_1048 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_Shelf_ContentRelocation", ex);
            }
            return(functionReturn);
        }
Exemplo n.º 4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Bool Invoke(string ConnectionString, P_L5SG_SSCR_1048 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }