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

            FR_CAS_GADfPID_1620_Array functionReturn = new FR_CAS_GADfPID_1620_Array();

            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_All_Drugs_for_PracticeID", ex);
            }
            return(functionReturn);
        }
Example #2
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_CAS_GADfPID_1620_Array Invoke(string ConnectionString, P_CAS_GADfPID_1620 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }
Example #3
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_CAS_GADfPID_1620_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_CAS_GADfPID_1620 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Example #4
0
        protected static FR_CAS_GADfPID_1620_Array Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_GADfPID_1620 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue  = new FR_CAS_GADfPID_1620_Array();
            var drugs_result = new List <CAS_GADfPID_1620>();

            var distinct_contracts = cls_Get_Assigned_ContractIDs_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GACIDsfPID_2057()
            {
                PracticeID = Parameter.PracticeID
            }, securityTicket).Result;

            var drugs = cls_Get_All_Drugs_for_ContractIDs.Invoke(Connection, Transaction, new P_CAS_GADfCIDs_2046()
            {
                ContractIDs = distinct_contracts.Select(t => t.ContractID).ToArray()
            }, securityTicket).Result;

            foreach (var drug in drugs)
            {
                if (!drugs_result.Any(drug_from_db => drug_from_db.drug_id == drug.drug_id))
                {
                    drugs_result.Add(new CAS_GADfPID_1620()
                    {
                        drug_id = drug.drug_id, drug_name = drug.drug_name
                    });
                }
            }


            returnValue.Result = drugs_result.OrderBy(drug => drug.drug_name).ToArray();
            return(returnValue);

            #endregion UserCode
        }