/** 版本信息模板在安装目录下,可自行修改。 * usernotice.cs * * 功 能: N/A * 类 名: usernotice * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── * V0.01 2022/2/21 10:07:01 N/A 初版 * * Copyright (c) 2012 Maticsoft Corporation. All rights reserved. *┌──────────────────────────────────┐ *│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │ *│ 版权所有:动软卓越(北京)科技有限公司              │ *└──────────────────────────────────┘ */ using System; using System.Data; using System.Text; using System.Data.SqlClient; using YTSoft.DBUtility; namespace YTSoft.BaseCallCenter.DAL { /// /// 数据访问类:usernotice /// public partial class usernotice { public usernotice() {} #region BasicMethod /// /// 增加一条数据 /// public int Add(YTSoft.BaseCallCenter.Model.usernotice model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into usernotice("); strSql.Append("F_noticeid,F_userid,F_state)"); strSql.Append(" values ("); strSql.Append("SQL2012F_noticeid,SQL2012F_userid,SQL2012F_state)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("SQL2012F_noticeid", SqlDbType.Int,4), new SqlParameter("SQL2012F_userid", SqlDbType.Int,4), new SqlParameter("SQL2012F_state", SqlDbType.Int,4)}; parameters[0].Value = model.F_noticeid; parameters[1].Value = model.F_userid; parameters[2].Value = model.F_state; object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// /// 更新一条数据 /// public bool Update(YTSoft.BaseCallCenter.Model.usernotice model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update usernotice set "); strSql.Append("F_noticeid=SQL2012F_noticeid,"); strSql.Append("F_userid=SQL2012F_userid,"); strSql.Append("F_state=SQL2012F_state"); strSql.Append(" where F_id=SQL2012F_id"); SqlParameter[] parameters = { new SqlParameter("SQL2012F_noticeid", SqlDbType.Int,4), new SqlParameter("SQL2012F_userid", SqlDbType.Int,4), new SqlParameter("SQL2012F_state", SqlDbType.Int,4), new SqlParameter("SQL2012F_id", SqlDbType.Int,4)}; parameters[0].Value = model.F_noticeid; parameters[1].Value = model.F_userid; parameters[2].Value = model.F_state; parameters[3].Value = model.F_id; int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } } /// /// 删除一条数据 /// public bool Delete(int F_id) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from usernotice "); strSql.Append(" where F_id=SQL2012F_id"); SqlParameter[] parameters = { new SqlParameter("SQL2012F_id", SqlDbType.Int,4) }; parameters[0].Value = F_id; int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } } /// /// 批量删除数据 /// public bool DeleteList(string F_idlist ) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from usernotice "); strSql.Append(" where F_id in ("+F_idlist + ") "); int rows=DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return true; } else { return false; } } /// /// 得到一个对象实体 /// public YTSoft.BaseCallCenter.Model.usernotice GetModel(int F_id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 F_id,F_noticeid,F_userid,F_state from usernotice "); strSql.Append(" where F_id=SQL2012F_id"); SqlParameter[] parameters = { new SqlParameter("SQL2012F_id", SqlDbType.Int,4) }; parameters[0].Value = F_id; YTSoft.BaseCallCenter.Model.usernotice model=new YTSoft.BaseCallCenter.Model.usernotice(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } } /// /// 得到一个对象实体 /// public YTSoft.BaseCallCenter.Model.usernotice DataRowToModel(DataRow row) { YTSoft.BaseCallCenter.Model.usernotice model=new YTSoft.BaseCallCenter.Model.usernotice(); if (row != null) { if(row["F_id"]!=null && row["F_id"].ToString()!="") { model.F_id=int.Parse(row["F_id"].ToString()); } if(row["F_noticeid"]!=null && row["F_noticeid"].ToString()!="") { model.F_noticeid=int.Parse(row["F_noticeid"].ToString()); } if(row["F_userid"]!=null && row["F_userid"].ToString()!="") { model.F_userid=int.Parse(row["F_userid"].ToString()); } if(row["F_state"]!=null && row["F_state"].ToString()!="") { model.F_state=int.Parse(row["F_state"].ToString()); } } return model; } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("select F_id,F_noticeid,F_userid,F_state "); strSql.Append(" FROM usernotice "); 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(" F_id,F_noticeid,F_userid,F_state "); strSql.Append(" FROM usernotice "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } strSql.Append(" order by " + filedOrder); return DbHelperSQL.Query(strSql.ToString()); } /// /// 获取记录总数 /// public int GetRecordCount(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("select count(1) FROM usernotice "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } object obj = DbHelperSQL.GetSingle(strSql.ToString()); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// /// 分页获取数据列表 /// 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_id desc"); } strSql.Append(")AS Row, T.* from usernotice 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()); } /* /// /// 分页获取数据列表 /// public DataSet GetList(int PageSize,int PageIndex,string strWhere) { SqlParameter[] parameters = { new SqlParameter("SQL2012tblName", SqlDbType.VarChar, 255), new SqlParameter("SQL2012fldName", SqlDbType.VarChar, 255), new SqlParameter("SQL2012PageSize", SqlDbType.Int), new SqlParameter("SQL2012PageIndex", SqlDbType.Int), new SqlParameter("SQL2012IsReCount", SqlDbType.Bit), new SqlParameter("SQL2012OrderType", SqlDbType.Bit), new SqlParameter("SQL2012strWhere", SqlDbType.VarChar,1000), }; parameters[0].Value = "usernotice"; parameters[1].Value = "F_id"; parameters[2].Value = PageSize; parameters[3].Value = PageIndex; parameters[4].Value = 0; parameters[5].Value = 0; parameters[6].Value = strWhere; return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); }*/ #endregion BasicMethod #region ExtensionMethod #endregion ExtensionMethod } }