#region
|
|
using System;
|
using System.Data;
|
using CSFrameworkV5.Common;
|
using CSFrameworkV5.Core;
|
using CSFrameworkV5.Core.CodeGenerator;
|
using CSFrameworkV5.Models;
|
|
#endregion
|
|
namespace CSFrameworkV5.DataAccess
|
{
|
/// <summary>
|
/// 功能点资料的DAL层
|
/// </summary>
|
[DefaultORM_UpdateMode(typeof(tb_MyActions), true)]
|
public class dalActions : dalBaseDataDict
|
{
|
public dalActions(Loginer loginer)
|
: base(loginer)
|
{
|
_KeyName = tb_MyActions.__KeyName;
|
_TableName = tb_MyActions.__TableName;
|
_ModelType = typeof(tb_MyActions);
|
_Database = DatabaseProvider.SystemDatabase;
|
}
|
|
/// <summary>
|
/// 根据表名获取该表的SQL命令生成器
|
/// </summary>
|
/// <param name="tableName">表名</param>
|
/// <returns></returns>
|
protected override IGenerateSqlCommand CreateSqlGenerator(
|
DataTable table)
|
{
|
Type ORM = null;
|
|
if (table.TableName == tb_MyActions.__TableName)
|
ORM = typeof(tb_MyActions);
|
|
if (ORM == null) throw new Exception(table.TableName + "表没有ORM模型!");
|
|
//支持两种SQL命令生成器
|
return new GenerateSqlCmdByTableFields(ORM, table,
|
GeneratorFactory);
|
}
|
|
public DataTable GetActionData()
|
{
|
var sql = "SELECT * FROM tb_MyActions ORDER BY ActionValue";
|
return _Database.GetTable(sql, tb_MyActions.__TableName);
|
}
|
|
/// <summary>
|
/// 获取主表数据
|
/// </summary>
|
/// <returns></returns>
|
public override DataTable GetSummaryData()
|
{
|
AssertTableName();
|
return GetActionData();
|
}
|
|
public bool IsExistsAction(int actionValue)
|
{
|
var sql =
|
$"SELECT COUNT(*) FROM tb_MyActions WHERE AuthorityValue>0 AND AuthorityValue={_Database.ParamSymboName}AuthorityValue";
|
var cmd = _Database.CreateCommand(sql);
|
cmd.AddParam("AuthorityValue", actionValue);
|
var o = _Database.ExecuteScalar(cmd.Command);
|
return ConvertEx.ToInt(o) > 0;
|
}
|
}
|
}
|