예제 #1
0
        public override void Insert(DatabaseHelper dbHelper)
        {
            try {
                OracleDecimal output;
                OracleCommand command = dbHelper.Connection.CreateCommand();
                command.CommandText = QRY_LOCK;
                command.ExecuteNonQuery();

                command.CommandText = String.Format(QRY_INSERT, Name, Description, Datestart.ToString("yy-MM-dd"));
                command.Parameters.Add("output", OracleDbType.Decimal, ParameterDirection.ReturnValue);
                command.ExecuteNonQuery();

                output  = (OracleDecimal)command.Parameters["output"].Value;
                this.Id = output.ToInt32();

                dbHelper.LogTransaction(LogActions.Undo, String.Format(QRY_DELETE, output.ToInt32()));
                dbHelper.LogTransaction(LogActions.Redo, String.Format(QRY_INSERT, Name, Description, Datestart));

                dbHelper.Transaction.Commit();

                BoardGameEventCollection.Instance().BoardgameEvents.Add(this);
            }
            catch (OracleException e) {
                throw e;
            }
        }
예제 #2
0
        public override void Update(DatabaseHelper dbHelper)
        {
            try {
                OracleCommand command = dbHelper.Connection.CreateCommand();
                command.CommandText = String.Format(QRY_UPDATE, Name, Description, Datestart.ToString("yy-MM-dd"), Id);
                command.ExecuteNonQuery();

                dbHelper.LogTransaction(LogActions.Undo, String.Format(QRY_UPDATE, Memento.Name, Memento.Description, Memento.Datestart, Memento.Id));
                dbHelper.LogTransaction(LogActions.Redo, command.CommandText);

                dbHelper.Transaction.Commit();
            }
            catch (OracleException e) {
                Name        = Memento.Name;
                Description = Memento.Description;
                Datestart   = Memento.Datestart;
                throw e;
            }
        }