WebMailProfile.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:7k
- //------------------------------------------------------------------------------
- // 创建标识: 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>
- /// 数据访问类 WebMailProfile
- /// </summary>
- public class WebMailProfile : DALHelper
- {
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(Model.WebMailProfile model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("INSERT INTO WebMailProfile(");
- strSql.Append("UserName,AliasName,Email,MailServerIP,MailServerPort,UID)");
- strSql.Append(" VALUES (");
- strSql.Append("@in_UserName,@in_AliasName,@in_Email,@in_MailServerIP,@in_MailServerPort,@in_UID)");
DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_UserName", DbType.AnsiString, model.UserName),
- DataBaseOAHelper.CreateInDbParameter("@in_AliasName", DbType.AnsiString, model.AliasName),
- DataBaseOAHelper.CreateInDbParameter("@in_Email", DbType.AnsiString, model.Email),
- DataBaseOAHelper.CreateInDbParameter("@in_MailServerIP", DbType.AnsiString, model.MailServerIP),
- DataBaseOAHelper.CreateInDbParameter("@in_MailServerPort", DbType.Int32, model.MailServerPort),
- DataBaseOAHelper.CreateInDbParameter("@in_UID", DbType.Int32, model.UID)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public int Update(Model.WebMailProfile model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("UPDATE WebMailProfile SET ");
- strSql.Append("UserName=@in_UserName,");
- strSql.Append("AliasName=@in_AliasName,");
- strSql.Append("Email=@in_Email,");
- strSql.Append("MailServerIP=@in_MailServerIP,");
- strSql.Append("MailServerPort=@in_MailServerPort,");
- strSql.Append("UID=@in_UID");
- strSql.Append(" WHERE WebMailID=@in_WebMailID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_UserName", DbType.AnsiString, model.UserName),
- DataBaseOAHelper.CreateInDbParameter("@in_AliasName", DbType.AnsiString, model.AliasName),
- DataBaseOAHelper.CreateInDbParameter("@in_Email", DbType.AnsiString, model.Email),
- DataBaseOAHelper.CreateInDbParameter("@in_MailServerIP", DbType.AnsiString, model.MailServerIP),
- DataBaseOAHelper.CreateInDbParameter("@in_MailServerPort", DbType.Int32, model.MailServerPort),
- DataBaseOAHelper.CreateInDbParameter("@in_UID", DbType.Int32, model.UID),
- DataBaseOAHelper.CreateInDbParameter("@in_WebMailID", DbType.Int32, model.WebMailID)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 删除一条数据
- /// </summary>
- public int Delete(int WebMailID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("DELETE FROM WebMailProfile ");
- strSql.Append(" WHERE WebMailID=@in_WebMailID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_WebMailID", DbType.Int32, WebMailID)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 得到最大ID
- /// </summary>
- public int GetMaxId()
- {
- object obj = DataBaseOAHelper.ExecuteScalar(CommandType.Text, "SELECT MAX(WebMailID) FROM WebMailProfile", null);
- return DataBaseOAHelper.GetInt(obj);
- }
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int WebMailID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT COUNT(1) FROM WebMailProfile");
- strSql.Append(" WHERE WebMailID=@in_WebMailID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_WebMailID", DbType.Int32, WebMailID)};
- object obj = DataBaseOAHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), cmdParms);
- return DataBaseOAHelper.GetInt(obj) > 0;
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public Model.WebMailProfile GetModel(int WebMailID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT * FROM WebMailProfile ");
- strSql.Append(" WHERE WebMailID=@in_WebMailID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_WebMailID", DbType.Int32, WebMailID)};
- Model.WebMailProfile 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.WebMailProfile> GetList()
- {
- StringBuilder strSql = new StringBuilder("SELECT * FROM WebMailProfile");
- using (DbDataReader dr = DataBaseOAHelper.ExecuteReader(CommandType.Text, strSql.ToString(), null))
- {
- List<Model.WebMailProfile> lst = GetList(dr);
- return lst;
- }
- }
- /// <summary>
- /// 得到数据条数
- /// </summary>
- public int GetCount(string condition)
- {
- return DataBaseOAHelper.GetCount("WebMailProfile", condition);
- }
- /// <summary>
- /// 分页获取泛型数据列表
- /// </summary>
- public List<Model.WebMailProfile> GetPageList(int pageSize, int pageIndex, string fldSort, bool fldDir, string condition)
- {
- using (DbDataReader dr = DataBaseOAHelper.GetPageList("WebMailProfile", pageSize, pageIndex, fldSort, fldDir, condition))
- {
- List<Model.WebMailProfile> lst = GetList(dr);
- return lst;
- }
- }
- #region -------- 私有方法,通常情况下无需修改 --------
- /// <summary>
- /// 由一行数据得到一个实体
- /// </summary>
- private Model.WebMailProfile GetModel(DbDataReader dr)
- {
- Model.WebMailProfile model = new Model.WebMailProfile();
- model.WebMailID = DataBaseOAHelper.GetInt(dr["WebMailID"]);
- model.UserName = DataBaseOAHelper.GetString(dr["UserName"]);
- model.AliasName = DataBaseOAHelper.GetString(dr["AliasName"]);
- model.Email = DataBaseOAHelper.GetString(dr["Email"]);
- model.MailServerIP = DataBaseOAHelper.GetString(dr["MailServerIP"]);
- model.MailServerPort = DataBaseOAHelper.GetInt(dr["MailServerPort"]);
- model.UID = DataBaseOAHelper.GetInt(dr["UID"]);
- return model;
- }
- /// <summary>
- /// 由DbDataReader得到泛型数据列表
- /// </summary>
- private List<Model.WebMailProfile> GetList(DbDataReader dr)
- {
- List<Model.WebMailProfile> lst = new List<Model.WebMailProfile>();
- while (dr.Read())
- {
- lst.Add(GetModel(dr));
- }
- return lst;
- }
- #endregion
- }
- }