using MESClassLibrary.BLL.Log; using MESClassLibrary.DAL; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; namespace MESClassLibrary.BLL.Painting { public class NotStockBarCodeDal { public DataTable NotStockInBarCode(string time1, string time2) { DataTable res = null; try { string sql = @"if OBJECT_ID(N'tempdb..#a',N'U') is not null DROP TABLE #a CREATE TABLE #a(barcode nvarchar(50)) INSERT INTO #a ( barcode ) SELECT DISTINCT barcode FROM dbo.tb_InspectResult WHERE createTime BETWEEN '" + time1 + @"' AND '" + time2 + @"' AND inspectResult ='[合格]' --质检合格的所有条码 --SELECT * FROM #a --入库的条码 --SELECT barcode FROM #a WHERE barcode IN (SELECT barcode FROM dbo.tb_StockIn) --未入库条码 SELECT #a.barcode FROM #a LEFT OUTER JOIN dbo.tb_StockIn s ON #a.barcode=s.barcode where s.ID is null"; res = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0]; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); } return res; } } }