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_DigitalPrintPaperInfoDAL : ISysInquiry_DigitalPrintPaperInfoDAL
|
{
|
private Database _dataBase = null;
|
|
public SysInquiry_DigitalPrintPaperInfoDAL()
|
{
|
_dataBase = new Database();
|
}
|
|
public IEnumerable<Model.SysInquiry_DigitalPrintPaperInfo> SelectModelPage(string paperName, string status, Infrastructure.Query.Pagination pagination)
|
{
|
string condition = string.Empty;
|
condition = " 1=1 ";
|
if (!string.IsNullOrEmpty(paperName))
|
{
|
condition += " and paperName like '%" + paperName + "%' ";
|
}
|
if (!string.IsNullOrEmpty(status))
|
{
|
condition += " and Status='" + status + "'";
|
}
|
return _dataBase.SelectModelPage<SysInquiry_DigitalPrintPaperInfo>(pagination, "*", "SysInquiry_DigitalPrintPaperInfo", "OrderNum", "OrderNum", condition);
|
}
|
|
public Model.SysInquiry_DigitalPrintPaperInfo SelectModelByKey(int keyid)
|
{
|
string condition = string.Empty;
|
condition = " KeyId=" + keyid;
|
IList<SysInquiry_DigitalPrintPaperInfo> result = _dataBase.SelectModel<SysInquiry_DigitalPrintPaperInfo>("*", "SysInquiry_DigitalPrintPaperInfo", condition);
|
return null == result || result.Count == 0 ? null : result[0];
|
}
|
|
public int GetOrderNumByMax()
|
{
|
int orderNum = 1;
|
try
|
{
|
IList<SysInquiry_DigitalPrintPaperInfo> result = _dataBase.SelectModel<SysInquiry_DigitalPrintPaperInfo>(" MAX(OrderNum)+1 AS OrderNum ", "SysInquiry_DigitalPrintPaperInfo", "");
|
if (result != null && result.Count > 0)
|
{
|
orderNum = result[0].OrderNum;
|
}
|
}
|
catch
|
{
|
orderNum = 1;
|
}
|
return orderNum;
|
}
|
|
public IList<Model.SysInquiry_DigitalPrintPaperInfo> GetModelList()
|
{
|
string condition = string.Empty;
|
condition = " Status='true' order by orderNum ";
|
IList<SysInquiry_DigitalPrintPaperInfo> result = _dataBase.SelectModel<SysInquiry_DigitalPrintPaperInfo>("*", "SysInquiry_DigitalPrintPaperInfo", condition);
|
|
return result;
|
}
|
|
/// <summary>
|
/// 是否已经存在纸张
|
/// </summary>
|
/// <param name="paperName"></param>
|
/// <returns></returns>
|
public bool IsExistPaperName(string paperName)
|
{
|
bool isExist = false;
|
string condition = string.Empty;
|
condition = " PaperName='" + paperName + "' ";
|
IList<SysInquiry_DigitalPrintPaperInfo> result = _dataBase.SelectModel<SysInquiry_DigitalPrintPaperInfo>("*", "SysInquiry_DigitalPrintPaperInfo", condition);
|
if (result != null && result.Count > 0)
|
{
|
isExist = true;
|
}
|
return isExist;
|
}
|
|
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.SysInquiry_DigitalPrintPaperInfo trueModel = model as Model.SysInquiry_DigitalPrintPaperInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@PaperName",trueModel.PaperName),
|
new SqlParameter("@GramWeights",trueModel.GramWeights),
|
new SqlParameter("@Status",trueModel.Status),
|
new SqlParameter("@OrderNum",trueModel.OrderNum)
|
};
|
try
|
{
|
_dataBase.Query("SysInquiry_DigitalPrintPaperInfo_ADD", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.SysInquiry_DigitalPrintPaperInfo trueModel = model as Model.SysInquiry_DigitalPrintPaperInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@KeyId",trueModel.KeyId),
|
new SqlParameter("@PaperName",trueModel.PaperName),
|
new SqlParameter("@GramWeights",trueModel.GramWeights),
|
new SqlParameter("@Status",trueModel.Status),
|
new SqlParameter("@OrderNum",trueModel.OrderNum)
|
};
|
try
|
{
|
_dataBase.Query("SysInquiry_DigitalPrintPaperInfo_Update", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
throw new NotImplementedException();
|
}
|
}
|
}
|