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年03月17日 /// public class ScanIPConfigDAL { /// /// 获取全部规则 /// /// public List 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 parameters = new List(); using (IDataSession session = AppDataFactory.CreateMainSession()) { return session.GetList(sql, parameters.ToArray()).ToList(); } } catch (Exception ex) { throw ex; } } #region 更新信息 /// /// 更新信息 /// /// /// 更新行数 public int Update(ScanIPConfig model) { int count = 0; try { List parameters = new List(); 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(model); } return count; } catch (Exception ex) { throw ex; } } #endregion #region 信息是否重复 /// /// 判断名称是否存在 /// /// /// true:已存在;fasel:不存在。 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 } }