1
yhj
2024-07-24 5e5d945e91568b973faa27d8ab0bcef99fc4a6c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#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;
        }
    }
}