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