예제 #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
            {
                PartialHouseDAO PartialHouseDAO = new PartialHouseDAO();
                if (PartialHouseDAO.IsHouseExist(this))
                {
                    result = PartialHouseDAO.Update(this, db, transaction);
                }
                else
                {
                    result = PartialHouseDAO.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);
        }
예제 #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
             {
                 PartialHouseDAO PartialHouseDAO = new PartialHouseDAO();
                 if (PartialHouseDAO.IsHouseExist(this))
                 {
                     result = PartialHouseDAO.Update(this, db, transaction);
                 }
                 else
                 {
                     result = PartialHouseDAO.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;
        }