using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using CY.Model;
|
using System.Data.SqlClient;
|
using System.Data;
|
using CY.IDAL.Inquiry;
|
|
namespace CY.SQLDAL
|
{
|
public class SysInquiry_LEDMaterialDAL : ISysInquiry_LEDMaterialDAL
|
{
|
private Database _dataBase = null;
|
|
public SysInquiry_LEDMaterialDAL()
|
{
|
_dataBase = new Database();
|
}
|
|
public IEnumerable<Model.SysInquiry_LEDMaterial> SelectModelPage(string name, string status, Infrastructure.Query.Pagination pagination)
|
{
|
string condition = string.Empty;
|
condition = " 1=1 ";
|
if (!string.IsNullOrEmpty(name))
|
{
|
condition += " and name like '%" + name + "%' ";
|
}
|
if (!string.IsNullOrEmpty(status))
|
{
|
condition += " and Status='" + status+"'" ;
|
}
|
return _dataBase.SelectModelPage<SysInquiry_LEDMaterial>(pagination, "*", "SysInquiry_LEDMaterial", "OrderNum", "OrderNum", condition);
|
}
|
|
public Model.SysInquiry_LEDMaterial SelectModelByKey(int keyid)
|
{
|
string condition = string.Empty;
|
condition = " KeyId=" + keyid;
|
IList<SysInquiry_LEDMaterial> result = _dataBase.SelectModel<SysInquiry_LEDMaterial>("*", "SysInquiry_LEDMaterial", condition);
|
return null == result || result.Count == 0 ? null : result[0];
|
}
|
|
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.SysInquiry_LEDMaterial trueModel = model as Model.SysInquiry_LEDMaterial;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@Name",trueModel.Name),
|
new SqlParameter("@Status",trueModel.Status),
|
new SqlParameter("@OrderNum",trueModel.OrderNum)
|
};
|
try
|
{
|
_dataBase.Query("SysInquiry_LEDMaterial_ADD", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.SysInquiry_LEDMaterial trueModel = model as Model.SysInquiry_LEDMaterial;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@KeyId",trueModel.KeyId),
|
new SqlParameter("@Name",trueModel.Name),
|
new SqlParameter("@Status",trueModel.Status),
|
new SqlParameter("@OrderNum",trueModel.OrderNum)
|
};
|
try
|
{
|
_dataBase.Query("SysInquiry_LEDMaterial_Update", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
|
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
throw new NotImplementedException();
|
}
|
|
/// <summary>
|
/// 获取最新排序顺序
|
/// </summary>
|
/// <returns></returns>
|
public int GetOrderNumByMax()
|
{
|
int orderNum = 1;
|
try
|
{
|
IList<SysInquiry_LEDMaterial> result = _dataBase.SelectModel<SysInquiry_LEDMaterial>(" MAX(OrderNum)+1 AS OrderNum ", "SysInquiry_LEDMaterial", "");
|
if (result != null && result.Count > 0)
|
{
|
orderNum = result[0].OrderNum;
|
}
|
}
|
catch
|
{
|
orderNum = 1;
|
}
|
return orderNum;
|
}
|
|
|
public IList<SysInquiry_LEDMaterial> GetModelList()
|
{
|
string condition = string.Empty;
|
condition = " Status='true' order by orderNum ";
|
IList<SysInquiry_LEDMaterial> result = _dataBase.SelectModel<SysInquiry_LEDMaterial>("*", "SysInquiry_LEDMaterial", condition);
|
|
return result;
|
}
|
|
/// <summary>
|
/// 判断是否存在相同的数据
|
/// </summary>
|
/// <param name="name"></param>
|
/// <returns></returns>
|
public bool IsExist(string name)
|
{
|
bool isExist = false;
|
string condition = string.Empty;
|
condition = " name='" + name + "' ";
|
IList<SysInquiry_LEDMaterial> result = _dataBase.SelectModel<SysInquiry_LEDMaterial>("*", "SysInquiry_LEDMaterial", condition);
|
if (result != null && result.Count > 0)
|
{
|
isExist = true;
|
}
|
return isExist;
|
}
|
}
|
}
|