username@email.com
2025-05-21 a980cd04341d71216e0f59bd4b7327fe9fc50032
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CY.Model;
using System.Data.SqlClient;
using System.Data;
using CY.IDAL.Inquiry;
 
namespace CY.SQLDAL
{
    public class SysInquiry_LEDMaterialDAL : ISysInquiry_LEDMaterialDAL
    {
        private Database _dataBase = null;
 
        public SysInquiry_LEDMaterialDAL()
        {
            _dataBase = new Database();
        }
 
        public IEnumerable<Model.SysInquiry_LEDMaterial> SelectModelPage(string name, string status, Infrastructure.Query.Pagination pagination)
        {
            string condition = string.Empty;
            condition = " 1=1 ";
            if (!string.IsNullOrEmpty(name))
            {
                condition += " and name like '%" + name + "%' ";
            }
            if (!string.IsNullOrEmpty(status))
            {
                condition += " and Status='" + status+"'" ;
            }
            return _dataBase.SelectModelPage<SysInquiry_LEDMaterial>(pagination, "*", "SysInquiry_LEDMaterial", "OrderNum", "OrderNum", condition);
        }
 
        public Model.SysInquiry_LEDMaterial SelectModelByKey(int keyid)
        {
            string condition = string.Empty;
            condition = " KeyId=" + keyid;
            IList<SysInquiry_LEDMaterial> result = _dataBase.SelectModel<SysInquiry_LEDMaterial>("*", "SysInquiry_LEDMaterial", condition);
            return null == result || result.Count == 0 ? null : result[0];
        }
 
        public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
        {
            Model.SysInquiry_LEDMaterial trueModel = model as Model.SysInquiry_LEDMaterial;
            if (trueModel == null)
            {
                return false;
            }
            IList<SqlParameter> sqlParms = new List<SqlParameter>()
            {
                    new SqlParameter("@Name",trueModel.Name),
                    new SqlParameter("@Status",trueModel.Status),
                    new SqlParameter("@OrderNum",trueModel.OrderNum)
            };
            try
            {
                _dataBase.Query("SysInquiry_LEDMaterial_ADD", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return true;
        }
 
        public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
        {
            Model.SysInquiry_LEDMaterial trueModel = model as Model.SysInquiry_LEDMaterial;
            if (trueModel == null)
            {
                return false;
            }
            IList<SqlParameter> sqlParms = new List<SqlParameter>()
            {
                    new SqlParameter("@KeyId",trueModel.KeyId),
                    new SqlParameter("@Name",trueModel.Name),
                    new SqlParameter("@Status",trueModel.Status),
                    new SqlParameter("@OrderNum",trueModel.OrderNum)
            };
            try
            {
                _dataBase.Query("SysInquiry_LEDMaterial_Update", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return true;
        }
 
 
        public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
        {
            throw new NotImplementedException();
        }
 
        /// <summary>
        /// 获取最新排序顺序
        /// </summary>
        /// <returns></returns>
        public int GetOrderNumByMax()
        {
            int orderNum = 1;
            try
            {
                IList<SysInquiry_LEDMaterial> result = _dataBase.SelectModel<SysInquiry_LEDMaterial>(" MAX(OrderNum)+1 AS OrderNum ", "SysInquiry_LEDMaterial", "");
                if (result != null && result.Count > 0)
                {
                    orderNum = result[0].OrderNum;
                }
            }
            catch
            {
                orderNum = 1;
            }
            return orderNum;
        }
 
 
        public IList<SysInquiry_LEDMaterial> GetModelList()
        {
            string condition = string.Empty;
            condition = " Status='true' order by orderNum ";
            IList<SysInquiry_LEDMaterial> result = _dataBase.SelectModel<SysInquiry_LEDMaterial>("*", "SysInquiry_LEDMaterial", condition);
 
            return result;
        }
 
        /// <summary>
        /// 判断是否存在相同的数据
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool IsExist(string name)
        {
            bool isExist = false;
            string condition = string.Empty;
            condition = " name='" + name + "' ";
            IList<SysInquiry_LEDMaterial> result = _dataBase.SelectModel<SysInquiry_LEDMaterial>("*", "SysInquiry_LEDMaterial", condition);
            if (result != null && result.Count > 0)
            {
                isExist = true;
            }
            return isExist;
        }
    }
}