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.

258 lines
12 KiB
C#

10 months 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
{
//sys_message
public partial class sys_messageDAL
{
public bool Exists(string GID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(1) from [sys_message]");
strSql.Append(" where ");
strSql.Append(" GID = @GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
return DbHelperSQL.Exists(strSql.ToString(), parameters);
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(DSWeb.SoftMng.Model.sys_message model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into [sys_message](");
strSql.Append("GID,TYPE,TASKURL,TASKID,ISDELETE,DELETEUSER,DELETETIME,RECVTYPE,ISSEND,NAME,DESCRIPTION,CREATETIME,ISREAD,READCOUNT,MESSAGECONTENT,LASTREADTIME,RECEIVER");
strSql.Append(") values (");
strSql.Append("@GID,@TYPE,@TASKURL,@TASKID,@ISDELETE,@DELETEUSER,@DELETETIME,@RECVTYPE,@ISSEND,@NAME,@DESCRIPTION,@CREATETIME,@ISREAD,@READCOUNT,@MESSAGECONTENT,@LASTREADTIME,@RECEIVER");
strSql.Append(") ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@TYPE", SqlDbType.Int,4) ,
new SqlParameter("@TASKURL", SqlDbType.VarChar,300) ,
new SqlParameter("@TASKID", SqlDbType.VarChar,100) ,
new SqlParameter("@ISDELETE", SqlDbType.Bit,1) ,
new SqlParameter("@DELETEUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@DELETETIME", SqlDbType.DateTime) ,
new SqlParameter("@RECVTYPE", SqlDbType.Int,4) ,
new SqlParameter("@ISSEND", SqlDbType.Bit,1) ,
new SqlParameter("@NAME", SqlDbType.VarChar,50) ,
new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,50) ,
new SqlParameter("@CREATETIME", SqlDbType.DateTime) ,
new SqlParameter("@ISREAD", SqlDbType.Bit,1) ,
new SqlParameter("@READCOUNT", SqlDbType.Int,4) ,
new SqlParameter("@MESSAGECONTENT", SqlDbType.VarChar,500) ,
new SqlParameter("@LASTREADTIME", SqlDbType.DateTime) ,
new SqlParameter("@RECEIVER", SqlDbType.VarChar,36)
};
parameters[0].Value = model.GID ?? (Object)DBNull.Value;
parameters[1].Value = model.TYPE ?? (Object)DBNull.Value;
parameters[2].Value = model.TASKURL ?? (Object)DBNull.Value;
parameters[3].Value = model.TASKID ?? (Object)DBNull.Value;
parameters[4].Value = model.ISDELETE ?? (Object)DBNull.Value;
parameters[5].Value = model.DELETEUSER ?? (Object)DBNull.Value;
parameters[6].Value = model.DELETETIME ?? (Object)DBNull.Value;
parameters[7].Value = model.RECVTYPE;
parameters[8].Value = model.ISSEND ?? (Object)DBNull.Value;
parameters[9].Value = model.NAME ?? (Object)DBNull.Value;
parameters[10].Value = model.DESCRIPTION ?? (Object)DBNull.Value;
parameters[11].Value = model.CREATETIME ?? (Object)DBNull.Value;
parameters[12].Value = model.ISREAD ?? (Object)DBNull.Value;
parameters[13].Value = model.READCOUNT ?? (Object)DBNull.Value;
parameters[14].Value = model.MESSAGECONTENT ?? (Object)DBNull.Value;
parameters[15].Value = model.LASTREADTIME ?? (Object)DBNull.Value;
parameters[16].Value = model.RECEIVER ?? (Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
}
/// <summary>
/// 更新一条数据
/// </summary>
public int Update(DSWeb.SoftMng.Model.sys_message model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update [sys_message] set ");
strSql.Append(" GID = @GID,");
strSql.Append(" TYPE = @TYPE,");
strSql.Append(" TASKURL = @TASKURL,");
strSql.Append(" TASKID = @TASKID,");
strSql.Append(" ISDELETE = @ISDELETE,");
strSql.Append(" DELETEUSER = @DELETEUSER,");
strSql.Append(" DELETETIME = @DELETETIME,");
strSql.Append(" RECVTYPE = @RECVTYPE,");
strSql.Append(" ISSEND = @ISSEND,");
strSql.Append(" NAME = @NAME,");
strSql.Append(" DESCRIPTION = @DESCRIPTION,");
//strSql.Append(" CREATETIME = @CREATETIME,");//sys_message分区后该列不能修改
strSql.Append(" ISREAD = @ISREAD,");
strSql.Append(" READCOUNT = @READCOUNT,");
strSql.Append(" MESSAGECONTENT = @MESSAGECONTENT,");
strSql.Append(" LASTREADTIME = @LASTREADTIME,");
strSql.Append(" RECEIVER = @RECEIVER");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@TYPE", SqlDbType.Int,4) ,
new SqlParameter("@TASKURL", SqlDbType.VarChar,300) ,
new SqlParameter("@TASKID", SqlDbType.VarChar,100) ,
new SqlParameter("@ISDELETE", SqlDbType.Bit,1) ,
new SqlParameter("@DELETEUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@DELETETIME", SqlDbType.DateTime) ,
new SqlParameter("@NUMBER", SqlDbType.Int,4) ,
new SqlParameter("@RECVTYPE", SqlDbType.Int,4) ,
new SqlParameter("@ISSEND", SqlDbType.Bit,1) ,
new SqlParameter("@NAME", SqlDbType.VarChar,50) ,
new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,50) ,
//new SqlParameter("@CREATETIME", SqlDbType.DateTime) ,
new SqlParameter("@ISREAD", SqlDbType.Bit,1) ,
new SqlParameter("@READCOUNT", SqlDbType.Int,4) ,
new SqlParameter("@MESSAGECONTENT", SqlDbType.VarChar,500) ,
new SqlParameter("@LASTREADTIME", SqlDbType.DateTime) ,
new SqlParameter("@RECEIVER", SqlDbType.VarChar,36)
};
parameters[0].Value = model.GID ?? (Object)DBNull.Value;
parameters[1].Value = model.TYPE ?? (Object)DBNull.Value;
parameters[2].Value = model.TASKURL ?? (Object)DBNull.Value;
parameters[3].Value = model.TASKID ?? (Object)DBNull.Value;
parameters[4].Value = model.ISDELETE ?? (Object)DBNull.Value;
parameters[5].Value = model.DELETEUSER ?? (Object)DBNull.Value;
parameters[6].Value = model.DELETETIME ?? (Object)DBNull.Value;
parameters[7].Value = model.NUMBER;
parameters[8].Value = model.RECVTYPE;
parameters[9].Value = model.ISSEND ?? (Object)DBNull.Value;
parameters[10].Value = model.NAME ?? (Object)DBNull.Value;
parameters[11].Value = model.DESCRIPTION ?? (Object)DBNull.Value;
//parameters[12].Value = model.CREATETIME ?? (Object)DBNull.Value;
parameters[12].Value = model.ISREAD ?? (Object)DBNull.Value;
parameters[13].Value = model.READCOUNT ?? (Object)DBNull.Value;
parameters[14].Value = model.MESSAGECONTENT ?? (Object)DBNull.Value;
parameters[15].Value = model.LASTREADTIME ?? (Object)DBNull.Value;
parameters[16].Value = model.RECEIVER ?? (Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
}
/// <summary>
/// 删除一条数据
/// </summary>
public int Delete(string GID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from [sys_message] ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
return DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
}
/// <summary>
/// 按条件批量删除
/// </summary>
public int DeleteListWhere(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from [sys_message] ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
return DbHelperSQL.ExecuteSql(strSql.ToString());
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public DataSet GetModel(string GID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select GID, TYPE, TASKURL, TASKID, ISDELETE, DELETEUSER, DELETETIME, NUMBER, RECVTYPE, ISSEND, NAME, DESCRIPTION, CREATETIME, ISREAD, READCOUNT, MESSAGECONTENT, LASTREADTIME, RECEIVER ");
strSql.Append(" from [sys_message] ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
DSWeb.SoftMng.Model.sys_message model = new DSWeb.SoftMng.Model.sys_message();
return DbHelperSQL.Query(strSql.ToString(), parameters);
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * ");
strSql.Append(" FROM [sys_message] ");
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 [sys_message] ");
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 [sys_message] 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 [sys_message] ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
return DbHelperSQL.ExcuteScalarSQL(strSql.ToString());
}
}
}