using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; using MESClassLibrary.BLL.Log; namespace MESClassLibrary.DAL.TruckBox { public class ScanRecordDAL { public DataTable SearchInfo(string time1, string time2) { DataTable res = null; try { string sql = @"SELECT top 100 dbo.tb_ScanRecord_OpenDoor.BarCode, dbo.tb_ScanRecord_OpenDoor.IsOk, dbo.tb_ScanRecord_OpenDoor.ScanTime, dbo.tb_Product.ProductName FROM dbo.tb_ScanRecord_OpenDoor LEFT OUTER JOIN dbo.tb_Product ON substring(dbo.tb_ScanRecord_OpenDoor.BarCode,1,10) = dbo.tb_Product.StockNo where ScanTime between '" + time1 + @"' and '" + time2 + @"' order by dbo.tb_ScanRecord_OpenDoor.ID desc"; return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0]; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod()); } return res; } public string ScanCount(string startTime, string endTime) { string res = "0"; try { string sql = @"SELECT count(DISTINCT BarCode) as qty FROM [dbo].[tb_ScanRecord_OpenDoor] WHERE IsOk=1 AND ScanTime BETWEEN '" + startTime + @"' AND '" + endTime + @"'"; DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0]; if (dt != null && dt.Rows.Count > 0) { res = dt.Rows[0]["qty"].ToString(); } } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod()); } return res; } } }