Beispiel #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
            {
                OptionItemDAO OptionItemDAO = new OptionItemDAO();
                if (this.OptionItemId.HasValue)
                {
                    result = OptionItemDAO.Update(this, db, transaction);
                }
                else
                {
                    result = OptionItemDAO.Insert(this, db, transaction);
                }

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

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

            try
            {
                OptionItemDAO OptionItemDAO = new OptionItemDAO();
                if (this.OptionItemId.HasValue)
                {
                    result = OptionItemDAO.Update(this, db, transaction);
                }
                else
                {
                    result = OptionItemDAO.Insert(this, db, transaction);
                }

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