3. Bll Template
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using <xsl:value-of select="TabelModel/NameSpacePri"/>Model;
using <xsl:value-of select="TabelModel/NameSpacePri"/>DAL;
namespace <xsl:value-of select="TabelModel/NameSpacePri"/>BLL
{
public partial class <xsl:value-of select="TabelModel/ModelName"/>BLL
{
# Region attributes/Constructor
/// <Summary>
/// Data Link Access Object
/// </Summary>
Private <XSL: value-of select = "tabelmodel/modelname"/> Dal = NULL;
/// <Summary>
/// Default constructor
/// </Summary>
Public <XSL: value-of select = "tabelmodel/modelname"/> BLL ()
{
Dal = new <XSL: value-of select = "tabelmodel/modelname"/> Dal ();
}
# Endregion
# Region Data Detection
<XSL: If test = "tabelmodel/haspk = 'true'">
/// <Summary>
/// Whether data with the specified primary key exists
/// </Summary>
<XSL: For-each select = "tabelmodel/fields/fieldmodel [ispk = 'true']">
/// <Param> <XSL: attribute name = "name"> <XSL: value-of select = "varname"/> </XSL: attribute> specify <XSL: value-of select = "varname"/> </param>
</XSL: For-each>
/// <Returns> true/false </returns>
Public bool existswithpk (<XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/vartype"/> <XSL: text> </XSL: Text> <XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [position ()> 1]" >,< XSL: value-of select = "vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "varname"/> </XSL: for-each>)
{
Return Dal. existswithpk (<XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [position ()> 1]" >,< XSL: value-of select = "varname"/> </XSL: For-each> );
}
</XSL: If>
<XSL: If test = "tabelmodel/haslogickey = 'true'">
/// <Summary>
/// Whether data with the specified logical primary key exists
/// </Summary>
<XSL: For-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true']">
/// <Param> <XSL: attribute name = "name"> <XSL: value-of select = "varname"/> </XSL: attribute> specify <XSL: value-of select = "varname"/> </param>
</XSL: For-each>
/// <Returns> true/false </returns>
Public bool existswithlogickey (<XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/vartype"/> <XSL: text> </XSL: Text> <XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [position ()> 1]" >,< XSL: value-of select = "vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "varname"/> </XSL: for-each>)
{
Return Dal. existswithlogickey (<XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [position ()> 1]" >,< XSL: value-of select = "varname"/> </XSL: For-each> );
}
</XSL: If>
/// <Summary>
/// Whether data that meets the specified conditions exists
/// </Summary>
/// <Param name = "strwhere"> condition (excluding the "where" keyword) </param>
/// <Returns> true/false </returns>
Public bool existswithparam (string strwhere)
{
Return Dal. existswithparam (strwhere );
}
#endregion
# Region Data Retrieval
<XSL: If test = "tabelmodel/haspk = 'true'">
/// <Summary>
/// Retrieve the data entity based on the primary key
/// </Summary>
<XSL: For-each select = "tabelmodel/fields/fieldmodel [ispk = 'true']">
/// <Param>
<XSL: attribute name = "name">
<XSL: value-of select = "varname"/>
</XSL: attribute>
<XSL: value-of select = "varname"/>
</Param>
</XSL: For-each>
/// <Returns> Search Result </returns>
Public <XSL: value-of select = "tabelmodel/modelname"/> model get <XSL: value-of select = "tabelmodel/modelname"/> bypk (<XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [position ()> 1]" >,< XSL: value-of select = "vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "varname"/> </XSL: for-each>)
{
Return Dal. get <XSL: value-of select = "tabelmodel/modelname"/> bypk (<XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [position ()> 1]" >,< XSL: value-of select = "varname"/> </XSL: For-each> );
}
</XSL: If>
<XSL: If test = "tabelmodel/haslogickey = 'true'">
/// <Summary>
/// Retrieve the data entity based on the Logical primary key
/// </Summary>
<XSL: For-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true']">
/// <Param>
<XSL: attribute name = "name">
<XSL: value-of select = "varname"/>
</XSL: attribute>
<XSL: value-of select = "varname"/>
</Param>
</XSL: For-each>
/// <Returns> Search Result </returns>
Public <XSL: value-of select = "tabelmodel/modelname"/> model get <XSL: value-of select = "tabelmodel/modelname"/> bylogickey (<XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [position ()> 1]" >,< XSL: value-of select = "vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "varname"/> </XSL: for-each>)
{
Return Dal. get <XSL: value-of select = "tabelmodel/modelname"/> bylogickey (<XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [position ()> 1]" >,< XSL: value-of select = "varname"/> </XSL: For-each> );
}
</XSL: If>
/// <Summary>
/// Retrieve data entities based on conditions
/// </Summary>
/// <Param name = "strwhere"> condition </param>
/// <Returns> Search Result </returns>
Public <XSL: value-of select = "tabelmodel/modelname"/> model get <XSL: value-of select = "tabelmodel/modelname"/> byparam (string strwhere)
{
Return Dal. Get <XSL: value-of select = "tabelmodel/modelname"/> byparam (strwhere );
}
<XSL: If test = "tabelmodel/haspk = 'true'">
/// <Summary>
/// Retrieve data based on the primary key (datarow)
/// </Summary>
<XSL: For-each select = "tabelmodel/fields/fieldmodel [ispk = 'true']">
/// <Param>
<XSL: attribute name = "name">
<XSL: value-of select = "varname"/>
</XSL: attribute>
<XSL: value-of select = "varname"/>
</Param>
</XSL: For-each>
/// <Returns> Search Result </returns>
Public datarow getrowbypk (<XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/vartype"/> <XSL: text> </XSL: Text> <XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [position ()> 1]" >,< XSL: value-of select = "vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "varname"/> </XSL: for-each>)
{
Return Dal. getrowbypk (<XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [position ()> 1]" >,< XSL: value-of select = "varname"/> </XSL: For-each> );
}
</XSL: If>
<XSL: If test = "tabelmodel/haslogickey = 'true'">
/// <Summary>
/// Data retrieval based on the Logical primary key (datarow)
/// </Summary>
<XSL: For-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true']">
/// <Param>
<XSL: attribute name = "name">
<XSL: value-of select = "varname"/>
</XSL: attribute>
<XSL: value-of select = "varname"/>
</Param>
</XSL: For-each>
/// <Returns> Search Result </returns>
Public datarow getrowbylogickey (<XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/vartype"/> <XSL: text> </XSL: Text> <XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [position ()> 1]" >,< XSL: value-of select = "vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "varname"/> </XSL: for-each>)
{
Return Dal. getrowbylogickey (<XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [position ()> 1]" >,< XSL: value-of select = "varname"/> </XSL: For-each> );
}
</XSL: If>
/// <Summary>
/// Retrieve data based on conditions (datarow)
/// </Summary>
/// <Param name = "strwhere"> condition </param>
/// <Returns> Search Result </returns>
Public datarow getrowbyparam (string strwhere)
{
Return Dal. getrowbyparam (strwhere );
}
/// <Summary>
/// Obtain the list of all data entities
/// </Summary>
/// <Returns> Search Result </returns>
Public list <XSL: Text disable-output-escaping = "yes"> & lt; </XSL: Text> <XSL: value-of select = "tabelmodel/modelname"/> Model <XSL: Text disable-output-escaping = "yes"> & gt; </XSL: Text> Get <XSL: value-of select = "tabelmodel/modelname"/> List ()
{
Return Dal. Get <XSL: value-of select = "tabelmodel/modelname"/> List ();
}
/// <Summary>
/// Retrieve the data Entity List based on conditions
/// </Summary>
/// <Param name = "strwhere"> condition </param>
/// <Returns> Search Result </returns>
Public list <XSL: Text disable-output-escaping = "yes"> & lt; </XSL: Text> <XSL: value-of select = "tabelmodel/modelname"/> Model <XSL: Text disable-output-escaping = "yes"> & gt; </XSL: Text> Get <XSL: value-of select = "tabelmodel/modelname"/> listbyparam (string strwhere)
{
Return Dal. Get <XSL: value-of select = "tabelmodel/modelname"/> listbyparam (strwhere );
}
/// <Summary>
/// Retrieve all data lists (datatable)
/// </Summary>
/// <Returns> Search Result </returns>
Public datatable gettable ()
{
Return Dal. gettablebyparam (string. Empty );
}
/// <Summary>
/// Able)
/// </Summary>
/// <Param name = "strwhere"> condition </param>
/// <Returns> Search Result </returns>
Public datatable gettablebyparam (string strwhere)
{
Return Dal. gettablebyparam (strwhere );
}
#endregion
<XSL: If test = "tabelmodel/isview = 'false'">
# Add/delete/modify region data
/// <Summary>
/// Add
/// </Summary>
/// <Param name = "model"> data entity </param>
/// <Returns> </returns>
Public int add <XSL: value-of select = "tabelmodel/modelname"/> (<XSL: value-of select = "tabelmodel/modelname"/> Model)
{
Return Dal. Add <XSL: value-of select = "tabelmodel/modelname"/> (model );
}
<XSL: If test = "tabelmodel/haspk = 'true'">
/// <Summary>
/// Edit
/// </Summary>
/// <Param name = "model"> data entity </param>
/// <Returns> </returns>
Public int update <XSL: value-of select = "tabelmodel/modelname"/> (<XSL: value-of select = "tabelmodel/modelname"/> Model)
{
Return Dal. Update <XSL: value-of select = "tabelmodel/modelname"/> (model );
}
/// <Summary>
/// Delete a data entity
/// </Summary>
/// <Param name = "model"> data entity </param>
/// <Returns> </returns>
Public int Delete <XSL: value-of select = "tabelmodel/modelname"/> (<XSL: value-of select = "tabelmodel/modelname"/> Model)
{
Return Dal. Delete <XSL: value-of select = "tabelmodel/modelname"/> (model );
}
/// <Summary>
/// Delete based on the primary key
/// </Summary>
<XSL: For-each select = "tabelmodel/fields/fieldmodel [ispk = 'true']">
/// <Param>
<XSL: attribute name = "name">
<XSL: value-of select = "varname"/>
</XSL: attribute>
<XSL: value-of select = "varname"/>
</Param>
</XSL: For-each>
/// <Returns> </returns>
Public int deletewithpk (<XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/vartype"/> <XSL: text> </XSL: Text> <XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [position ()> 1]" >,< XSL: value-of select = "vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "varname"/> </XSL: for-each>)
{
Return Dal. deletewithpk (<XSL: value-of select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [ispk = 'true'] [position ()> 1]" >,< XSL: value-of select = "varname"/> </XSL: For-each> );
}
</XSL: If>
<XSL: If test = "tabelmodel/haslogickey = 'true'">
/// <Summary>
/// Edit (based on the Logical primary key)
/// </Summary>
/// <Param name = "model"> data entity </param>
/// <Returns> </returns>
Public int update <XSL: value-of select = "tabelmodel/modelname"/> withlogickey (<XSL: value-of select = "tabelmodel/modelname"/> Model)
{
Return Dal. Update <XSL: value-of select = "tabelmodel/modelname"/> withlogickey (model );
}
/// <Summary>
/// Delete the data entity (based on the Logical primary key)
/// </Summary>
/// <Param name = "model"> data entity </param>
/// <Returns> </returns>
Public int Delete <XSL: value-of select = "tabelmodel/modelname"/> withlogickey (<XSL: value-of select = "tabelmodel/modelname"/> Model)
{
Return Dal. Delete <XSL: value-of select = "tabelmodel/modelname"/> withlogickey (model );
}
/// <Summary>
/// Delete a logical primary key
/// </Summary>
<XSL: For-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true']">
/// <Param>
<XSL: attribute name = "name">
<XSL: value-of select = "varname"/>
</XSL: attribute>
<XSL: value-of select = "varname"/>
</Param>
</XSL: For-each>
/// <Returns> </returns>
Public int deletewithlogickey (<XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/vartype"/> <XSL: text> </XSL: Text> <XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [position ()> 1]" >,< XSL: value-of select = "vartype"/> <XSL: Text> </XSL: Text> <XSL: value-of select = "varname"/> </XSL: for-each>)
{
Return Dal. deletewithlogickey (<XSL: value-of select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [1]/varname"/> <XSL: for-each select = "tabelmodel/fields/fieldmodel [islogickey = 'true'] [position ()> 1]" >,< XSL: value-of select = "varname"/> </XSL: For-each> );
}
</XSL: If>
/// <Summary>
/// Delete based on conditions
/// </Summary>
/// <Param name = "strwhere"> condition </param>
/// <Returns> Number of deleted items </returns>
Public int deletebyparam (string strwhere)
{
Return Dal. deletebyparam (strwhere );
}
# Endregion
</XSL: If>
}
}
</XSL: Template>
</XSL: stylesheet>