Пример #1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5BL_SB_1645 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            #region Bill Header

            Guid BillHeaderID;

            if (Parameter.BillHeaderData.BIL_BillHeaderID == Guid.Empty)
            {
                // Create bill header data
                P_L5CO_CBH_1606 paramHeader = new P_L5CO_CBH_1606 {
                    Bill_Parameter = Parameter
                };
                BillHeaderID = cls_CreateBillHeader.Invoke(Connection, Transaction, paramHeader, securityTicket).Result;
            }
            else
            {
                //Edit bill header data
                P_L5CO_EBH_1108 paramHeader = new P_L5CO_EBH_1108 {
                    Bill_Parameter = Parameter
                };
                BillHeaderID = cls_Edit_BillHeader.Invoke(Connection, Transaction, paramHeader, securityTicket).Result;
            }

            if (Parameter.InstallmentPlan != null)
            {
                var installmentParameter = Parameter.InstallmentPlan;
                installmentParameter.BillHeaderID = BillHeaderID;
                cls_Save_InstallmentPlan_for_Bill.Invoke(Connection, Transaction, installmentParameter, securityTicket);
            }

            #endregion

            #region Bill Positions

            if (Parameter.BillHeaderData.ShipmentHeaderIDs != null && Parameter.BillHeaderData.ShipmentHeaderIDs.Count() != 0)
            {
                var paramPos = new P_L5BL_CBPfSH();
                paramPos.BillHeaderID      = BillHeaderID;
                paramPos.ShipmentHeaderIDs = Parameter.BillHeaderData.ShipmentHeaderIDs;
                cls_Create_BillPositions_for_ShipmentHeaders.Invoke(Connection, Transaction, paramPos, securityTicket);
            }

            #endregion

            returnValue.Result = BillHeaderID;
            return(returnValue);

            #endregion UserCode
        }
Пример #2
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5CO_EBH_1108 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            #region Preloading data

            var BillParam = Parameter.Bill_Parameter.BillHeaderData;

            var billHeader = CL1_BIL.ORM_BIL_BillHeader.Query.Search(Connection, Transaction,
                                                                     new CL1_BIL.ORM_BIL_BillHeader.Query()
            {
                BIL_BillHeaderID = BillParam.BIL_BillHeaderID
            }).SingleOrDefault();

            var ucd = CL1_CMN.ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction,
                                                                          new CL1_CMN.ORM_CMN_UniversalContactDetail.Query()
            {
                CMN_UniversalContactDetailID = BillParam.CMN_UniversalContactDetailID
            }).SingleOrDefault();

            var account = new CL1_USR.ORM_USR_Account();
            account.Load(Connection, Transaction, securityTicket.AccountID);
            var customer = CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction,
                                                                                 new CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_Customer.Query()
            {
                CMN_BPT_CTM_CustomerID = BillParam.BillingReceiverCustomer.CMN_BPT_CTM_CustomerID
            }).SingleOrDefault();

            #endregion

            if (BillParam.BillingAddressID != Guid.Empty)
            {
                List <L3ACAAD_GCAfT_1612> customerAddresses = cls_Get_CustomerAddresses_for_CustomerID.Invoke(Connection, Transaction, new P_L3ACAAD_GCAfCID_1612 {
                    CustomerID = BillParam.BillingReceiverCustomer.CMN_BPT_CTM_CustomerID
                }, securityTicket).Result.ToList();
                L3ACAAD_GCAfT_1612 customerAddress = customerAddresses.Where(x => x.AddressID == BillParam.BillingAddressID).SingleOrDefault();
                ucd.CMN_UniversalContactDetailID = BillParam.CMN_UniversalContactDetailID;
                ucd.Country_639_1_ISOCode        = customerAddress.Country_639_1_ISOCode;
                ucd.Country_Name      = customerAddress.Country_Name;
                ucd.Street_Name       = customerAddress.Street_Name;
                ucd.Street_Number     = customerAddress.Street_Number;
                ucd.Town              = customerAddress.Town;
                ucd.ZIP               = customerAddress.ZIP;
                ucd.Tenant_RefID      = account.Tenant_RefID;
                ucd.CompanyName_Line1 = BillParam.BillingReceiverCustomer.DisplayName;
                ucd.First_Name        = BillParam.BillingReceiverCustomer.FirstName;
                ucd.Last_Name         = BillParam.BillingReceiverCustomer.LastName;
                ucd.IsCompany         = BillParam.BillingReceiverCustomer.IsCompany;
                ucd.Save(Connection, Transaction);
            }
            billHeader.CreatedBy_BusinessParticipant_RefID     = account.BusinessParticipant_RefID;
            billHeader.BillRecipient_BuisnessParticipant_RefID = customer.Ext_BusinessParticipant_RefID;
            billHeader.Tenant_RefID             = account.Tenant_RefID;
            billHeader.BillingAddress_UCD_RefID = ucd.CMN_UniversalContactDetailID;
            billHeader.DateOnBill  = BillParam.BillingDate;
            billHeader.BillComment = BillParam.Comment;
            billHeader.BillHeader_PaymentCondition_RefID = Parameter.Bill_Parameter.BillHeaderData.PaymentTargetID;
            billHeader.Save(Connection, Transaction);

            #region Method of Payment

            var methodOfPayment = CL1_BIL.ORM_BIL_BillHeader_MethodOfPayment.Query.Search(Connection, Transaction,
                                                                                          new CL1_BIL.ORM_BIL_BillHeader_MethodOfPayment.Query
            {
                BIL_BillHeader_RefID = billHeader.BIL_BillHeaderID,
                IsDeleted            = false,
                Tenant_RefID         = securityTicket.TenantID
            }).SingleOrDefault();

            if (methodOfPayment == null)
            {
                methodOfPayment = new CL1_BIL.ORM_BIL_BillHeader_MethodOfPayment
                {
                    BIL_BillHeader_MethodOfPaymentID = Guid.NewGuid(),
                    ACC_PAY_Type_RefID         = Parameter.Bill_Parameter.BillHeaderData.PaymentTypeID,
                    BIL_BillHeader_RefID       = billHeader.BIL_BillHeaderID,
                    IsPreferredMethodOfPayment = true,
                    SequenceNumber             = 0,
                    Tenant_RefID = securityTicket.TenantID
                };
            }

            methodOfPayment.ACC_PAY_Type_RefID = Parameter.Bill_Parameter.BillHeaderData.PaymentTypeID;
            methodOfPayment.Save(Connection, Transaction);

            #endregion

            returnValue.Result = billHeader.BIL_BillHeaderID;

            return(returnValue);

            #endregion UserCode
        }
Пример #3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5CO_EBH_1108 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Guid functionReturn = new FR_Guid();

            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_Edit_BillHeader", ex);
            }
            return(functionReturn);
        }
Пример #4
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, P_L5CO_EBH_1108 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Пример #5
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Guid Invoke(string ConnectionString, P_L5CO_EBH_1108 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }