using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.Entity.Basic;
using QMFrameWork.Data;
using System.Data;
using QMAPP.Entity;
namespace QMAPP.FJC.DAL.Basic
{
///
/// 模块名称:配置表
/// 作 者:张松男
/// 编写日期:2021年05月14日
///
public class MaterialBomConfigDAL
{
///
/// 查询自动输入的输入条码
///
///
///
///
public List GetAutoInputBarCode(string pBomCode, string pWorkLoc)
{
List parameter = new List();
List list = new List();
var data = new DataTable();
//var sqlScript = $"select Product_Code from T_MD_MaterialBomConfig_QD where workloc = '{pWorkLoc}' and material_code = '{pBomCode}'";
string sqlScript = $@"select Product_Code from T_MD_MaterialBomConfig_QD
where material_code is not null and material_code in
(select material_code from T_MD_PBOM_ITEM where pbom_code = '{pBomCode}'
INTERSECT
select material_code from T_MD_MaterialBomConfig_QD where workloc = '{pWorkLoc}' ) and workloc ='{pWorkLoc}'";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//DataSet dataSet = SqlHelper.ExecuteDataset(Config.maindbConnectionString, CommandType.Text, sqlScript);
data = session.GetTable(sqlScript, parameter.ToArray());
}
if (data.Rows.Count > 0)
{
foreach (DataRow dataRow in data.Rows)
{
string pbom = dataRow["Product_Code"].ToString();
if (!list.Contains(pbom) && !string.IsNullOrEmpty(pbom))
{
list.Add(pbom);
}
}
}
return list;
}
///
/// 获取全部规则
///
///
public List Get(MaterialBomConfig MaterialBomConfig)
{
try
{
string sql = $"SELECT PID,Material_Code,Workloc,Product_Code,Material_Name FROM [T_MD_ScanIPConfig_QD] where Workloc = '{MaterialBomConfig.Workloc}' and Material_Code = '{MaterialBomConfig.Material_Code}' ";
List parameters = new List();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.GetList(sql, parameters.ToArray()).ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}