bklLiudl
2024-07-23 675b8bcc4a3630d95e3d0b97d933e63442075ecb
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
using System;
using System.Collections.Generic;
using System.Text;
using Model;
using Common;
using System.Data;
using System.Collections;
 
namespace BLL
{
    public class DALOrdType : IDALOrdType
    {
        public IList<OrdType> GetList()
        {
            try
            {
                IList<OrdType> ls = new List<OrdType>();
                StringBuilder strSql = new StringBuilder();
                strSql.Append("Select Id,OrdTypeNo,OrdTypeName,Demo,Demo1,Demo2 from OrdType where IsDel !=1");
                
                IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
                ls = ModelConvertHelper<OrdType>.DataReaderToModel(dt);
 
                return ls;
            }
            catch
            { 
            throw new NotImplementedException();
            }
        }
 
        public IList<OrdType> GetList(AjaxOrdTypeList Json,ref PageInfo page)
        {
            try
            {
 
                IList<OrdType> list = new List<OrdType>();
                StringBuilder strSql = new StringBuilder();
                List<SqlParam> para = new List<SqlParam>();
                strSql.Append("Select ID,OrdTypeNo,OrdTypeName,Demo,Demo1,Demo2 from OrdType ");
 
                if (!string.IsNullOrEmpty(Json.OrdTypeNo))
                {
                    if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
                    strSql.Append("OrdTypeNo like '%' + @OrdTypeNo + '%' ");
                    para.Add(new SqlParam("@OrdTypeNo", Json.OrdTypeNo));
                }
 
                if (!string.IsNullOrEmpty(Json.OrdTypeName))
                {
                    if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
                    strSql.Append("OrdTypeName like '%' + @OrdTypeName + '%'  ");
                    para.Add(new SqlParam("@OrdTypeName", Json.OrdTypeName));
                }
 
                SqlParam[] param = null;
                if (para != null)
                    param = para.ToArray();
 
                DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "ID", "Asc", ref page);
                list = ModelConvertHelper<OrdType>.DataTableToModel(dt);
 
                return list;
            }
            catch
            {
                throw new NotImplementedException();
            }
 
        }
 
 
        public OrdType GetModel(string OrdTypeNo)
        {
            try
            {
                OrdType us = null;
                StringBuilder strSql = new StringBuilder();
                strSql.Append("Select OrdTypeNo,OrdTypeName,Demo,Demo1,Demo2 from OrdType where ");
                strSql.Append("OrdTypeNo = @OrdTypeNo ");
                
                SqlParam[] para = new SqlParam[]
                {
                    new SqlParam("@OrdTypeNo", OrdTypeNo),
                };
 
                IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
 
                us = ModelConvertHelper<OrdType>.ReaderToModel(dt);
 
                return us;
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
 
 
        public bool Add(OrdType model)
        {
            bool result = false;
            try
            {
                Hashtable ht = new Hashtable();
 
                ht["OrdTypeNo"] = "'" + model.OrdTypeNo + "'";
                ht["OrdTypeName"] = "'" + model.OrdTypeName + "'";
     
                ht["Demo"] = "'" + model.Demo + "'";
 
                int _ret = DataFactory.SqlDataBase().InsertByHashtableNullParam("OrdTypeNo", ht);
 
                if (_ret == 1) result = true;
                return result;
            }
            catch
            {
                return result;
            }
        }
 
        public bool Update(OrdType model)
        {
            bool result = false;
            try
            {
                Hashtable ht = new Hashtable();
 
                ht["StorageName"] = string.IsNullOrEmpty(model.OrdTypeName) ? "''" : "'" + model.OrdTypeName + "'";
                ht["Demo"] = string.IsNullOrEmpty(model.Demo) ? "''" : "'" + model.Demo + "'";
 
                string OrdTypeNo = "'" + model.OrdTypeNo + "'";
 
                int _ret = DataFactory.SqlDataBase().UpdateByHashtable("OrdType", nameof(model.OrdTypeNo), OrdTypeNo, ht);
 
                if (_ret == 1) result = true;
 
                return result;
 
            }
            catch
            {
                return result;
            }
        }
        public bool IsExist(string name, string value)
        {
            bool result = false;
            try
            {
                string[] para = new string[] { value };
                int dt = DataFactory.SqlDataBase().IsExist("OrdTypeNo", name, para);
                if (dt > 0) result = true;
                return result;
            }
            catch
            {
                return result;
            }
 
        }
 
        public DataTable GetDataTable(string[] strWhere)
        {
            DataTable dt = null;
            try
            {
                int index = 0;
                string str = "@RoleNum" + index;
                SqlParam[] param = new SqlParam[strWhere.Length];
                StringBuilder sql = new StringBuilder();
                sql.Append("Select RoleNum as 角色编号, RoleName as 角色名,CreatUser as 创建人,CreatTime as 创建时间,UpdateUser as 更新人,UpdateTime as 更新时间,Demo as 备注 FROM View_GetRoles where RoleNum in (");
 
                for (int i = 0; i < param.Length - 1; i++)
                {
                    string obj2 = strWhere[i];
                    str = "@RoleNum" + index;
                    sql.Append(str).Append(",");
                    param[index] = new SqlParam(str, obj2);
                    index++;
                }
                str = "@RoleNum" + index;
                sql.Append(str);
                param[index] = new SqlParam(str, strWhere[index]);
                sql.Append(")");
 
                dt = DataFactory.SqlDataBase().GetDataTableBySQL(sql, param, "");
 
                return dt;
 
            }
            catch
            {
                throw new NotImplementedException();
            }
 
        }
        public bool BatchDelete(string[] RoleNum)
        {
            bool result = false;
            try
            {
                int dt = DataFactory.SqlDataBase().IsExist("StorageArea", "StorageNo", RoleNum);
                if (dt >= RoleNum.Length)
                {
                    int _ret = DataFactory.SqlDataBase().BatchDeleteData("StorageArea", "StorageNo", RoleNum);
                    if (_ret >= RoleNum.Length) result = true;
                }
                return result;
            }
            catch
            {
                return result;
            }
        }
    }
}