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
{
//FeedbackInfo
public partial class FeedbackInfoDAL
{
public bool Exists(int id)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from FeedbackInfo");
strSql.Append(" where ");
strSql.Append(" id = @id ");
SqlParameter[] parameters = {
new SqlParameter("@id", SqlDbType.Int,4)
};
parameters[0].Value = id;
return DbHelperSQL.Exists(strSql.ToString(),parameters);
}
///
/// 增加一条数据
///
public int Add(DSWeb.SoftMng.Model.FeedbackInfo model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into FeedbackInfo(");
strSql.Append("replyMsg,replyUser,replyUserID,replyDate,attachMent,isDelete,feedbackID");
strSql.Append(") values (");
strSql.Append("@replyMsg,@replyUser,@replyUserID,@replyDate,@attachMent,@isDelete,@feedbackID");
strSql.Append(") ");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = {
new SqlParameter("@replyMsg", SqlDbType.NVarChar,500) ,
new SqlParameter("@replyUser", SqlDbType.NVarChar,50) ,
new SqlParameter("@replyUserID", SqlDbType.NVarChar,50) ,
new SqlParameter("@replyDate", SqlDbType.DateTime) ,
new SqlParameter("@attachMent", SqlDbType.NText) ,
new SqlParameter("@isDelete", SqlDbType.Bit,1) ,
new SqlParameter("@feedbackID", SqlDbType.Char,10)
};
parameters[0].Value = model.replyMsg??(Object)DBNull.Value;
parameters[1].Value = model.replyUser??(Object)DBNull.Value;
parameters[2].Value = model.replyUserID??(Object)DBNull.Value;
parameters[3].Value = model.replyDate??(Object)DBNull.Value;
parameters[4].Value = model.attachMent??(Object)DBNull.Value;
parameters[5].Value = model.isDelete??(Object)DBNull.Value;
parameters[6].Value = model.feedbackID??(Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
///
/// 更新一条数据
///
public int Update(DSWeb.SoftMng.Model.FeedbackInfo model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update FeedbackInfo set ");
strSql.Append(" replyMsg = @replyMsg,");
strSql.Append(" replyUser = @replyUser,");
strSql.Append(" replyUserID = @replyUserID,");
strSql.Append(" replyDate = @replyDate,");
strSql.Append(" attachMent = @attachMent,");
strSql.Append(" isDelete = @isDelete,");
strSql.Append(" feedbackID = @feedbackID");
strSql.Append(" where id=@id ");
SqlParameter[] parameters = {
new SqlParameter("@id", SqlDbType.Int,4) ,
new SqlParameter("@replyMsg", SqlDbType.NVarChar,500) ,
new SqlParameter("@replyUser", SqlDbType.NVarChar,50) ,
new SqlParameter("@replyUserID", SqlDbType.NVarChar,50) ,
new SqlParameter("@replyDate", SqlDbType.DateTime) ,
new SqlParameter("@attachMent", SqlDbType.NText) ,
new SqlParameter("@isDelete", SqlDbType.Bit,1) ,
new SqlParameter("@feedbackID", SqlDbType.Char,10)
};
parameters[0].Value = model.id;
parameters[1].Value = model.replyMsg??(Object)DBNull.Value;
parameters[2].Value = model.replyUser??(Object)DBNull.Value;
parameters[3].Value = model.replyUserID??(Object)DBNull.Value;
parameters[4].Value = model.replyDate??(Object)DBNull.Value;
parameters[5].Value = model.attachMent??(Object)DBNull.Value;
parameters[6].Value = model.isDelete??(Object)DBNull.Value;
parameters[7].Value = model.feedbackID??(Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
///
/// 删除一条数据
///
public int Delete(int id)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from FeedbackInfo ");
strSql.Append(" where id=@id");
SqlParameter[] parameters = {
new SqlParameter("@id", SqlDbType.Int,4)
};
parameters[0].Value = id;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
///
/// 批量删除一批数据
///
public int DeleteList(string idlist )
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from FeedbackInfo ");
strSql.Append(" where ID in ("+idlist + ") ");
return DbHelperSQL.ExecuteSql(strSql.ToString());
}
///
/// 按条件批量删除
///
public int DeleteListWhere(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from FeedbackInfo ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExecuteSql(strSql.ToString());
}
///
/// 得到一个对象实体
///
public DataSet GetModel(int id)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select id, replyMsg, replyUser, replyUserID, replyDate, attachMent, isDelete, feedbackID ");
strSql.Append(" from FeedbackInfo ");
strSql.Append(" where id=@id");
SqlParameter[] parameters = {
new SqlParameter("@id", SqlDbType.Int,4)
};
parameters[0].Value = id;
DSWeb.SoftMng.Model.FeedbackInfo model=new DSWeb.SoftMng.Model.FeedbackInfo();
return DbHelperSQL.Query(strSql.ToString(),parameters);
}
///
/// 获得数据列表
///
public DataSet GetList(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select * ");
strSql.Append(" FROM FeedbackInfo ");
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 FeedbackInfo ");
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 FeedbackInfo 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 FeedbackInfo ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExcuteScalarSQL(strSql.ToString());
}
}
}