/// <summary> /// Inserts a LibraryManagement.Domain.Transnum object into the datasource using a transaction. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="entity">LibraryManagement.Domain.Transnum object to insert.</param> /// <remarks> /// After inserting into the datasource, the LibraryManagement.Domain.Transnum object will be updated /// to refelect any changes made by the datasource. (ie: identity or computed columns) /// </remarks> /// <returns>Returns true if operation is successful.</returns> /// <exception cref="System.Exception">The command could not be executed.</exception> /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception> /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception> public override bool Insert(TransactionManager transactionManager, LibraryManagement.Domain.Transnum entity) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblTransnum_Insert", _useStoredProcedure); database.AddInParameter(commandWrapper, "@TransType", DbType.AnsiStringFixedLength, entity.TransType); database.AddInParameter(commandWrapper, "@LastNum", DbType.Decimal, entity.LastNum); database.AddInParameter(commandWrapper, "@LastDate", DbType.DateTime, entity.LastDate); int results = 0; //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity)); if (transactionManager != null) { results = Utility.ExecuteNonQuery(transactionManager, commandWrapper); } else { results = Utility.ExecuteNonQuery(database, commandWrapper); } entity.OriginalTransType = entity.TransType; entity.AcceptChanges(); //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity)); return(Convert.ToBoolean(results)); }
///<summary> /// A simple factory method to create a new <see cref="Transnum"/> instance. ///</summary> ///<param name="_transType"></param> ///<param name="_lastNum"></param> ///<param name="_lastDate"></param> public static Transnum CreateTransnum(System.String _transType, System.Decimal _lastNum, System.DateTime _lastDate) { Transnum newTransnum = new Transnum(); newTransnum.TransType = _transType; newTransnum.LastNum = _lastNum; newTransnum.LastDate = _lastDate; return(newTransnum); }
///<summary> /// Returns a Typed Transnum Entity ///</summary> protected virtual Transnum Copy(IDictionary existingCopies) { if (existingCopies == null) { // This is the root of the tree to be copied! existingCopies = new Hashtable(); } //shallow copy entity Transnum copy = new Transnum(); existingCopies.Add(this, copy); copy.SuppressEntityEvents = true; copy.TransType = this.TransType; copy.OriginalTransType = this.OriginalTransType; copy.LastNum = this.LastNum; copy.LastDate = this.LastDate; copy.EntityState = this.EntityState; copy.SuppressEntityEvents = false; return(copy); }