duan
2024-08-21 22bd5bc1ce2b49284cc2f042c7f4f48619fcf85b
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
using DIXWeb.DAL;
using DIXWeb.Entity.GlobalM;
using DIXWeb.Entity.Workflow;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace DIXWeb.Business.Workflow
{
    public class BillBusiness
    {
        public List<BillType> GetWorkflowBillType()
        {
            List<BillType> list = null;
            using (DBContext db = new DBContext())
            {
                list = db.BillType.ToList();
            }
            return list;
        }
 
        public ReceiveBill GetBillById(int BillId)
        {
            ReceiveBill record = null;
            using (DBContext db = new DBContext())
            {
                System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                    new System.Data.SqlClient.SqlParameter("@BillId", BillId),
                };
                record = db.Database.SqlQuery<ReceiveBill>("EXEC meta.p_getBillById @BillId ", paramList).FirstOrDefault();
            }
            return record;
        }
 
        public Receive SubmitBill(string Code, string Name, int BillTypeId, int UserId)
        {
            Receive record = null;
            using (DBContext db = new DBContext())
            {
                System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                    new System.Data.SqlClient.SqlParameter("@Code", Code),
                    new System.Data.SqlClient.SqlParameter("@Name", Name),
                    new System.Data.SqlClient.SqlParameter("@BillTypeId", BillTypeId),
                    new System.Data.SqlClient.SqlParameter("@UserId", UserId),
                };
                record = db.Database.SqlQuery<Receive>("EXEC meta.p_submitBill @Code,@Name,@BillTypeId,@UserId ", paramList).FirstOrDefault();
            }
            return record;
        }
 
        public Receive SubmitBill(int BookId, int BillTypeId, int UserId)
        {
            Receive record = null;
            using (DBContext db = new DBContext())
            {
                System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                    new System.Data.SqlClient.SqlParameter("@BookId", BookId),
                    new System.Data.SqlClient.SqlParameter("@BillTypeId", BillTypeId),
                    new System.Data.SqlClient.SqlParameter("@UserId", UserId),
                };
                record = db.Database.SqlQuery<Receive>("EXEC biz.p_submitInspectBook @BookId,@BillTypeId,@UserId ", paramList).FirstOrDefault();
            }
            return record;
        }
 
 
        public Receive ReckDataUpdateHistory(int InspectBookId,string FilterType, int rows, int page)
        {
            int Total = 0;
            Receive record = new Receive();
            try
            {
                using (DBContext db = new DBContext())
                {
                    System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                        new System.Data.SqlClient.SqlParameter("@InspectBookId", InspectBookId),
                        new System.Data.SqlClient.SqlParameter("@pageSize", rows),
                        new System.Data.SqlClient.SqlParameter("@pageIndex", page),
                        new System.Data.SqlClient.SqlParameter("@filterType", FilterType),
                        new System.Data.SqlClient.SqlParameter("@Total", Total),
                    };
                    int index = paramList.Length - 1;
                    paramList[index].Direction = ParameterDirection.Output;
                    record.rows = db.Database.SqlQuery<ReceiveInspectDetail>("exec biz.p_getReckDataUpdateHistory @InspectBookId,@pageSize,@pageIndex,@filterType,@Total output ", paramList).ToList();
                    record.total = int.Parse(paramList[index].Value.ToString());
                }
                record.Code = 200;
                record.Message = "SUCCESS";
            }
            catch (Exception ex)
            {
                record.Code = 500;
                record.Message = ex.Message;
            }
            return record;
        }
 
        public Receive ReckImgUpdateHistory(int InspectBookId,string FilterType, int rows, int page)
        {
            int Total = 0;
            Receive record = new Receive();
            try
            {
                using (DBContext db = new DBContext())
                {
                    System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                        new System.Data.SqlClient.SqlParameter("@InspectBookId", InspectBookId),
                        new System.Data.SqlClient.SqlParameter("@pageSize", rows),
                        new System.Data.SqlClient.SqlParameter("@pageIndex", page),
                        new System.Data.SqlClient.SqlParameter("@filterType", FilterType),
                        new System.Data.SqlClient.SqlParameter("@Total", Total),
                    };
                    int index = paramList.Length - 1;
                    paramList[index].Direction = ParameterDirection.Output;
                    record.rows = db.Database.SqlQuery<ReceiveReckImgHistory>("exec biz.p_getReckImgUpdateHistory @InspectBookId,@pageSize,@pageIndex,@filterType,@Total output ", paramList).ToList();
                    record.total = int.Parse(paramList[index].Value.ToString());
                }
                record.Code = 200;
                record.Message = "SUCCESS";
            }
            catch (Exception ex)
            {
                record.Code = 500;
                record.Message = ex.Message;
            }
            return record;
        }
 
        public Receive GetInspectBook(string InspectObjectCode, DateTime TimeBegin, DateTime TimeEnd, int Status, int rows, int page,string filterType,int UserId )
        {
            int Total = 0;
            Receive record = new Receive();
            try
            {
                using (DBContext db = new DBContext())
                {
                    System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                        new System.Data.SqlClient.SqlParameter("@InspectObjectCode", InspectObjectCode),
                        new System.Data.SqlClient.SqlParameter("@TimeBegin", TimeBegin),
                        new System.Data.SqlClient.SqlParameter("@TimeEnd", TimeEnd),
                        new System.Data.SqlClient.SqlParameter("@Status", Status),
                        new System.Data.SqlClient.SqlParameter("@pageSize", rows),
                        new System.Data.SqlClient.SqlParameter("@pageIndex", page),
                        new System.Data.SqlClient.SqlParameter("@FilterType", filterType),
                        new System.Data.SqlClient.SqlParameter("@UserId", UserId),
                        new System.Data.SqlClient.SqlParameter("@Total", Total),
                    };
                    int index = paramList.Length - 1;
                    paramList[index].Direction = ParameterDirection.Output;
                    record.rows = db.Database.SqlQuery<ReceiveInspectBook>("exec biz.p_getInspectBook @InspectObjectCode,@TimeBegin,@TimeEnd,@Status,@pageSize,@pageIndex,@FilterType,@UserId,@Total output ", paramList).ToList();
                    record.total = int.Parse(paramList[index].Value.ToString());
                }
                record.Code = 200;
                record.Message = "SUCCESS";
            }
            catch (Exception ex)
            {
                record.Code = 500;
                record.Message = ex.Message;
            }
            return record;
        }
 
        public Receive GetFalseInspectBook(int InspectAreaId, int InspectObjectTypeId, string InspectObjectCode, DateTime TimeBegin, DateTime TimeEnd, int rows, int page)
        {
            int Total = 0;
            Receive record = new Receive();
            try
            {
                using (DBContext db = new DBContext())
                {
                    System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                        new System.Data.SqlClient.SqlParameter("@InspectAreaId", InspectAreaId),
                        new System.Data.SqlClient.SqlParameter("@InspectObjectTypeId", InspectObjectTypeId),
                        new System.Data.SqlClient.SqlParameter("@InspectObjectCode", InspectObjectCode),
                        new System.Data.SqlClient.SqlParameter("@TimeBegin", TimeBegin),
                        new System.Data.SqlClient.SqlParameter("@TimeEnd", TimeEnd),
                        new System.Data.SqlClient.SqlParameter("@pageSize", rows),
                        new System.Data.SqlClient.SqlParameter("@pageIndex", page),
                        new System.Data.SqlClient.SqlParameter("@Total", Total),
                    };
                    int index = paramList.Length - 1;
                    paramList[index].Direction = ParameterDirection.Output;
                    record.rows = db.Database.SqlQuery<ReceiveInspectBook>("exec biz.p_getFalseInspectBook @InspectAreaId,@InspectObjectTypeId,@InspectObjectCode,@TimeBegin,@TimeEnd,@pageSize,@pageIndex,@Total output ", paramList).ToList();
                    record.total = int.Parse(paramList[index].Value.ToString());
                }
                record.Code = 200;
                record.Message = "SUCCESS";
            }
            catch (Exception ex)
            {
                record.Code = 500;
                record.Message = ex.Message;
            }
            return record;
        }
 
 
        public Receive GetInspectDetailByBookId(int BookId,string filterType)
        {
            int Total = 0;
            Receive record = new Receive();
            try
            {
                using (DBContext db = new DBContext())
                {
                    System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                        new System.Data.SqlClient.SqlParameter("@BookId", BookId),
                        new System.Data.SqlClient.SqlParameter("@filterType", filterType),
                        new System.Data.SqlClient.SqlParameter("@Total", Total),
                    };
                    int index = paramList.Length - 1;
                    paramList[index].Direction = ParameterDirection.Output;
                    record.rows = db.Database.SqlQuery<ReceiveInspectDetail>("exec biz.p_getInspectDetailByBookId @BookId,@filterType,@Total output ", paramList).ToList();
                    if (string.IsNullOrEmpty(paramList[index].Value.ToString()))
                    {
                        record.total = 0;
                    }
                    else
                    {
                        record.total = int.Parse(paramList[index].Value.ToString());
                    }
                }
                record.Code = 200;
                record.Message = "SUCCESS";
            }
            catch (Exception ex)
            {
                record.Code = 500;
                record.Message = ex.Message;
            }
            return record;
        }
 
 
        public Receive UpdateInspectReck(int InspectReckId, string InspectLimit, int Judge, string NGReason, int DealInScene, string Answer, string InspectOperator,string FilterType)
        {
            Receive receive = new Receive();
            try
            {
                using (DBContext db = new DBContext())
                {
                    System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                        new System.Data.SqlClient.SqlParameter("@InspectReckId", InspectReckId),
                        new System.Data.SqlClient.SqlParameter("@InspectLimit", InspectLimit),
                        new System.Data.SqlClient.SqlParameter("@Judge", Judge),
                        new System.Data.SqlClient.SqlParameter("@NGReason", NGReason),
                        new System.Data.SqlClient.SqlParameter("@DealInScene", DealInScene),
                        new System.Data.SqlClient.SqlParameter("@Answer", Answer),
                        new System.Data.SqlClient.SqlParameter("@InspectOperator", InspectOperator),
                        new System.Data.SqlClient.SqlParameter("@filterType", FilterType),
                    };
                    receive = db.Database.SqlQuery<Receive>("exec biz.p_updateInspectReck @InspectReckId,@InspectLimit,@Judge,@NGReason,@DealInScene,@Answer,@InspectOperator,@filterType ", paramList).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                receive.Code = 500;
                receive.Message = ex.Message;
            }
            return receive;
        }
 
        public Receive UpdateInspectReck(int InspectReckId, string ImgArrStr, string InspectOperator,string FilterType)
        {
            Receive receive = new Receive();
            try
            {
                using (DBContext db = new DBContext())
                {
                    System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                        new System.Data.SqlClient.SqlParameter("@InspectReckId", InspectReckId),
                        new System.Data.SqlClient.SqlParameter("@ImgArrStr", ImgArrStr),
                        new System.Data.SqlClient.SqlParameter("@InspectOperator", InspectOperator),
                        new System.Data.SqlClient.SqlParameter("@filterType", FilterType),
                    };
                    receive = db.Database.SqlQuery<Receive>("exec biz.p_updateInspectReckImg @InspectReckId,@ImgArrStr,@InspectOperator,@filterType ", paramList).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                receive.Code = 500;
                receive.Message = ex.Message;
            }
            return receive;
        }
        public string GetNeedDealtNumByUserCode(string UserNo)
        {
            string result = string.Empty;
            try
            {
                using (DBContext db = new DBContext())
                {
                    System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                        new System.Data.SqlClient.SqlParameter("@UserCode", UserNo),
                    };
                    result = db.Database.SqlQuery<string>("exec biz.p_GetNeedDealtNumByUserCode @UserCode ", paramList).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
                result = "";
            }
            return result;
        }
 
 
    }
}