username@email.com
2025-05-12 ae6e40362a745caef9ead36f81f38313fb8c2c66
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CY.IDAL.Sys;
using CY.Model;
using System.Data.SqlClient;
using System.Data;
using System.Transactions;
 
namespace CY.SQLDAL
{
    public class LogDAL : ILogDAL
    {
 
        private Database _dataBase = null;
 
        public LogDAL()
        {
            _dataBase = new Database();
        }
 
        public IEnumerable<Model.Log> SelectModelPage(string startTime, string endTime, Infrastructure.Query.Pagination pagination)
        {
            string condition = " 1=1 ";
            if (!string.IsNullOrEmpty(startTime))
            {
                condition += " and CAST(Date AS date)>='" + startTime + "'";
            }
 
            if (!string.IsNullOrEmpty(endTime))
            {
                condition += " and CAST(Date AS date)<='" + endTime + "'";
            }
 
            return _dataBase.SelectModelPage<Log>(pagination, "*", "Log", "Date Desc", "Date Desc", condition);
        }
 
        public bool DeleteModel(int id)
        {
            bool isSuccess = false;
            try
            {
                string sqlStr = "delete from Log where Id=@Id";
                SqlParameter[] pars = new SqlParameter[]{
                    new SqlParameter("@Id",SqlDbType.Int,4)
                };
                pars[0].Value = id;
                isSuccess = (_dataBase.ExecuteSql(sqlStr, pars) > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return isSuccess;
        }
 
        public bool DeleteModeList(IList<int> idList)
        {
            bool isSuccess = true;
            if (idList != null && idList.Count > 0)
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    foreach (int id in idList)
                    {
                        isSuccess = DeleteModel(id);
                        if (!isSuccess)
                            break;
                    }
                    if (isSuccess)
                        scope.Complete();
                }
            }
            return isSuccess;
        }
 
        public Log GetModel(int id)
        {
            Log model = null;
            string condition = " id=" + id;
            IList<Log> list = _dataBase.SelectModel<Log>("*", "Log",condition);
            if (list != null && list.Count > 0)
            {
                model = list[0];
            }
            return model;
        }
    }
}