using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using CY.IDAL;
|
using System.Data.SqlClient;
|
using System.Data;
|
using CY.Model;
|
using System.Transactions;
|
namespace CY.SQLDAL
|
{
|
//Pay_CreditRecard
|
public class Pay_CreditRecardDAL : IPay_CreditRecardDAL
|
{
|
private Database _dataBase = null;
|
|
public Pay_CreditRecardDAL()
|
{
|
_dataBase = new Database();
|
}
|
|
public Pay_CreditRecardDAL(Database dataBase)
|
{
|
_dataBase = dataBase;
|
}
|
|
/// <summary>
|
/// 新增
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Pay_CreditRecard trueModel = model as Model.Pay_CreditRecard;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@CreateTime", trueModel.CreateTime) ,
|
new SqlParameter("@Remark", trueModel.Remark) ,
|
new SqlParameter("@PayId", trueModel.PayId) ,
|
new SqlParameter("@TradingName", trueModel.TradingName) ,
|
new SqlParameter("@TradingType", trueModel.TradingType) ,
|
new SqlParameter("@TradingState", trueModel.TradingState) ,
|
new SqlParameter("@TradingMoney", trueModel.TradingMoney) ,
|
new SqlParameter("@ResidualMoney", trueModel.ResidualMoney)
|
};
|
try
|
{
|
_dataBase.Query("sp_Pay_CreditRecard_Insert", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
/// <summary>
|
/// 修改
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Pay_CreditRecard trueModel = model as Model.Pay_CreditRecard;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@Keyid", trueModel.Keyid) ,
|
new SqlParameter("@CreateTime", trueModel.CreateTime) ,
|
new SqlParameter("@Remark", trueModel.Remark) ,
|
new SqlParameter("@PayId", trueModel.PayId) ,
|
new SqlParameter("@TradingName", trueModel.TradingName) ,
|
new SqlParameter("@TradingType", trueModel.TradingType) ,
|
new SqlParameter("@TradingState", trueModel.TradingState) ,
|
new SqlParameter("@TradingMoney", trueModel.TradingMoney) ,
|
new SqlParameter("@ResidualMoney", trueModel.ResidualMoney)
|
};
|
try
|
{
|
_dataBase.Query("sp_Pay_CreditRecard_Update", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
/// <summary>
|
/// 删除
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Pay_CreditRecard trueModel = model as Model.Pay_CreditRecard;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@Keyid",trueModel.Keyid)
|
};
|
try
|
{
|
_dataBase.Query("sp_Pay_CreditRecard_DeleteRow", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
|
return true;
|
}
|
|
/// <summary>
|
/// 分页查询
|
/// </summary>
|
/// <param name="query"></param>
|
/// <param name="pagination"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.Pay_CreditRecard> SelectModelPage(Infrastructure.Query.Query query, Infrastructure.Query.Pagination pagination)
|
{
|
throw new NotImplementedException();
|
}
|
|
/// <summary>
|
/// 单个查询
|
/// </summary>
|
/// <param name="query"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.Pay_CreditRecard> SelectAllModel(Infrastructure.Query.Query query)
|
{
|
throw new NotImplementedException();
|
}
|
|
/// <summary>
|
/// 根据编号获得信息
|
/// </summary>
|
/// <param name="Keyid">编号</param>
|
/// <returns></returns>
|
public Pay_CreditRecard GetModelByKeyid(int? Keyid)
|
{
|
try
|
{
|
if (Keyid == null || Keyid < 0)
|
return null;//错误数据返会空
|
|
IList<Pay_CreditRecard> result = _dataBase.SelectModel<Pay_CreditRecard>(" * ", " Pay_CreditRecard ", string.Format(" Keyid='{0}'", Keyid)) as IList<Pay_CreditRecard>;//执行查询
|
|
return (null == result || result.Count == 0) ? null : result[0];//返回结果
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 分页查询
|
/// </summary>
|
/// <param name="pagination"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.Pay_CreditRecard> SelectModelPage(Infrastructure.Query.Pagination pagination, int? _PayId, string _TradingName, int? _TradingType, int? _TradingState, decimal? _TradingMoney, decimal? _ResidualMoney, DateTime? _BeginCreateTime, DateTime? _EndCreateTime, string _Remark)
|
{
|
try
|
{
|
string condition = " 1=1 ";
|
|
if (_BeginCreateTime.HasValue)
|
condition += string.Format(" and CAST(CreateTime AS DATE) >='{0}' ", _BeginCreateTime);
|
|
if (_EndCreateTime.HasValue)
|
condition += string.Format(" and CAST(CreateTime AS DATE) <='{0}' ", _EndCreateTime);
|
|
if (!string.IsNullOrEmpty(_Remark))
|
condition += " and Remark = '" + _Remark + "' ";
|
|
if (_PayId.HasValue)
|
condition += " and PayId = '" + _PayId + "' ";
|
|
if (!string.IsNullOrEmpty(_TradingName))
|
condition += " and TradingName = '" + _TradingName + "' ";
|
|
if (_TradingType.HasValue)
|
condition += " and TradingType = '" + _TradingType + "' ";
|
|
if (_TradingState.HasValue)
|
condition += " and TradingState = '" + _TradingState + "' ";
|
|
if (_TradingMoney.HasValue)
|
condition += " and TradingMoney = '" + _TradingMoney + "' ";
|
|
if (_ResidualMoney.HasValue)
|
condition += " and ResidualMoney = '" + _ResidualMoney + "' ";
|
|
return _dataBase.SelectModelPage<Model.Pay_CreditRecard>(pagination, " * ", " Pay_CreditRecard ", " Keyid desc", " Keyid desc ", condition);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
}
|
}
|