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
using BLL.IDAL;
using Common;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace BLL
{
    public class DALPalletMatOut:IDALPalletMatOut
    {
        public IList<PltOut> GetList(AjaxPalletMatOutList ajaxPalletMatOut, ref PageInfo page)
        {
            try
            {     
                List<SqlParam> para = new List<SqlParam>();
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select * from View_Log_Store where TurnoverDemand = '02' " + $" AND DepartGuid='{ajaxPalletMatOut.DepartGuid}' ");
                if (!string.IsNullOrEmpty(ajaxPalletMatOut.LocationCode))
                {
                    strSql.Append("and LocationCode like '%' + @LocationCode + '%' ");
                    para.Add(new SqlParam("@LocationCode", ajaxPalletMatOut.LocationCode));
                }
                if (!string.IsNullOrEmpty(ajaxPalletMatOut.Palno))
                {
                    strSql.Append("and Palno like '%' + @Palno + '%' ");
                    para.Add(new SqlParam("@Palno", ajaxPalletMatOut.Palno));
                }
                if (!string.IsNullOrEmpty(ajaxPalletMatOut.MatNo))
                {
                    strSql.Append("and MatNo like '%' + @MatNo + '%' ");
                    para.Add(new SqlParam("@MatNo", ajaxPalletMatOut.MatNo));
                }
                if (!string.IsNullOrEmpty(ajaxPalletMatOut.MatName))
                {
                    strSql.Append("and MatName like '%' + @MatName + '%' ");
                    para.Add(new SqlParam("@MatName", ajaxPalletMatOut.MatName));
                }
                if (!string.IsNullOrEmpty(ajaxPalletMatOut.BatchNo))
                {
                    strSql.Append("and BatchNo like '%' + @BatchNo + '%' ");
                    para.Add(new SqlParam("@BatchNo", ajaxPalletMatOut.BatchNo));
                }
                if (!string.IsNullOrEmpty(ajaxPalletMatOut.LingNo))
                {
                    strSql.Append("and LingNo like '%' + @LingNo + '%' ");
                    para.Add(new SqlParam("@LingNo", ajaxPalletMatOut.LingNo));
                }
 
                SqlParam[] param = null;
                if (para != null) 
                {
                    param = para.ToArray();
                }
 
                DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "Palno", "asc", ref page);
                return ModelConvertHelper<PltOut>.DataTableToModel(dt);
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
 
        public bool IsCanPalletOut(string PalletNo, string Addre)
        {
            try
            {
                bool r = false;
                StringBuilder strSQL = new StringBuilder();
 
                //liudl add 验证库位状态 
                strSQL.Append("select count(*) from DepotsLocation ");
                strSQL.Append("where LocationCode = '"+ Addre + "' and TurnoverDemand='02'");
                DataTable dtt = DataFactory.SqlDataBase().GetDataTableBySQL(strSQL);
                if (dtt.Rows[0][0].ToString() == "0") 
                {
                    return r;
                }
 
                // 验证托盘是否存在
                strSQL.Clear();
                strSQL.Append( "select * from View_Log_Store where Palno = '");
                strSQL.Append(PalletNo);
                strSQL.Append("'");
                DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSQL);
                if(dt == null)
                {
                    return r;
                }
                if(dt.Rows.Count == 0)
                {
                    return r;
                }
                
                r = true;            
                return r;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
    }
}