bklLiudl
2024-07-23 277bbae216debe7e6c04e8cc6ee6e1ba9763e14b
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
219
220
221
222
223
224
225
226
227
228
229
230
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Text;
using Commom.Utility;
using Common;
using Model;
 
namespace BLL
{
    public class DALUnit : IDALUnit
    {
        public bool Add(Unit model, string loginUser)
        {
            bool result = false;
            try
            {
                Hashtable ht = new Hashtable();
 
                ht["UnitNum"] = "'" + model.UnitNum + "'";
                ht["UnitName"] = "'" + model.UnitName + "'";
               
                ht["CreatUser"] = "'" + loginUser + "'";
                ht["Demo"] = "'" + model.Demo + "'";
 
                int _ret = DataFactory.SqlDataBase().InsertByHashtableNullParam("Unit", ht);
 
                if (_ret == 1) result = true;
 
                return result;
 
            }
            catch
            {
                return result;
            }
        }
        //审核
        public bool AnditUnit(string[] UnitNum, string AuditModel,string User)
        {
            bool result = false;
            try
            {
                int dt = DataFactory.SqlDataBase().IsExist("Log_Unit", "UnitNum", UnitNum);
                if (dt >= UnitNum.Length)
                {
                    Hashtable ht = new Hashtable();
 
                    ht["AuditFlag"] = string.IsNullOrEmpty(AuditModel) ? "'AD01'" : "'" + AuditModel + "'";
                    ht["AuditUser"] ="'"+ User+"'";
                    ht["AuditTime"] = "getdate()";
                    int _ret = DataFactory.SqlDataBase().UpdateByHashtableA("Unit", "UnitNum", UnitNum, ht);
 
                    if (_ret >= UnitNum.Length) result = true;
                }
                return result;
 
            }
            catch
            {
                return result;
            }
        }
 
        public bool BatchDelete(string[] UnitNum)
        {
            bool result = false;
            try
            {
                int i = 0;
                int _ret = 0;
                while (i < UnitNum.Length)
                {
                    StringBuilder sql = new StringBuilder();
                    sql.Append("update Unit set IsDel=1 where Guid='" + UnitNum[i] + "'");
                    _ret += DataFactory.SqlDataBase().ExecuteBySql(sql);
                    if (_ret >= UnitNum.Length) 
                    {
                        result = true;
                    }
                    
                    i++;
                }
 
                return result;
            }
            catch
            {
                return result;
            }
        }
 
        public bool Delete(string UnitNum)
        {
            throw new NotImplementedException();
        }
 
        public DataTable GetDataTable(string[] strWhere)
        {
            throw new NotImplementedException();
        }
 
        public DataTable GetDataTable(int PageSize, int PageIndex, string strWhere)
        {
            throw new NotImplementedException();
        }
 
        public IList<Unit> GetUnitList()
        {
            try
            {
 
                IList<Unit> ls = new List<Unit>();
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select UnitName,UnitNum,guid from Unit where IsDel = 0 order by creatTime");
 
                IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
                ls = ModelConvertHelper<Unit>.DataReaderToModel(dt);
 
                return ls;
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
 
        public IList<Unit> GetList(AjaxUnitList Json, ref PageInfo pageInfo)
        {
            try
            {
 
                IList<Unit> list = new List<Unit>();
                StringBuilder strSql = new StringBuilder();
                List<SqlParam> para = new List<SqlParam>();
                strSql.Append("Select * from view_Log_Unit ");
 
 
                if (Json.UnitNum != null && Json.UnitNum != "")
                {
                    if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
                    strSql.Append("UnitNum like '%' + @UnitNum + '%' ");
                    para.Add(new SqlParam("@UnitNum", Json.UnitNum));
                }
 
                if (Json.UnitName != null && Json.UnitName != "")
                {
                    if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
                    strSql.Append("UnitName like '%' + @UnitName + '%'  ");
                    para.Add(new SqlParam("@UnitName", Json.UnitName));
                }
 
                if (para.Count < 1) strSql.Append("where IsDel = 0"); else strSql.Append(" and  IsDel = 0");
 
                SqlParam[] param = null;
                if (para != null)
                    param = para.ToArray();
 
 
                DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "CreatTime", "DESC", ref pageInfo);
 
                list = ModelConvertHelper<Unit>.DataTableToModel(dt);
 
                return list;
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
 
        public Unit GetModel(string UnitNum)
        {
            try
            {
                Unit us = null;
                StringBuilder strSql = new StringBuilder();
                strSql.Append("Select * from view_Log_Unit where ");
                strSql.Append("Guid = @UnitNum ");
 
                SqlParam[] para = new SqlParam[]
                {
                    new SqlParam("@UnitNum", UnitNum),
                };
 
                IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
 
                us = ModelConvertHelper<Unit>.ReaderToModel(dt);
 
                return us;
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
 
        public bool IsExist(string sqlWhere)
        {
            return DataFactory.SqlDataBase().IsExist("Unit", sqlWhere);
        }
 
        public bool Update(Unit model, string loginUser)
        {
            bool result = false;
            try
            {
                Hashtable ht = new Hashtable();
                ht["UnitName"] = model.UnitName.AddQuotes();
                ht["Demo"] =  model.Demo.AddQuotes();
                ht["UpdateTime"] = "convert(varchar(20),getdate(),120)";
                ht["UpdateUser"] = loginUser.AddQuotes();
 
                string UnitNum =  model.UnitNum.AddQuotes();
 
                int _ret = DataFactory.SqlDataBase().UpdateByHashtable("Unit", "UnitNum", UnitNum, ht);
 
                if (_ret == 1) result = true;
 
                return result;
 
            }
            catch
            {
                return result;
            }
        }
    }
}