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
76
77
78
79
80
81
82
#region
 
using System;
using System.Data;
using System.Data.Common;
using CSFrameworkV5.Core;
using CSFrameworkV5.Core.CodeGenerator;
using CSFrameworkV5.Models;
 
#endregion
 
/*===================================================================
 *   程序说明: BusinessTables的数据访问层源码
 *   作者资料: 孙中吕
 *   创建日期: 2017-12-29 04:26:27
 *   最后修改: 2017-12-29 04:26:27
 *
 *   注: 本文件由代码生成器(Code Generator)自动生成。
 *   (此源码文件请放置在 YourProject.DataAccess 模块)
 *   版权所有 Copyright 2006~2017, C/S框架网(www.cscode.net)
 *===================================================================*/
 
namespace CSFrameworkV5.DataAccess
{
    /// <summary>
    ///     DAL数据层:dalBusinessTables
    /// </summary>
    [DefaultORM_UpdateMode(typeof(sys_BusinessTables), true)]
    public class dalBusinessTables : dalBaseDataDict
    {
        /// <summary>
        ///     构造器
        /// </summary>
        /// <param name="loginer">当前登录用户</param>
        public dalBusinessTables(Loginer loginer) : base(loginer)
        {
            _KeyName = sys_BusinessTables.__KeyName; //主键字段
            _TableName = sys_BusinessTables.__TableName; //表名
            _ModelType = typeof(sys_BusinessTables); //指定ORM模型
            _UpdateSummaryKeyMode =
                UpdateKeyMode.OnlyGuid; //自动生成GUID号            
            _Database = DatabaseProvider.SystemDatabase;
        }
 
        /// <summary>
        ///     根据表名获取该表的SQL命令生成器
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <returns></returns>
        protected override IGenerateSqlCommand CreateSqlGenerator(
            DataTable table)
        {
            Type ORM = null;
            if (table.TableName == sys_BusinessTables.__TableName)
                ORM = typeof(sys_BusinessTables); //指定表与ORM模型的对应关系
 
            if (ORM == null) throw new Exception(table.TableName + "表没有ORM模型!");
 
            return new GenerateSqlCmdByTableFields(ORM, table,
                GeneratorFactory);
        }
 
        /// <summary>
        //获取流水号码
        /// </summary>
        protected override string GetNumber(DbTransaction tran)
        {
            var SN =
                DocNoTool.GetDataSN(_Database, tran, "ST", true,
                    6); //注意修改流水号字头!
            return SN;
        }
 
        public DataTable Query()
        {
            var sql = "SELECT * FROM sys_BusinessTables WHERE ORDER BY RowID ";
            var cmd = _Database.CreateCommand(sql);
            return _Database.GetTable(cmd.Command,
                sys_BusinessTables.__TableName);
        }
    } //public class
} //namespace