Ejemplo n.º 1
0
        public bool Save()
        {
            bool result = false;

            Database     db         = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbConnection connection = db.CreateConnection();

            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                StudentHouseDAO studentHouseDAO = new StudentHouseDAO();
                if (studentHouseDAO != null)
                {
                    result = studentHouseDAO.Insert(this, db, transaction);
                }

                if (result)
                {
                    transaction.Commit();
                }
                else
                {
                    transaction.Rollback();
                }
            }
            catch (System.Exception ex)
            {
                transaction.Rollback();
                result = false;
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
Ejemplo n.º 2
0
        public bool Save()
        {
            bool result = false;

               Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
               DbConnection connection = db.CreateConnection();
               connection.Open();
               DbTransaction transaction = connection.BeginTransaction();

               try
               {
               StudentHouseDAO studentHouseDAO = new StudentHouseDAO();
               if (studentHouseDAO != null)
               {
                   result = studentHouseDAO.Insert(this, db, transaction);
               }

               if (result)
               {
                   transaction.Commit();
               }
               else
               {
                   transaction.Rollback();
               }

               }
               catch (System.Exception ex)
               {
               transaction.Rollback();
               result = false;
               throw ex;
               }
               finally
               {
               connection.Close();
               }
               return result;
        }