CarUse.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:8k
- //------------------------------------------------------------------------------
- // 创建标识: Copyright (C) 2009 Socansoft.com 版权所有
- // 创建描述: SocanCode代码生成器 V4.3.3.5 自动创建于 2009-12-25 15:18:14
- //
- // 功能描述:
- //
- // 修改标识:
- // 修改描述:
- //------------------------------------------------------------------------------
- using System;
- using System.Data;
- using System.Data.Common;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- namespace SqlServerDAL
- {
- /// <summary>
- /// 数据访问类 CarUse
- /// </summary>
- public class CarUse : DALHelper
- {
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(Model.CarUse model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("INSERT INTO CarUse(");
- strSql.Append("CPH,YCR,SY,KSSJ,SYZT,JSSJ,BZ,MDD,LC,SJ,YCBM,SQR,DDY)");
- strSql.Append(" VALUES (");
- strSql.Append("@in_CPH,@in_YCR,@in_SY,@in_KSSJ,@in_SYZT,@in_JSSJ,@in_BZ,@in_MDD,@in_LC,@in_SJ,@in_YCBM,@in_SQR,@in_DDY)");
DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_CPH", DbType.AnsiString, model.CPH),
- DataBaseOAHelper.CreateInDbParameter("@in_YCR", DbType.AnsiString, model.YCR),
- DataBaseOAHelper.CreateInDbParameter("@in_SY", DbType.AnsiString, model.SY),
- DataBaseOAHelper.CreateInDbParameter("@in_KSSJ", DbType.String, model.KSSJ),
- DataBaseOAHelper.CreateInDbParameter("@in_SYZT", DbType.AnsiString, model.SYZT),
- DataBaseOAHelper.CreateInDbParameter("@in_JSSJ", DbType.String, model.JSSJ),
- DataBaseOAHelper.CreateInDbParameter("@in_BZ", DbType.String, model.BZ),
- DataBaseOAHelper.CreateInDbParameter("@in_MDD", DbType.AnsiString, model.MDD),
- DataBaseOAHelper.CreateInDbParameter("@in_LC", DbType.Double, model.LC),
- DataBaseOAHelper.CreateInDbParameter("@in_SJ", DbType.AnsiString, model.SJ),
- DataBaseOAHelper.CreateInDbParameter("@in_YCBM", DbType.Int32, model.YCBM),
- DataBaseOAHelper.CreateInDbParameter("@in_SQR", DbType.AnsiString, model.SQR),
- DataBaseOAHelper.CreateInDbParameter("@in_DDY", DbType.AnsiString, model.DDY)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public int Update(Model.CarUse model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("UPDATE CarUse SET ");
- strSql.Append("CPH=@in_CPH,");
- strSql.Append("YCR=@in_YCR,");
- strSql.Append("SY=@in_SY,");
- strSql.Append("KSSJ=@in_KSSJ,");
- strSql.Append("SYZT=@in_SYZT,");
- strSql.Append("JSSJ=@in_JSSJ,");
- strSql.Append("BZ=@in_BZ,");
- strSql.Append("MDD=@in_MDD,");
- strSql.Append("LC=@in_LC,");
- strSql.Append("SJ=@in_SJ,");
- strSql.Append("YCBM=@in_YCBM,");
- strSql.Append("SQR=@in_SQR,");
- strSql.Append("DDY=@in_DDY");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_CPH", DbType.AnsiString, model.CPH),
- DataBaseOAHelper.CreateInDbParameter("@in_YCR", DbType.AnsiString, model.YCR),
- DataBaseOAHelper.CreateInDbParameter("@in_SY", DbType.AnsiString, model.SY),
- DataBaseOAHelper.CreateInDbParameter("@in_KSSJ", DbType.String, model.KSSJ),
- DataBaseOAHelper.CreateInDbParameter("@in_SYZT", DbType.AnsiString, model.SYZT),
- DataBaseOAHelper.CreateInDbParameter("@in_JSSJ", DbType.String, model.JSSJ),
- DataBaseOAHelper.CreateInDbParameter("@in_BZ", DbType.String, model.BZ),
- DataBaseOAHelper.CreateInDbParameter("@in_MDD", DbType.AnsiString, model.MDD),
- DataBaseOAHelper.CreateInDbParameter("@in_LC", DbType.Double, model.LC),
- DataBaseOAHelper.CreateInDbParameter("@in_SJ", DbType.AnsiString, model.SJ),
- DataBaseOAHelper.CreateInDbParameter("@in_YCBM", DbType.Int32, model.YCBM),
- DataBaseOAHelper.CreateInDbParameter("@in_SQR", DbType.AnsiString, model.SQR),
- DataBaseOAHelper.CreateInDbParameter("@in_DDY", DbType.AnsiString, model.DDY),
- 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 CarUse ");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, ID)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT COUNT(1) FROM CarUse");
- 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.CarUse GetModel(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT * FROM CarUse ");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, ID)};
- Model.CarUse 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.CarUse> GetList()
- {
- StringBuilder strSql = new StringBuilder("SELECT * FROM CarUse");
- using (DbDataReader dr = DataBaseOAHelper.ExecuteReader(CommandType.Text, strSql.ToString(), null))
- {
- List<Model.CarUse> lst = GetList(dr);
- return lst;
- }
- }
- /// <summary>
- /// 得到数据条数
- /// </summary>
- public int GetCount(string condition)
- {
- return DataBaseOAHelper.GetCount("CarUse", condition);
- }
- /// <summary>
- /// 分页获取泛型数据列表
- /// </summary>
- public List<Model.CarUse> GetPageList(int pageSize, int pageIndex, string fldSort, bool fldDir, string condition)
- {
- using (DbDataReader dr = DataBaseOAHelper.GetPageList("CarUse", pageSize, pageIndex, fldSort, fldDir, condition))
- {
- List<Model.CarUse> lst = GetList(dr);
- return lst;
- }
- }
- #region -------- 私有方法,通常情况下无需修改 --------
- /// <summary>
- /// 由一行数据得到一个实体
- /// </summary>
- private Model.CarUse GetModel(DbDataReader dr)
- {
- Model.CarUse model = new Model.CarUse();
- model.ID = DataBaseOAHelper.GetInt(dr["ID"]);
- model.CPH = DataBaseOAHelper.GetString(dr["CPH"]);
- model.YCR = DataBaseOAHelper.GetString(dr["YCR"]);
- model.SY = DataBaseOAHelper.GetString(dr["SY"]);
- model.KSSJ = DataBaseOAHelper.GetDateTime(dr["KSSJ"]);
- model.SYZT = DataBaseOAHelper.GetString(dr["SYZT"]);
- model.JSSJ = DataBaseOAHelper.GetDateTime(dr["JSSJ"]);
- model.BZ = DataBaseOAHelper.GetString(dr["BZ"]);
- model.MDD = DataBaseOAHelper.GetString(dr["MDD"]);
- model.LC = DataBaseOAHelper.GetDouble(dr["LC"]);
- model.SJ = DataBaseOAHelper.GetString(dr["SJ"]);
- model.YCBM = DataBaseOAHelper.GetInt(dr["YCBM"]);
- model.SQR = DataBaseOAHelper.GetString(dr["SQR"]);
- model.DDY = DataBaseOAHelper.GetString(dr["DDY"]);
- return model;
- }
- /// <summary>
- /// 由DbDataReader得到泛型数据列表
- /// </summary>
- private List<Model.CarUse> GetList(DbDataReader dr)
- {
- List<Model.CarUse> lst = new List<Model.CarUse>();
- while (dr.Read())
- {
- lst.Add(GetModel(dr));
- }
- return lst;
- }
- #endregion
- }
- }