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.
DS7/DSWeb/Areas/SoftMng/DAL/t_code_cust_mailproject_det...

216 lines
8.5 KiB
C#

3 years ago
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
{
//t_code_cust_mailproject_detail
public partial class t_code_cust_mailproject_detailDAL
{
public bool Exists(int DE_ID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from t_code_cust_mailproject_detail");
strSql.Append(" where ");
strSql.Append(" DE_ID = @DE_ID ");
SqlParameter[] parameters = {
new SqlParameter("@DE_ID", SqlDbType.Int,4)
};
parameters[0].Value = DE_ID;
return DbHelperSQL.Exists(strSql.ToString(),parameters);
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(DSWeb.SoftMng.Model.t_code_cust_mailproject_detail model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into t_code_cust_mailproject_detail(");
strSql.Append("方案代码,单据类型,收件人,主题模板,邮件内容,附件名称");
strSql.Append(") values (");
strSql.Append("@方案代码,@单据类型,@收件人,@主题模板,@邮件内容,@附件名称");
strSql.Append(") ");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = {
new SqlParameter("@方案代码", SqlDbType.Int,4) ,
new SqlParameter("@单据类型", SqlDbType.VarChar,20) ,
new SqlParameter("@收件人", SqlDbType.VarChar,100) ,
new SqlParameter("@主题模板", SqlDbType.VarChar,100) ,
new SqlParameter("@邮件内容", SqlDbType.VarChar,200) ,
new SqlParameter("@附件名称", SqlDbType.VarChar,100)
};
parameters[0].Value = model.;
parameters[1].Value = model.??(Object)DBNull.Value;
parameters[2].Value = model.??(Object)DBNull.Value;
parameters[3].Value = model.??(Object)DBNull.Value;
parameters[4].Value = model.??(Object)DBNull.Value;
parameters[5].Value = model.??(Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 更新一条数据
/// </summary>
public int Update(DSWeb.SoftMng.Model.t_code_cust_mailproject_detail model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update t_code_cust_mailproject_detail set ");
strSql.Append(" 方案代码 = @方案代码,");
strSql.Append(" 单据类型 = @单据类型,");
strSql.Append(" 收件人 = @收件人,");
strSql.Append(" 主题模板 = @主题模板,");
strSql.Append(" 邮件内容 = @邮件内容,");
strSql.Append(" 附件名称 = @附件名称");
strSql.Append(" where DE_ID=@DE_ID ");
SqlParameter[] parameters = {
new SqlParameter("@DE_ID", SqlDbType.Int,4) ,
new SqlParameter("@方案代码", SqlDbType.Int,4) ,
new SqlParameter("@单据类型", SqlDbType.VarChar,20) ,
new SqlParameter("@收件人", SqlDbType.VarChar,100) ,
new SqlParameter("@主题模板", SqlDbType.VarChar,100) ,
new SqlParameter("@邮件内容", SqlDbType.VarChar,200) ,
new SqlParameter("@附件名称", SqlDbType.VarChar,100)
};
parameters[0].Value = model.DE_ID;
parameters[1].Value = model.;
parameters[2].Value = model.??(Object)DBNull.Value;
parameters[3].Value = model.??(Object)DBNull.Value;
parameters[4].Value = model.??(Object)DBNull.Value;
parameters[5].Value = model.??(Object)DBNull.Value;
parameters[6].Value = model.??(Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 删除一条数据
/// </summary>
public int Delete(int DE_ID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from t_code_cust_mailproject_detail ");
strSql.Append(" where DE_ID=@DE_ID");
SqlParameter[] parameters = {
new SqlParameter("@DE_ID", SqlDbType.Int,4)
};
parameters[0].Value = DE_ID;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 批量删除一批数据
/// </summary>
public int DeleteList(string DE_IDlist )
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from t_code_cust_mailproject_detail ");
strSql.Append(" where ID in ("+DE_IDlist + ") ");
return DbHelperSQL.ExecuteSql(strSql.ToString());
}
/// <summary>
/// 按条件批量删除
/// </summary>
public int DeleteListWhere(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from t_code_cust_mailproject_detail ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExecuteSql(strSql.ToString());
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public DataSet GetModel(int DE_ID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select DE_ID, 方案代码, 单据类型, 收件人, 主题模板, 邮件内容, 附件名称 ");
strSql.Append(" from t_code_cust_mailproject_detail ");
strSql.Append(" where DE_ID=@DE_ID");
SqlParameter[] parameters = {
new SqlParameter("@DE_ID", SqlDbType.Int,4)
};
parameters[0].Value = DE_ID;
DSWeb.SoftMng.Model.t_code_cust_mailproject_detail model=new DSWeb.SoftMng.Model.t_code_cust_mailproject_detail();
return DbHelperSQL.Query(strSql.ToString(),parameters);
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select * ");
strSql.Append(" FROM t_code_cust_mailproject_detail ");
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 t_code_cust_mailproject_detail ");
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 t_code_cust_mailproject_detail 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 t_code_cust_mailproject_detail ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExcuteScalarSQL(strSql.ToString());
}
}
}