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 Integrity_ComplainanInfoDAL : IIntegrity_ComplainanInfoDAL
|
{
|
private Database _dataBase = null;
|
|
public Integrity_ComplainanInfoDAL()
|
{
|
_dataBase = new Database();
|
}
|
|
/// <summary>
|
/// 新增
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Integrity_ComplainanInfo trueModel = model as Model.Integrity_ComplainanInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
SqlParameter orderIdPar = null;
|
if (trueModel.OrderId.HasValue)
|
{
|
orderIdPar = new SqlParameter("@OrderId", trueModel.OrderId);
|
}
|
else
|
{
|
orderIdPar = new SqlParameter("@OrderId", DBNull.Value);
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@RespondentId",trueModel.RespondentId),
|
new SqlParameter("@ComplainantId",trueModel.ComplainantId),
|
new SqlParameter("@OrderCode",trueModel.OrderCode),
|
new SqlParameter("@ComplaintsReason",trueModel.ComplaintsReason),
|
new SqlParameter("@ComplaintsStatusId",trueModel.ComplaintsStatusId),
|
new SqlParameter("@ComplaintsTypeId",trueModel.ComplaintsTypeId),
|
new SqlParameter("@ComplaintsTime",trueModel.ComplaintsTime),
|
new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime),
|
orderIdPar
|
};
|
try
|
{
|
_dataBase.Query("sp_Integrity_ComplainanInfo_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.Integrity_ComplainanInfo trueModel = model as Model.Integrity_ComplainanInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
SqlParameter auditTimePar = null;
|
if (trueModel.AuditTime.HasValue)
|
{
|
auditTimePar = new SqlParameter("@AuditTime", trueModel.AuditTime.Value);
|
}
|
else
|
{
|
auditTimePar = new SqlParameter("@AuditTime", DBNull.Value);
|
}
|
SqlParameter handleTimePar = null;
|
if (trueModel.HandleTime.HasValue)
|
{
|
handleTimePar = new SqlParameter("@HandleTime", trueModel.HandleTime.Value);
|
}
|
else
|
{
|
handleTimePar = new SqlParameter("@HandleTime", DBNull.Value);
|
}
|
SqlParameter canclTimePar = null;
|
if (trueModel.CanclTime.HasValue)
|
{
|
canclTimePar = new SqlParameter("@CanclTime", trueModel.CanclTime.Value);
|
}
|
else
|
{
|
canclTimePar = new SqlParameter("@CanclTime", DBNull.Value);
|
}
|
SqlParameter reciveTimePar = null;
|
if (trueModel.ReciveTime.HasValue)
|
{
|
reciveTimePar = new SqlParameter("@ReciveTime", trueModel.ReciveTime.Value);
|
}
|
else
|
{
|
reciveTimePar = new SqlParameter("@ReciveTime", DBNull.Value);
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{ new SqlParameter("@Keyid",trueModel.Keyid),
|
new SqlParameter("@ComplaintsStatusId",trueModel.ComplaintsStatusId),
|
new SqlParameter("@ProcessingResults",trueModel.ProcessingResults),
|
new SqlParameter("@HandlePeople",trueModel.HandlePeople),
|
new SqlParameter("@AuditPeople",trueModel.AuditPeople),
|
new SqlParameter("@RecivePeople",trueModel.RecivePeople),
|
auditTimePar,
|
handleTimePar,
|
canclTimePar,
|
reciveTimePar,
|
new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime)
|
};
|
try
|
{
|
_dataBase.Query("sp_Integrity_ComplainanInfo_Update", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
/// <summary>
|
/// 删除
|
/// </summary>
|
/// <param name="id"></param>
|
/// <returns></returns>
|
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Integrity_ComplainanInfo trueModel = model as Model.Integrity_ComplainanInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@Keyid",trueModel.Keyid)
|
};
|
try
|
{
|
_dataBase.Query("sp_Integrity_ComplainanInfo_DeleteRow", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
public IEnumerable<Model.Integrity_ComplainanInfo> SelectModelPageByFirm(int complaintsTypeId, string respondentName, string orderCode, int complaintsStatusId, Guid memberId, Infrastructure.Query.Pagination pagination)
|
{
|
string selectTarget = @" t.* ";
|
string fromSouce = @" (
|
SELECT a.*,b.Name AS RespondentName,c.Name AS ComplaintsStatus,d.Name as ComplaintsTypeName
|
FROM Integrity_ComplainanInfo a INNER JOIN dbo.EC_MemberBasic b
|
ON a.RespondentId=b.MemberId INNER JOIN Sys_Dictionary c ON a.ComplaintsStatusId=c.MeanValue AND c.DicType='投诉状态'
|
INNER JOIN Sys_Dictionary d ON a.ComplaintsTypeId=d.MeanValue AND d.DicType='投诉类型'
|
where a.ComplainantId='" + memberId.ToString() + "' ";
|
|
if (complaintsTypeId != -1)
|
{
|
fromSouce += " and a.complaintsTypeId='" + complaintsTypeId + "'";
|
}
|
if (!string.IsNullOrEmpty(respondentName))
|
{
|
fromSouce += " and b.Name like '%" + respondentName + "%'";
|
}
|
if (!string.IsNullOrEmpty(orderCode))
|
{
|
fromSouce += " and a.orderCode like '%" + orderCode + "%'";
|
}
|
|
if (complaintsStatusId != -1)
|
{
|
fromSouce += " and a.complaintsStatusId=" + complaintsStatusId;
|
}
|
fromSouce += " ) as t";
|
return _dataBase.SelectModelPage<Integrity_ComplainanInfo>(pagination, selectTarget, fromSouce, "t.LastUpdateTime desc ", "LastUpdateTime desc ");
|
}
|
|
public IEnumerable<Model.Integrity_ComplainanInfo> SelectModelPageBysys(int complaintsTypeId, string respondentName, string orderCode, int complaintsStatusId, Infrastructure.Query.Pagination pagination)
|
{
|
string selectTarget = @" t.* ";
|
string fromSouce = @" (
|
SELECT a.*,b.Name AS RespondentName,c.Name AS ComplaintsStatus,d.Name as ComplaintsTypeName,e.Name as ComplainantName
|
FROM Integrity_ComplainanInfo a INNER JOIN dbo.EC_MemberBasic b
|
ON a.RespondentId=b.MemberId
|
INNER JOIN dbo.EC_MemberBasic e
|
ON a.ComplainantId=e.MemberId
|
INNER JOIN Sys_Dictionary c ON a.ComplaintsStatusId=c.MeanValue AND c.DicType='投诉状态'
|
INNER JOIN Sys_Dictionary d ON a.ComplaintsTypeId=d.MeanValue AND d.DicType='投诉类型'
|
where 1=1 ";
|
|
if (complaintsTypeId != -1)
|
{
|
fromSouce += " and a.complaintsTypeId='" + complaintsTypeId + "'";
|
}
|
if (!string.IsNullOrEmpty(respondentName))
|
{
|
fromSouce += " and b.Name like '%" + respondentName + "%'";
|
}
|
if (!string.IsNullOrEmpty(orderCode))
|
{
|
fromSouce += " and a.orderCode like '%" + orderCode + "%'";
|
}
|
|
if (complaintsStatusId != -1)
|
{
|
fromSouce += " and a.complaintsStatusId=" + complaintsStatusId;
|
}
|
fromSouce += " ) as t";
|
return _dataBase.SelectModelPage<Integrity_ComplainanInfo>(pagination, selectTarget, fromSouce, "t.LastUpdateTime desc ", "LastUpdateTime desc ");
|
}
|
|
/// <summary>
|
/// 根据keyId获取投诉实体
|
/// </summary>
|
/// <param name="keyId"></param>
|
/// <returns></returns>
|
public Integrity_ComplainanInfo GetModel(int keyId)
|
{
|
string selectTarget = " a.*,b.Name AS RespondentName,c.Name AS ComplaintsStatus,d.Name as ComplaintsTypeName,e.Name as ComplainantName ";
|
string fromSouce = @" Integrity_ComplainanInfo a INNER JOIN dbo.EC_MemberBasic b
|
ON a.RespondentId=b.MemberId
|
INNER JOIN dbo.EC_MemberBasic e
|
ON a.ComplainantId=e.MemberId
|
INNER JOIN Sys_Dictionary c ON a.ComplaintsStatusId=c.MeanValue AND c.DicType='投诉状态'
|
INNER JOIN Sys_Dictionary d ON a.ComplaintsTypeId=d.MeanValue AND d.DicType='投诉类型' ";
|
string condition = string.Empty;
|
condition = " a.KeyId=" + keyId;
|
IList<Integrity_ComplainanInfo> result = _dataBase.SelectModel<Integrity_ComplainanInfo>(selectTarget, fromSouce, condition);
|
return null == result || result.Count == 0 ? null : result[0];
|
}
|
}
|
}
|