using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMAPP.FJC.Entity.Basic; using QMFrameWork.Data; using QMFrameWork.Log; using QMAPP.KB.Entity; using QMAPP.DAL; namespace QMAPP.FJC.DAL.Basic { public class MoldConfigDAL : BaseDAL { /// /// 获取列表 /// /// 条件 /// 全部集合 public List GetList(MoldConfig condition) { List list = new List(); string sql = null; List parameters = new List(); try { sql = "select * from T_BD_MOLDCONFIG where 1=1"; if (string.IsNullOrEmpty(condition.HB) == false) { sql += string.Format(" and HB='{0}'", condition.HB); } if (condition.STATUS >= 0) { sql += string.Format(" and STATUS={0}", condition.STATUS); } sql += " ORDER BY INDEXVALUE ASC"; using (IDataSession session = AppDataFactory.CreateMainSession()) { list = session.GetList(sql, parameters.ToArray()).ToList(); } return list; } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "物料号信息数据层-获取列表" }); throw; } } /// /// 获取模架号和模具号的最大值 /// /// public MoldConfig GetMaxMold() { try { MoldConfig moldConfig = new MoldConfig(); string sql = "select max(MAXMOLDSTATION) as MAXMOLDSTATION,max(MAXMOLDVALUE) as MAXMOLDVALUE from T_BD_MOLDCONFIG"; using (IDataSession session = AppDataFactory.CreateMainSession()) { moldConfig = session.Get(sql, new List().ToArray()); } return moldConfig; } catch (Exception ex) { throw ex; } } /// /// 插入模腔配置信息 /// /// /// public DataResult Insert(MoldConfig entity) { DataResult result = new DataResult(); result.IsSuccess = true; try { if (BaseSession != null) { BaseSession.Insert(entity); } else { using (IDataSession session = AppDataFactory.CreateMainSession()) { session.Insert(entity); } } } catch (Exception ex) { result.IsSuccess = false; result.Msg = ex.Message; } return result; } public DataResult Update(MoldConfig entity) { DataResult result = new DataResult(); result.IsSuccess = true; try { if (BaseSession != null) { BaseSession.Update(entity); } else { using (IDataSession session = AppDataFactory.CreateMainSession()) { session.Update(entity); } } } catch (Exception ex) { result.IsSuccess = false; result.Msg = ex.Message; } return result; } public void UpdateOtherUsed(MoldConfig entity) { string sql = string.Format("update T_BD_MOLDCONFIG set used=0 where pid<>'{0}'", entity.PID); if (BaseSession != null) { BaseSession.ExecuteSql(sql,new List().ToArray()); } else { using (IDataSession session = AppDataFactory.CreateMainSession()) { session.ExecuteSql(sql, new List().ToArray()); } } } /// /// 获取配置对象 /// /// /// public MoldConfig Get(MoldConfig condition) { using (IDataSession session = AppDataFactory.CreateMainSession()) { condition = session.Get(condition); } return condition; } public void Delete(MoldConfig condition) { using (IDataSession session = AppDataFactory.CreateMainSession()) { session.Delete(condition); } } } }