/// <summary> /// Inserts a LibraryManagement.Domain.KitInfo object into the datasource using a transaction. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="entity">LibraryManagement.Domain.KitInfo object to insert.</param> /// <remarks> /// After inserting into the datasource, the LibraryManagement.Domain.KitInfo 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.KitInfo entity) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblKit_info_Insert", _useStoredProcedure); database.AddInParameter(commandWrapper, "@KitId", DbType.StringFixedLength, entity.KitId); database.AddInParameter(commandWrapper, "@GoodsId", DbType.StringFixedLength, entity.GoodsId); database.AddInParameter(commandWrapper, "@Qty", DbType.Decimal, (entity.Qty.HasValue ? (object)entity.Qty : System.DBNull.Value)); 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.OriginalKitId = entity.KitId; entity.OriginalGoodsId = entity.GoodsId; 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="KitInfo"/> instance. ///</summary> ///<param name="_kitId"></param> ///<param name="_goodsId"></param> ///<param name="_qty"></param> public static KitInfo CreateKitInfo(System.String _kitId, System.String _goodsId, System.Decimal?_qty) { KitInfo newKitInfo = new KitInfo(); newKitInfo.KitId = _kitId; newKitInfo.GoodsId = _goodsId; newKitInfo.Qty = _qty; return(newKitInfo); }
///<summary> /// Returns a Typed KitInfo Entity ///</summary> protected virtual KitInfo Copy(IDictionary existingCopies) { if (existingCopies == null) { // This is the root of the tree to be copied! existingCopies = new Hashtable(); } //shallow copy entity KitInfo copy = new KitInfo(); existingCopies.Add(this, copy); copy.SuppressEntityEvents = true; copy.KitId = this.KitId; copy.OriginalKitId = this.OriginalKitId; copy.GoodsId = this.GoodsId; copy.OriginalGoodsId = this.OriginalGoodsId; copy.Qty = this.Qty; copy.EntityState = this.EntityState; copy.SuppressEntityEvents = false; return(copy); }