Files.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:9k
- //------------------------------------------------------------------------------
- // 创建标识: Copyright (C) 2009 Socansoft.com 版权所有
- // 创建描述: SocanCode代码生成器 V4.3.2.3 自动创建于 2009-12-18 17:25:05
- //
- // 功能描述:
- //
- // 修改标识:
- // 修改描述:
- //------------------------------------------------------------------------------
- using System;
- using System.Data;
- using System.Data.Common;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- namespace SqlServerDAL
- {
- /// <summary>
- /// 数据访问类 Files
- /// </summary>
- public class Files : DALHelper
- {
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(Model.Files model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("INSERT INTO Files(");
- strSql.Append("WJH,BJBT,FWDW,MJ,WJFL,WJYS,BZ,FJPath,WJZTC,WJFBT,FWRQ,JJDJ,GWLB,DYYS,SSJA,SCR)");
- strSql.Append(" VALUES (");
- strSql.Append("@in_WJH,@in_BJBT,@in_FWDW,@in_MJ,@in_WJFL,@in_WJYS,@in_BZ,@in_FJPath,@in_WJZTC,@in_WJFBT,@in_FWRQ,@in_JJDJ,@in_GWLB,@in_DYYS,@in_SSJA,@in_SCR)");
DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_WJH", DbType.AnsiString, model.WJH),
- DataBaseOAHelper.CreateInDbParameter("@in_BJBT", DbType.AnsiString, model.BJBT),
- DataBaseOAHelper.CreateInDbParameter("@in_FWDW", DbType.AnsiString, model.FWDW),
- DataBaseOAHelper.CreateInDbParameter("@in_MJ", DbType.AnsiString, model.MJ),
- DataBaseOAHelper.CreateInDbParameter("@in_WJFL", DbType.AnsiString, model.WJFL),
- DataBaseOAHelper.CreateInDbParameter("@in_WJYS", DbType.Int32, model.WJYS),
- DataBaseOAHelper.CreateInDbParameter("@in_BZ", DbType.String, model.BZ),
- DataBaseOAHelper.CreateInDbParameter("@in_FJPath", DbType.String, model.FJPath),
- DataBaseOAHelper.CreateInDbParameter("@in_WJZTC", DbType.AnsiString, model.WJZTC),
- DataBaseOAHelper.CreateInDbParameter("@in_WJFBT", DbType.AnsiString, model.WJFBT),
- DataBaseOAHelper.CreateInDbParameter("@in_FWRQ", DbType.String, model.FWRQ),
- DataBaseOAHelper.CreateInDbParameter("@in_JJDJ", DbType.AnsiString, model.JJDJ),
- DataBaseOAHelper.CreateInDbParameter("@in_GWLB", DbType.AnsiString, model.GWLB),
- DataBaseOAHelper.CreateInDbParameter("@in_DYYS", DbType.Int32, model.DYYS),
- DataBaseOAHelper.CreateInDbParameter("@in_SSJA", DbType.AnsiString, model.SSJA),
- DataBaseOAHelper.CreateInDbParameter("@in_SCR", DbType.AnsiString, model.SCR)};
- return DataBaseOAHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public int Update(Model.Files model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("UPDATE Files SET ");
- strSql.Append("WJH=@in_WJH,");
- strSql.Append("BJBT=@in_BJBT,");
- strSql.Append("FWDW=@in_FWDW,");
- strSql.Append("MJ=@in_MJ,");
- strSql.Append("WJFL=@in_WJFL,");
- strSql.Append("WJYS=@in_WJYS,");
- strSql.Append("BZ=@in_BZ,");
- strSql.Append("FJPath=@in_FJPath,");
- strSql.Append("WJZTC=@in_WJZTC,");
- strSql.Append("WJFBT=@in_WJFBT,");
- strSql.Append("FWRQ=@in_FWRQ,");
- strSql.Append("JJDJ=@in_JJDJ,");
- strSql.Append("GWLB=@in_GWLB,");
- strSql.Append("DYYS=@in_DYYS,");
- strSql.Append("SSJA=@in_SSJA,");
- strSql.Append("SCR=@in_SCR");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_WJH", DbType.AnsiString, model.WJH),
- DataBaseOAHelper.CreateInDbParameter("@in_BJBT", DbType.AnsiString, model.BJBT),
- DataBaseOAHelper.CreateInDbParameter("@in_FWDW", DbType.AnsiString, model.FWDW),
- DataBaseOAHelper.CreateInDbParameter("@in_MJ", DbType.AnsiString, model.MJ),
- DataBaseOAHelper.CreateInDbParameter("@in_WJFL", DbType.AnsiString, model.WJFL),
- DataBaseOAHelper.CreateInDbParameter("@in_WJYS", DbType.Int32, model.WJYS),
- DataBaseOAHelper.CreateInDbParameter("@in_BZ", DbType.String, model.BZ),
- DataBaseOAHelper.CreateInDbParameter("@in_FJPath", DbType.String, model.FJPath),
- DataBaseOAHelper.CreateInDbParameter("@in_WJZTC", DbType.AnsiString, model.WJZTC),
- DataBaseOAHelper.CreateInDbParameter("@in_WJFBT", DbType.AnsiString, model.WJFBT),
- DataBaseOAHelper.CreateInDbParameter("@in_FWRQ", DbType.String, model.FWRQ),
- DataBaseOAHelper.CreateInDbParameter("@in_JJDJ", DbType.AnsiString, model.JJDJ),
- DataBaseOAHelper.CreateInDbParameter("@in_GWLB", DbType.AnsiString, model.GWLB),
- DataBaseOAHelper.CreateInDbParameter("@in_DYYS", DbType.Int32, model.DYYS),
- DataBaseOAHelper.CreateInDbParameter("@in_SSJA", DbType.AnsiString, model.SSJA),
- DataBaseOAHelper.CreateInDbParameter("@in_SCR", DbType.AnsiString, model.SCR),
- 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 Files ");
- 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 Files", null);
- return DataBaseOAHelper.GetInt(obj);
- }
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT COUNT(1) FROM Files");
- 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.Files GetModel(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT * FROM Files ");
- strSql.Append(" WHERE ID=@in_ID");
- DbParameter[] cmdParms = {
- DataBaseOAHelper.CreateInDbParameter("@in_ID", DbType.Int32, ID)};
- Model.Files 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.Files> GetList()
- {
- StringBuilder strSql = new StringBuilder("SELECT * FROM Files");
- using (DbDataReader dr = DataBaseOAHelper.ExecuteReader(CommandType.Text, strSql.ToString(), null))
- {
- List<Model.Files> lst = GetList(dr);
- return lst;
- }
- }
- /// <summary>
- /// 得到数据条数
- /// </summary>
- public int GetCount(string condition)
- {
- return DataBaseOAHelper.GetCount("Files", condition);
- }
- /// <summary>
- /// 分页获取泛型数据列表
- /// </summary>
- public List<Model.Files> GetPageList(int pageSize, int pageIndex, string fldSort, bool fldDir, string condition)
- {
- using (DbDataReader dr = DataBaseOAHelper.GetPageList("Files", pageSize, pageIndex, fldSort, fldDir, condition))
- {
- List<Model.Files> lst = GetList(dr);
- return lst;
- }
- }
- #region -------- 私有方法,通常情况下无需修改 --------
- /// <summary>
- /// 由一行数据得到一个实体
- /// </summary>
- private Model.Files GetModel(DbDataReader dr)
- {
- Model.Files model = new Model.Files();
- model.ID = DataBaseOAHelper.GetInt(dr["ID"]);
- model.WJH = DataBaseOAHelper.GetString(dr["WJH"]);
- model.BJBT = DataBaseOAHelper.GetString(dr["BJBT"]);
- model.FWDW = DataBaseOAHelper.GetString(dr["FWDW"]);
- model.MJ = DataBaseOAHelper.GetString(dr["MJ"]);
- model.WJFL = DataBaseOAHelper.GetString(dr["WJFL"]);
- model.WJYS = DataBaseOAHelper.GetInt(dr["WJYS"]);
- model.BZ = DataBaseOAHelper.GetString(dr["BZ"]);
- model.FJPath = DataBaseOAHelper.GetString(dr["FJPath"]);
- model.WJZTC = DataBaseOAHelper.GetString(dr["WJZTC"]);
- model.WJFBT = DataBaseOAHelper.GetString(dr["WJFBT"]);
- model.FWRQ = DataBaseOAHelper.GetDateTime(dr["FWRQ"]);
- model.JJDJ = DataBaseOAHelper.GetString(dr["JJDJ"]);
- model.GWLB = DataBaseOAHelper.GetString(dr["GWLB"]);
- model.DYYS = DataBaseOAHelper.GetInt(dr["DYYS"]);
- model.SSJA = DataBaseOAHelper.GetString(dr["SSJA"]);
- model.SCR = DataBaseOAHelper.GetString(dr["SCR"]);
- return model;
- }
- /// <summary>
- /// 由DbDataReader得到泛型数据列表
- /// </summary>
- private List<Model.Files> GetList(DbDataReader dr)
- {
- List<Model.Files> lst = new List<Model.Files>();
- while (dr.Read())
- {
- lst.Add(GetModel(dr));
- }
- return lst;
- }
- #endregion
- }
- }