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.
185 lines
5.3 KiB
185 lines
5.3 KiB
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
|
|
{
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <returns>全部集合</returns>
|
|
public List<MoldConfig> GetList(MoldConfig condition)
|
|
{
|
|
List<MoldConfig> list = new List<MoldConfig>();
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
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<MoldConfig>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
return list;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "物料号信息数据层-获取列表"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取模架号和模具号的最大值
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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<MoldConfig>(sql, new List<DataParameter>().ToArray());
|
|
}
|
|
return moldConfig;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 插入模腔配置信息
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
public DataResult Insert(MoldConfig entity)
|
|
{
|
|
DataResult result = new DataResult();
|
|
result.IsSuccess = true;
|
|
try
|
|
{
|
|
if (BaseSession != null)
|
|
{
|
|
BaseSession.Insert<MoldConfig>(entity);
|
|
}
|
|
else
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.Insert<MoldConfig>(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<MoldConfig>(entity);
|
|
}
|
|
else
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.Update<MoldConfig>(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<DataParameter>().ToArray());
|
|
}
|
|
else
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.ExecuteSql(sql, new List<DataParameter>().ToArray());
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取配置对象
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
public MoldConfig Get(MoldConfig condition)
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
condition = session.Get<MoldConfig>(condition);
|
|
}
|
|
return condition;
|
|
}
|
|
|
|
public void Delete(MoldConfig condition)
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.Delete<MoldConfig>(condition);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|