|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+using RMYY_CallCenter_Api.DB;
|
|
|
2
|
+using System;
|
|
|
3
|
+using System.Collections.Generic;
|
|
|
4
|
+using System.Data;
|
|
|
5
|
+using System.Data.SqlClient;
|
|
|
6
|
+using System.Linq;
|
|
|
7
|
+using System.Text;
|
|
|
8
|
+using System.Threading.Tasks;
|
|
|
9
|
+
|
|
|
10
|
+namespace RMYY_CallCenter_Api.Dal
|
|
|
11
|
+{
|
|
|
12
|
+ /// <summary>
|
|
|
13
|
+ /// 数据访问类:T_Sys_CustomFiled
|
|
|
14
|
+ /// </summary>
|
|
|
15
|
+ public partial class T_Sys_CustomFiled
|
|
|
16
|
+ {
|
|
|
17
|
+ public T_Sys_CustomFiled()
|
|
|
18
|
+ { }
|
|
|
19
|
+ #region BasicMethod
|
|
|
20
|
+
|
|
|
21
|
+ /// <summary>
|
|
|
22
|
+ /// 得到最大ID
|
|
|
23
|
+ /// </summary>
|
|
|
24
|
+ public int GetMaxId()
|
|
|
25
|
+ {
|
|
|
26
|
+ return DbHelperSQL.GetMaxID("F_Id", "T_Sys_CustomFiled");
|
|
|
27
|
+ }
|
|
|
28
|
+
|
|
|
29
|
+ /// <summary>
|
|
|
30
|
+ /// 是否存在该记录
|
|
|
31
|
+ /// </summary>
|
|
|
32
|
+ public bool Exists(int F_Id)
|
|
|
33
|
+ {
|
|
|
34
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
35
|
+ strSql.Append("select count(1) from T_Sys_CustomFiled");
|
|
|
36
|
+ strSql.Append(" where F_Id=SQL2012F_Id");
|
|
|
37
|
+ SqlParameter[] parameters = {
|
|
|
38
|
+ new SqlParameter("SQL2012F_Id", SqlDbType.Int,4)
|
|
|
39
|
+ };
|
|
|
40
|
+ parameters[0].Value = F_Id;
|
|
|
41
|
+
|
|
|
42
|
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
|
|
|
43
|
+ }
|
|
|
44
|
+
|
|
|
45
|
+
|
|
|
46
|
+ /// <summary>
|
|
|
47
|
+ /// 增加一条数据
|
|
|
48
|
+ /// </summary>
|
|
|
49
|
+ public int Add(RMYY_CallCenter_Api.Model.T_Sys_CustomFiled model)
|
|
|
50
|
+ {
|
|
|
51
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
52
|
+ strSql.Append("insert into T_Sys_CustomFiled(");
|
|
|
53
|
+ strSql.Append("F_TableId,F_Fileds,F_FiledNames,F_CreateUser,F_CreateTime)");
|
|
|
54
|
+ strSql.Append(" values (");
|
|
|
55
|
+ strSql.Append("SQL2012F_TableId,SQL2012F_Fileds,SQL2012F_FiledNames,SQL2012F_CreateUser,SQL2012F_CreateTime)");
|
|
|
56
|
+ strSql.Append(";select @@IDENTITY");
|
|
|
57
|
+ SqlParameter[] parameters = {
|
|
|
58
|
+ new SqlParameter("SQL2012F_TableId", SqlDbType.NVarChar,50),
|
|
|
59
|
+ new SqlParameter("SQL2012F_Fileds", SqlDbType.NVarChar,-1),
|
|
|
60
|
+ new SqlParameter("SQL2012F_FiledNames", SqlDbType.NVarChar,-1),
|
|
|
61
|
+ new SqlParameter("SQL2012F_CreateUser", SqlDbType.NVarChar,50),
|
|
|
62
|
+ new SqlParameter("SQL2012F_CreateTime", SqlDbType.DateTime)};
|
|
|
63
|
+ parameters[0].Value = model.F_TableId;
|
|
|
64
|
+ parameters[1].Value = model.F_Fileds;
|
|
|
65
|
+ parameters[2].Value = model.F_FiledNames;
|
|
|
66
|
+ parameters[3].Value = model.F_CreateUser;
|
|
|
67
|
+ parameters[4].Value = model.F_CreateTime;
|
|
|
68
|
+
|
|
|
69
|
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
|
|
|
70
|
+ if (obj == null)
|
|
|
71
|
+ {
|
|
|
72
|
+ return 0;
|
|
|
73
|
+ }
|
|
|
74
|
+ else
|
|
|
75
|
+ {
|
|
|
76
|
+ return Convert.ToInt32(obj);
|
|
|
77
|
+ }
|
|
|
78
|
+ }
|
|
|
79
|
+ /// <summary>
|
|
|
80
|
+ /// 更新一条数据
|
|
|
81
|
+ /// </summary>
|
|
|
82
|
+ public bool Update(RMYY_CallCenter_Api.Model.T_Sys_CustomFiled model)
|
|
|
83
|
+ {
|
|
|
84
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
85
|
+ strSql.Append("update T_Sys_CustomFiled set ");
|
|
|
86
|
+ strSql.Append("F_TableId=SQL2012F_TableId,");
|
|
|
87
|
+ strSql.Append("F_Fileds=SQL2012F_Fileds,");
|
|
|
88
|
+ strSql.Append("F_FiledNames=SQL2012F_FiledNames,");
|
|
|
89
|
+ strSql.Append("F_CreateUser=SQL2012F_CreateUser,");
|
|
|
90
|
+ strSql.Append("F_CreateTime=SQL2012F_CreateTime");
|
|
|
91
|
+ strSql.Append(" where F_Id=SQL2012F_Id");
|
|
|
92
|
+ SqlParameter[] parameters = {
|
|
|
93
|
+ new SqlParameter("SQL2012F_TableId", SqlDbType.NVarChar,50),
|
|
|
94
|
+ new SqlParameter("SQL2012F_Fileds", SqlDbType.NVarChar,-1),
|
|
|
95
|
+ new SqlParameter("SQL2012F_FiledNames", SqlDbType.NVarChar,-1),
|
|
|
96
|
+ new SqlParameter("SQL2012F_CreateUser", SqlDbType.NVarChar,50),
|
|
|
97
|
+ new SqlParameter("SQL2012F_CreateTime", SqlDbType.DateTime),
|
|
|
98
|
+ new SqlParameter("SQL2012F_Id", SqlDbType.Int,4)};
|
|
|
99
|
+ parameters[0].Value = model.F_TableId;
|
|
|
100
|
+ parameters[1].Value = model.F_Fileds;
|
|
|
101
|
+ parameters[2].Value = model.F_FiledNames;
|
|
|
102
|
+ parameters[3].Value = model.F_CreateUser;
|
|
|
103
|
+ parameters[4].Value = model.F_CreateTime;
|
|
|
104
|
+ parameters[5].Value = model.F_Id;
|
|
|
105
|
+
|
|
|
106
|
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
|
107
|
+ if (rows > 0)
|
|
|
108
|
+ {
|
|
|
109
|
+ return true;
|
|
|
110
|
+ }
|
|
|
111
|
+ else
|
|
|
112
|
+ {
|
|
|
113
|
+ return false;
|
|
|
114
|
+ }
|
|
|
115
|
+ }
|
|
|
116
|
+
|
|
|
117
|
+ /// <summary>
|
|
|
118
|
+ /// 删除一条数据
|
|
|
119
|
+ /// </summary>
|
|
|
120
|
+ public bool Delete(int F_Id)
|
|
|
121
|
+ {
|
|
|
122
|
+
|
|
|
123
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
124
|
+ strSql.Append("delete from T_Sys_CustomFiled ");
|
|
|
125
|
+ strSql.Append(" where F_Id=SQL2012F_Id");
|
|
|
126
|
+ SqlParameter[] parameters = {
|
|
|
127
|
+ new SqlParameter("SQL2012F_Id", SqlDbType.Int,4)
|
|
|
128
|
+ };
|
|
|
129
|
+ parameters[0].Value = F_Id;
|
|
|
130
|
+
|
|
|
131
|
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
|
132
|
+ if (rows > 0)
|
|
|
133
|
+ {
|
|
|
134
|
+ return true;
|
|
|
135
|
+ }
|
|
|
136
|
+ else
|
|
|
137
|
+ {
|
|
|
138
|
+ return false;
|
|
|
139
|
+ }
|
|
|
140
|
+ }
|
|
|
141
|
+ /// <summary>
|
|
|
142
|
+ /// 批量删除数据
|
|
|
143
|
+ /// </summary>
|
|
|
144
|
+ public bool DeleteList(string F_Idlist)
|
|
|
145
|
+ {
|
|
|
146
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
147
|
+ strSql.Append("delete from T_Sys_CustomFiled ");
|
|
|
148
|
+ strSql.Append(" where F_Id in (" + F_Idlist + ") ");
|
|
|
149
|
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
|
|
|
150
|
+ if (rows > 0)
|
|
|
151
|
+ {
|
|
|
152
|
+ return true;
|
|
|
153
|
+ }
|
|
|
154
|
+ else
|
|
|
155
|
+ {
|
|
|
156
|
+ return false;
|
|
|
157
|
+ }
|
|
|
158
|
+ }
|
|
|
159
|
+
|
|
|
160
|
+
|
|
|
161
|
+ /// <summary>
|
|
|
162
|
+ /// 得到一个对象实体
|
|
|
163
|
+ /// </summary>
|
|
|
164
|
+ public RMYY_CallCenter_Api.Model.T_Sys_CustomFiled GetModel(int F_Id)
|
|
|
165
|
+ {
|
|
|
166
|
+
|
|
|
167
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
168
|
+ strSql.Append("select top 1 F_Id,F_TableId,F_Fileds,F_FiledNames,F_CreateUser,F_CreateTime from T_Sys_CustomFiled ");
|
|
|
169
|
+ strSql.Append(" where F_Id=SQL2012F_Id");
|
|
|
170
|
+ SqlParameter[] parameters = {
|
|
|
171
|
+ new SqlParameter("SQL2012F_Id", SqlDbType.Int,4)
|
|
|
172
|
+ };
|
|
|
173
|
+ parameters[0].Value = F_Id;
|
|
|
174
|
+
|
|
|
175
|
+ RMYY_CallCenter_Api.Model.T_Sys_CustomFiled model = new RMYY_CallCenter_Api.Model.T_Sys_CustomFiled();
|
|
|
176
|
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
|
|
|
177
|
+ if (ds.Tables[0].Rows.Count > 0)
|
|
|
178
|
+ {
|
|
|
179
|
+ return DataRowToModel(ds.Tables[0].Rows[0]);
|
|
|
180
|
+ }
|
|
|
181
|
+ else
|
|
|
182
|
+ {
|
|
|
183
|
+ return null;
|
|
|
184
|
+ }
|
|
|
185
|
+ }
|
|
|
186
|
+
|
|
|
187
|
+
|
|
|
188
|
+ /// <summary>
|
|
|
189
|
+ /// 得到一个对象实体
|
|
|
190
|
+ /// </summary>
|
|
|
191
|
+ public RMYY_CallCenter_Api.Model.T_Sys_CustomFiled DataRowToModel(DataRow row)
|
|
|
192
|
+ {
|
|
|
193
|
+ RMYY_CallCenter_Api.Model.T_Sys_CustomFiled model = new RMYY_CallCenter_Api.Model.T_Sys_CustomFiled();
|
|
|
194
|
+ if (row != null)
|
|
|
195
|
+ {
|
|
|
196
|
+ if (row["F_Id"] != null && row["F_Id"].ToString() != "")
|
|
|
197
|
+ {
|
|
|
198
|
+ model.F_Id = int.Parse(row["F_Id"].ToString());
|
|
|
199
|
+ }
|
|
|
200
|
+ if (row["F_TableId"] != null)
|
|
|
201
|
+ {
|
|
|
202
|
+ model.F_TableId = row["F_TableId"].ToString();
|
|
|
203
|
+ }
|
|
|
204
|
+ if (row["F_Fileds"] != null)
|
|
|
205
|
+ {
|
|
|
206
|
+ model.F_Fileds = row["F_Fileds"].ToString();
|
|
|
207
|
+ }
|
|
|
208
|
+ if (row["F_FiledNames"] != null)
|
|
|
209
|
+ {
|
|
|
210
|
+ model.F_FiledNames = row["F_FiledNames"].ToString();
|
|
|
211
|
+ }
|
|
|
212
|
+ if (row["F_CreateUser"] != null)
|
|
|
213
|
+ {
|
|
|
214
|
+ model.F_CreateUser = row["F_CreateUser"].ToString();
|
|
|
215
|
+ }
|
|
|
216
|
+ if (row["F_CreateTime"] != null && row["F_CreateTime"].ToString() != "")
|
|
|
217
|
+ {
|
|
|
218
|
+ model.F_CreateTime = DateTime.Parse(row["F_CreateTime"].ToString());
|
|
|
219
|
+ }
|
|
|
220
|
+ }
|
|
|
221
|
+ return model;
|
|
|
222
|
+ }
|
|
|
223
|
+
|
|
|
224
|
+ /// <summary>
|
|
|
225
|
+ /// 获得数据列表
|
|
|
226
|
+ /// </summary>
|
|
|
227
|
+ public DataSet GetList(string strWhere)
|
|
|
228
|
+ {
|
|
|
229
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
230
|
+ strSql.Append("select F_Id,F_TableId,F_Fileds,F_FiledNames,F_CreateUser,F_CreateTime ");
|
|
|
231
|
+ strSql.Append(" FROM T_Sys_CustomFiled ");
|
|
|
232
|
+ if (strWhere.Trim() != "")
|
|
|
233
|
+ {
|
|
|
234
|
+ strSql.Append(" where " + strWhere);
|
|
|
235
|
+ }
|
|
|
236
|
+ return DbHelperSQL.Query(strSql.ToString());
|
|
|
237
|
+ }
|
|
|
238
|
+
|
|
|
239
|
+ /// <summary>
|
|
|
240
|
+ /// 获得前几行数据
|
|
|
241
|
+ /// </summary>
|
|
|
242
|
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
|
|
|
243
|
+ {
|
|
|
244
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
245
|
+ strSql.Append("select ");
|
|
|
246
|
+ if (Top > 0)
|
|
|
247
|
+ {
|
|
|
248
|
+ strSql.Append(" top " + Top.ToString());
|
|
|
249
|
+ }
|
|
|
250
|
+ strSql.Append(" F_Id,F_TableId,F_Fileds,F_FiledNames,F_CreateUser,F_CreateTime ");
|
|
|
251
|
+ strSql.Append(" FROM T_Sys_CustomFiled ");
|
|
|
252
|
+ if (strWhere.Trim() != "")
|
|
|
253
|
+ {
|
|
|
254
|
+ strSql.Append(" where " + strWhere);
|
|
|
255
|
+ }
|
|
|
256
|
+ strSql.Append(" order by " + filedOrder);
|
|
|
257
|
+ return DbHelperSQL.Query(strSql.ToString());
|
|
|
258
|
+ }
|
|
|
259
|
+
|
|
|
260
|
+ /// <summary>
|
|
|
261
|
+ /// 获取记录总数
|
|
|
262
|
+ /// </summary>
|
|
|
263
|
+ public int GetRecordCount(string strWhere)
|
|
|
264
|
+ {
|
|
|
265
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
266
|
+ strSql.Append("select count(1) FROM T_Sys_CustomFiled ");
|
|
|
267
|
+ if (strWhere.Trim() != "")
|
|
|
268
|
+ {
|
|
|
269
|
+ strSql.Append(" where " + strWhere);
|
|
|
270
|
+ }
|
|
|
271
|
+ object obj = DbHelperSQL.GetSingle(strSql.ToString());
|
|
|
272
|
+ if (obj == null)
|
|
|
273
|
+ {
|
|
|
274
|
+ return 0;
|
|
|
275
|
+ }
|
|
|
276
|
+ else
|
|
|
277
|
+ {
|
|
|
278
|
+ return Convert.ToInt32(obj);
|
|
|
279
|
+ }
|
|
|
280
|
+ }
|
|
|
281
|
+ /// <summary>
|
|
|
282
|
+ /// 分页获取数据列表
|
|
|
283
|
+ /// </summary>
|
|
|
284
|
+ public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
|
|
285
|
+ {
|
|
|
286
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
287
|
+ strSql.Append("SELECT * FROM ( ");
|
|
|
288
|
+ strSql.Append(" SELECT ROW_NUMBER() OVER (");
|
|
|
289
|
+ if (!string.IsNullOrEmpty(orderby.Trim()))
|
|
|
290
|
+ {
|
|
|
291
|
+ strSql.Append("order by T." + orderby);
|
|
|
292
|
+ }
|
|
|
293
|
+ else
|
|
|
294
|
+ {
|
|
|
295
|
+ strSql.Append("order by T.F_Id desc");
|
|
|
296
|
+ }
|
|
|
297
|
+ strSql.Append(")AS Row, T.* from T_Sys_CustomFiled T ");
|
|
|
298
|
+ if (!string.IsNullOrEmpty(strWhere.Trim()))
|
|
|
299
|
+ {
|
|
|
300
|
+ strSql.Append(" WHERE " + strWhere);
|
|
|
301
|
+ }
|
|
|
302
|
+ strSql.Append(" ) TT");
|
|
|
303
|
+ strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
|
|
304
|
+ return DbHelperSQL.Query(strSql.ToString());
|
|
|
305
|
+ }
|
|
|
306
|
+
|
|
|
307
|
+ /*
|
|
|
308
|
+ /// <summary>
|
|
|
309
|
+ /// 分页获取数据列表
|
|
|
310
|
+ /// </summary>
|
|
|
311
|
+ public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
|
|
312
|
+ {
|
|
|
313
|
+ SqlParameter[] parameters = {
|
|
|
314
|
+ new SqlParameter("SQL2012tblName", SqlDbType.VarChar, 255),
|
|
|
315
|
+ new SqlParameter("SQL2012fldName", SqlDbType.VarChar, 255),
|
|
|
316
|
+ new SqlParameter("SQL2012PageSize", SqlDbType.Int),
|
|
|
317
|
+ new SqlParameter("SQL2012PageIndex", SqlDbType.Int),
|
|
|
318
|
+ new SqlParameter("SQL2012IsReCount", SqlDbType.Bit),
|
|
|
319
|
+ new SqlParameter("SQL2012OrderType", SqlDbType.Bit),
|
|
|
320
|
+ new SqlParameter("SQL2012strWhere", SqlDbType.VarChar,1000),
|
|
|
321
|
+ };
|
|
|
322
|
+ parameters[0].Value = "T_Sys_CustomFiled";
|
|
|
323
|
+ parameters[1].Value = "F_Id";
|
|
|
324
|
+ parameters[2].Value = PageSize;
|
|
|
325
|
+ parameters[3].Value = PageIndex;
|
|
|
326
|
+ parameters[4].Value = 0;
|
|
|
327
|
+ parameters[5].Value = 0;
|
|
|
328
|
+ parameters[6].Value = strWhere;
|
|
|
329
|
+ return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
|
|
|
330
|
+ }*/
|
|
|
331
|
+
|
|
|
332
|
+ #endregion BasicMethod
|
|
|
333
|
+ #region ExtensionMethod
|
|
|
334
|
+
|
|
|
335
|
+ #endregion ExtensionMethod
|
|
|
336
|
+ }
|
|
|
337
|
+}
|