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
150
151
152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CY.IDAL.Inquiry;
using System.Data.SqlClient;
using System.Data;
using CY.Model;
 
namespace CY.SQLDAL
{
    /// <summary>
    /// 绳子类型管理接口--SQL实现
    /// </summary>
    public class SysInquiry_RopeTypeDAL : ISysInquiry_RopeTypeDAL
    {
        private Database _dataBase = null;
 
        public SysInquiry_RopeTypeDAL()
        {
            _dataBase = new Database();
        }
 
        public IEnumerable<Model.SysInquiry_RopeType> SelectModelPage(string typeName, string status, Infrastructure.Query.Pagination pagination)
        {
            string condition = string.Empty;
            condition = " 1=1 ";
            if (!string.IsNullOrEmpty(typeName))
            {
                condition += " and RopeTypeName like '%" + typeName + "%' ";
            }
            if (!string.IsNullOrEmpty(status))
            {
                condition += " and Status='" + status+"'" ;
            }
            return _dataBase.SelectModelPage<SysInquiry_RopeType>(pagination, "*", "SysInquiry_RopeType", "OrderNum", "OrderNum", condition);
        }
 
        public Model.SysInquiry_RopeType SelectModelByKey(int keyid)
        {
            string condition = string.Empty;
            condition = " KeyId=" + keyid;
            IList<SysInquiry_RopeType> result = _dataBase.SelectModel<SysInquiry_RopeType>("*", "SysInquiry_RopeType", condition);
            return null == result || result.Count == 0 ? null : result[0];
        }
 
        public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
        {
            Model.SysInquiry_RopeType trueModel = model as Model.SysInquiry_RopeType;
            if (trueModel == null)
            {
                return false;
            }
            IList<SqlParameter> sqlParms = new List<SqlParameter>()
            {
                    new SqlParameter("@RopeTypeName",trueModel.RopeTypeName),
                    new SqlParameter("@Status",trueModel.Status),
                    new SqlParameter("@OrderNum",trueModel.OrderNum)
            };
            try
            {
                _dataBase.Query("SysInquiry_RopeType_ADD", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return true;
        }
 
        public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
        {
            Model.SysInquiry_RopeType trueModel = model as Model.SysInquiry_RopeType;
            if (trueModel == null)
            {
                return false;
            }
            IList<SqlParameter> sqlParms = new List<SqlParameter>()
            {
                    new SqlParameter("@KeyId",trueModel.KeyId),
                    new SqlParameter("@RopeTypeName",trueModel.RopeTypeName),
                    new SqlParameter("@Status",trueModel.Status),
                    new SqlParameter("@OrderNum",trueModel.OrderNum)
            };
            try
            {
                _dataBase.Query("SysInquiry_RopeType_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_RopeType> result = _dataBase.SelectModel<SysInquiry_RopeType>(" MAX(OrderNum)+1 AS OrderNum ", "SysInquiry_RopeType", "");
                if (result != null && result.Count > 0)
                {
                    orderNum = result[0].OrderNum;
                }
            }
            catch
            {
                orderNum = 1;
            }
            return orderNum;
        }
 
 
        public IList<SysInquiry_RopeType> GetModelList()
        {
            string condition = string.Empty;
            condition = " Status='true' order by orderNum ";
            IList<SysInquiry_RopeType> result = _dataBase.SelectModel<SysInquiry_RopeType>("*", "SysInquiry_RopeType", condition);
 
            return result;
        }
 
        /// <summary>
        /// 判断是否存在相同的数据
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool IsExist(string ropeTypeName)
        {
            bool isExist = false;
            string condition = string.Empty;
            condition = " RopeTypeName='" + ropeTypeName + "' ";
            IList<SysInquiry_RopeType> result = _dataBase.SelectModel<SysInquiry_RopeType>("*", "SysInquiry_RopeType", condition);
            if (result != null && result.Count > 0)
            {
                isExist = true;
            }
            return isExist;
        }
    }
}