天津投入产出系统后端
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.
 
 
 
 
 
 

117 lines
3.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Data;
using QMAPP.FJC.Entity.Basic;
using System.Data;
using QMFrameWork.Log;
namespace QMAPP.FJC.DAL.Basic
{
/// <summary>
/// 加工参数配置表
/// 作者:
/// 编写日期:2015年06月01日
///</summary>
public class ParameterConfigDAL
{
#region 获取加工参数配置
/// <summary>
///
/// </summary>
/// <returns></returns>
public List<ParameterConfig> GetList(ParameterConfig condition)
{
List<ParameterConfig> list = new List<ParameterConfig>();
List<DataParameter> parameters = new List<DataParameter>();
string sql = null;
try
{
sql = this.GetQuerySql(condition, ref parameters);
//分页关键字段及排序
using (IDataSession session = AppDataFactory.CreateMainSession())
{
list = session.GetList<ParameterConfig>(sql, parameters.ToArray()).ToList<ParameterConfig>();
}
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取查询语句
/// <summary>
/// 获取查询语句
/// </summary>
/// <param name="user">查询条件</param>
/// <param name="parameters">参数</param>
/// <returns>查询语句</returns>
private string GetQuerySql(ParameterConfig condition, ref List<DataParameter> parameters)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.Append("SELECT ");
sqlBuilder.Append( new DataQueryHelper().GetSelectColumns<ParameterConfig>() + " FROM T_BD_PARAMETERCONFIG");
//查询条件
if (string.IsNullOrEmpty(condition.MACHINECODDE) == false)
{
whereBuilder.Append(" AND MACHINECODDE=@MACHINECODDE");
parameters.Add(new DataParameter { ParameterName = "MACHINECODDE", DataType = DbType.String, Value = condition.MACHINECODDE });
}
if (string.IsNullOrEmpty(condition.MOLDNUMBER) == false)
{
whereBuilder.Append(" AND MOLDNUMBER=@MOLDNUMBER");
parameters.Add(new DataParameter { ParameterName = "MOLDNUMBER", DataType = DbType.String, Value = condition.MOLDNUMBER });
}
if (string.IsNullOrEmpty(condition.COLUMNTYPE) == false)
{
whereBuilder.Append(" AND COLUMNTYPE=@COLUMNTYPE");
parameters.Add(new DataParameter { ParameterName = "COLUMNTYPE", DataType = DbType.String, Value = condition.COLUMNTYPE });
}
if (string.IsNullOrEmpty(condition.PROCESSTYPE) == false)
{
whereBuilder.Append(" AND PROCESSTYPE=@PROCESSTYPE");
parameters.Add(new DataParameter { ParameterName = "PROCESSTYPE", DataType = DbType.String, Value = condition.PROCESSTYPE });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}