yl
2022-12-27 4d4e3ad417beccd49f1fe61a158bb1bc3a3537c2
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
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using VueWebApi.Tools;
 
namespace VueWebApi.DLL.DAL
{
    public class PurchaseOrderDAL
    {
        public static DataTable dt;    //定义全局变量dt
        public static bool res;       //定义全局变量dt
        public static ToMessage mes = new ToMessage(); //定义全局返回信息对象
        public static string strProcName = ""; //定义全局sql变量
        public static List<SqlParameter> listStr = new List<SqlParameter>(); //定义全局参数集合
        public static SqlParameter[] parameters; //定义全局SqlParameter参数数组
 
 
        #region[采购订单查询]
        public static ToMessage PurchaseOrderSearch(string mesorderstus, string mesordercode, string customercode, string orderdateopendate, string orderdateclosedate, string sourceorder, string deptcode, string creatuser, string createopendate, string createclosedate, int startNum, int endNum, string prop, string order)
        {
            var dynamicParams = new DynamicParameters();
            string search = "";
            try
            {
                if (mesorderstus != "" && mesorderstus != null)
                {
                    search += "and A.status=@mesorderstus ";
                    dynamicParams.Add("@mesorderstus", mesorderstus);
                }
                if (mesordercode != "" && mesordercode != null)
                {
                    search += "and A.ordercode like '%'+@mesordercode+'%' ";
                    dynamicParams.Add("@mesordercode", mesordercode);
                }
                if (customercode != "" && customercode != null)
                {
                    search += "and A.customercode=@customercode ";
                    dynamicParams.Add("@customercode", customercode);
                }
                if (deptcode != "" && deptcode != null)
                {
                    search += "and A.departmentcode=@deptcode ";
                    dynamicParams.Add("@deptcode", deptcode);
                }
                if (sourceorder != "" && sourceorder != null)
                {
                    search += "and A.saleorderCode like '%'+@sourceorder+'%' ";
                    dynamicParams.Add("@sourceorder", sourceorder);
                }
                if (orderdateopendate != "" && orderdateopendate != null)
                {
                    search += "and A.orderdate between @orderdateopendate and @orderdateclosedate ";
                    dynamicParams.Add("@orderdateopendate", orderdateopendate + " 00:00:00");
                    dynamicParams.Add("@orderdateclosedate", orderdateclosedate + " 23:59:59");
                }
                if (creatuser != "" && creatuser != null)
                {
                    search += "and A.lm_user like '%'+@creatuser+'%' ";
                    dynamicParams.Add("@creatuser", creatuser);
                }
                if (createopendate != "" && createopendate != null)
                {
                    search += "and A.lm_date between @createopendate and @createclosedate ";
                    dynamicParams.Add("@createopendate", createopendate + " 00:00:00");
                    dynamicParams.Add("@createclosedate", createclosedate + " 23:59:59");
                }
                if (search == "")
                {
                    search = "and 1=1 ";
                }
                // --------------查询指定数据--------------
                var total = 0; //总条数
                var sql = @"select case when A.status='NEW' then '新订单' when A.status='CHECK' then '已审核' when A.status='CLOSED' then '已关闭'  end as status,
                            A.orderdate,A.ordercode,T.org_name as deptname,C.name as customername,A.saleorderCode,A.acceptdate,A.lm_user,A.lm_date,U.username as auditoruser,A.auditordate  
                            from T_PurchaseOrder A
                            left join TOrganization T on  A.departmentcode=T.org_code 
                            left join TCustomer C on A.customercode=C.code 
                            left join TUser U on A.auditorusercode=U.usercode
                            where  T.description='D' and C.mtype='WG' " + search;
                var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                mes.code = "200";
                mes.Message = "查询成功!";
                mes.count = total;
                mes.data = data.ToList();
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.Message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
    }
}