222
schangxiang@126.com
2025-04-29 4352ad5cbeef498392178655cb367ee38e574178
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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
 
    }
}