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;
namespace CY.SQLDAL
{
public class Pay_AccountedRecordDAL : IPay_AccountedRecordDAL
{
private Database _dataBase = null;
public Pay_AccountedRecordDAL()
{
_dataBase = new Database();
}
public Pay_AccountedRecordDAL(Database database)
{
_dataBase = database;
}
///
/// 新增
///
///
///
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.Pay_AccountedRecord trueModel = model as Model.Pay_AccountedRecord;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{
new SqlParameter("@OperateTypeId",trueModel.OperateTypeId),
new SqlParameter("@PayId",trueModel.PayId),
new SqlParameter("@AccountingTarget",trueModel.AccountingTarget),
new SqlParameter("@AccountingMoney",trueModel.AccountingMoney),
new SqlParameter("@NoteDate",trueModel.NoteDate),
new SqlParameter("@StatusId",trueModel.StatusId),
new SqlParameter("@RecordNumber",trueModel.RecordNumber)
};
try
{
_dataBase.Query("sp_Pay_AccountedRecord_Insert", CommandType.StoredProcedure, sqlParms.ToArray());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 修改
///
///
///
public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.Pay_AccountedRecord trueModel = model as Model.Pay_AccountedRecord;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{ new SqlParameter("@Keyid",trueModel.Keyid),
new SqlParameter("@OperateTypeId",trueModel.OperateTypeId),
new SqlParameter("@PayId",trueModel.PayId),
new SqlParameter("@AccountingTarget",trueModel.AccountingTarget),
new SqlParameter("@AccountingMoney",trueModel.AccountingMoney),
new SqlParameter("@NoteDate",trueModel.NoteDate),
new SqlParameter("@StatusId",trueModel.StatusId),
new SqlParameter("@RecordNumber",trueModel.RecordNumber)
};
try
{
_dataBase.Query("sp_Pay_AccountedRecord_Update", CommandType.StoredProcedure, sqlParms.ToArray());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 删除
///
///
///
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.Pay_AccountedRecord trueModel = model as Model.Pay_AccountedRecord;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{
new SqlParameter("@Keyid",trueModel.Keyid)
};
try
{
_dataBase.Query("sp_Pay_AccountedRecord_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 SelectModelPage(Infrastructure.Query.Pagination pagination, int? PayId)
{
if (PayId == null || PayId <= 0)
return null;//错误数据返会空
try
{
IList result = _dataBase.SelectModelPage(pagination, "*", "Pay_AccountedRecord", "NoteDate DESC", "NoteDate DESC", string.Format(" PayId = '{0}' ", PayId)) as IList;//执行查询
return null == result ? null : result;//返回结果
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 单个查询
///
///
///
public IEnumerable SelectAllModel(Infrastructure.Query.Query query)
{
throw new NotImplementedException();
}
///
/// 根据流水号获取实体信息
///
/// 流水号
///
public Pay_AccountedRecord SelectModleByRecordNumber(string RecordNumber)
{
if (string.IsNullOrEmpty(RecordNumber))
return null;//错误数据返会空
IList result = _dataBase.SelectModel("*", "Pay_AccountedRecord", " RecordNumber = '" + RecordNumber + "'") as IList;//执行查询
return (null == result || result.Count == 0) ? null : result[0];//返回结果
}
}
}