示例#1
0
        protected static FR_Guids Execute(DbConnection Connection, DbTransaction Transaction, P_L5ME_SRS_1512 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guids();
            //Put your code here
            List <Guid> resultID = new List <Guid>();
            foreach (var substanceParam in Parameter.RecommendedSubstance)
            {
                ORM_HEC_DIA_RecommendedSubstance existintSubstance = ORM_HEC_DIA_RecommendedSubstance.Query.Search(Connection, Transaction, new ORM_HEC_DIA_RecommendedSubstance.Query
                {
                    HEC_DIA_RecommendedSubstanceID = substanceParam.HEC_DIA_RecommendedSubstanceID,
                    IsDeleted    = false,
                    Tenant_RefID = securityTicket.TenantID
                }).SingleOrDefault();

                if (!substanceParam.IsDeleted)
                {
                    Guid SubstanceID = substanceParam.SubstanceID;
                    Guid DiagnosisID = substanceParam.DiagnoseID;

                    if (existintSubstance == null)
                    {
                        existintSubstance = new ORM_HEC_DIA_RecommendedSubstance();
                        existintSubstance.HEC_DIA_RecommendedSubstanceID = substanceParam.HEC_DIA_RecommendedSubstanceID;
                        existintSubstance.PotentialDiagnosis_RefID       = DiagnosisID;
                        existintSubstance.Substance_RefID = SubstanceID;
                        existintSubstance.IsDeleted       = false;
                    }
                    existintSubstance.Substance_Unit_RefID = substanceParam.Substance_Unit_RefID;
                    existintSubstance.SubstanceStrength    = substanceParam.SubstanceStrength;
                    existintSubstance.Tenant_RefID         = securityTicket.TenantID;
                    existintSubstance.Save(Connection, Transaction);
                    resultID.Add(existintSubstance.HEC_DIA_RecommendedSubstanceID);

                    foreach (var dosageParam in substanceParam.DosageList)
                    {
                        ORM_HEC_DIA_RecommendedSubstance_Dosage existingDosage = ORM_HEC_DIA_RecommendedSubstance_Dosage.Query.Search(Connection, Transaction, new ORM_HEC_DIA_RecommendedSubstance_Dosage.Query
                        {
                            HEC_DIA_RecommendedSubstance_DosageID = dosageParam.HEC_DIA_RecommendedSubstance_DosageID,
                            IsDeleted    = false,
                            Tenant_RefID = securityTicket.TenantID
                        }).SingleOrDefault();

                        if (!dosageParam.IsDeleted)
                        {
                            if (existingDosage == null)
                            {
                                existingDosage = new ORM_HEC_DIA_RecommendedSubstance_Dosage();
                                existingDosage.HEC_DIA_RecommendedSubstance_DosageID = dosageParam.HEC_DIA_RecommendedSubstance_DosageID;
                            }

                            existingDosage.RecommendedSubstance_RefID = existintSubstance.HEC_DIA_RecommendedSubstanceID;
                            existingDosage.Dosage_RefID = dosageParam.Dosage_RefID;
                            existingDosage.IsDefault    = dosageParam.IsDefault;
                            existingDosage.IsDeleted    = false;
                            existingDosage.Tenant_RefID = securityTicket.TenantID;
                            existingDosage.Save(Connection, Transaction);
                        }
                        else if (existingDosage != null && dosageParam.IsDeleted)
                        {
                            existingDosage.IsDeleted = true;
                            existingDosage.Save(Connection, Transaction);
                        }
                    }
                }
                else
                {
                    ORM_HEC_DIA_RecommendedSubstance_Dosage.Query.SoftDelete(Connection, Transaction, new ORM_HEC_DIA_RecommendedSubstance_Dosage.Query
                    {
                        RecommendedSubstance_RefID = existintSubstance.HEC_DIA_RecommendedSubstanceID,
                        IsDeleted    = false,
                        Tenant_RefID = securityTicket.TenantID
                    });
                    existintSubstance.IsDeleted = true;
                    existintSubstance.Save(Connection, Transaction);
                }
            }
            returnValue.Result = resultID.ToArray();
            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_Guids Invoke(DbConnection Connection, DbTransaction Transaction, P_L5ME_SRS_1512 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_Guids Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5ME_SRS_1512 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Guids functionReturn = new FR_Guids();

            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_RecommendedSubstance", ex);
            }
            return(functionReturn);
        }
示例#4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Guids Invoke(string ConnectionString, P_L5ME_SRS_1512 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }