|
using System;
using System.Data;
using System.Data.SqlClient;
namespace DAT
{
abstract public class PMFactory
{
/// <summary>
/// This is the super class of PMFactory_In and PMFactory_Out
/// which are responsible for creating various kind of SqlParameters.
/// This pattern corresponds to the pattern �abstract factory� and two majar types
/// are ParameterDirection.Input and ParameterDirection.Output
/// </summary>
public PMFactory()
{
}
/// <summary>
/// Creates SqlParameter for DbType: int with the size:4
/// </summary>
/// <param name="strName">Name of the Parameter</param>
/// <param name="iValue">SqlParameter</param>
abstract public SqlParameter GetPMInt4(string strName);
/// <summary>
/// Creates SqlParameter DbType:Char with the length 5
/// </summary>
/// <param name="strName">Name of the Parameter</param>
/// <returns>SqlParameter</returns>
abstract public SqlParameter GetPMChar5(string strName);
/// <summary>
/// Creates SqlParameter DbType:VChar with the length 5
/// </summary>
/// <param name="strName">Name of the Parameter</param>
/// <returns>SqlParameter</returns>
abstract public SqlParameter GetPMVChar5(string strName);
/// <summary>
/// Creates SqlParameter Image
/// </summary>
/// <param name="strName">Name of the Parameter</param>
abstract public SqlParameter GetPMImage(string strName);
}
/// <summary>
/// Responsible for creating SqlParameters type:Input
/// </summary>
public class PMFactory_In:PMFactory
{
/// <summary>
/// This class is derived from PMFactory and
/// responsible for the creating input SqlParameters
/// </summary>
public PMFactory_In()
{
}
/// <summary>
/// Creates input SqlParameter for DbType: int and size:4
/// </summary>
/// <param name="strName">Name of the parameter</param>
/// <param name="iValue">Value of the parameter</param>
/// <returns>SqlParameter</returns>
public override SqlParameter GetPMInt4(string strName)
{
try
{
SqlParameter oParameter = new SqlParameter(strName,SqlDbType.Int,4);
oParameter.Direction = ParameterDirection.Input;
return oParameter;
}
catch
{
throw;
}
}
/// <summary>
/// Creates SqlParameter for DbType:Image
/// </summary>
/// <param name="strName"></param>
/// <returns></returns>
public override SqlParameter GetPMImage(string strName)
{
try
{
SqlParameter oParameter = new SqlParameter(strName,SqlDbType.Image);
oParameter.Direction = ParameterDirection.Input;
return oParameter;
}
catch
{
throw;
}
}
/// <summary>
/// Creates input SqlParameter for DbType: Char with the length 5
/// </summary>
/// <param name="strName">Name of the parameter</param>
/// <param name="iValue">SqlParameter</param>
/// <returns>SqlParameter</returns>
public override SqlParameter GetPMChar5(string strName)
{
try
{
SqlParameter oParameter = new SqlParameter(strName,SqlDbType.Char,5);
oParameter.Direction = ParameterDirection.Input;
return oParameter;
}
catch
{
throw;
}
}
/// <summary>
/// Creates input SqlParameter for DbType: VarChar with the length 5
/// </summary>
/// <param name="strName">Name of the parameter</param>
/// <param name="iValue">SqlParameter</param>
/// <returns>SqlParameter</returns>
public override SqlParameter GetPMVChar5(string strName)
{
try
{
SqlParameter oParameter = new SqlParameter(strName,SqlDbType.VarChar,5);
oParameter.Direction = ParameterDirection.Input;
return oParameter;
}
catch
{
throw;
}
}
}
/// <summary>
/// Responsible for creating SqlParameters type:Input
/// </summary>
public class PMFactory_Out:PMFactory
{
/// <summary>
/// This class is derived from PMFactory and
/// responsible for the creating output SqlParameters
/// </summary>
public PMFactory_Out()
{
}
/// <summary>
/// Creates output SqlParameter for DbType: int with size:4
/// </summary>
/// <param name="strName">Name of the parameter</param>
/// <returns>SqlParameter</returns>
public override SqlParameter GetPMInt4(string strName)
{
try
{
SqlParameter oParameter = new SqlParameter(strName,SqlDbType.Int,4);
oParameter.Direction = ParameterDirection.Output;
return oParameter;
}
catch
{
throw;
}
}
/// <summary>
/// Creates SqlParameter for DbType:Image
/// </summary>
/// <param name="strName"></param>
/// <returns></returns>
public override SqlParameter GetPMImage(string strName)
{
try
{
SqlParameter oParameter = new SqlParameter(strName,SqlDbType.Image);
oParameter.Direction = ParameterDirection.Output;
return oParameter;
}
catch
{
throw;
}
}
/// <summary>
/// Creates output SqlParameter for DbType: Char with the length 5
/// </summary>
/// <param name="strName">Name of the parameter</param>
/// <param name="iValue">SqlParameter</param>
/// <returns>SqlParameter</returns>
public override SqlParameter GetPMChar5(string strName)
{
try
{
SqlParameter oParameter = new SqlParameter(strName,SqlDbType.Char,5);
oParameter.Direction = ParameterDirection.Output;
return oParameter;
}
catch
{
throw;
}
}
/// <summary>
/// Creates output SqlParameter for DbType: VChar with the length 5
/// </summary>
/// <param name="strName">Name of the parameter</param>
/// <param name="iValue">SqlParameter</param>
/// <returns>SqlParameter</returns>
public override SqlParameter GetPMVChar5(string strName)
{
try
{
SqlParameter oParameter = new SqlParameter(strName,SqlDbType.VarChar,5);
oParameter.Direction = ParameterDirection.Output;
return oParameter;
}
catch
{
throw;
}
}
}
}
|
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.
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
Paul Abraham is a software developer who designs and develops multi-shop systems.
He has received his M.Sc in Mathematics and Computer Science from the FernUniversität Hagen(
http://www.fernuni-hagen.de Germany) and his main interests are neural networks and bayesian statistics He lives in Rosenheim (South Germany http://www.rosenheim.de). You can reach him at admin@paul-abraham.com.