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

            ORM_HEC_MedicalPractis practices;
            if (Parameter.HEC_MedicalPractiseID != Guid.Empty)
            {
                var practicesQuery = new ORM_HEC_MedicalPractis.Query();
                practicesQuery.HEC_MedicalPractiseID = Parameter.HEC_MedicalPractiseID;
                practices = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, practicesQuery).First();
            }
            else
            {
                practices = new ORM_HEC_MedicalPractis();
                practices.HEC_MedicalPractiseID = Guid.NewGuid();
            }
            practices.Tenant_RefID = securityTicket.TenantID;
            if (Parameter.isLucentis == false)
            {
                practices.Contact_EmergencyPhoneNumber = Parameter.Contact_EmergencyPhoneNumber;
            }

            ORM_CMN_COM_CompanyInfo companyInfo;
            if (practices.Ext_CompanyInfo_RefID != Guid.Empty)
            {
                var companyInfoQuery = new ORM_CMN_COM_CompanyInfo.Query();
                companyInfoQuery.CMN_COM_CompanyInfoID = practices.Ext_CompanyInfo_RefID;
                companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfoQuery).First();
            }
            else
            {
                companyInfo = new ORM_CMN_COM_CompanyInfo();
                companyInfo.CMN_COM_CompanyInfoID = Guid.NewGuid();
                practices.Ext_CompanyInfo_RefID   = companyInfo.CMN_COM_CompanyInfoID;
            }
            companyInfo.Tenant_RefID = securityTicket.TenantID;
            if (Parameter.isLucentis)
            {
                companyInfo.CompanyInfo_EstablishmentNumber = Parameter.ifLucentis_BSNR;
            }

            ORM_CMN_BPT_BusinessParticipant bParticipant;
            var bParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query();
            bParticipantQuery.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID;
            var bpRes = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bParticipantQuery);
            if (bpRes.Count == 0)
            {
                bParticipant = new ORM_CMN_BPT_BusinessParticipant();
                bParticipant.CMN_BPT_BusinessParticipantID = Guid.NewGuid();
                bParticipant.IsCompany = true;
                bParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID;
            }
            else
            {
                bParticipant = bpRes.First();
            }
            bParticipant.DisplayName  = Parameter.PracticeName;
            bParticipant.Tenant_RefID = securityTicket.TenantID;


            ORM_CMN_UniversalContactDetail contactDetails;
            if (companyInfo.Contact_UCD_RefID != Guid.Empty)
            {
                var ucdQuery = new ORM_CMN_UniversalContactDetail.Query();
                ucdQuery.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID;
                contactDetails = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, ucdQuery).First();
            }
            else
            {
                contactDetails = new ORM_CMN_UniversalContactDetail();
                contactDetails.CMN_UniversalContactDetailID = Guid.NewGuid();
                companyInfo.Contact_UCD_RefID = contactDetails.CMN_UniversalContactDetailID;
                contactDetails.IsCompany      = true;
            }
            contactDetails.Tenant_RefID = securityTicket.TenantID;
            if (Parameter.isLucentis == false)
            {
                contactDetails.Contact_Website_URL = Parameter.Contact_Website_URL;
            }
            contactDetails.Contact_Email = Parameter.PracticeEmail;
            contactDetails.Town          = Parameter.Town;
            contactDetails.Street_Number = Parameter.Street_Number;
            contactDetails.Street_Name   = Parameter.Street_Name;
            contactDetails.ZIP           = Parameter.ZIP;
            if (Parameter.isLucentis == false)
            {
                contactDetails.Region_Name = Parameter.Region_Name;
            }
            if (Parameter.isLucentis)
            {
                contactDetails.Street_Name_Line2 = Parameter.Street_Name_Line2;
            }

            companyInfo.Save(Connection, Transaction);
            bParticipant.Save(Connection, Transaction);
            contactDetails.Save(Connection, Transaction);
            practices.Save(Connection, Transaction);

            returnValue.Result = practices.HEC_MedicalPractiseID;

            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_Guid Invoke(DbConnection Connection, DbTransaction Transaction, P_L3MP_SPBI_1602 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3MP_SPBI_1602 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_Save_Practice_BaseInfo", ex);
            }
            return(functionReturn);
        }
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Guid Invoke(string ConnectionString, P_L3MP_SPBI_1602 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }