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.
201 lines
6.5 KiB
201 lines
6.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMAPP.FJC.Entity.MD;
|
|
using QMFrameWork.Data;
|
|
using System.Data;
|
|
using QMAPP.Entity;
|
|
using QMAPP.MD.Entity.Bucket;
|
|
using QMAPP.MD.Entity.TianJin;
|
|
|
|
namespace QMAPP.FJC.DAL.TianJin
|
|
{
|
|
/// <summary>
|
|
/// 模块名称:库存日志信息
|
|
/// 作 者:张松男
|
|
/// 编写日期:2022年02月17日
|
|
/// </summary>
|
|
public class MonitordataDAL
|
|
{
|
|
#region 获取信息
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>*信息</returns>
|
|
public Monitordata Get(Monitordata info)
|
|
{
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//获取信息
|
|
info = session.Get<Monitordata>(info);
|
|
}
|
|
return info;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>*信息</returns>
|
|
public Monitordata Get(string materialcode)
|
|
{
|
|
try
|
|
{
|
|
string sql = "SELECT top1 * FROM [T_AW_Monitordata] WHERE [ProductCode]=@ProductCode";
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
parameters.Add(new DataParameter("ProductCode", materialcode));
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//获取信息
|
|
var info = session.Get<Monitordata>(sql, parameters.ToArray());
|
|
return info;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public DataPage GetList(Monitordata condition, DataPage page)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
sql = this.GetQuerySql(condition, ref parameters);
|
|
//分页关键字段及排序
|
|
page.KeyName = "id";
|
|
if (string.IsNullOrEmpty(page.SortExpression))
|
|
page.SortExpression = "RecordDate DESC";
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
page = session.GetDataPage<Monitordata>(sql, parameters.ToArray(), page);
|
|
}
|
|
return page;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public List<Monitordata> GetALL()
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
sql = "SELECT * FROM T_AW_Monitordata ";
|
|
//分页关键字段及排序
|
|
var LIST = new List<Monitordata>();
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
LIST = session.GetList<Monitordata>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
return LIST;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取查询语句
|
|
/// <summary>
|
|
/// 获取查询语句
|
|
/// </summary>
|
|
/// <param name="user">查询条件</param>
|
|
/// <param name="parameters">参数</param>
|
|
/// <returns>查询语句</returns>
|
|
private string GetQuerySql(Monitordata condition, ref List<DataParameter> parameters)
|
|
{
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
StringBuilder whereBuilder = new StringBuilder();
|
|
try
|
|
{
|
|
|
|
//构成查询语句
|
|
sqlBuilder.Append("SELECT * ");
|
|
sqlBuilder.Append("FROM monitordata ");
|
|
|
|
if (string.IsNullOrEmpty(condition.QrCodeContent) == false)
|
|
{
|
|
whereBuilder.Append(" AND QrCodeContent = @QrCodeContent");
|
|
parameters.Add(new DataParameter { ParameterName = "QrCodeContent", DataType = DbType.String, Value = condition.QrCodeContent });
|
|
}
|
|
|
|
if (condition.BeginTime != DateTime.MinValue)
|
|
whereBuilder.Append($" and RecordDate >= '{condition.BeginTime}' ");
|
|
if (condition.EndTime != DateTime.MinValue)
|
|
whereBuilder.Append($" and RecordDate <= '{condition.EndTime}' ");
|
|
|
|
//查询条件
|
|
if (whereBuilder.Length > 0)
|
|
{
|
|
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
|
|
}
|
|
return sqlBuilder.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取导出的数据
|
|
/// <summary>
|
|
/// 获取导出的数据
|
|
/// </summary>
|
|
/// <param name="user">查询条件</param>
|
|
/// <returns>数据</returns>
|
|
public DataTable GetExportData(Monitordata model)
|
|
{
|
|
DataTable dt = null;
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
//构成查询语句
|
|
sql = this.GetQuerySql(model, ref parameters);
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
dt = session.GetTable(sql, parameters.ToArray());
|
|
dt.TableName = "T_AW_Monitordata";
|
|
}
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|