Esempio 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
            {
                OptionDAO OptionDAO = new OptionDAO();
                if (this.OptionId.HasValue)
                {
                    result = OptionDAO.Update(this, db, transaction);
                }
                else
                {
                    result = OptionDAO.Insert(this, db, transaction);
                }

                transaction.Commit();
            }
            catch (System.Exception ex)
            {
                transaction.Rollback();
                result = false;
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
 private void LoadGrid()
 {
     DataSet ds;
     ds = new OptionDAO().SelectAllDataset();
     ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["OptionId"] };
     gvFeatureList.SettingsText.ConfirmDelete = Messages.Delete_Confirm;
     gvFeatureList.DataSource = ds.Tables[0];
     gvFeatureList.DataBind();
 }
Esempio n. 3
0
        public bool Save()
        {
            bool result = false;

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

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

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