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;
|
using System.Transactions;
|
namespace CY.SQLDAL
|
{
|
//软件代理
|
public class Soft_ProxyDAL:ISoft_ProxyDAL
|
{
|
private Database _dataBase = null;
|
|
public Soft_ProxyDAL()
|
{
|
_dataBase = new Database();
|
}
|
|
public Soft_ProxyDAL(Database dataBase)
|
{
|
_dataBase = dataBase;
|
}
|
|
/// <summary>
|
/// 新增
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Soft_Proxy trueModel = model as Model.Soft_Proxy;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{ new SqlParameter("@ProxyName", trueModel.ProxyName) ,
|
new SqlParameter("@ProxyStatus", trueModel.ProxyStatus) ,
|
new SqlParameter("@ProxyPhone", trueModel.ProxyPhone) ,
|
new SqlParameter("@ProxyQQ", trueModel.ProxyQQ) ,
|
new SqlParameter("@ProxyMobile", trueModel.ProxyMobile) ,
|
new SqlParameter("@ProxyCardNum", trueModel.ProxyCardNum) ,
|
new SqlParameter("@ProxyCardImg", trueModel.ProxyCardImg) ,
|
new SqlParameter("@ProxyProvince", trueModel.ProxyProvince) ,
|
new SqlParameter("@ProxyCity", trueModel.ProxyCity) ,
|
new SqlParameter("@ProxyCountry", trueModel.ProxyCountry) ,
|
new SqlParameter("@ProxyType", trueModel.ProxyType) ,
|
new SqlParameter("@ProxyMoneyWay", trueModel.ProxyMoneyWay) ,
|
new SqlParameter("@ProxyMoneyNum", trueModel.ProxyMoneyNum) ,
|
new SqlParameter("@ProxyCreatTime", trueModel.ProxyCreatTime) ,
|
new SqlParameter("@ProxyEndTime", trueModel.ProxyEndTime) ,
|
new SqlParameter("@LastUpdateTime", trueModel.LastUpdateTime) ,
|
new SqlParameter("@Operator", trueModel.Operator)
|
};
|
try
|
{
|
_dataBase.Query("sp_Soft_Proxy_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.Soft_Proxy trueModel = model as Model.Soft_Proxy;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{ new SqlParameter("@Keyid", trueModel.Keyid) ,
|
new SqlParameter("@ProxyName", trueModel.ProxyName) ,
|
new SqlParameter("@ProxyStatus", trueModel.ProxyStatus) ,
|
new SqlParameter("@ProxyPhone", trueModel.ProxyPhone) ,
|
new SqlParameter("@ProxyQQ", trueModel.ProxyQQ) ,
|
new SqlParameter("@ProxyMobile", trueModel.ProxyMobile) ,
|
new SqlParameter("@ProxyCardNum", trueModel.ProxyCardNum) ,
|
new SqlParameter("@ProxyCardImg", trueModel.ProxyCardImg) ,
|
new SqlParameter("@ProxyProvince", trueModel.ProxyProvince) ,
|
new SqlParameter("@ProxyCity", trueModel.ProxyCity) ,
|
new SqlParameter("@ProxyCountry", trueModel.ProxyCountry) ,
|
new SqlParameter("@ProxyType", trueModel.ProxyType) ,
|
new SqlParameter("@ProxyMoneyWay", trueModel.ProxyMoneyWay) ,
|
new SqlParameter("@ProxyMoneyNum", trueModel.ProxyMoneyNum) ,
|
new SqlParameter("@ProxyCreatTime", trueModel.ProxyCreatTime) ,
|
new SqlParameter("@ProxyEndTime", trueModel.ProxyEndTime) ,
|
new SqlParameter("@LastUpdateTime", trueModel.LastUpdateTime) ,
|
new SqlParameter("@Operator", trueModel.Operator)
|
};
|
try
|
{
|
_dataBase.Query("sp_Soft_Proxy_Update", CommandType.StoredProcedure, sqlParms.ToArray<SqlParameter>());
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
/// <summary>
|
/// 删除
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
|
{
|
Model.Soft_Proxy trueModel = model as Model.Soft_Proxy;
|
if (trueModel == null)
|
{
|
return false;
|
}
|
IList<SqlParameter> sqlParms = new List<SqlParameter>()
|
{
|
new SqlParameter("@Keyid",trueModel.Keyid)
|
};
|
try
|
{
|
_dataBase.Query("sp_Soft_Proxy_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.Soft_Proxy> SelectModelPage(Infrastructure.Query.Query query, Infrastructure.Query.Pagination pagination)
|
{
|
throw new NotImplementedException();
|
}
|
|
/// <summary>
|
/// 单个查询
|
/// </summary>
|
/// <param name="query"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.Soft_Proxy> SelectAllModel(Infrastructure.Query.Query query)
|
{
|
throw new NotImplementedException();
|
}
|
|
/// <summary>
|
/// 根据编号获得信息
|
/// </summary>
|
/// <param name="Keyid">编号</param>
|
/// <returns></returns>
|
public Soft_Proxy GetModelByKeyid(int? Keyid)
|
{
|
try
|
{
|
if (Keyid == null || Keyid < 0)
|
return null;//错误数据返会空
|
|
IList<Soft_Proxy> result = _dataBase.SelectModel<Soft_Proxy>(" * ", " Soft_Proxy ", string.Format(" Keyid='{0}'", Keyid)) as IList<Soft_Proxy>;//执行查询
|
|
return (null == result || result.Count == 0) ? null : result[0];//返回结果
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 分页查询
|
/// </summary>
|
/// <param name="pagination"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.Soft_Proxy> SelectModelPage(Infrastructure.Query.Pagination pagination,string _ProxyName,int? _ProxyStatus,string _ProxyPhone,string _ProxyQQ,string _ProxyMobile,string _ProxyCardNum,string _ProxyCardImg,string _ProxyProvince,string _ProxyCity,string _ProxyCountry,int? _ProxyType,int? _ProxyMoneyWay,int? _ProxyMoneyNum,DateTime? _BeginProxyCreatTime,DateTime? _EndProxyCreatTime,DateTime? _BeginProxyEndTime,DateTime? _EndProxyEndTime,DateTime? _BeginLastUpdateTime,DateTime? _EndLastUpdateTime,string _Operator)
|
{
|
try
|
{
|
string condition = " 1=1 ";
|
|
if (!string.IsNullOrEmpty(_ProxyName))
|
condition += " and ProxyName = '" + _ProxyName + "' ";
|
|
if (_ProxyStatus.HasValue)
|
condition += " and ProxyStatus = '" + _ProxyStatus + "' ";
|
|
if (!string.IsNullOrEmpty(_ProxyPhone))
|
condition += " and ProxyPhone = '" + _ProxyPhone + "' ";
|
|
if (!string.IsNullOrEmpty(_ProxyQQ))
|
condition += " and ProxyQQ = '" + _ProxyQQ + "' ";
|
|
if (!string.IsNullOrEmpty(_ProxyMobile))
|
condition += " and ProxyMobile = '" + _ProxyMobile + "' ";
|
|
if (!string.IsNullOrEmpty(_ProxyCardNum))
|
condition += " and ProxyCardNum = '" + _ProxyCardNum + "' ";
|
|
if (!string.IsNullOrEmpty(_ProxyCardImg))
|
condition += " and ProxyCardImg = '" + _ProxyCardImg + "' ";
|
|
if (!string.IsNullOrEmpty(_ProxyProvince))
|
condition += " and ProxyProvince = '" + _ProxyProvince + "' ";
|
|
if (!string.IsNullOrEmpty(_ProxyCity))
|
condition += " and ProxyCity = '" + _ProxyCity + "' ";
|
|
if (!string.IsNullOrEmpty(_ProxyCountry))
|
condition += " and ProxyCountry = '" + _ProxyCountry + "' ";
|
|
if (_ProxyType.HasValue)
|
condition += " and ProxyType = '" + _ProxyType + "' ";
|
|
if (_ProxyMoneyWay.HasValue)
|
condition += " and ProxyMoneyWay = '" + _ProxyMoneyWay + "' ";
|
|
if (_ProxyMoneyNum.HasValue)
|
condition += " and ProxyMoneyNum = '" + _ProxyMoneyNum + "' ";
|
|
if (_BeginProxyCreatTime.HasValue)
|
condition += string.Format(" and CAST(ProxyCreatTime AS DATE) >='{0}' ", _BeginProxyCreatTime);
|
|
if (_EndProxyCreatTime.HasValue)
|
condition += string.Format(" and CAST(ProxyCreatTime AS DATE) <='{0}' ", _EndProxyCreatTime);
|
|
if (_BeginProxyEndTime.HasValue)
|
condition += string.Format(" and CAST(ProxyEndTime AS DATE) >='{0}' ", _BeginProxyEndTime);
|
|
if (_EndProxyEndTime.HasValue)
|
condition += string.Format(" and CAST(ProxyEndTime AS DATE) <='{0}' ", _EndProxyEndTime);
|
|
if (_BeginLastUpdateTime.HasValue)
|
condition += string.Format(" and CAST(LastUpdateTime AS DATE) >='{0}' ", _BeginLastUpdateTime);
|
|
if (_EndLastUpdateTime.HasValue)
|
condition += string.Format(" and CAST(LastUpdateTime AS DATE) <='{0}' ", _EndLastUpdateTime);
|
|
if (!string.IsNullOrEmpty(_Operator))
|
condition += " and Operator = '" + _Operator + "' ";
|
|
return _dataBase.SelectModelPage<Model.Soft_Proxy>(pagination, " * ", " Soft_Proxy ", " Keyid desc", " Keyid desc ", condition);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
}
|
}
|