示例#1
0
        /// <summary>
        /// Fill method for populating an entire collection of ARMCollection
        /// </summary>
        public virtual void Fill(ARMCollection aRMCollection)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(ARM.GetConnectionString());


            try
            {
                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectARMCollection");


                    // Send the collection and data to the object factory
                    CreateObjectsFromData(aRMCollection, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
示例#2
0
        /// <summary>
        /// Deletes the object.
        /// </summary>
        public virtual void Delete(ARM deleteObject)
        {
            // create a new instance of the connection
            SqlConnection cnn = new SqlConnection(ARM.GetConnectionString());
            // create local variable array for the sql parameters
            SqlParameterHash sqlparams = null;


            try
            {
                // discover the parameters
                sqlparams = SqlHelperParameterCache.GetSpParameterSet(ARM.GetConnectionString(), "gsp_DeleteARM");


                // Store the parameter for the LoanApplicationId attribute.
                sqlparams["@loanApplicationId"].Value = deleteObject.LoanApplicationId;


                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // Execute the stored proc to perform the delete on the instance.
                    SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_DeleteARM", sqlparams);


                    // close the connection after usage
                    cnn.Close();
                }


                // nullify the connection var
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }


            // nullify the reference
            deleteObject = null;
        }
示例#3
0
        /// <summary>
        /// Fill method for populating a collection by LOAN_PRODUCT_DATA
        /// </summary>
        public void FillByLoanProductData(ARMCollection aRMCollection, System.Int64 loanApplicationId)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(ARM.GetConnectionString());


            try
            {
                // discover the sql parameters
                SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(ARM.GetConnectionString(), "gsp_SelectARMCollectionByLoanProductData");


                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // set the parameters
                    sqlparams["@loanApplicationId"].Value = loanApplicationId;


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectARMCollectionByLoanProductData", sqlparams);


                    // Send the collection and data to the object factory.
                    CreateObjectsFromData(aRMCollection, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
示例#4
0
        /// <summary>
        /// Fills a single instance with data based on its primary key values.
        /// </summary>
        public virtual void Fill(ARM arm, System.Int64 loanApplicationId)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(ARM.GetConnectionString());

            try
            {
                // discover the sql parameters
                SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(ARM.GetConnectionString(), "gsp_SelectARM");


                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // set the parameters
                    sqlparams["@loanApplicationId"].Value = loanApplicationId;


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectARM", sqlparams);


                    if (datareader.Read())
                    {
                        arm.SetMembers(ref datareader);
                    }


                    cnn.Close();                     // close the connection
                }


                // nullify the connection var
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
示例#5
0
        /// <summary>
        /// Persists the object.
        /// </summary>
        public virtual void Persist(ARM persistObject, SqlTransaction sqlTrans)
        {
            // create local variable array for the sql parameters
            SqlParameterHash sqlparams = null;
            // Create a local variable for the connection
            SqlConnection cnn = null;


            // Use the parameter overload or create a new instance
            if (sqlTrans == null)
            {
                cnn = new SqlConnection(ARM.GetConnectionString());
            }


            try
            {
                // discover the parameters
                if (persistObject.Persisted)
                {
                    sqlparams = SqlHelperParameterCache.GetSpParameterSet(ARM.GetConnectionString(), "gsp_UpdateARM");
                }
                else
                {
                    sqlparams = SqlHelperParameterCache.GetSpParameterSet(ARM.GetConnectionString(), "gsp_CreateARM");
                }


                // Store the parameter for the IndexCurrentValuePercent attribute.
                if (!persistObject.IndexCurrentValuePercentIsNull)
                {
                    sqlparams["@indexCurrentValuePercent"].Value = persistObject.IndexCurrentValuePercent;
                }
                // Store the parameter for the IndexMarginPercent attribute.
                if (!persistObject.IndexMarginPercentIsNull)
                {
                    sqlparams["@indexMarginPercent"].Value = persistObject.IndexMarginPercent;
                }
                // Store the parameter for the IndexType attribute.
                if (!persistObject.IndexTypeIsNull)
                {
                    sqlparams["@indexType"].Value = persistObject.IndexType;
                }
                // Store the parameter for the QualifyingRatePercent attribute.
                if (!persistObject.QualifyingRatePercentIsNull)
                {
                    sqlparams["@qualifyingRatePercent"].Value = persistObject.QualifyingRatePercent;
                }
                // Store the parameter for the ConversionOptionIndicator attribute.
                sqlparams["@conversionOptionIndicator"].Value = persistObject.ConversionOptionIndicator;
                // Store the parameter for the PaymentAdjustmentLifetimeCapAmount attribute.
                if (!persistObject.PaymentAdjustmentLifetimeCapAmountIsNull)
                {
                    sqlparams["@paymentAdjustmentLifetimeCapAmount"].Value = persistObject.PaymentAdjustmentLifetimeCapAmount;
                }
                // Store the parameter for the PaymentAdjustmentLifetimeCapPercent attribute.
                if (!persistObject.PaymentAdjustmentLifetimeCapPercentIsNull)
                {
                    sqlparams["@paymentAdjustmentLifetimeCapPercent"].Value = persistObject.PaymentAdjustmentLifetimeCapPercent;
                }
                // Store the parameter for the RateAdjustmentLifetimeCapPercent attribute.
                if (!persistObject.RateAdjustmentLifetimeCapPercentIsNull)
                {
                    sqlparams["@rateAdjustmentLifetimeCapPercent"].Value = persistObject.RateAdjustmentLifetimeCapPercent;
                }
                // Store the parameter for the LoanApplicationId attribute.
                sqlparams["@loanApplicationId"].Value = persistObject.LoanApplicationId;
                if (!persistObject.Persisted)
                {
                    // store the create only (historical fixed) values
                }
                else
                {
                    // store the update only (historical changeable) values
                }


                if (sqlTrans == null)
                {
                    // Process using the isolated connection
                    using (cnn)
                    {
                        // open the connection
                        cnn.Open();


                        if (!persistObject.Persisted)
                        {
                            SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_CreateARM", sqlparams);
                        }
                        else
                        {
                            SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdateARM", sqlparams);
                        }


                        // close the connection after usage
                        cnn.Close();
                    }


                    // nullify the connection var
                    cnn = null;
                }
                else
                {
                    // Process using the shared transaction
                    if (!persistObject.Persisted)
                    {
                        SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_CreateARM", sqlparams);
                    }
                    else
                    {
                        SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdateARM", sqlparams);
                    }
                }
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }