天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

111 lines
3.4 KiB

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
{
/// </summary>
/// 模块名称:配置表
/// 作 者:张松男
/// 编写日期:2021年03月17日
/// </summary>
public class ScanIPConfigDAL
{
/// <summary>
/// 获取全部规则
/// </summary>
/// <returns></returns>
public List<ScanIPConfig> Get(ScanIPConfig ScanIPConfig)
{
try
{
string sql = $"SELECT PID,MaterialCode,CFG,LocCode,PlcAddr,BarCode FROM [T_MD_ScanIPConfig_QD] where LocCode = '{ScanIPConfig.LocCode}' and MaterialCode = '{ScanIPConfig.MaterialCode}' ";
List<DataParameter> parameters = new List<DataParameter>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.GetList<ScanIPConfig>(sql, parameters.ToArray()).ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
#region 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public int Update(ScanIPConfig model)
{
int count = 0;
try
{
List<DataParameter> parameters = new List<DataParameter>();
var SQL = $"update T_MD_ScanIPConfig_QD set PlcAddr = '{model.PlcAddr}' where PID = '{model.PID}'";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
count = session.ExecuteSql(SQL, parameters.ToArray());
//更新基本信息
//count = session.Update<ScanIPConfig>(model);
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool Exists(ScanIPConfig model)
{
string PID = "";
int count = 0;
StringBuilder sqlBuilder = new StringBuilder();
try
{
if (string.IsNullOrEmpty(model.PID) == false)
{
PID = model.PID;
}
sqlBuilder.AppendLine("SELECT COUNT(*) FROM T_BD_PRODUCTINFO ");
sqlBuilder.AppendLine(" WHERE PID <> @PID ");
using (IDataSession session = AppDataFactory.CreateMainSession())
{
count = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(),
new DataParameter("PID", PID)));
}
if (count > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}