jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
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
using HanHe.Utility.Data;
using HH.WMS.Common;
using HH.WMS.DAL;
using HH.WMS.Entitys;
using HH.WMS.Entitys.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace HH.WMS.DAL.CoreServer
{
    public class OutDataDAL : DapperBaseDAL
    {
        public SqlExecuteResult UpdateRdrecordCheckState(string cCode, string collectionName)
        {
            string strSql = @"update " + collectionName + @" set bIsRead_WMS=1,cReader_WMS=:cReader_WMS,dReadDate_WMS=getdate() WHERE cCode=:cCode ";
            DbCommand cmd = DataAccess.GetSqlStringCommand(strSql);
            DataAccess.AddInParameter(cmd, "cReader_WMS", ComDbType.STRING, "汉和信息");
            DataAccess.AddInParameter(cmd, "cCode", ComDbType.STRING, cCode);
 
            return ExecuteCommand(cmd, null);
        }
 
        public DataTable GetOutMstData(string tableName)
        {
            string sql = @" select top 50 * from " + tableName + @" where bIsRead_WMS=0 and cbustype='销售出库'";
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataTable dt = DataAccessExtensive.ExecuteDataTable(this.DataAccess, cmd);
            return dt;
        }
 
        public DataTable GetOutMstDataTH(string tableName)
        {
            string sql = @" select top 50 * from " + tableName + @" where bIsRead_WMS=0 and cbustype='销售退货'";
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataTable dt = DataAccessExtensive.ExecuteDataTable(this.DataAccess, cmd);
            return dt;
        }
        public DataTable GetOutDtlData(string collectionName, string cCode)
        {
            string sql = @" select  top 50 * from " + collectionName + @" where cCode='" + cCode + "' ";
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataTable dt = DataAccessExtensive.ExecuteDataTable(this.DataAccess, cmd);
            return dt;
        }
 
        public SqlExecuteResult UpdateRdrecordCheckFlag(string opNo, string tableName, TN_WM_OUT_MSTEntity outMst)
        {
            try
            {
                Log.Info("UpdateRdrecordCheckFlag2", opNo);
                List<DbCommand> cmdlist = new List<DbCommand>();
                List<TN_WM_OUT_DTLEntity> dtlList = new List<TN_WM_OUT_DTLEntity>();
                dtlList = outMst.OutDtlList;
                for (int i = 0; i < dtlList.Count; i++)
                {
                    Log.Info("UpdateRdrecordCheckFlag3", opNo);
                    string strSql = @"update " + (tableName.Split('$'))[0] + @" set bIsCheck_WMS=1,cChecker_WMS=:cChecker_WMS,dCheckDate_WMS=getdate() WHERE cCode=:cCode 
                                  update " + (tableName.Split('$'))[1] + @" set iWMSReturnQty=:iWMSReturnQty,cWMSReturnbatch=:cWMSReturnbatch WHERE cCode=:cCode and cInvCode=:cInvCode";
                    DbCommand cmd = DataAccess.GetSqlStringCommand(strSql);
                    DataAccess.AddInParameter(cmd, "cChecker_WMS", ComDbType.STRING, "汉和信息");
                    DataAccess.AddInParameter(cmd, "cCode", ComDbType.STRING, opNo);
                    DataAccess.AddInParameter(cmd, "iWMSReturnQty", ComDbType.STRING, dtlList[i].CN_F_QUANTITY);
                    DataAccess.AddInParameter(cmd, "cWMSReturnbatch", ComDbType.STRING, dtlList[i].CN_S_PRODUCTION_BATCH);
                    DataAccess.AddInParameter(cmd, "cInvCode", ComDbType.STRING, dtlList[i].CN_S_ITEM_CODE);
                    cmdlist.Add(cmd);
 
                    Log.Info("sql语句拼接" + i, strSql);
                }
                //CreateDataBase("U8Connection");
                return ExecuteCommands(cmdlist, null);
            }catch(Exception ex)
            {
                Log.Info("sql_ex", ex.ToString());
                return new SqlExecuteResult() { };
            }
        }
    }
}