using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.Entity.Operation;
using QMFrameWork.Data;
using QMAPP.DAL;
using System.Data;
namespace QMAPP.FJC.DAL.Operation
{
///
/// 电检记录
///
public class ElectricalCheckDAL:BaseDAL
{
///
/// 校验电检结果是否合格
/// return 0:无电检记录;1:电检合格; -1:电检不合格
///
///
/// 0:无电检记录;1:电检合格; -1:电检不合格
public int ValidElectricalCheck(string productcode)
{
try
{
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT [ID]");
sql.AppendLine(" ,[Barcode]");
sql.AppendLine(" ,[Result]");
sql.AppendLine(" ,[Time]");
sql.AppendLine(" FROM [T_ID_DIANJIAN]");
sql.AppendLine(" WHERE [Barcode] LIKE '%'+@productcode");
List parameters = new List();
parameters.Add(new DataParameter("productcode",productcode));
using (IDataSession session = AppDataFactory.CreateMainSession())
{
var record = session.GetTable(sql.ToString(), parameters.ToArray());
if (record.Rows.Count < 1)
{
return 0;
}
var r = (from DataRow row in record.Rows
where row["Result"].ToString() == "OK"
select row["ID"]).Count();
if (r > 0)
{
return 1;
}
else
{
return -1;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}