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

103 lines
3.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Data;
using QMAPP.FJC.Entity.FIS;
using QMFrameWork.Log;
using System.Data;
namespace QMAPP.FJC.DAL.FIS
{
/// <summary>
/// 模块编号:M16-4
/// 作 用:FIS M100生产信息数据层
/// 作 者:王丹丹
/// 编写日期:2015年07月10日
///</summary>
public class FISInfoDAL
{
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetList(FISInfo condition, DataPage page)
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
try
{
sql = this.GetQuerySql(condition, ref parameters);
//分页关键字段及排序
page.KeyName = "PID";
page.SortExpression = "CP5A DESC";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
page = session.GetDataPage<FISInfo>(sql, parameters.ToArray(), page);
}
return page;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "FIS M100生产信息数据层-获取列表"
});
throw;
}
}
#endregion
#region 获取查询语句
/// <summary>
/// 获取查询语句
/// </summary>
/// <param name="user">查询条件</param>
/// <param name="parameters">参数</param>
/// <returns>查询语句</returns>
private string GetQuerySql(FISInfo condition, ref List<DataParameter> parameters)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_FISINFO ");
//查询条件
if (string.IsNullOrEmpty(condition.ONLINETIMESTART) == false)
{
whereBuilder.Append(" AND CP5A >= @ONLINETIMESTART");
parameters.Add(new DataParameter { ParameterName = "ONLINETIMESTART", DataType = DbType.String, Value = condition.ONLINETIMESTART });
}
if (string.IsNullOrEmpty(condition.ONLINETIMEEND) == false)
{
whereBuilder.Append(" AND CP5A <= @ONLINETIMEEND");
parameters.Add(new DataParameter { ParameterName = "ONLINETIMEEND", DataType = DbType.String, Value = condition.ONLINETIMEEND });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}