UseThings.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:8k
- //------------------------------------------------------------------------------
- // 创建标识: Copyright (C) 2009 Socansoft.com 版权所有
- // 创建描述: SocanCode代码生成器 V4.3.2.3 自动创建于 2009-12-17 16:12:23
- //
- // 功能描述:
- //
- // 修改标识:
- // 修改描述:
- //------------------------------------------------------------------------------
- using System;
- using System.Data;
- using System.Data.Common;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- namespace SqlServerDAL
- {
- /// <summary>
- /// 数据访问类 UseThings
- /// </summary>
- public class UseThings : DALHelper
- {
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(Model.UseThings model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("INSERT INTO UseThings(");
- strSql.Append("YPMC,YPBM,YPLB,YPMS,JLDW,DJ,GYS,JJKC,DQKC,CJR,DJQX)");
- strSql.Append(" VALUES (");
- strSql.Append("@in_YPMC,@in_YPBM,@in_YPLB,@in_YPMS,@in_JLDW,@in_DJ,@in_GYS,@in_JJKC,@in_DQKC,@in_CJR,@in_DJQX)");
DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_YPMC", DbType.AnsiString, model.YPMC),
- DataBaseOAHelper.CreateInDbParameter("@in_YPBM", DbType.AnsiString, model.YPBM),
- DataBaseOAHelper.CreateInDbParameter("@in_YPLB", DbType.AnsiString, model.YPLB),
- DataBaseOAHelper.CreateInDbParameter("@in_YPMS", DbType.AnsiString, model.YPMS),
- DataBaseOAHelper.CreateInDbParameter("@in_JLDW", DbType.AnsiString, model.JLDW),
- DataBaseOAHelper.CreateInDbParameter("@in_DJ", DbType.Currency, model.DJ),
- DataBaseOAHelper.CreateInDbParameter("@in_GYS", DbType.AnsiString, model.GYS),
- DataBaseOAHelper.CreateInDbParameter("@in_JJKC", DbType.Int32, model.JJKC),
- DataBaseOAHelper.CreateInDbParameter("@in_DQKC", DbType.Int32, model.DQKC),
- DataBaseOAHelper.CreateInDbParameter("@in_CJR", DbType.AnsiString, model.CJR),
- DataBaseOAHelper.CreateInDbParameter("@in_DJQX", DbType.String, model.DJQX)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public int Update(Model.UseThings model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("UPDATE UseThings SET ");
- strSql.Append("YPMC=@in_YPMC,");
- strSql.Append("YPBM=@in_YPBM,");
- strSql.Append("YPLB=@in_YPLB,");
- strSql.Append("YPMS=@in_YPMS,");
- strSql.Append("JLDW=@in_JLDW,");
- strSql.Append("DJ=@in_DJ,");
- strSql.Append("GYS=@in_GYS,");
- strSql.Append("JJKC=@in_JJKC,");
- strSql.Append("DQKC=@in_DQKC,");
- strSql.Append("CJR=@in_CJR,");
- strSql.Append("DJQX=@in_DJQX");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_YPMC", DbType.AnsiString, model.YPMC),
- DataBaseOAHelper.CreateInDbParameter("@in_YPBM", DbType.AnsiString, model.YPBM),
- DataBaseOAHelper.CreateInDbParameter("@in_YPLB", DbType.AnsiString, model.YPLB),
- DataBaseOAHelper.CreateInDbParameter("@in_YPMS", DbType.AnsiString, model.YPMS),
- DataBaseOAHelper.CreateInDbParameter("@in_JLDW", DbType.AnsiString, model.JLDW),
- DataBaseOAHelper.CreateInDbParameter("@in_DJ", DbType.Currency, model.DJ),
- DataBaseOAHelper.CreateInDbParameter("@in_GYS", DbType.AnsiString, model.GYS),
- DataBaseOAHelper.CreateInDbParameter("@in_JJKC", DbType.Int32, model.JJKC),
- DataBaseOAHelper.CreateInDbParameter("@in_DQKC", DbType.Int32, model.DQKC),
- DataBaseOAHelper.CreateInDbParameter("@in_CJR", DbType.AnsiString, model.CJR),
- DataBaseOAHelper.CreateInDbParameter("@in_DJQX", DbType.String, model.DJQX),
- 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 UseThings ");
- 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 UseThings", null);
- return DataBaseOAHelper.GetInt(obj);
- }
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT COUNT(1) FROM UseThings");
- 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.UseThings GetModel(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT * FROM UseThings ");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, ID)};
- Model.UseThings 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.UseThings> GetList()
- {
- StringBuilder strSql = new StringBuilder("SELECT * FROM UseThings");
- using (DbDataReader dr = DataBaseOAHelper.ExecuteReader(CommandType.Text, strSql.ToString(), null))
- {
- List<Model.UseThings> lst = GetList(dr);
- return lst;
- }
- }
- /// <summary>
- /// 得到数据条数
- /// </summary>
- public int GetCount(string condition)
- {
- return DataBaseOAHelper.GetCount("UseThings", condition);
- }
- /// <summary>
- /// 分页获取泛型数据列表
- /// </summary>
- public List<Model.UseThings> GetPageList(int pageSize, int pageIndex, string fldSort, bool fldDir, string condition)
- {
- using (DbDataReader dr = DataBaseOAHelper.GetPageList("UseThings", pageSize, pageIndex, fldSort, fldDir, condition))
- {
- List<Model.UseThings> lst = GetList(dr);
- return lst;
- }
- }
- #region -------- 私有方法,通常情况下无需修改 --------
- /// <summary>
- /// 由一行数据得到一个实体
- /// </summary>
- private Model.UseThings GetModel(DbDataReader dr)
- {
- Model.UseThings model = new Model.UseThings();
- model.ID = DataBaseOAHelper.GetInt(dr["ID"]);
- model.YPMC = DataBaseOAHelper.GetString(dr["YPMC"]);
- model.YPBM = DataBaseOAHelper.GetString(dr["YPBM"]);
- model.YPLB = DataBaseOAHelper.GetString(dr["YPLB"]);
- model.YPMS = DataBaseOAHelper.GetString(dr["YPMS"]);
- model.JLDW = DataBaseOAHelper.GetString(dr["JLDW"]);
- model.DJ = DataBaseOAHelper.GetDecimal(dr["DJ"]);
- model.GYS = DataBaseOAHelper.GetString(dr["GYS"]);
- model.JJKC = DataBaseOAHelper.GetInt(dr["JJKC"]);
- model.DQKC = DataBaseOAHelper.GetInt(dr["DQKC"]);
- model.CJR = DataBaseOAHelper.GetString(dr["CJR"]);
- model.DJQX = DataBaseOAHelper.GetString(dr["DJQX"]);
- return model;
- }
- /// <summary>
- /// 由DbDataReader得到泛型数据列表
- /// </summary>
- private List<Model.UseThings> GetList(DbDataReader dr)
- {
- List<Model.UseThings> lst = new List<Model.UseThings>();
- while (dr.Read())
- {
- lst.Add(GetModel(dr));
- }
- return lst;
- }
- #endregion
- }
- }