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
public partial class t_code_cust_mailprojectDAL
{
public bool Exists(int 方案代码)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from t_code_cust_mailproject");
strSql.Append(" where ");
strSql.Append(" 方案代码 = @方案代码 ");
SqlParameter[] parameters = {
new SqlParameter("@方案代码", SqlDbType.Int,4)
};
parameters[0].Value = 方案代码;
return DbHelperSQL.Exists(strSql.ToString(),parameters);
}
///
/// 增加一条数据
///
public int Add(DSWeb.SoftMng.Model.t_code_cust_mailproject model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into t_code_cust_mailproject(");
strSql.Append("客户名称,方案名称,默认方案,录入人,录入日期,方案备注");
strSql.Append(") values (");
strSql.Append("@客户名称,@方案名称,@默认方案,@录入人,@录入日期,@方案备注");
strSql.Append(") ");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = {
new SqlParameter("@客户名称", SqlDbType.VarChar,30) ,
new SqlParameter("@方案名称", SqlDbType.VarChar,30) ,
new SqlParameter("@默认方案", SqlDbType.Bit,1) ,
new SqlParameter("@录入人", SqlDbType.VarChar,10) ,
new SqlParameter("@录入日期", SqlDbType.DateTime) ,
new SqlParameter("@方案备注", SqlDbType.VarChar,60)
};
parameters[0].Value = model.客户名称??(Object)DBNull.Value;
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.录入日期;
parameters[5].Value = model.方案备注??(Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
///
/// 更新一条数据
///
public int Update(DSWeb.SoftMng.Model.t_code_cust_mailproject model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update t_code_cust_mailproject set ");
strSql.Append(" 客户名称 = @客户名称,");
strSql.Append(" 方案名称 = @方案名称,");
strSql.Append(" 默认方案 = @默认方案,");
strSql.Append(" 录入人 = @录入人,");
strSql.Append(" 录入日期 = @录入日期,");
strSql.Append(" 方案备注 = @方案备注");
strSql.Append(" where 方案代码=@方案代码 ");
SqlParameter[] parameters = {
new SqlParameter("@方案代码", SqlDbType.Int,4) ,
new SqlParameter("@客户名称", SqlDbType.VarChar,30) ,
new SqlParameter("@方案名称", SqlDbType.VarChar,30) ,
new SqlParameter("@默认方案", SqlDbType.Bit,1) ,
new SqlParameter("@录入人", SqlDbType.VarChar,10) ,
new SqlParameter("@录入日期", SqlDbType.DateTime) ,
new SqlParameter("@方案备注", SqlDbType.VarChar,60)
};
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.录入日期;
parameters[6].Value = model.方案备注??(Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
///
/// 删除一条数据
///
public int Delete(int 方案代码)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from t_code_cust_mailproject ");
strSql.Append(" where 方案代码=@方案代码");
SqlParameter[] parameters = {
new SqlParameter("@方案代码", SqlDbType.Int,4)
};
parameters[0].Value = 方案代码;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
///
/// 批量删除一批数据
///
public int DeleteList(string 方案代码list )
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from t_code_cust_mailproject ");
strSql.Append(" where ID in ("+方案代码list + ") ");
return DbHelperSQL.ExecuteSql(strSql.ToString());
}
///
/// 按条件批量删除
///
public int DeleteListWhere(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from t_code_cust_mailproject ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExecuteSql(strSql.ToString());
}
///
/// 得到一个对象实体
///
public DataSet GetModel(int 方案代码)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select 方案代码, 客户名称, 方案名称, 默认方案, 录入人, 录入日期, 方案备注 ");
strSql.Append(" from t_code_cust_mailproject ");
strSql.Append(" where 方案代码=@方案代码");
SqlParameter[] parameters = {
new SqlParameter("@方案代码", SqlDbType.Int,4)
};
parameters[0].Value = 方案代码;
DSWeb.SoftMng.Model.t_code_cust_mailproject model=new DSWeb.SoftMng.Model.t_code_cust_mailproject();
return DbHelperSQL.Query(strSql.ToString(),parameters);
}
///
/// 获得数据列表
///
public DataSet GetList(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select * ");
strSql.Append(" FROM t_code_cust_mailproject ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 获得前几行数据
///
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 ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
strSql.Append(" order by " + filedOrder);
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 分页获取数据列表
///
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 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());
}
///
/// 获取记录总数
///
public int GetRecordCount(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) FROM t_code_cust_mailproject ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExcuteScalarSQL(strSql.ToString());
}
}
}