using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using WIP_common;
|
using WIP_DAL;
|
using WIP_Models;
|
|
namespace WIP_BLL
|
{
|
/// <summary>
|
/// $ChinaComment$ÒµÎñ´¦ÀíÀà
|
/// </summary>
|
public class $FilePrefixName$BLL
|
{
|
private readonly $FilePrefixName$DAL $TableAlias$DAL = new $FilePrefixName$DAL();
|
|
#region Add
|
|
/// <summary>
|
/// Ôö¼ÓÒ»Ìõ$ChinaComment$Êý¾Ý
|
/// </summary>
|
/// <param name="param">ÒªÔö¼ÓµÄ$ChinaComment$²ÎÊýÀà</param>
|
/// <param name="creator">´´½¨ÈË</param>
|
/// <returns>²åÈëµÄ×îÐÂÖ÷¼üÖµ</returns>
|
public int Add($AddEntityParam$ param,string creator)
|
{
|
$EntityName$ model = null;
|
model = WIPCommon.T1ToT2<$AddEntityParam$, $EntityName$>(param);
|
model.creator = model.lastModifier = creator;
|
model.createTime = model.lastModifyTime = DateTime.Now;
|
model.delFlag=false;
|
return $TableAlias$DAL.Add(model);
|
}
|
|
#endregion
|
|
#region Edit
|
|
/// <summary>
|
/// ¸üÐÂÒ»Ìõ$ChinaComment$Êý¾Ý
|
/// </summary>
|
/// <param name="model">Òª¸üеÄ$ChinaComment$ʵÌå</param>
|
/// <param name="lastModifier">×îºóÐÞ¸ÄÈË</param>
|
/// <returns>¸üÐÂÊÇ·ñ³É¹¦</returns>
|
public bool Update($EntityName$ model,string lastModifier)
|
{
|
model.lastModifier = lastModifier;
|
model.lastModifyTime = DateTime.Now;
|
return $TableAlias$DAL.Update(model);
|
}
|
|
#endregion
|
|
#region Del
|
|
/// <summary>
|
/// ɾ³ýÒ»Ìõ$ChinaComment$Êý¾Ý
|
/// </summary>
|
/// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param>
|
/// <returns>ÊÇ·ñɾ³ý³É¹¦</returns>
|
public bool Delete(string $PrimaryKey$)
|
{
|
return $TableAlias$DAL.Delete($PrimaryKey$);
|
}
|
|
#endregion
|
|
#region Enable
|
|
/// <summary>
|
/// ½ûÆôÓÃ$ChinaComment$Êý¾Ý
|
/// </summary>
|
/// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param>
|
/// <param name="delFlag">½ûÓÃ1/ÆôÓÃ0</param>
|
/// <param name="lastModifier">×îºóÐÞ¸ÄÈË</param>
|
/// <param name="transModel">ÊÂÎñÀà</param>
|
/// <returns>ÊÇ·ñ½ûÆôÓóɹ¦</returns>
|
public bool Enable(string $PrimaryKey$, string delFlag, string lastModifier)
|
{
|
return $TableAlias$DAL.Enable($PrimaryKey$,delFlag,lastModifier);
|
}
|
|
#endregion
|
|
#region QueryList(Page)
|
|
/// <summary>
|
/// »ñµÃ$ChinaComment$Êý¾ÝÁбí(·ÖÒ³)
|
/// </summary>
|
/// <param name="pageParam">²éѯ²ÎÊý</param>
|
/// <returns>$ChinaComment$·ÖÒ³Êý¾Ý</returns>
|
public PageResultModel<$EntityName$> GetModelListForPage(Query$Modulelogo$Param pageParam)
|
{
|
DataSet ds = $TableAlias$DAL.GetModelListForPage(pageParam);
|
List<$EntityName$> list = DataTableToList(ds.Tables[0]);
|
int total = Convert.ToInt32(ds.Tables[1].Rows[0]["COUNT"]);
|
PageResultModel<$EntityName$> result = new PageResultModel<$EntityName$>();
|
result.total = total;
|
result.rows = list;
|
return result;
|
}
|
|
#endregion
|
|
#region QueryList
|
|
/// <summary>
|
/// »ñµÃ$ChinaComment$Êý¾ÝÁбí
|
/// </summary>
|
/// <param name="strWhere">²éѯÌõ¼þ</param>
|
/// <returns>$ChinaComment$Êý¾Ý¼¯ºÏ</returns>
|
public List<$EntityName$> GetModelList(string strWhere)
|
{
|
DataSet ds = $TableAlias$DAL.GetList(strWhere);
|
return DataTableToList(ds.Tables[0]);
|
}
|
|
#endregion
|
|
#region Query(Single)
|
|
/// <summary>
|
/// µÃµ½Ò»¸ö$ChinaComment$ʵÌå
|
/// </summary>
|
/// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param>
|
/// <returns>$ChinaComment$ʵÌå</returns>
|
public $EntityName$ GetModel(string $PrimaryKey$)
|
{
|
|
return $TableAlias$DAL.GetModel($PrimaryKey$);
|
}
|
|
#endregion
|
|
#region Other
|
|
/// <summary>
|
/// ÊÇ·ñ´æÔÚ¸Ã$ChinaComment$¼Ç¼
|
/// </summary>
|
/// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param>
|
/// <returns></returns>
|
public bool Exists(string $PrimaryKey$, int? id = null)
|
{
|
return $TableAlias$DAL.Exists($PrimaryKey$,id);
|
}
|
|
#endregion
|
|
#region Common
|
|
/// <summary>
|
/// »ñµÃ$ChinaComment$Êý¾ÝÁбí
|
/// </summary>
|
private List<$EntityName$> DataTableToList(DataTable dt)
|
{
|
List<$EntityName$> modelList = new List<$EntityName$>();
|
int rowsCount = dt.Rows.Count;
|
if (rowsCount > 0)
|
{
|
$EntityName$ model;
|
for (int n = 0; n < rowsCount; n++)
|
{
|
model = new $EntityName$();
|
var dataRow = dt.Rows[n];
|
|
$ToSingleModel$
|
|
|
modelList.Add(model);
|
}
|
}
|
return modelList;
|
}
|
|
#endregion
|
|
}
|
}
|