예제 #1
0
        /// <summary>
        /// Performs one "insert into" database command in a transactional context.
        /// * The method uses a transaction object already created and does not close the connection.
        /// * Must have "MultipleActiveResultSets=True" on connection string.
        /// </summary>
        /// <param name="EmployeesInfo">Object to insert.</param>
        /// <param name="transaction">Inform "DBTransaction".</param>
        /// <param name="errorMessage">Error message if exception is throwed.</param>
        public virtual void InsertOne(EmployeesInfo parEmployeesInfo, DbTransaction transaction, out string errorMessage)
        {
            errorMessage = string.Empty;

//If is trying to insert FKValue without the ID but has the unique description,
//the system will try to get the class with the ID and populate it.
            if ((parEmployeesInfo.ReportsTo == null) && (parEmployeesInfo.FK0_FirstName != null))
            {
                EmployeesInfo fkClass = Get_ReportsToID_FKEmployees(parEmployeesInfo, transaction);
                parEmployeesInfo.ReportsTo = fkClass.EmployeeID;
            }

            EmployeesDAO.InsertOne(parEmployeesInfo, transaction, out errorMessage);
            //By default, the caller of this method will do the commit.
            //motor.Commit();
            //motor.CloseConnection();
        }