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
using System;
using System.Collections.Generic;
using System.Text;
using Model;
using Common;
using System.Data;
using System.Collections;
 
namespace BLL.DAL
{
    public class DALDeliveryOutDetail
    {
        public IList<DeliveryOutDetail> GetList(AjaxOutDetail Json, ref PageInfo page)
        {
            try
            {
                string viewName = "View_DeliveryOutDetail";
                if (Json.OrdnoType == "IN")
                {
                    viewName = "View_DeliveryInDetail";
                }
 
                StringBuilder sqlString = new StringBuilder();
                sqlString.Append("select * from " + viewName + " where 1=1 " + $" AND DepartGuid='{Json.DepartGuid}' ");
                if (!string.IsNullOrEmpty(Json.LingNo))
                {
                    sqlString.Append("and LingNo like '%" + Json.LingNo + "%' ");
                }
                if (!string.IsNullOrEmpty(Json.PageNo))
                {
                    sqlString.Append("and PageNo like '%" + Json.PageNo + "%' ");
                }
                if (!string.IsNullOrEmpty(Json.MatNo))
                {
                    sqlString.Append("and MatNo like '%" + Json.MatNo + "%' ");
                }
                if (!string.IsNullOrEmpty(Json.MatName))
                {
                    sqlString.Append("and MatName like '%" + Json.MatName + "%' ");
                }
                if (!string.IsNullOrEmpty(Json.PickerUser))
                {
                    sqlString.Append("and PickerUser like '%" + Json.PickerUser + "%' ");
                }
                if (!string.IsNullOrEmpty(Json.MatType))
                {
                    sqlString.Append("and MatType = '" + Json.MatType + "' ");
                }
                // 时间段
                if (Json.BeginTime != DateTime.MinValue && Json.BeginTime != null && Json.BeginTime != DateTime.MaxValue)
                {
                    sqlString.Append("and CreateTime >= '" + Convert.ToDateTime(Json.BeginTime) + "' ");
                }
 
                // 合格证判定
                if (!string.IsNullOrEmpty(Json.Certificate))
                {
                    if (Json.Certificate == "有")
                    {
                        sqlString.Append("and LEN(isnull(certificate,'')) > 0 ");
                    }
                    else
                    {
                        sqlString.Append("and LEN(isnull(certificate,'')) = 0 ");
                    }
                }
 
                if (Json.EndTime != DateTime.MinValue && Json.EndTime != null && Json.EndTime != DateTime.MaxValue)
                {
                    sqlString.Append("and CreateTime <= '" + Convert.ToDateTime(Json.EndTime).ToShortDateString() + " 23:59:59.999" + "' ");
                }
 
                SqlParam[] para = new SqlParam[] { };
                DataTable dt = DataFactory.SqlDataBase().GetPageList(sqlString.ToString(), para, "CreateTime", "DESC", ref page);
                IList<DeliveryOutDetail> list = ModelConvertHelper<DeliveryOutDetail>.DataTableToModel(dt);
 
                return list;
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
 
        public DeliveryOutDetail GetCertificate(string ordNo, string matNo)
        {
            try
            {
                StringBuilder sqlString = new StringBuilder();
                sqlString.Append("select *,HeGeZheng as Certificate from ErpInDetail where ordno='" + ordNo);
                sqlString.Append("'and MatNo = '" + matNo + "';");
                DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(sqlString);
 
                IList<DeliveryOutDetail> list = ModelConvertHelper<DeliveryOutDetail>.DataTableToModel(dt);
                return list[0];
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
 
        public bool SetCertificates(DeliveryOutDetail model)
        {
            bool bl = false;
            try
            {
                if (String.IsNullOrEmpty(model.MatNo) || string.IsNullOrEmpty(model.OrdNo))
                {
                    return bl;
                }
 
                StringBuilder sqlString = new StringBuilder();
                sqlString.Append("UPDATE ErpInDetail SET HeGeZheng = '" + model.Certificate + "',");
                sqlString.Append("Demo='" + model.Demo + "',PalNo='补录合格证' ");
                sqlString.Append("WHERE OrdNo = '" + model.OrdNo + "' AND MatNo='" + model.MatNo + "';");
 
                int rowCount = DataFactory.SqlDataBase().ExecuteBySql(sqlString);
                if (rowCount > 0)
                {
                    bl = true;
                }
 
                return bl;
            }
            catch (Exception)
            {
                return bl;
            }
        }
    }
}