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;
}
///
/// 新增
///
///
///
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.Pay_CreditRecard trueModel = model as Model.Pay_CreditRecard;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{
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());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 修改
///
///
///
public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.Pay_CreditRecard trueModel = model as Model.Pay_CreditRecard;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{
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());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 删除
///
///
///
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.Pay_CreditRecard trueModel = model as Model.Pay_CreditRecard;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{
new SqlParameter("@Keyid",trueModel.Keyid)
};
try
{
_dataBase.Query("sp_Pay_CreditRecard_DeleteRow", CommandType.StoredProcedure, sqlParms.ToArray());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 分页查询
///
///
///
///
public IEnumerable SelectModelPage(Infrastructure.Query.Query query, Infrastructure.Query.Pagination pagination)
{
throw new NotImplementedException();
}
///
/// 单个查询
///
///
///
public IEnumerable SelectAllModel(Infrastructure.Query.Query query)
{
throw new NotImplementedException();
}
///
/// 根据编号获得信息
///
/// 编号
///
public Pay_CreditRecard GetModelByKeyid(int? Keyid)
{
try
{
if (Keyid == null || Keyid < 0)
return null;//错误数据返会空
IList result = _dataBase.SelectModel(" * ", " Pay_CreditRecard ", string.Format(" Keyid='{0}'", Keyid)) as IList;//执行查询
return (null == result || result.Count == 0) ? null : result[0];//返回结果
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 分页查询
///
///
///
public IEnumerable 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(pagination, " * ", " Pay_CreditRecard ", " Keyid desc", " Keyid desc ", condition);
}
catch (Exception ex)
{
throw ex;
}
}
}
}