using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using CY.IDAL.Inquiry;
|
using CY.Model;
|
using System.Data.SqlClient;
|
using System.Data;
|
|
namespace CY.SQLDAL
|
{
|
public class SysInquiry_SignboardInfoDAL : ISysInquiry_SignboardInfoDAL
|
{
|
private Database _dataBase = null;
|
|
public SysInquiry_SignboardInfoDAL()
|
{
|
_dataBase = new Database();
|
}
|
|
public IEnumerable<Model.SysInquiry_SignboardInfo> SelectModelPage(string characterName, string thickness, string status, Infrastructure.Query.Pagination pagination)
|
{
|
string condition = string.Empty;
|
condition = " 1=1 ";
|
if (!string.IsNullOrEmpty(characterName))
|
{
|
condition += " and characterName like '%" + characterName + "%' ";
|
}
|
if (!string.IsNullOrEmpty(thickness))
|
{
|
condition += " and thickness like '%" + thickness + "%' ";
|
}
|
if (!string.IsNullOrEmpty(status))
|
{
|
condition += " and Status='" + status + "'";
|
}
|
return _dataBase.SelectModelPage<SysInquiry_SignboardInfo>(pagination, "*", "SysInquiry_SignboardInfo", "OrderNum", "OrderNum", condition);
|
}
|
|
public Model.SysInquiry_SignboardInfo SelectModelByKey(int keyid)
|
{
|
string condition = string.Empty;
|
condition = " KeyId=" + keyid;
|
IList<SysInquiry_SignboardInfo> result = _dataBase.SelectModel<SysInquiry_SignboardInfo>("*", "SysInquiry_SignboardInfo", condition);
|
return null == result || result.Count == 0 ? null : result[0];
|
}
|
|
public int GetOrderNumByMax()
|
{
|
int orderNum = 1;
|
try
|
{
|
IList<SysInquiry_SignboardInfo> result = _dataBase.SelectModel<SysInquiry_SignboardInfo>(" MAX(OrderNum)+1 AS OrderNum ", "SysInquiry_SignboardInfo", "");
|
if (result != null && result.Count > 0)
|
{
|
orderNum = result[0].OrderNum;
|
}
|
}
|
catch
|
{
|
orderNum = 1;
|
}
|
return orderNum;
|
}
|
|
public IList<Model.SysInquiry_SignboardInfo> GetModelList()
|
{
|
string condition = string.Empty;
|
condition = " Status='true' order by orderNum ";
|
IList<SysInquiry_SignboardInfo> result = _dataBase.SelectModel<SysInquiry_SignboardInfo>("*", "SysInquiry_SignboardInfo", condition);
|
|
return result;
|
}
|
|
public IList<string> GetCharacterNameList()
|
{
|
IList<string> characterNameList = new List<string>();
|
string condition = " Status='true' order by orderNum ";
|
IList<SysInquiry_SignboardInfo> result = _dataBase.SelectModel<SysInquiry_SignboardInfo>("CharacterName", "SysInquiry_SignboardInfo", condition);
|
if (result != null && result.Count > 0)
|
{
|
foreach (SysInquiry_SignboardInfo model in result)
|
{
|
if (!characterNameList.Contains(model.CharacterName))
|
characterNameList.Add(model.CharacterName);
|
}
|
}
|
return characterNameList;
|
}
|
|
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.SysInquiry_SignboardInfo trueModel = model as Model.SysInquiry_SignboardInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@CharacterName",trueModel.CharacterName),
|
new SqlParameter("@Thickness",trueModel.Thickness),
|
new SqlParameter("@Status",trueModel.Status),
|
new SqlParameter("@OrderNum",trueModel.OrderNum)
|
};
|
try
|
{
|
_dataBase.Query("SysInquiry_SignboardInfo_ADD", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.SysInquiry_SignboardInfo trueModel = model as Model.SysInquiry_SignboardInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@KeyId",trueModel.KeyId),
|
new SqlParameter("@CharacterName",trueModel.CharacterName),
|
new SqlParameter("@Thickness",trueModel.Thickness),
|
new SqlParameter("@Status",trueModel.Status),
|
new SqlParameter("@OrderNum",trueModel.OrderNum)
|
};
|
try
|
{
|
_dataBase.Query("SysInquiry_SignboardInfo_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>
|
/// <param name="characterName"></param>
|
/// <param name="thickness"></param>
|
/// <returns></returns>
|
public bool IsExist(string characterName, string thickness)
|
{
|
bool isExist = false;
|
string condition = " characterName='" + characterName + "' and thickness='" + thickness + "' ";
|
IList<SysInquiry_SignboardInfo> result = _dataBase.SelectModel<SysInquiry_SignboardInfo>("*", "SysInquiry_SignboardInfo", condition);
|
if (result != null && result.Count > 0)
|
{
|
isExist = true;
|
}
|
return isExist;
|
}
|
}
|
}
|