| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- using CallCenterApi.DB;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CallCenterApi.DAL
- {
- /// <summary>
- /// 数据访问类:T_RepositoryLog
- /// </summary>
- public partial class T_RepositoryLog
- {
- public T_RepositoryLog()
- { }
- #region BasicMethod
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int F_LogId)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select count(1) from T_RepositoryLog");
- strSql.Append(" where F_LogId=@F_LogId");
- SqlParameter[] parameters = {
- new SqlParameter("@F_LogId", SqlDbType.Int,4)
- };
- parameters[0].Value = F_LogId;
- return DbHelperSQL.Exists(strSql.ToString(), parameters);
- }
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(CallCenterApi.Model.T_RepositoryLog model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("insert into T_RepositoryLog(");
- strSql.Append("F_RepositoryId,F_Action,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_CreateOn,F_CreateBy,F_Expand1,F_Expand2,F_IntExpand1)");
- strSql.Append(" values (");
- strSql.Append("@F_RepositoryId,@F_Action,@F_Title,@F_Content,@F_Description,@F_Url,@F_KeyWords,@F_CreateOn,@F_CreateBy,@F_Expand1,@F_Expand2,@F_IntExpand1)");
- strSql.Append(";select @@IDENTITY");
- SqlParameter[] parameters = {
- new SqlParameter("@F_RepositoryId", SqlDbType.Int,4),
- new SqlParameter("@F_Action", SqlDbType.Int,4),
- new SqlParameter("@F_Title", SqlDbType.NVarChar,200),
- new SqlParameter("@F_Content", SqlDbType.NText),
- new SqlParameter("@F_Description", SqlDbType.NText),
- new SqlParameter("@F_Url", SqlDbType.NText),
- new SqlParameter("@F_KeyWords", SqlDbType.NVarChar,500),
- new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
- new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
- new SqlParameter("@F_Expand1", SqlDbType.NVarChar,100),
- new SqlParameter("@F_Expand2", SqlDbType.NVarChar,200),
- new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2)};
- parameters[0].Value = model.F_RepositoryId;
- parameters[1].Value = model.F_Action;
- parameters[2].Value = model.F_Title;
- parameters[3].Value = model.F_Content;
- parameters[4].Value = model.F_Description;
- parameters[5].Value = model.F_Url;
- parameters[6].Value = model.F_KeyWords;
- parameters[7].Value = model.F_CreateOn;
- parameters[8].Value = model.F_CreateBy;
- parameters[9].Value = model.F_Expand1;
- parameters[10].Value = model.F_Expand2;
- parameters[11].Value = model.F_IntExpand1;
- object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
- if (obj == null)
- {
- return 0;
- }
- else
- {
- return Convert.ToInt32(obj);
- }
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public bool Update(CallCenterApi.Model.T_RepositoryLog model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("update T_RepositoryLog set ");
- strSql.Append("F_RepositoryId=@F_RepositoryId,");
- strSql.Append("F_Action=@F_Action,");
- strSql.Append("F_Title=@F_Title,");
- strSql.Append("F_Content=@F_Content,");
- strSql.Append("F_Description=@F_Description,");
- strSql.Append("F_Url=@F_Url,");
- strSql.Append("F_KeyWords=@F_KeyWords,");
- strSql.Append("F_CreateOn=@F_CreateOn,");
- strSql.Append("F_CreateBy=@F_CreateBy,");
- strSql.Append("F_Expand1=@F_Expand1,");
- strSql.Append("F_Expand2=@F_Expand2,");
- strSql.Append("F_IntExpand1=@F_IntExpand1");
- strSql.Append(" where F_LogId=@F_LogId");
- SqlParameter[] parameters = {
- new SqlParameter("@F_RepositoryId", SqlDbType.Int,4),
- new SqlParameter("@F_Action", SqlDbType.Int,4),
- new SqlParameter("@F_Title", SqlDbType.NVarChar,200),
- new SqlParameter("@F_Content", SqlDbType.NText),
- new SqlParameter("@F_Description", SqlDbType.NText),
- new SqlParameter("@F_Url", SqlDbType.NText),
- new SqlParameter("@F_KeyWords", SqlDbType.NVarChar,500),
- new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
- new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
- new SqlParameter("@F_Expand1", SqlDbType.NVarChar,100),
- new SqlParameter("@F_Expand2", SqlDbType.NVarChar,200),
- new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2),
- new SqlParameter("@F_LogId", SqlDbType.Int,4)};
- parameters[0].Value = model.F_RepositoryId;
- parameters[1].Value = model.F_Action;
- parameters[2].Value = model.F_Title;
- parameters[3].Value = model.F_Content;
- parameters[4].Value = model.F_Description;
- parameters[5].Value = model.F_Url;
- parameters[6].Value = model.F_KeyWords;
- parameters[7].Value = model.F_CreateOn;
- parameters[8].Value = model.F_CreateBy;
- parameters[9].Value = model.F_Expand1;
- parameters[10].Value = model.F_Expand2;
- parameters[11].Value = model.F_IntExpand1;
- parameters[12].Value = model.F_LogId;
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 删除一条数据
- /// </summary>
- public bool Delete(int F_LogId)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from T_RepositoryLog ");
- strSql.Append(" where F_LogId=@F_LogId");
- SqlParameter[] parameters = {
- new SqlParameter("@F_LogId", SqlDbType.Int,4)
- };
- parameters[0].Value = F_LogId;
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 批量删除数据
- /// </summary>
- public bool DeleteList(string F_LogIdlist)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from T_RepositoryLog ");
- strSql.Append(" where F_LogId in (" + F_LogIdlist + ") ");
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public CallCenterApi.Model.T_RepositoryLog GetModel(int F_LogId)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 F_LogId,F_RepositoryId,F_Action,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_CreateOn,F_CreateBy,F_Expand1,F_Expand2,F_IntExpand1 from T_RepositoryLog ");
- strSql.Append(" where F_LogId=@F_LogId");
- SqlParameter[] parameters = {
- new SqlParameter("@F_LogId", SqlDbType.Int,4)
- };
- parameters[0].Value = F_LogId;
- CallCenterApi.Model.T_RepositoryLog model = new CallCenterApi.Model.T_RepositoryLog();
- DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
- if (ds.Tables[0].Rows.Count > 0)
- {
- return DataRowToModel(ds.Tables[0].Rows[0]);
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public CallCenterApi.Model.T_RepositoryLog DataRowToModel(DataRow row)
- {
- CallCenterApi.Model.T_RepositoryLog model = new CallCenterApi.Model.T_RepositoryLog();
- if (row != null)
- {
- if (row["F_LogId"] != null && row["F_LogId"].ToString() != "")
- {
- model.F_LogId = int.Parse(row["F_LogId"].ToString());
- }
- if (row["F_RepositoryId"] != null && row["F_RepositoryId"].ToString() != "")
- {
- model.F_RepositoryId = int.Parse(row["F_RepositoryId"].ToString());
- }
- if (row["F_Action"] != null && row["F_Action"].ToString() != "")
- {
- model.F_Action = int.Parse(row["F_Action"].ToString());
- }
- if (row["F_Title"] != null)
- {
- model.F_Title = row["F_Title"].ToString();
- }
- if (row["F_Content"] != null)
- {
- model.F_Content = row["F_Content"].ToString();
- }
- if (row["F_Description"] != null)
- {
- model.F_Description = row["F_Description"].ToString();
- }
- if (row["F_Url"] != null)
- {
- model.F_Url = row["F_Url"].ToString();
- }
- if (row["F_KeyWords"] != null)
- {
- model.F_KeyWords = row["F_KeyWords"].ToString();
- }
- if (row["F_CreateOn"] != null && row["F_CreateOn"].ToString() != "")
- {
- model.F_CreateOn = DateTime.Parse(row["F_CreateOn"].ToString());
- }
- if (row["F_CreateBy"] != null && row["F_CreateBy"].ToString() != "")
- {
- model.F_CreateBy = int.Parse(row["F_CreateBy"].ToString());
- }
- if (row["F_Expand1"] != null)
- {
- model.F_Expand1 = row["F_Expand1"].ToString();
- }
- if (row["F_Expand2"] != null)
- {
- model.F_Expand2 = row["F_Expand2"].ToString();
- }
- if (row["F_IntExpand1"] != null && row["F_IntExpand1"].ToString() != "")
- {
- model.F_IntExpand1 = int.Parse(row["F_IntExpand1"].ToString());
- }
- }
- return model;
- }
- /// <summary>
- /// 获得数据列表
- /// </summary>
- public DataSet GetList(string strWhere)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select F_LogId,F_RepositoryId,F_Action,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_CreateOn,F_CreateBy,F_Expand1,F_Expand2,F_IntExpand1 ");
- strSql.Append(" FROM T_RepositoryLog ");
- 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(" F_LogId,F_RepositoryId,F_Action,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_CreateOn,F_CreateBy,F_Expand1,F_Expand2,F_IntExpand1 ");
- strSql.Append(" FROM T_RepositoryLog ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- strSql.Append(" order by " + filedOrder);
- return DbHelperSQL.Query(strSql.ToString());
- }
- /// <summary>
- /// 获取记录总数
- /// </summary>
- public int GetRecordCount(string strWhere)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select count(1) FROM T_RepositoryLog ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- object obj = DbHelperSQL.GetSingle(strSql.ToString());
- if (obj == null)
- {
- return 0;
- }
- else
- {
- return Convert.ToInt32(obj);
- }
- }
- /// <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);
- }
- else
- {
- strSql.Append("order by T.F_LogId desc");
- }
- strSql.Append(")AS Row, T.* from T_RepositoryLog T ");
- if (!string.IsNullOrEmpty(strWhere.Trim()))
- {
- strSql.Append(" WHERE " + strWhere);
- }
- strSql.Append(" ) TT");
- strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
- return DbHelperSQL.Query(strSql.ToString());
- }
- #endregion BasicMethod
- #region ExtensionMethod
- #endregion ExtensionMethod
- }
- }
|