Cars.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:8k
- //------------------------------------------------------------------------------
- // 创建标识: Copyright (C) 2009 Socansoft.com 版权所有
- // 创建描述: SocanCode代码生成器 V4.3.2.3 自动创建于 2009-12-7 19:55:37
- //
- // 功能描述:
- //
- // 修改标识:
- // 修改描述:
- //------------------------------------------------------------------------------
- using System;
- using System.Data;
- using System.Data.Common;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- namespace SqlServerDAL
- {
- /// <summary>
- /// 数据访问类 Cars
- /// </summary>
- public class Cars : DALHelper
- {
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(Model.Cars model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("INSERT INTO Cars(");
- strSql.Append("CPH,FDJH,CPXH,CLLX,JSY,GMJG,CLTPPath,GMRQ,NJRQ,DQZT,BZ)");
- strSql.Append(" VALUES (");
- strSql.Append("@in_CPH,@in_FDJH,@in_CPXH,@in_CLLX,@in_JSY,@in_GMJG,@in_CLTPPath,@in_GMRQ,@in_NJRQ,@in_DQZT,@in_BZ)");
DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_CPH", DbType.AnsiString, model.CPH),
- DataBaseOAHelper.CreateInDbParameter("@in_FDJH", DbType.AnsiString, model.FDJH),
- DataBaseOAHelper.CreateInDbParameter("@in_CPXH", DbType.AnsiString, model.CPXH),
- DataBaseOAHelper.CreateInDbParameter("@in_CLLX", DbType.AnsiString, model.CLLX),
- DataBaseOAHelper.CreateInDbParameter("@in_JSY", DbType.AnsiString, model.JSY),
- DataBaseOAHelper.CreateInDbParameter("@in_GMJG", DbType.Currency, model.GMJG),
- DataBaseOAHelper.CreateInDbParameter("@in_CLTPPath", DbType.AnsiString, model.CLTPPath),
- DataBaseOAHelper.CreateInDbParameter("@in_GMRQ", DbType.String, model.GMRQ),
- DataBaseOAHelper.CreateInDbParameter("@in_NJRQ", DbType.String, model.NJRQ),
- DataBaseOAHelper.CreateInDbParameter("@in_DQZT", DbType.AnsiString, model.DQZT),
- DataBaseOAHelper.CreateInDbParameter("@in_BZ", DbType.String, model.BZ)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public int Update(Model.Cars model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("UPDATE Cars SET ");
- strSql.Append("CPH=@in_CPH,");
- strSql.Append("FDJH=@in_FDJH,");
- strSql.Append("CPXH=@in_CPXH,");
- strSql.Append("CLLX=@in_CLLX,");
- strSql.Append("JSY=@in_JSY,");
- strSql.Append("GMJG=@in_GMJG,");
- strSql.Append("CLTPPath=@in_CLTPPath,");
- strSql.Append("GMRQ=@in_GMRQ,");
- strSql.Append("NJRQ=@in_NJRQ,");
- strSql.Append("DQZT=@in_DQZT,");
- strSql.Append("BZ=@in_BZ");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_CPH", DbType.AnsiString, model.CPH),
- DataBaseOAHelper.CreateInDbParameter("@in_FDJH", DbType.AnsiString, model.FDJH),
- DataBaseOAHelper.CreateInDbParameter("@in_CPXH", DbType.AnsiString, model.CPXH),
- DataBaseOAHelper.CreateInDbParameter("@in_CLLX", DbType.AnsiString, model.CLLX),
- DataBaseOAHelper.CreateInDbParameter("@in_JSY", DbType.AnsiString, model.JSY),
- DataBaseOAHelper.CreateInDbParameter("@in_GMJG", DbType.Currency, model.GMJG),
- DataBaseOAHelper.CreateInDbParameter("@in_CLTPPath", DbType.AnsiString, model.CLTPPath),
- DataBaseOAHelper.CreateInDbParameter("@in_GMRQ", DbType.String, model.GMRQ),
- DataBaseOAHelper.CreateInDbParameter("@in_NJRQ", DbType.String, model.NJRQ),
- DataBaseOAHelper.CreateInDbParameter("@in_DQZT", DbType.AnsiString, model.DQZT),
- DataBaseOAHelper.CreateInDbParameter("@in_BZ", DbType.String, model.BZ),
- 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 Cars ");
- 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 Cars", null);
- return DataBaseOAHelper.GetInt(obj);
- }
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT COUNT(1) FROM Cars");
- 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.Cars GetModel(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT * FROM Cars ");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, ID)};
- Model.Cars 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.Cars> GetList()
- {
- StringBuilder strSql = new StringBuilder("SELECT * FROM Cars");
- using (DbDataReader dr = DataBaseOAHelper.ExecuteReader(CommandType.Text, strSql.ToString(), null))
- {
- List<Model.Cars> lst = GetList(dr);
- return lst;
- }
- }
- /// <summary>
- /// 得到数据条数
- /// </summary>
- public int GetCount(string condition)
- {
- return DataBaseOAHelper.GetCount("Cars", condition);
- }
- /// <summary>
- /// 分页获取泛型数据列表
- /// </summary>
- public List<Model.Cars> GetPageList(int pageSize, int pageIndex, string fldSort, bool fldDir, string condition)
- {
- using (DbDataReader dr = DataBaseOAHelper.GetPageList("Cars", pageSize, pageIndex, fldSort, fldDir, condition))
- {
- List<Model.Cars> lst = GetList(dr);
- return lst;
- }
- }
- #region -------- 私有方法,通常情况下无需修改 --------
- /// <summary>
- /// 由一行数据得到一个实体
- /// </summary>
- private Model.Cars GetModel(DbDataReader dr)
- {
- Model.Cars model = new Model.Cars();
- model.ID = DataBaseOAHelper.GetInt(dr["ID"]);
- model.CPH = DataBaseOAHelper.GetString(dr["CPH"]);
- model.FDJH = DataBaseOAHelper.GetString(dr["FDJH"]);
- model.CPXH = DataBaseOAHelper.GetString(dr["CPXH"]);
- model.CLLX = DataBaseOAHelper.GetString(dr["CLLX"]);
- model.JSY = DataBaseOAHelper.GetString(dr["JSY"]);
- model.GMJG = DataBaseOAHelper.GetDecimal(dr["GMJG"]);
- model.CLTPPath = DataBaseOAHelper.GetString(dr["CLTPPath"]);
- model.GMRQ = DataBaseOAHelper.GetDateTime(dr["GMRQ"]);
- model.NJRQ = DataBaseOAHelper.GetDateTime(dr["NJRQ"]);
- model.DQZT = DataBaseOAHelper.GetString(dr["DQZT"]);
- model.BZ = DataBaseOAHelper.GetString(dr["BZ"]);
- return model;
- }
- /// <summary>
- /// 由DbDataReader得到泛型数据列表
- /// </summary>
- private List<Model.Cars> GetList(DbDataReader dr)
- {
- List<Model.Cars> lst = new List<Model.Cars>();
- while (dr.Read())
- {
- lst.Add(GetModel(dr));
- }
- return lst;
- }
- #endregion
- }
- }