Beispiel #1
0
        /// <summary>
        /// Fill method for populating an entire collection of DataInformationCollection
        /// </summary>
        public virtual void Fill(DataInformationCollection dataInformationCollection)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(DataInformation.GetConnectionString());


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


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


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


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


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


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


                // 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_DeleteDataInformation", sqlparams);


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


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


            // nullify the reference
            deleteObject = null;
        }
Beispiel #3
0
        /// <summary>
        /// Fill method for populating a collection by LOAN_APPLICATION
        /// </summary>
        public void FillByLoanApplication(DataInformationCollection dataInformationCollection, System.Int64 id)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(DataInformation.GetConnectionString());


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


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


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


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


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


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


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

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


                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_SelectDataInformation", sqlparams);


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


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


                // nullify the connection var
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Persists the object.
        /// </summary>
        public virtual void Persist(DataInformation 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(DataInformation.GetConnectionString());
            }


            try
            {
                // discover the parameters
                if (persistObject.Persisted)
                {
                    sqlparams = SqlHelperParameterCache.GetSpParameterSet(DataInformation.GetConnectionString(), "gsp_UpdateDataInformation");
                }
                else
                {
                    sqlparams = SqlHelperParameterCache.GetSpParameterSet(DataInformation.GetConnectionString(), "gsp_CreateDataInformation");
                }


                // 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_CreateDataInformation", sqlparams);
                        }
                        else
                        {
                            SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdateDataInformation", 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_CreateDataInformation", sqlparams);
                    }
                    else
                    {
                        SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdateDataInformation", sqlparams);
                    }
                }
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }