Click here to Skip to main content
15,894,405 members
Articles / Web Development / ASP.NET

Template-Based Code Generation with SmartCode

Rate me:
Please Sign up or sign in to vote.
4.82/5 (35 votes)
25 Dec 20067 min read 101.1K   3.5K   121  
SmartCode is a template based code generator.This tutorial describes the process of building a templates to SmartCode
/*
 * Copyright � 2005-2006 Danilo Mendez <danilo.mendez@kontac.net>
 * Adolfo Socorro <ajs@esolutionspr.com>
 * www.kontac.net 
 * All rights reserved.
 * Released under both BSD license and Lesser GPL library license.
 * Whenever there is any discrepancy between the two licenses,
 * the BSD license will take precedence.
 */

namespace Businesslayer{
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Collections;
    using DataAccess;
    using Common;

	/// <summary>
	/// Employeess Business Class  
	/// </summary>
	public class EmployeesBiz {

        #region Constructor
        /// <summary>
        /// Initializes a new instance of the <see cref="EmployeesBiz"/> 
        /// class with the specified <see cref="Biz"/>.
        /// </summary>
        public EmployeesBiz()
        {
        }
        #endregion

        #region Persist Methods

        /// <summary>
		/// A method for inserting and updating Employees data.
		/// Multiple rows may be inserted or updated simultaneously.
		/// </summary>
		/// <param name="updates">A DataSet containing a EmployeesDataTable with data to insert or update.</param>
		public EmployeesDS Persist(EmployeesDS updates) {
			EmployeesDal dao = null;
			try {
				dao = new EmployeesDal ();
				return dao.Persist(updates);
			}
			catch (Exception ex) 
			{
				throw new Exception (ex.Message ,ex);
			}
			finally 
			{
				if (dao != null) dao.Dispose();
			}
        }

		/// <summary>
		/// A method for inserting and updating Employees data.
		/// Multiple rows may be inserted  simultaneously.
		/// </summary>
		/// <param name="updates">A DataSet containing a EmployeesDataTable with data to insert or update.</param>
		public EmployeesDS InsertEmployees(EmployeesDS ds) {
			EmployeesDal dao = null;
			try {
				dao = new EmployeesDal ();
				return dao.InsertEmployees(ds);
			}
			catch (Exception ex) 
			{
				throw new Exception (ex.Message ,ex);
			}
			finally 
			{
				if (dao != null) dao.Dispose();
			}
        }

		/// <summary>
		/// A method for updating Employees data.
		/// Multiple rows may be  updated simultaneously.
		/// </summary>
		/// <param name="updates">A DataSet containing a EmployeesDataTable with data to insert or update.</param>
		public EmployeesDS UpdateEmployees(EmployeesDS ds) {
			EmployeesDal dao = null;
			try {
				dao = new EmployeesDal ();
				return dao.UpdateEmployees(ds);
			}
			catch (Exception ex) 
			{
				throw new Exception (ex.Message ,ex);
			}
			finally 
			{
				if (dao != null) dao.Dispose();
			}
        }

		/// <summary>
		/// A method for delete Employees data.
		/// Multiple rows may be deleted  simultaneously.
		/// </summary>
		/// <param name="updates">A DataSet containing a EmployeesDataTable with data to insert or update.</param>
		public void DeleteEmployees(EmployeesDS ds) {
			EmployeesDal dao = null;
			try {
				dao = new EmployeesDal ();
				dao.DeleteEmployees(ds);
			}
			catch (Exception ex) 
			{
				throw new Exception (ex.Message ,ex);
			}
			finally 
			{
				if (dao != null) dao.Dispose();
			}
        }
        #endregion

        #region Get Methods

        /// <summary>
		/// Fills a DataSet with a Employees by its primary-key attributes:System.Int32 employeeid
		/// </summary> 
		/// <param name="employeeid">The EmployeeID</param>
		/// <returns>A EmployeesDS</returns>
		public EmployeesDS Populate(System.Int32 employeeid) {
			EmployeesDal dao = null;
			try {
				dao = new EmployeesDal ();
				return dao.Populate(employeeid);
			}
			catch (Exception ex) 
			{
				throw new Exception (ex.Message ,ex);
			}
			finally 
			{
				if (dao != null) dao.Dispose();
			}
		}

		/// <summary>
		/// Fills a DataSet with all Employeess based on a condition.
		/// </summary>
		/// <param name="whereSql">A string with an SQL condition for the data to look up.</param>
		/// <returns>A EmployeesDS</returns>
		public EmployeesDS PopulateList(string whereSql) {
			EmployeesDal dao = null;
			try {
				dao = new EmployeesDal ();
				return dao.PopulateList(whereSql);
			}
			catch (Exception ex) 
			{
				throw new Exception (ex.Message ,ex);
			}
			finally 
			{
				if (dao != null) dao.Dispose();
			}
		}

        #endregion

        #region Get Methods for each child
        #endregion
    }
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Danilo is the creator of SmartRules, a Business Rules Engine. He is an industry consultant working primarily with companies interested in implementing dynamic rules programming concepts to add flexibility to their architectures on web, CE, and desktop platforms. He operates his own website, Kontac, where you will find more information.

To contact Danilo, email him at danilo.mendez@gmail.com.

Comments and Discussions