Sms.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:8k
- //------------------------------------------------------------------------------
- // 创建标识: Copyright (C) 2009 Socansoft.com 版权所有
- // 创建描述: SocanCode代码生成器 V4.3.2.3 自动创建于 2009-11-15 20:10:34
- //
- // 功能描述:
- //
- // 修改标识:
- // 修改描述:
- //------------------------------------------------------------------------------
- using System;
- using System.Data;
- using System.Data.Common;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- namespace SqlServerDAL
- {
- /// <summary>
- /// 数据访问类 Sms
- /// </summary>
- public class Sms : DALHelper
- {
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(Model.Sms model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("INSERT INTO Sms(");
- strSql.Append("SmsId,FromId,ToId,Type,Content,SendTime,RemindFlag,Url,DeleteFlag,TableName,RelateId)");
- strSql.Append(" VALUES (");
- strSql.Append("@in_SmsId,@in_FromId,@in_ToId,@in_Type,@in_Content,@in_SendTime,@in_RemindFlag,@in_Url,@in_DeleteFlag,@in_TableName,@in_RelateId)");
DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_SmsId", DbType.Int32, model.SmsId),
- DataBaseOAHelper.CreateInDbParameter("@in_FromId", DbType.String, model.FromId),
- DataBaseOAHelper.CreateInDbParameter("@in_ToId", DbType.String, model.ToId),
- DataBaseOAHelper.CreateInDbParameter("@in_Type", DbType.Int32, model.Type),
- DataBaseOAHelper.CreateInDbParameter("@in_Content", DbType.String, model.Content),
- DataBaseOAHelper.CreateInDbParameter("@in_SendTime", DbType.String, model.SendTime),
- DataBaseOAHelper.CreateInDbParameter("@in_RemindFlag", DbType.Boolean, model.RemindFlag),
- DataBaseOAHelper.CreateInDbParameter("@in_Url", DbType.String, model.Url),
- DataBaseOAHelper.CreateInDbParameter("@in_DeleteFlag", DbType.Int32, model.DeleteFlag),
- DataBaseOAHelper.CreateInDbParameter("@in_TableName", DbType.String, model.TableName),
- DataBaseOAHelper.CreateInDbParameter("@in_RelateId", DbType.Int32, model.RelateId)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public int Update(Model.Sms model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("UPDATE Sms SET ");
- strSql.Append("SmsId=@in_SmsId,");
- strSql.Append("FromId=@in_FromId,");
- strSql.Append("ToId=@in_ToId,");
- strSql.Append("Type=@in_Type,");
- strSql.Append("Content=@in_Content,");
- strSql.Append("SendTime=@in_SendTime,");
- strSql.Append("RemindFlag=@in_RemindFlag,");
- strSql.Append("Url=@in_Url,");
- strSql.Append("DeleteFlag=@in_DeleteFlag,");
- strSql.Append("TableName=@in_TableName,");
- strSql.Append("RelateId=@in_RelateId");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_SmsId", DbType.Int32, model.SmsId),
- DataBaseOAHelper.CreateInDbParameter("@in_FromId", DbType.String, model.FromId),
- DataBaseOAHelper.CreateInDbParameter("@in_ToId", DbType.String, model.ToId),
- DataBaseOAHelper.CreateInDbParameter("@in_Type", DbType.Int32, model.Type),
- DataBaseOAHelper.CreateInDbParameter("@in_Content", DbType.String, model.Content),
- DataBaseOAHelper.CreateInDbParameter("@in_SendTime", DbType.String, model.SendTime),
- DataBaseOAHelper.CreateInDbParameter("@in_RemindFlag", DbType.Boolean, model.RemindFlag),
- DataBaseOAHelper.CreateInDbParameter("@in_Url", DbType.String, model.Url),
- DataBaseOAHelper.CreateInDbParameter("@in_DeleteFlag", DbType.Int32, model.DeleteFlag),
- DataBaseOAHelper.CreateInDbParameter("@in_TableName", DbType.String, model.TableName),
- DataBaseOAHelper.CreateInDbParameter("@in_RelateId", DbType.Int32, model.RelateId),
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, model.ID)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 删除一条数据
- /// </summary>
- public int Delete(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("DELETE FROM Sms ");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, ID)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 得到最大ID
- /// </summary>
- public int GetMaxId()
- {
- object obj = DataBaseOAHelper.ExecuteScalar(CommandType.Text, "SELECT MAX(ID) FROM Sms", null);
- return DataBaseOAHelper.GetInt(obj);
- }
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT COUNT(1) FROM Sms");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, ID)};
- object obj = DataBaseOAHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), cmdParms);
- return DataBaseOAHelper.GetInt(obj) > 0;
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public Model.Sms GetModel(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT * FROM Sms ");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, ID)};
- Model.Sms model = null;
- using (DbDataReader dr = DataBaseOAHelper.ExecuteReader(CommandType.Text, strSql.ToString(), cmdParms))
- {
- while (dr.Read())
- {
- model = GetModel(dr);
- }
- return model;
- }
- }
- /// <summary>
- /// 获取泛型数据列表
- /// </summary>
- public List<Model.Sms> GetList()
- {
- StringBuilder strSql = new StringBuilder("SELECT * FROM Sms");
- using (DbDataReader dr = DataBaseOAHelper.ExecuteReader(CommandType.Text, strSql.ToString(), null))
- {
- List<Model.Sms> lst = GetList(dr);
- return lst;
- }
- }
- /// <summary>
- /// 得到数据条数
- /// </summary>
- public int GetCount(string condition)
- {
- return DataBaseOAHelper.GetCount("Sms", condition);
- }
- /// <summary>
- /// 分页获取泛型数据列表
- /// </summary>
- public List<Model.Sms> GetPageList(int pageSize, int pageIndex, string fldSort, bool fldDir, string condition)
- {
- using (DbDataReader dr = DataBaseOAHelper.GetPageList("Sms", pageSize, pageIndex, fldSort, fldDir, condition))
- {
- List<Model.Sms> lst = GetList(dr);
- return lst;
- }
- }
- #region -------- 私有方法,通常情况下无需修改 --------
- /// <summary>
- /// 由一行数据得到一个实体
- /// </summary>
- private Model.Sms GetModel(DbDataReader dr)
- {
- Model.Sms model = new Model.Sms();
- model.SmsId = DataBaseOAHelper.GetInt(dr["SmsId"]);
- model.FromId = DataBaseOAHelper.GetString(dr["FromId"]);
- model.ToId = DataBaseOAHelper.GetString(dr["ToId"]);
- model.Type = DataBaseOAHelper.GetInt(dr["Type"]);
- model.Content = DataBaseOAHelper.GetString(dr["Content"]);
- model.SendTime = DataBaseOAHelper.GetDateTime(dr["SendTime"]);
- model.RemindFlag = DataBaseOAHelper.GetBool(dr["RemindFlag"]);
- model.Url = DataBaseOAHelper.GetString(dr["Url"]);
- model.DeleteFlag = DataBaseOAHelper.GetInt(dr["DeleteFlag"]);
- model.TableName = DataBaseOAHelper.GetString(dr["TableName"]);
- model.RelateId = DataBaseOAHelper.GetInt(dr["RelateId"]);
- model.ID = DataBaseOAHelper.GetInt(dr["ID"]);
- return model;
- }
- /// <summary>
- /// 由DbDataReader得到泛型数据列表
- /// </summary>
- private List<Model.Sms> GetList(DbDataReader dr)
- {
- List<Model.Sms> lst = new List<Model.Sms>();
- while (dr.Read())
- {
- lst.Add(GetModel(dr));
- }
- return lst;
- }
- #endregion
- }
- }