CRM.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:10k
- //------------------------------------------------------------------------------
- // 创建标识: Copyright (C) 2009 Socansoft.com 版权所有
- // 创建描述: SocanCode代码生成器 V4.3.2.3 自动创建于 2009-12-26 9:12:28
- //
- // 功能描述:
- //
- // 修改标识:
- // 修改描述:
- //------------------------------------------------------------------------------
- using System;
- using System.Data;
- using System.Data.Common;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- namespace SqlServerDAL
- {
- /// <summary>
- /// 数据访问类 CRM
- /// </summary>
- public class CRM : DALHelper
- {
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(Model.CRM model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("INSERT INTO CRM(");
- strSql.Append("XM,NC,XB,GDDH,SJHM,Email,QQ,MSN,BZ,GS,DZ,WZ,FL,XXDZ,DLIP,KFID,WYID,ZHJHM)");
- strSql.Append(" VALUES (");
- strSql.Append("@in_XM,@in_NC,@in_XB,@in_GDDH,@in_SJHM,@in_Email,@in_QQ,@in_MSN,@in_BZ,@in_GS,@in_DZ,@in_WZ,@in_FL,@in_XXDZ,@in_DLIP,@in_KFID,@in_WYID,@in_ZHJHM)");
DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_XM", DbType.AnsiString, model.XM),
- DataBaseOAHelper.CreateInDbParameter("@in_NC", DbType.AnsiString, model.NC),
- DataBaseOAHelper.CreateInDbParameter("@in_XB", DbType.AnsiString, model.XB),
- DataBaseOAHelper.CreateInDbParameter("@in_GDDH", DbType.AnsiString, model.GDDH),
- DataBaseOAHelper.CreateInDbParameter("@in_SJHM", DbType.AnsiString, model.SJHM),
- DataBaseOAHelper.CreateInDbParameter("@in_Email", DbType.AnsiString, model.Email),
- DataBaseOAHelper.CreateInDbParameter("@in_QQ", DbType.AnsiString, model.QQ),
- DataBaseOAHelper.CreateInDbParameter("@in_MSN", DbType.AnsiString, model.MSN),
- DataBaseOAHelper.CreateInDbParameter("@in_BZ", DbType.String, model.BZ),
- DataBaseOAHelper.CreateInDbParameter("@in_GS", DbType.AnsiString, model.GS),
- DataBaseOAHelper.CreateInDbParameter("@in_DZ", DbType.AnsiString, model.DZ),
- DataBaseOAHelper.CreateInDbParameter("@in_WZ", DbType.AnsiString, model.WZ),
- DataBaseOAHelper.CreateInDbParameter("@in_FL", DbType.AnsiString, model.FL),
- DataBaseOAHelper.CreateInDbParameter("@in_XXDZ", DbType.String, model.XXDZ),
- DataBaseOAHelper.CreateInDbParameter("@in_DLIP", DbType.AnsiString, model.DLIP),
- DataBaseOAHelper.CreateInDbParameter("@in_KFID", DbType.AnsiString, model.KFID),
- DataBaseOAHelper.CreateInDbParameter("@in_WYID", DbType.Int32, model.WYID),
- DataBaseOAHelper.CreateInDbParameter("@in_ZHJHM", DbType.AnsiString, model.ZHJHM)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public int Update(Model.CRM model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("UPDATE CRM SET ");
- strSql.Append("XM=@in_XM,");
- strSql.Append("NC=@in_NC,");
- strSql.Append("XB=@in_XB,");
- strSql.Append("GDDH=@in_GDDH,");
- strSql.Append("SJHM=@in_SJHM,");
- strSql.Append("Email=@in_Email,");
- strSql.Append("QQ=@in_QQ,");
- strSql.Append("MSN=@in_MSN,");
- strSql.Append("BZ=@in_BZ,");
- strSql.Append("GS=@in_GS,");
- strSql.Append("DZ=@in_DZ,");
- strSql.Append("WZ=@in_WZ,");
- strSql.Append("FL=@in_FL,");
- strSql.Append("XXDZ=@in_XXDZ,");
- strSql.Append("DLIP=@in_DLIP,");
- strSql.Append("TJSJ=@in_TJSJ,");
- strSql.Append("KFID=@in_KFID,");
- strSql.Append("WYID=@in_WYID,");
- strSql.Append("ZHJHM=@in_ZHJHM");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_XM", DbType.AnsiString, model.XM),
- DataBaseOAHelper.CreateInDbParameter("@in_NC", DbType.AnsiString, model.NC),
- DataBaseOAHelper.CreateInDbParameter("@in_XB", DbType.AnsiString, model.XB),
- DataBaseOAHelper.CreateInDbParameter("@in_GDDH", DbType.AnsiString, model.GDDH),
- DataBaseOAHelper.CreateInDbParameter("@in_SJHM", DbType.AnsiString, model.SJHM),
- DataBaseOAHelper.CreateInDbParameter("@in_Email", DbType.AnsiString, model.Email),
- DataBaseOAHelper.CreateInDbParameter("@in_QQ", DbType.AnsiString, model.QQ),
- DataBaseOAHelper.CreateInDbParameter("@in_MSN", DbType.AnsiString, model.MSN),
- DataBaseOAHelper.CreateInDbParameter("@in_BZ", DbType.String, model.BZ),
- DataBaseOAHelper.CreateInDbParameter("@in_GS", DbType.AnsiString, model.GS),
- DataBaseOAHelper.CreateInDbParameter("@in_DZ", DbType.AnsiString, model.DZ),
- DataBaseOAHelper.CreateInDbParameter("@in_WZ", DbType.AnsiString, model.WZ),
- DataBaseOAHelper.CreateInDbParameter("@in_FL", DbType.AnsiString, model.FL),
- DataBaseOAHelper.CreateInDbParameter("@in_XXDZ", DbType.String, model.XXDZ),
- DataBaseOAHelper.CreateInDbParameter("@in_DLIP", DbType.AnsiString, model.DLIP),
- DataBaseOAHelper.CreateInDbParameter("@in_TJSJ", DbType.String, model.TJSJ),
- DataBaseOAHelper.CreateInDbParameter("@in_KFID", DbType.AnsiString, model.KFID),
- DataBaseOAHelper.CreateInDbParameter("@in_WYID", DbType.Int32, model.WYID),
- DataBaseOAHelper.CreateInDbParameter("@in_ZHJHM", DbType.AnsiString, model.ZHJHM),
- 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 CRM ");
- 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 CRM", null);
- return DataBaseOAHelper.GetInt(obj);
- }
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT COUNT(1) FROM CRM");
- 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.CRM GetModel(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT * FROM CRM ");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, ID)};
- Model.CRM 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.CRM> GetList()
- {
- StringBuilder strSql = new StringBuilder("SELECT * FROM CRM");
- using (DbDataReader dr = DataBaseOAHelper.ExecuteReader(CommandType.Text, strSql.ToString(), null))
- {
- List<Model.CRM> lst = GetList(dr);
- return lst;
- }
- }
- /// <summary>
- /// 得到数据条数
- /// </summary>
- public int GetCount(string condition)
- {
- return DataBaseOAHelper.GetCount("CRM", condition);
- }
- /// <summary>
- /// 分页获取泛型数据列表
- /// </summary>
- public List<Model.CRM> GetPageList(int pageSize, int pageIndex, string fldSort, bool fldDir, string condition)
- {
- using (DbDataReader dr = DataBaseOAHelper.GetPageList("CRM", pageSize, pageIndex, fldSort, fldDir, condition))
- {
- List<Model.CRM> lst = GetList(dr);
- return lst;
- }
- }
- #region -------- 私有方法,通常情况下无需修改 --------
- /// <summary>
- /// 由一行数据得到一个实体
- /// </summary>
- private Model.CRM GetModel(DbDataReader dr)
- {
- Model.CRM model = new Model.CRM();
- model.ID = DataBaseOAHelper.GetInt(dr["ID"]);
- model.XM = DataBaseOAHelper.GetString(dr["XM"]);
- model.NC = DataBaseOAHelper.GetString(dr["NC"]);
- model.XB = DataBaseOAHelper.GetString(dr["XB"]);
- model.GDDH = DataBaseOAHelper.GetString(dr["GDDH"]);
- model.SJHM = DataBaseOAHelper.GetString(dr["SJHM"]);
- model.Email = DataBaseOAHelper.GetString(dr["Email"]);
- model.QQ = DataBaseOAHelper.GetString(dr["QQ"]);
- model.MSN = DataBaseOAHelper.GetString(dr["MSN"]);
- model.BZ = DataBaseOAHelper.GetString(dr["BZ"]);
- model.GS = DataBaseOAHelper.GetString(dr["GS"]);
- model.DZ = DataBaseOAHelper.GetString(dr["DZ"]);
- model.WZ = DataBaseOAHelper.GetString(dr["WZ"]);
- model.FL = DataBaseOAHelper.GetString(dr["FL"]);
- model.XXDZ = DataBaseOAHelper.GetString(dr["XXDZ"]);
- model.DLIP = DataBaseOAHelper.GetString(dr["DLIP"]);
- model.TJSJ = DataBaseOAHelper.GetDateTime(dr["TJSJ"]);
- model.KFID = DataBaseOAHelper.GetString(dr["KFID"]);
- model.WYID = DataBaseOAHelper.GetInt(dr["WYID"]);
- model.ZHJHM = DataBaseOAHelper.GetString(dr["ZHJHM"]);
- return model;
- }
- /// <summary>
- /// 由DbDataReader得到泛型数据列表
- /// </summary>
- private List<Model.CRM> GetList(DbDataReader dr)
- {
- List<Model.CRM> lst = new List<Model.CRM>();
- while (dr.Read())
- {
- lst.Add(GetModel(dr));
- }
- return lst;
- }
- #endregion
- }
- }