using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using CY.IDAL.Inquiry;
|
using System.Data.SqlClient;
|
using System.Data;
|
using System.Transactions;
|
using CY.Model;
|
|
namespace CY.SQLDAL
|
{
|
public class FollowRecordInfoDAL : IFollowRecordInfoDAL
|
{
|
private Database _dataBase = null;
|
|
public FollowRecordInfoDAL()
|
{
|
_dataBase = new Database();
|
}
|
|
public IList<Model.Inquiry_FollowRecordInfo> GetModeList(int recordId, Infrastructure.Query.Pagination pa)
|
{
|
string selectTarget = " a.*,b.Name AS FollowTypeName,c.Name AS IntentTypeName,d.Name as ResultStatusStr ";
|
string fromSouce = @" Inquiry_FollowRecordInfo a INNER JOIN Sys_Dictionary b
|
ON a.FollowTypeId=b.MeanValue AND b.DicType='跟单方式'
|
INNER JOIN Sys_Dictionary c ON a.IntentTypeId=c.MeanValue
|
AND c.DicType='成交意向'
|
inner join Sys_Dictionary d on a.resultStatus=d.meanvalue and d.DicType='成交状态'
|
where a.RecordId=" + recordId;
|
return _dataBase.SelectModelPage<Model.Inquiry_FollowRecordInfo>(pa, selectTarget, fromSouce, "a.FollowTime desc", "FollowTime desc ", string.Empty);
|
}
|
|
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Inquiry_FollowRecordInfo trueModel = model as Model.Inquiry_FollowRecordInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
SqlParameter customerPricePar = null;
|
if (trueModel.CustomerPrice.HasValue)
|
{
|
customerPricePar = new SqlParameter("@CustomerPrice", trueModel.CustomerPrice.Value);
|
}
|
else
|
{
|
customerPricePar = new SqlParameter("@CustomerPrice", DBNull.Value);
|
}
|
SqlParameter[] parameters = {
|
new SqlParameter("@FollowPerson", SqlDbType.VarChar,100),
|
new SqlParameter("@FollowTypeId", SqlDbType.Int,4),
|
new SqlParameter("@IntentTypeId", SqlDbType.Int,4),
|
new SqlParameter("@FollowRecord", SqlDbType.VarChar,400),
|
new SqlParameter("@FollowTime", SqlDbType.DateTime),
|
new SqlParameter("@RecordId", SqlDbType.Int,4),
|
new SqlParameter("@ResultStatus", SqlDbType.Int,4),
|
customerPricePar
|
};
|
parameters[0].Value = trueModel.FollowPerson;
|
parameters[1].Value = trueModel.FollowTypeId;
|
parameters[2].Value = trueModel.IntentTypeId;
|
parameters[3].Value = trueModel.FollowRecord;
|
parameters[4].Value = trueModel.FollowTime;
|
parameters[5].Value = trueModel.RecordId;
|
parameters[6].Value = trueModel.ResultStatus;
|
try
|
{
|
_dataBase.Query("Inquiry_FollowRecordInfo_ADD", CommandType.StoredProcedure, parameters);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Inquiry_FollowRecordInfo trueModel = model as Model.Inquiry_FollowRecordInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
SqlParameter customerPricePar = null;
|
if (trueModel.CustomerPrice.HasValue)
|
{
|
customerPricePar = new SqlParameter("@CustomerPrice", trueModel.CustomerPrice.Value);
|
}
|
else
|
{
|
customerPricePar = new SqlParameter("@CustomerPrice", DBNull.Value);
|
}
|
SqlParameter[] parameters = {
|
new SqlParameter("@FollowPerson", SqlDbType.VarChar,100),
|
new SqlParameter("@FollowTypeId", SqlDbType.Int,4),
|
new SqlParameter("@IntentTypeId", SqlDbType.Int,4),
|
new SqlParameter("@FollowRecord", SqlDbType.VarChar,400),
|
new SqlParameter("@FollowTime", SqlDbType.DateTime),
|
new SqlParameter("@KeyId", SqlDbType.Int,4),
|
new SqlParameter("@RecordId", SqlDbType.Int,4),
|
new SqlParameter("@ResultStatus", SqlDbType.Int,4),
|
customerPricePar
|
};
|
parameters[0].Value = trueModel.FollowPerson;
|
parameters[1].Value = trueModel.FollowTypeId;
|
parameters[2].Value = trueModel.IntentTypeId;
|
parameters[3].Value = trueModel.FollowRecord;
|
parameters[4].Value = trueModel.FollowTime;
|
parameters[5].Value = trueModel.KeyId;
|
parameters[6].Value = trueModel.RecordId;
|
parameters[7].Value = trueModel.ResultStatus;
|
try
|
{
|
_dataBase.Query("Inquiry_FollowRecordInfo_Update", CommandType.StoredProcedure, parameters);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Inquiry_FollowRecordInfo trueModel = model as Model.Inquiry_FollowRecordInfo;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
SqlParameter[] parameters = {
|
new SqlParameter("@KeyId", SqlDbType.Int,4)
|
};
|
parameters[0].Value = trueModel.KeyId;
|
try
|
{
|
_dataBase.Query("Inquiry_FollowRecordInfo_Delete", CommandType.StoredProcedure, parameters);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
public bool DeleteModel(int keyId)
|
{
|
SqlParameter[] parameters = {
|
new SqlParameter("@KeyId", SqlDbType.Int,4)
|
};
|
parameters[0].Value = keyId;
|
try
|
{
|
_dataBase.Query("Inquiry_FollowRecordInfo_Delete", CommandType.StoredProcedure, parameters);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
/// <summary>
|
/// 批量删除记录
|
/// </summary>
|
/// <param name="keyIdList"></param>
|
/// <returns></returns>
|
public bool DeleteModelList(List<int> keyIdList)
|
{
|
if (keyIdList == null || keyIdList.Count == 0)
|
{
|
return true;
|
}
|
bool isSuccess = true;
|
using (TransactionScope scope = new TransactionScope())
|
{
|
foreach (int keyId in keyIdList)
|
{
|
isSuccess = DeleteModel(keyId);
|
if (!isSuccess)
|
break;
|
}
|
if (isSuccess)
|
scope.Complete();
|
}
|
return isSuccess;
|
}
|
}
|
}
|