You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
6.6 KiB
C#
187 lines
6.6 KiB
C#
using System;
|
|
using System.Text;
|
|
using System.Data.SqlClient;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using DSWeb.SoftMng.DBUtility;
|
|
// ReSharper disable once CheckNamespace
|
|
namespace DSWeb.SoftMng.DAL
|
|
{
|
|
//EmailConfig
|
|
public partial class EmailConfigDAL
|
|
{
|
|
public bool Exists()
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select count(1) from EmailConfig");
|
|
SqlParameter[] parameters = {
|
|
};
|
|
|
|
return DbHelperSQL.Exists(strSql.ToString(),parameters);
|
|
}
|
|
/// <summary>
|
|
/// 增加一条数据
|
|
/// </summary>
|
|
public int Add(DSWeb.SoftMng.Model.EmailConfig model)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("insert into EmailConfig(");
|
|
strSql.Append("EmailAccount,EmailPass,ServerAddr,SSL,Port");
|
|
strSql.Append(") values (");
|
|
strSql.Append("@EmailAccount,@EmailPass,@ServerAddr,@SSL,@Port");
|
|
strSql.Append(") ");
|
|
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@EmailAccount", SqlDbType.VarChar,150) ,
|
|
new SqlParameter("@EmailPass", SqlDbType.VarChar,50) ,
|
|
new SqlParameter("@ServerAddr", SqlDbType.VarChar,50) ,
|
|
new SqlParameter("@SSL", SqlDbType.Bit,1) ,
|
|
new SqlParameter("@Port", SqlDbType.Int,4)
|
|
|
|
};
|
|
|
|
parameters[0].Value = model.EmailAccount??(Object)DBNull.Value;
|
|
parameters[1].Value = model.EmailPass??(Object)DBNull.Value;
|
|
parameters[2].Value = model.ServerAddr??(Object)DBNull.Value;
|
|
parameters[3].Value = model.SSL??(Object)DBNull.Value;
|
|
parameters[4].Value = model.Port??(Object)DBNull.Value;
|
|
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
|
|
}
|
|
/// <summary>
|
|
/// 更新一条数据
|
|
/// </summary>
|
|
public int Update(DSWeb.SoftMng.Model.EmailConfig model)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("update EmailConfig set ");
|
|
|
|
strSql.Append(" EmailAccount = @EmailAccount,");
|
|
strSql.Append(" EmailPass = @EmailPass,");
|
|
strSql.Append(" ServerAddr = @ServerAddr,");
|
|
strSql.Append(" SSL = @SSL,");
|
|
strSql.Append(" Port = @Port");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@EmailAccount", SqlDbType.VarChar,150) ,
|
|
new SqlParameter("@EmailPass", SqlDbType.VarChar,50) ,
|
|
new SqlParameter("@ServerAddr", SqlDbType.VarChar,50) ,
|
|
new SqlParameter("@SSL", SqlDbType.Bit,1) ,
|
|
new SqlParameter("@Port", SqlDbType.Int,4)
|
|
};
|
|
|
|
parameters[0].Value = model.EmailAccount??(Object)DBNull.Value;
|
|
parameters[1].Value = model.EmailPass??(Object)DBNull.Value;
|
|
parameters[2].Value = model.ServerAddr??(Object)DBNull.Value;
|
|
parameters[3].Value = model.SSL??(Object)DBNull.Value;
|
|
parameters[4].Value = model.Port??(Object)DBNull.Value;
|
|
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
|
|
}
|
|
/// <summary>
|
|
/// 删除一条数据
|
|
/// </summary>
|
|
public int Delete()
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("delete from EmailConfig ");
|
|
SqlParameter[] parameters = {
|
|
};
|
|
|
|
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
|
|
}
|
|
/// <summary>
|
|
/// 按条件批量删除
|
|
/// </summary>
|
|
public int DeleteListWhere(string strWhere)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("delete from EmailConfig ");
|
|
if(strWhere.Trim()!="")
|
|
{
|
|
strSql.Append(" where "+strWhere);
|
|
}
|
|
return DbHelperSQL.ExecuteSql(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 得到一个对象实体
|
|
/// </summary>
|
|
public DataSet GetModel()
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select EmailAccount, EmailPass, ServerAddr, SSL, Port ");
|
|
strSql.Append(" from EmailConfig ");
|
|
SqlParameter[] parameters = {
|
|
};
|
|
|
|
DSWeb.SoftMng.Model.EmailConfig model=new DSWeb.SoftMng.Model.EmailConfig();
|
|
return DbHelperSQL.Query(strSql.ToString(),parameters);
|
|
}
|
|
/// <summary>
|
|
/// 获得数据列表
|
|
/// </summary>
|
|
public DataSet GetList(string strWhere)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select * ");
|
|
strSql.Append(" FROM EmailConfig ");
|
|
if(strWhere.Trim()!="")
|
|
{
|
|
strSql.Append(" where "+strWhere);
|
|
}
|
|
return DbHelperSQL.Query(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获得前几行数据
|
|
/// </summary>
|
|
public DataSet GetList(int Top,string strWhere,string filedOrder)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select ");
|
|
if(Top>0)
|
|
{
|
|
strSql.Append(" top "+Top.ToString());
|
|
}
|
|
strSql.Append(" * ");
|
|
strSql.Append(" FROM EmailConfig ");
|
|
if(strWhere.Trim()!="")
|
|
{
|
|
strSql.Append(" where "+strWhere);
|
|
}
|
|
strSql.Append(" order by " + filedOrder);
|
|
return DbHelperSQL.Query(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 分页获取数据列表
|
|
/// </summary>
|
|
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
|
{
|
|
//动软代码
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("SELECT * FROM ( ");
|
|
strSql.Append(" SELECT ROW_NUMBER() OVER (");
|
|
if (!string.IsNullOrEmpty(orderby.Trim()))
|
|
strSql.Append("order by T." + orderby);
|
|
strSql.Append(")AS Row, T.* from EmailConfig T ");
|
|
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
|
{
|
|
strSql.Append(" WHERE " + strWhere);
|
|
}
|
|
strSql.Append(" ) TT");
|
|
strSql.AppendFormat(" WHERE TT.Row > {0} and TT.Row <= {1}", startIndex, endIndex);
|
|
//公共代码
|
|
return DbHelperSQL.Query(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取记录总数
|
|
/// </summary>
|
|
public int GetRecordCount(string strWhere)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select count(1) FROM EmailConfig ");
|
|
if(strWhere.Trim()!="")
|
|
{
|
|
strSql.Append(" where "+strWhere);
|
|
}
|
|
return DbHelperSQL.ExcuteScalarSQL(strSql.ToString());
|
|
}
|
|
}
|
|
}
|