Click here to Skip to main content
15,896,118 members
Articles / Database Development / SQL Server

Business Objects for CodeSmith

Rate me:
Please Sign up or sign in to vote.
4.38/5 (17 votes)
23 Nov 2004Ms-PL6 min read 144.2K   719   105  
Save time when developing large applications, by using code generation for your business objects.
//---------------------------------------------------------------------------------------
// Copyright Notice
// This file contains proprietary information of The Austin Conner Group.
// Copying or reproduction without prior written approval is prohibited.
// Copyright (C) 2004 The Austin Conner Group. All rights reserved.
// 
// The above copyright notice and this permission notice shall be included in all 
// copies or substantial portions of the Software.
//
// Redistribution and use in source and binary forms, with or without modification, 
// are permitted provided that the following conditions are met: 
// 
// * Redistributions of source code must retain the above copyright notice, this list 
//   of conditions and the following disclaimer. 
//
// * Redistributions in binary form must reproduce the above copyright notice, this list 
//   of conditions and the following disclaimer in the documentation and/or other materials 
//   provided with the distribution. 
//
// * Neither the name of The Austin Conner Group nor the names of its contributors may be 
//   used to endorse or promote products derived from this software without specific prior 
//   written permission. 
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
// OR OTHER DEALINGS IN THE SOFTWARE.
//---------------------------------------------------------------------------------------
// History
//    11/18/2004  The Austin Conner Group - J.R. Hull  - Generated Version
//---------------------------------------------------------------------------------------
using System;
using Sample.Objects.DataAccess;

namespace Sample.Objects.BusinessLogic
{
	/// <summary>
	/// Represents a  Invoice Detail Object.
	/// </summary>
	/// <remarks>
	/// InvoiceDetail provides a base class for a  Invoice Detail object within the Sample.Objects namespace.
	/// </remarks>
	public class InvoiceDetail : BaseObjectClass
	{
		#region Private Properties

		private String invoiceId;
		private int lineItem;
		private String itemDescription;
		private decimal itemCostPerUnit;
		private int itemQuanity;
		private String itemUnit;

		#endregion
		
		#region Public Properties
		/// <summary>
		/// InvoiceId.
		/// </summary>		
		public String InvoiceId
		{

			get
			{
				return invoiceId;
			}
			set
			{
				invoiceId = value;
				
			}

		}
		
		/// <summary>
		/// LineItem.
		/// </summary>		
		public int LineItem
		{

			get
			{
				return lineItem;
			}
			set
			{
				lineItem = value;
				
			}

		}
		
		/// <summary>
		/// ItemDescription.
		/// </summary>		
		public String ItemDescription
		{

			get
			{
				return itemDescription;
			}
			set
			{
				itemDescription = value;
				
			}

		}
		
		/// <summary>
		/// ItemCostPerUnit.
		/// </summary>		
		public decimal ItemCostPerUnit
		{

			get
			{
				return itemCostPerUnit;
			}
			set
			{
				itemCostPerUnit = value;
				
			}

		}
		
		/// <summary>
		/// ItemQuanity.
		/// </summary>		
		public int ItemQuanity
		{

			get
			{
				return itemQuanity;
			}
			set
			{
				itemQuanity = value;
				
			}

		}
		
		/// <summary>
		/// ItemUnit.
		/// </summary>		
		public String ItemUnit
		{

			get
			{
				return itemUnit;
			}
			set
			{
				itemUnit = value;
				
			}

		}
		
		#endregion

		
		#region Constructor
		
		/// <summary>
		///  Default Constructor - InvoiceDetail
		/// </summary>
		public InvoiceDetail()
		{
		}
		
		/// <summary>
		///  Constructor - InvoiceDetail
		/// </summary>
		/// <param name="_id">String: Id value for InvoiceDetail</param>
		/// <param name="_invoiceId">String: Invoice Id value for InvoiceDetail</param>
		/// <param name="_lineItem">int: Line Item value for InvoiceDetail</param>
		/// <param name="_itemDescription">String: Item Description value for InvoiceDetail</param>
		/// <param name="_itemCostPerUnit">decimal: Item Cost Per Unit value for InvoiceDetail</param>
		/// <param name="_itemQuanity">int: Item Quanity value for InvoiceDetail</param>
		/// <param name="_itemUnit">String: Item Unit value for InvoiceDetail</param>
		public InvoiceDetail(String _id, String _invoiceId, int _lineItem, String _itemDescription, decimal _itemCostPerUnit, int _itemQuanity, String _itemUnit)
		{
			this.Name = "invoiceDetail";
				this.Id = _id;
				this.InvoiceId = _invoiceId;
				this.LineItem = _lineItem;
				this.ItemDescription = _itemDescription;
				this.ItemCostPerUnit = _itemCostPerUnit;
				this.ItemQuanity = _itemQuanity;
				this.ItemUnit = _itemUnit;
			 			
		} // InvoiceDetail

		#endregion

		#region Public Methods
		/// <summary>
		///  Copy
		/// </summary>
		/// <param name="obj">InvoiceDetail</param>		
		public void Copy(InvoiceDetail obj)
		{
			Id = obj.Id;
			InvoiceId = obj.InvoiceId;
			LineItem = obj.LineItem;
			ItemDescription = obj.ItemDescription;
			ItemCostPerUnit = obj.ItemCostPerUnit;
			ItemQuanity = obj.ItemQuanity;
			ItemUnit = obj.ItemUnit;
		} // Copy

		/// <summary>
		///  Delete a InvoiceDetail
		/// </summary>
		public bool Delete()
		{
			
			InvoiceDetailData dataLayer = new InvoiceDetailData();
			return dataLayer.DeleteInvoiceDetail(this.id);
		} // Delete

		/// <summary>
		///  Save a InvoiceDetail
		/// </summary>
		public int Save()
		{
			
			InvoiceDetailData dataLayer = new InvoiceDetailData();
			return dataLayer.CreateNewInvoiceDetail(this);

		} // Save

		/// <summary>
		///  Update a InvoiceDetail
		/// </summary>
		public int Update()
		{
			
			InvoiceDetailData dataLayer = new InvoiceDetailData();
			return dataLayer.UpdateInvoiceDetail(this);

		} // Save

		/// <summary>
		///  Fetch a InvoiceDetail
		/// </summary>
		public InvoiceDetail Fetch(string id)
		{
			
			InvoiceDetailData dataLayer = new InvoiceDetailData();
			return dataLayer.FetchInvoiceDetail(id);

		} // Fetch

		#endregion
		
		#region Static Methods

		/// <summary>
		///  Fetch a InvoiceDetail	By InvoiceId
		/// </summary>
		public static InvoiceDetailCollection FetchByInvoiceId(string id)
		{
			
			InvoiceDetailData dataLayer = new InvoiceDetailData();
			return dataLayer.FetchByInvoiceId(id);

		} // FetchByInvoiceId

		/// <summary>
		///  Create New InvoiceDetail
		/// </summary>
		/// <param name="_id">String: Id value for InvoiceDetail</param>
		/// <param name="_invoiceId">String: Invoice Id value for InvoiceDetail</param>
		/// <param name="_lineItem">int: Line Item value for InvoiceDetail</param>
		/// <param name="_itemDescription">String: Item Description value for InvoiceDetail</param>
		/// <param name="_itemCostPerUnit">decimal: Item Cost Per Unit value for InvoiceDetail</param>
		/// <param name="_itemQuanity">int: Item Quanity value for InvoiceDetail</param>
		/// <param name="_itemUnit">String: Item Unit value for InvoiceDetail</param>
		public static InvoiceDetail CreateNewInvoiceDetail(String _id, String _invoiceId, int _lineItem, String _itemDescription, decimal _itemCostPerUnit, int _itemQuanity, String _itemUnit)
		{
		
			InvoiceDetail newInvoiceDetail = new InvoiceDetail( _id,  _invoiceId,  _lineItem,  _itemDescription,  _itemCostPerUnit,  _itemQuanity,  _itemUnit);
			if (newInvoiceDetail.Save()==0)
				return newInvoiceDetail;
			else
				return null;

		} // CreateNewInvoiceDetail	

		/// <summary>
		///  Delete InvoiceDetail
		/// </summary>
		/// <param name="_id">String</param>
		public static bool DeleteInvoiceDetail(String _id)
		{
			InvoiceDetailData dataLayer = new InvoiceDetailData();
			return dataLayer.DeleteInvoiceDetail(_id);
			
		} // DeleteInvoiceDetail

		#endregion
		
	} // class InvoiceDetail

} // Sample.Objects.BusinessLogic

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Web Developer
United States United States
Software Architect with 20++ years of software design and development experience with a strong hold in Object-Oriented software engineering using UML with Design Patterns. Architected and developed several industrial software packages and passed through full software development life-cycle. Currently managing a small group of developers, developing management software for the agriculture industry.

Comments and Discussions