コード例 #1
0
        protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5BL_CBH_1330 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Bool();

            foreach (var BillHeaderID in Parameter.BillHeaderIDs)
            {
                // Retrieve bill header
                var billHeader = new CL1_BIL.ORM_BIL_BillHeader();
                billHeader.Load(Connection, Transaction, BillHeaderID);

                // Find current status for bill header
                var billHeaderStatus = CL1_BIL.ORM_BIL_BillHeader_2_BillStatus.Query.Search(Connection, Transaction,
                                                                                            new CL1_BIL.ORM_BIL_BillHeader_2_BillStatus.Query
                {
                    BIL_BillHeader_RefID = BillHeaderID,
                    IsCurrentStatus      = true,
                    Tenant_RefID         = securityTicket.TenantID,
                    IsDeleted            = false
                }).Single();

                var status = CL1_BIL.ORM_BIL_BillStatus.Query.Search(Connection, Transaction,
                                                                     new CL1_BIL.ORM_BIL_BillStatus.Query
                {
                    BIL_BillStatusID = billHeaderStatus.BIL_BillStatus_RefID,
                    Tenant_RefID     = securityTicket.TenantID,
                    IsDeleted        = false
                }).Single();

                bool result = status.GlobalPropertyMatchingID ==
                              DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EBillStatus.Closed);

                if (result == false)
                {
                    throw new Exception("Bill header status is not expected. It cannot be canceled!");
                }

                #region Cancel customerOrderReturnPosition



                #endregion

                #region Cancel bill positions

                // Retrieve bill positions for bill header.
                var billPositions = CL1_BIL.ORM_BIL_BillPosition.Query.Search(Connection, Transaction,
                                                                              new CL1_BIL.ORM_BIL_BillPosition.Query
                {
                    BIL_BilHeader_RefID = BillHeaderID,
                    Tenant_RefID        = securityTicket.TenantID,
                    IsDeleted           = false
                });

                // Cancel all bill positions
                foreach (var billPosition in billPositions)
                {
                    // Delete relationship between BillPositions and ShipmentPosition in Assignment table.
                    CL1_BIL.ORM_BIL_BillPosition_2_ShipmentPosition.Query.SoftDelete(Connection, Transaction,
                                                                                     new CL1_BIL.ORM_BIL_BillPosition_2_ShipmentPosition.Query
                    {
                        BIL_BillPosition_RefID = billPosition.BIL_BillPositionID,
                        Tenant_RefID           = securityTicket.TenantID,
                        IsDeleted = false
                    });


                    CL1_BIL.ORM_BIL_BillPosition_2_CustomerOrderReturnPosition.Query.SoftDelete(Connection, Transaction,
                                                                                                new CL1_BIL.ORM_BIL_BillPosition_2_CustomerOrderReturnPosition.Query
                    {
                        BIL_BillPosition_RefID = billPosition.BIL_BillPositionID,
                        Tenant_RefID           = securityTicket.TenantID,
                        IsDeleted = false
                    });
                }

                #endregion

                #region Deactivate current bill statuses

                billHeaderStatus.IsCurrentStatus = false;
                billHeaderStatus.Save(Connection, Transaction);

                #endregion

                #region Add status "Canceled" for Bill Header

                var statusCanceled = CL1_BIL.ORM_BIL_BillStatus.Query.Search(Connection, Transaction,
                                                                             new CL1_BIL.ORM_BIL_BillStatus.Query
                {
                    GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EBillStatus.Canceled),
                    Tenant_RefID             = securityTicket.TenantID,
                    IsDeleted = false
                }).Single();

                var billHeader2BillStatusCanceled = new CL1_BIL.ORM_BIL_BillHeader_2_BillStatus()
                {
                    BIL_BillHeader_RefID = BillHeaderID,
                    BIL_BillStatus_RefID = statusCanceled.BIL_BillStatusID,
                    IsCurrentStatus      = true,
                    Tenant_RefID         = securityTicket.TenantID,
                    Creation_Timestamp   = DateTime.Now
                };
                billHeader2BillStatusCanceled.Save(Connection, Transaction);

                #endregion
            }

            // Return success
            returnValue.Status = FR_Status.Success;
            returnValue.Result = true;
            return(returnValue);

            #endregion UserCode
        }
コード例 #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_L5BL_CBH_1330 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
コード例 #3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Bool Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5BL_CBH_1330 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_Cancel_BillHeaders", ex);
            }
            return(functionReturn);
        }
コード例 #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_L5BL_CBH_1330 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }