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 EC_PrintingConsultancyDAL : IEC_PrintingConsultancyDAL
|
{
|
|
private Database _dataBase = null;
|
|
public EC_PrintingConsultancyDAL()
|
{
|
_dataBase = new Database();
|
}
|
|
/// <summary>
|
/// 新增
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.EC_PrintingConsultancy trueModel = model as Model.EC_PrintingConsultancy;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@PC_Type",trueModel.PC_Type),
|
new SqlParameter("@Memberid",trueModel.Memberid),
|
new SqlParameter("@PC_People",trueModel.PC_People),
|
new SqlParameter("@PC_Phone",trueModel.PC_Phone),
|
new SqlParameter("@PC_Price",trueModel.PC_Price),
|
new SqlParameter("@PC_HopeMoney",trueModel.PC_HopeMoney),
|
new SqlParameter("@PC_Status",trueModel.PC_Status),
|
new SqlParameter("@PC_Remark",trueModel.PC_Remark),
|
new SqlParameter("@PC_Content",trueModel.PC_Content),
|
new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime),
|
new SqlParameter("@Operator",trueModel.Operator)
|
};
|
try
|
{
|
_dataBase.Query("sp_EC_PrintingConsultancy_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.EC_PrintingConsultancy trueModel = model as Model.EC_PrintingConsultancy;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@Keyid",trueModel.Keyid),
|
new SqlParameter("@PC_Type",trueModel.PC_Type),
|
new SqlParameter("@Memberid",trueModel.Memberid),
|
new SqlParameter("@PC_People",trueModel.PC_People),
|
new SqlParameter("@PC_Phone",trueModel.PC_Phone),
|
new SqlParameter("@PC_Price",trueModel.PC_Price),
|
new SqlParameter("@PC_HopeMoney",trueModel.PC_HopeMoney),
|
new SqlParameter("@PC_Status",trueModel.PC_Status),
|
new SqlParameter("@PC_Remark",trueModel.PC_Remark),
|
new SqlParameter("@PC_Content",trueModel.PC_Content),
|
new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime),
|
new SqlParameter("@Operator",trueModel.Operator)
|
};
|
try
|
{
|
_dataBase.Query("sp_EC_PrintingConsultancy_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.EC_PrintingConsultancy trueModel = model as Model.EC_PrintingConsultancy;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@Keyid",trueModel.Keyid)
|
};
|
try
|
{
|
_dataBase.Query("sp_EC_PrintingConsultancy_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.EC_PrintingConsultancy> SelectModelPage(Infrastructure.Query.Query query, Infrastructure.Query.Pagination pagination)
|
{
|
throw new NotImplementedException();
|
}
|
|
/// <summary>
|
/// 根据会员编号分页查询
|
/// </summary>
|
/// <param name="pagination"></param>
|
/// <param name="MemberId"></param>
|
/// <param name="MemberName"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.EC_PrintingConsultancy> SelectModelPage(Infrastructure.Query.Pagination pagination, string MemberId, string MemberName, string PcType)
|
{
|
try
|
{
|
string condtion = " 1=1 ";
|
|
if (!string.IsNullOrEmpty(MemberId))
|
{
|
condtion += " and a.Memberid = '" + MemberId + "'";
|
}
|
|
if (!string.IsNullOrEmpty(MemberName))
|
{
|
condtion += " and b.Name like '%" + MemberName + "%'";
|
}
|
|
if (!string.IsNullOrEmpty(PcType))
|
{
|
condtion += " and a.PC_Type = '" + PcType + "'";
|
}
|
|
IList<EC_PrintingConsultancy> result = _dataBase.SelectModelPage<Model.EC_PrintingConsultancy>(pagination, "a.*,b.Name as MemberName", " EC_PrintingConsultancy a left join EC_MemberBasic b on a.Memberid=b.MemberId ", "a.LastUpdateTime DESC", "LastUpdateTime DESC", condtion) as IList<EC_PrintingConsultancy>;//执行查询
|
|
return null == result ? null : result;//返回结果
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 根据编号查询单个信息
|
/// </summary>
|
/// <param name="Keyid">编号</param>
|
/// <returns></returns>
|
public EC_PrintingConsultancy SelectModelByKeyId(int? KeyId)
|
{
|
if (KeyId == null)
|
return null;//错误数据返会空
|
|
EC_PrintingConsultancy m_EC_PrintingConsultancy = new EC_PrintingConsultancy();
|
try
|
{
|
IList<EC_PrintingConsultancy> result = _dataBase.SelectModel<EC_PrintingConsultancy>("*", "EC_PrintingConsultancy", string.Format(" Keyid='{0}' ", KeyId)) as IList<EC_PrintingConsultancy>;//执行查询
|
if (null == result || result.Count == 0)
|
{
|
m_EC_PrintingConsultancy = null;
|
}
|
else
|
{
|
m_EC_PrintingConsultancy = result[0];
|
}
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return m_EC_PrintingConsultancy;
|
}
|
|
/// <summary>
|
/// 单个查询
|
/// </summary>
|
/// <param name="query"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.EC_PrintingConsultancy> SelectAllModel(Infrastructure.Query.Query query)
|
{
|
|
throw new NotImplementedException();
|
}
|
}
|
}
|