// TODO: Implement changing journal record. public override void Flush() { Debug.Assert(Validate() == null, "Debug.Assert(Validate() == null)"); _isNew = _doc == null; if (!_isNew) { throw new InvalidOperationException("Cannot update DocSale - operation not allowed."); } // TODO: Parent doc should be created in transaction. _doc = Doc.CreateNew(Doc.DocType.Sale); _doc.Flush(); Id = _doc.Id; CustomSqlCommand sp = new AddObjectSql(); FillUpdateParams(sp); sp.Execute(); SetStorageConsistency(); _cache.Add(this); _isNew = false; }
public override void Flush() { if (_amount == 0 && _amountOld == 0) { return; } _modified = DateTime.Now; if (_amountOld == 0) { // insert: CustomSqlCommand sp = new AddObjectSql(); FillUpdateParams(sp); sp.Execute(); Id = ((AddObjectSql)sp).NewId; SetStorageConsistency(); _cache.Add(this); _isNew = false; _amountOld = _amount; } else if (_amount == 0) { // delete: CellInStock.Delete(this); Id = 0; _isNew = true; _amountOld = 0; } else { // update: CustomSqlCommand sp = new UpdateObjectSql(this); FillUpdateParams(sp); sp.Execute(); SetStorageConsistency(); _amountOld = _amount; } }