assetmanageDAL.cs
资源名称:OASystem.rar [点击查看]
上传用户:lishan0805
上传日期:2019-12-08
资源大小:12048k
文件大小:34k
源码类别:
OA系统
开发平台:
C#
- // ===================================================================
- // 产品(COM.OA.SqlServerDAL)项目
- //====================================================================
- // wangyp @Copy Right 2006-2008
- // 文件:assetmanageDAL.cs
- // 项目名称:工程项目管理
- // 创建时间:2008-9-23
- // 负责人:wangyp
- // 先创建SqlHelper.cs文件,引用System.Configuration程序集和实体(COM.OA.Entity)、产品规则(COM.OA.IDAL)项目、引用业务逻辑(COM.OA.BLL)项目
- // ===================================================================
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Text;
- using COM.OA.Entity;
- using COM.OA.IDAL;
- using COM.OA.BLL;
- namespace COM.OA.SqlServerDAL
- {
- /// <summary>
- /// 数据访问层dbo.assetmanage
- /// </summary>
- public partial class assetmanageDAL : IassetmanageDAL
- {
- #region 构造函数
- /// <summary>
- /// 数据层实例化
- /// </summary>
- public assetmanageDAL()
- {
- }
- #endregion
- #region -----------实例化接口函数-----------
- #region 添加
- /// <summary>
- /// 向数据库中插入一条新记录
- /// </summary>
- /// <param name="assetmanage">assetmanage实体对象</param>
- /// <returns></returns>
- public int Insert(assetmanage assetmanage)
- {
- string sqlCommand = "assetmanageInsert";
- int res;
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int),
- new SqlParameter("@am_assetname",SqlDbType.VarChar),
- new SqlParameter("@am_number",SqlDbType.VarChar),
- new SqlParameter("@am_measureunit",SqlDbType.VarChar),
- new SqlParameter("@am_scalar",SqlDbType.Int),
- new SqlParameter("@am_spectype",SqlDbType.VarChar),
- new SqlParameter("@am_leavefactorynumber",SqlDbType.VarChar),
- new SqlParameter("@am_artletternumber",SqlDbType.VarChar),
- new SqlParameter("@am_buyprice",SqlDbType.Float),
- new SqlParameter("@am_installcost",SqlDbType.Float),
- new SqlParameter("@am_depreciationcost",SqlDbType.Float),
- new SqlParameter("@am_betvalue",SqlDbType.Float),
- new SqlParameter("@am_production",SqlDbType.VarChar),
- new SqlParameter("@am_productiondate",SqlDbType.DateTime),
- new SqlParameter("@am_deliverusetime",SqlDbType.DateTime),
- new SqlParameter("@am_advanceuseyear",SqlDbType.Int),
- new SqlParameter("@am_buyordept",SqlDbType.VarChar),
- new SqlParameter("@am_storageordept",SqlDbType.VarChar),
- new SqlParameter("@am_purpose",SqlDbType.VarChar),
- new SqlParameter("@am_dept_id",SqlDbType.Int),
- new SqlParameter("@am_useaddress",SqlDbType.VarChar),
- new SqlParameter("@am_usestate",SqlDbType.Int),
- new SqlParameter("@am_bookerid",SqlDbType.Int),
- new SqlParameter("@am_remark",SqlDbType.VarChar),
- new SqlParameter("@am_registertime",SqlDbType.DateTime),
- new SqlParameter("@am_isscrap",SqlDbType.Int)
- };
- param[0].Direction = ParameterDirection.Output;
- param[1].Value = assetmanage.am_assetname;
- param[2].Value = assetmanage.am_number;
- param[3].Value = assetmanage.am_measureunit;
- param[4].Value = assetmanage.am_scalar;
- param[5].Value = assetmanage.am_spectype;
- param[6].Value = assetmanage.am_leavefactorynumber;
- param[7].Value = assetmanage.am_artletternumber;
- param[8].Value = assetmanage.am_buyprice;
- param[9].Value = assetmanage.am_installcost;
- param[10].Value = assetmanage.am_depreciationcost;
- param[11].Value = assetmanage.am_betvalue;
- param[12].Value = assetmanage.am_production;
- param[13].Value = assetmanage.am_productiondate;
- param[14].Value = assetmanage.am_deliverusetime;
- param[15].Value = assetmanage.am_advanceuseyear;
- param[16].Value = assetmanage.am_buyordept;
- param[17].Value = assetmanage.am_storageordept;
- param[18].Value = assetmanage.am_purpose;
- param[19].Value = assetmanage.am_dept_id;
- param[20].Value = assetmanage.am_useaddress;
- param[21].Value = assetmanage.am_usestate;
- param[22].Value = assetmanage.am_bookerid;
- param[23].Value = assetmanage.am_remark;
- param[24].Value = assetmanage.am_registertime;
- param[25].Value = assetmanage.am_isscrap;
- res = SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- assetmanage.am_id = ((param[0].Value) == DBNull.Value) ? 0 : Convert.ToInt32(param[0].Value);
- return res;
- }
- /// <summary>
- /// 向数据库中插入一条新记录。带事务
- /// </summary>
- /// <param name="sp">事务对象</param>
- /// <param name="assetmanage">assetmanage实体对象</param>
- /// <returns></returns>
- public int Insert(SqlTransaction sp, assetmanage assetmanage)
- {
- string sqlCommand = "assetmanageInsert";
- int res;
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int),
- new SqlParameter("@am_assetname",SqlDbType.VarChar),
- new SqlParameter("@am_number",SqlDbType.VarChar),
- new SqlParameter("@am_measureunit",SqlDbType.VarChar),
- new SqlParameter("@am_scalar",SqlDbType.Int),
- new SqlParameter("@am_spectype",SqlDbType.VarChar),
- new SqlParameter("@am_leavefactorynumber",SqlDbType.VarChar),
- new SqlParameter("@am_artletternumber",SqlDbType.VarChar),
- new SqlParameter("@am_buyprice",SqlDbType.Float),
- new SqlParameter("@am_installcost",SqlDbType.Float),
- new SqlParameter("@am_depreciationcost",SqlDbType.Float),
- new SqlParameter("@am_betvalue",SqlDbType.Float),
- new SqlParameter("@am_production",SqlDbType.VarChar),
- new SqlParameter("@am_productiondate",SqlDbType.DateTime),
- new SqlParameter("@am_deliverusetime",SqlDbType.DateTime),
- new SqlParameter("@am_advanceuseyear",SqlDbType.Int),
- new SqlParameter("@am_buyordept",SqlDbType.VarChar),
- new SqlParameter("@am_storageordept",SqlDbType.VarChar),
- new SqlParameter("@am_purpose",SqlDbType.VarChar),
- new SqlParameter("@am_dept_id",SqlDbType.Int),
- new SqlParameter("@am_useaddress",SqlDbType.VarChar),
- new SqlParameter("@am_usestate",SqlDbType.Int),
- new SqlParameter("@am_bookerid",SqlDbType.Int),
- new SqlParameter("@am_remark",SqlDbType.VarChar),
- new SqlParameter("@am_registertime",SqlDbType.DateTime),
- new SqlParameter("@am_isscrap",SqlDbType.Int)
- };
- param[0].Direction = ParameterDirection.Output;
- param[1].Value = assetmanage.am_assetname;
- param[2].Value = assetmanage.am_number;
- param[3].Value = assetmanage.am_measureunit;
- param[4].Value = assetmanage.am_scalar;
- param[5].Value = assetmanage.am_spectype;
- param[6].Value = assetmanage.am_leavefactorynumber;
- param[7].Value = assetmanage.am_artletternumber;
- param[8].Value = assetmanage.am_buyprice;
- param[9].Value = assetmanage.am_installcost;
- param[10].Value = assetmanage.am_depreciationcost;
- param[11].Value = assetmanage.am_betvalue;
- param[12].Value = assetmanage.am_production;
- param[13].Value = assetmanage.am_productiondate;
- param[14].Value = assetmanage.am_deliverusetime;
- param[15].Value = assetmanage.am_advanceuseyear;
- param[16].Value = assetmanage.am_buyordept;
- param[17].Value = assetmanage.am_storageordept;
- param[18].Value = assetmanage.am_purpose;
- param[19].Value = assetmanage.am_dept_id;
- param[20].Value = assetmanage.am_useaddress;
- param[21].Value = assetmanage.am_usestate;
- param[22].Value = assetmanage.am_bookerid;
- param[23].Value = assetmanage.am_remark;
- param[24].Value = assetmanage.am_registertime;
- param[25].Value = assetmanage.am_isscrap;
- res = SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
- assetmanage.am_id = ((param[0].Value) == DBNull.Value) ? 0 : Convert.ToInt32(param[0].Value);
- return res;
- }
- #endregion
- #region 更新
- /// <summary>
- /// 向数据表assetmanage更新一条记录
- /// </summary>
- /// <param name="assetmanage">assetmanage实体对象</param>
- /// <returns></returns>
- public int Update(assetmanage assetmanage)
- {
- string sqlCommand = "assetmanageUpdate";
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int),
- new SqlParameter("@am_assetname",SqlDbType.VarChar),
- new SqlParameter("@am_number",SqlDbType.VarChar),
- new SqlParameter("@am_measureunit",SqlDbType.VarChar),
- new SqlParameter("@am_scalar",SqlDbType.Int),
- new SqlParameter("@am_spectype",SqlDbType.VarChar),
- new SqlParameter("@am_leavefactorynumber",SqlDbType.VarChar),
- new SqlParameter("@am_artletternumber",SqlDbType.VarChar),
- new SqlParameter("@am_buyprice",SqlDbType.Float),
- new SqlParameter("@am_installcost",SqlDbType.Float),
- new SqlParameter("@am_depreciationcost",SqlDbType.Float),
- new SqlParameter("@am_betvalue",SqlDbType.Float),
- new SqlParameter("@am_production",SqlDbType.VarChar),
- new SqlParameter("@am_productiondate",SqlDbType.DateTime),
- new SqlParameter("@am_deliverusetime",SqlDbType.DateTime),
- new SqlParameter("@am_advanceuseyear",SqlDbType.Int),
- new SqlParameter("@am_buyordept",SqlDbType.VarChar),
- new SqlParameter("@am_storageordept",SqlDbType.VarChar),
- new SqlParameter("@am_purpose",SqlDbType.VarChar),
- new SqlParameter("@am_dept_id",SqlDbType.Int),
- new SqlParameter("@am_useaddress",SqlDbType.VarChar),
- new SqlParameter("@am_usestate",SqlDbType.Int),
- new SqlParameter("@am_bookerid",SqlDbType.Int),
- new SqlParameter("@am_remark",SqlDbType.VarChar),
- new SqlParameter("@am_registertime",SqlDbType.DateTime),
- new SqlParameter("@am_isscrap",SqlDbType.Int)
- };
- param[0].Value = assetmanage.am_id;
- param[1].Value = assetmanage.am_assetname;
- param[2].Value = assetmanage.am_number;
- param[3].Value = assetmanage.am_measureunit;
- param[4].Value = assetmanage.am_scalar;
- param[5].Value = assetmanage.am_spectype;
- param[6].Value = assetmanage.am_leavefactorynumber;
- param[7].Value = assetmanage.am_artletternumber;
- param[8].Value = assetmanage.am_buyprice;
- param[9].Value = assetmanage.am_installcost;
- param[10].Value = assetmanage.am_depreciationcost;
- param[11].Value = assetmanage.am_betvalue;
- param[12].Value = assetmanage.am_production;
- param[13].Value = assetmanage.am_productiondate;
- param[14].Value = assetmanage.am_deliverusetime;
- param[15].Value = assetmanage.am_advanceuseyear;
- param[16].Value = assetmanage.am_buyordept;
- param[17].Value = assetmanage.am_storageordept;
- param[18].Value = assetmanage.am_purpose;
- param[19].Value = assetmanage.am_dept_id;
- param[20].Value = assetmanage.am_useaddress;
- param[21].Value = assetmanage.am_usestate;
- param[22].Value = assetmanage.am_bookerid;
- param[23].Value = assetmanage.am_remark;
- param[24].Value = assetmanage.am_registertime;
- param[25].Value = assetmanage.am_isscrap;
- return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- }
- /// <summary>
- /// 向数据表assetmanage更新一条记录。带事务
- /// </summary>
- /// <param name="sp">事务对象</param>
- /// <param name="assetmanage">assetmanage实体对象</param>
- /// <returns></returns>
- public int Update(SqlTransaction sp, assetmanage assetmanage)
- {
- string sqlCommand = "assetmanageUpdate";
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int),
- new SqlParameter("@am_assetname",SqlDbType.VarChar),
- new SqlParameter("@am_number",SqlDbType.VarChar),
- new SqlParameter("@am_measureunit",SqlDbType.VarChar),
- new SqlParameter("@am_scalar",SqlDbType.Int),
- new SqlParameter("@am_spectype",SqlDbType.VarChar),
- new SqlParameter("@am_leavefactorynumber",SqlDbType.VarChar),
- new SqlParameter("@am_artletternumber",SqlDbType.VarChar),
- new SqlParameter("@am_buyprice",SqlDbType.Float),
- new SqlParameter("@am_installcost",SqlDbType.Float),
- new SqlParameter("@am_depreciationcost",SqlDbType.Float),
- new SqlParameter("@am_betvalue",SqlDbType.Float),
- new SqlParameter("@am_production",SqlDbType.VarChar),
- new SqlParameter("@am_productiondate",SqlDbType.DateTime),
- new SqlParameter("@am_deliverusetime",SqlDbType.DateTime),
- new SqlParameter("@am_advanceuseyear",SqlDbType.Int),
- new SqlParameter("@am_buyordept",SqlDbType.VarChar),
- new SqlParameter("@am_storageordept",SqlDbType.VarChar),
- new SqlParameter("@am_purpose",SqlDbType.VarChar),
- new SqlParameter("@am_dept_id",SqlDbType.Int),
- new SqlParameter("@am_useaddress",SqlDbType.VarChar),
- new SqlParameter("@am_usestate",SqlDbType.Int),
- new SqlParameter("@am_bookerid",SqlDbType.Int),
- new SqlParameter("@am_remark",SqlDbType.VarChar),
- new SqlParameter("@am_registertime",SqlDbType.DateTime),
- new SqlParameter("@am_isscrap",SqlDbType.Int)
- };
- param[0].Value = assetmanage.am_id;
- param[1].Value = assetmanage.am_assetname;
- param[2].Value = assetmanage.am_number;
- param[3].Value = assetmanage.am_measureunit;
- param[4].Value = assetmanage.am_scalar;
- param[5].Value = assetmanage.am_spectype;
- param[6].Value = assetmanage.am_leavefactorynumber;
- param[7].Value = assetmanage.am_artletternumber;
- param[8].Value = assetmanage.am_buyprice;
- param[9].Value = assetmanage.am_installcost;
- param[10].Value = assetmanage.am_depreciationcost;
- param[11].Value = assetmanage.am_betvalue;
- param[12].Value = assetmanage.am_production;
- param[13].Value = assetmanage.am_productiondate;
- param[14].Value = assetmanage.am_deliverusetime;
- param[15].Value = assetmanage.am_advanceuseyear;
- param[16].Value = assetmanage.am_buyordept;
- param[17].Value = assetmanage.am_storageordept;
- param[18].Value = assetmanage.am_purpose;
- param[19].Value = assetmanage.am_dept_id;
- param[20].Value = assetmanage.am_useaddress;
- param[21].Value = assetmanage.am_usestate;
- param[22].Value = assetmanage.am_bookerid;
- param[23].Value = assetmanage.am_remark;
- param[24].Value = assetmanage.am_registertime;
- param[25].Value = assetmanage.am_isscrap;
- return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
- }
- #endregion
- #region 删除
- /// <summary>
- /// 删除数据表assetmanage中的一条记录
- /// </summary>
- /// <param name="am_id">am_id</param>
- /// <returns></returns>
- public int Delete(int am_id)
- {
- string sqlCommand = "assetmanageDelete";
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int)
- };
- param[0].Value = am_id;
- return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- }
- /// <summary>
- /// 删除数据表assetmanage中的一条记录
- /// </summary>
- /// <param name="assetmanage">assetmanage实体对象</param>
- /// <returns></returns>
- public int Delete(assetmanage assetmanage)
- {
- string sqlCommand = "assetmanageDelete";
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int)
- };
- param[0].Value = assetmanage.am_id;
- return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- }
- /// <summary>
- /// 删除数据表assetmanage中的一条记录,带事务
- /// </summary>
- /// <param name="sp">事务对象</param>
- /// <param name="am_id">am_id</param>
- /// <returns></returns>
- public int Delete(SqlTransaction sp, int am_id)
- {
- string sqlCommand = "assetmanageDelete";
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int)
- };
- param[0].Value = am_id;
- return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
- }
- /// <summary>
- /// 删除数据表assetmanage中的一条记录,带事务
- /// </summary>
- /// <param name="sp">事务对象</param>
- /// <param name="assetmanage">assetmanage实体对象</param>
- /// <returns></returns>
- public int Delete(SqlTransaction sp, assetmanage assetmanage)
- {
- string sqlCommand = "assetmanageDelete";
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int)
- };
- param[0].Value = assetmanage.am_id;
- return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
- }
- #endregion
- #region 实体对象
- /// <summary>
- /// 得到assetmanage实体对象
- /// </summary>
- /// <param name="row">row</param>
- /// <returns>assetmanage实体对象</returns>
- public assetmanage Select(DataRow row)
- {
- assetmanage obj = new assetmanage();
- if (row != null)
- {
- obj.am_id = ((row["am_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_id"]);
- obj.am_assetname = row["am_assetname"].ToString();
- obj.am_number = row["am_number"].ToString();
- obj.am_measureunit = row["am_measureunit"].ToString();
- obj.am_scalar = ((row["am_scalar"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_scalar"]);
- obj.am_spectype = row["am_spectype"].ToString();
- obj.am_leavefactorynumber = row["am_leavefactorynumber"].ToString();
- obj.am_artletternumber = row["am_artletternumber"].ToString();
- obj.am_buyprice = ((row["am_buyprice"]) == DBNull.Value) ? 0 : Convert.ToDouble(row["am_buyprice"]);
- obj.am_installcost = ((row["am_installcost"]) == DBNull.Value) ? 0 : Convert.ToDouble(row["am_installcost"]);
- obj.am_depreciationcost = ((row["am_depreciationcost"]) == DBNull.Value) ? 0 : Convert.ToDouble(row["am_depreciationcost"]);
- obj.am_betvalue = ((row["am_betvalue"]) == DBNull.Value) ? 0 : Convert.ToDouble(row["am_betvalue"]);
- obj.am_production = row["am_production"].ToString();
- obj.am_productiondate = ((row["am_productiondate"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["am_productiondate"]);
- obj.am_deliverusetime = ((row["am_deliverusetime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["am_deliverusetime"]);
- obj.am_advanceuseyear = ((row["am_advanceuseyear"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_advanceuseyear"]);
- obj.am_buyordept = row["am_buyordept"].ToString();
- obj.am_storageordept = row["am_storageordept"].ToString();
- obj.am_purpose = row["am_purpose"].ToString();
- obj.am_dept_id = ((row["am_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_dept_id"]);
- obj.am_useaddress = row["am_useaddress"].ToString();
- obj.am_usestate = ((row["am_usestate"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_usestate"]);
- obj.am_bookerid = ((row["am_bookerid"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_bookerid"]);
- obj.am_remark = row["am_remark"].ToString();
- obj.am_registertime = ((row["am_registertime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["am_registertime"]);
- obj.am_isscrap = ((row["am_isscrap"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_isscrap"]);
- }
- else
- {
- return null;
- }
- return obj;
- }
- /// <summary>
- /// 得到assetmanage实体对象
- /// </summary>
- /// <param name="dr">dr</param>
- /// <returns>assetmanage实体对象</returns>
- public assetmanage Select(IDataReader dr)
- {
- assetmanage obj = new assetmanage();
- obj.am_id = ((dr["am_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_id"]);
- obj.am_assetname = dr["am_assetname"].ToString();
- obj.am_number = dr["am_number"].ToString();
- obj.am_measureunit = dr["am_measureunit"].ToString();
- obj.am_scalar = ((dr["am_scalar"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_scalar"]);
- obj.am_spectype = dr["am_spectype"].ToString();
- obj.am_leavefactorynumber = dr["am_leavefactorynumber"].ToString();
- obj.am_artletternumber = dr["am_artletternumber"].ToString();
- obj.am_buyprice = ((dr["am_buyprice"]) == DBNull.Value) ? 0 : Convert.ToDouble(dr["am_buyprice"]);
- obj.am_installcost = ((dr["am_installcost"]) == DBNull.Value) ? 0 : Convert.ToDouble(dr["am_installcost"]);
- obj.am_depreciationcost = ((dr["am_depreciationcost"]) == DBNull.Value) ? 0 : Convert.ToDouble(dr["am_depreciationcost"]);
- obj.am_betvalue = ((dr["am_betvalue"]) == DBNull.Value) ? 0 : Convert.ToDouble(dr["am_betvalue"]);
- obj.am_production = dr["am_production"].ToString();
- obj.am_productiondate = ((dr["am_productiondate"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["am_productiondate"]);
- obj.am_deliverusetime = ((dr["am_deliverusetime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["am_deliverusetime"]);
- obj.am_advanceuseyear = ((dr["am_advanceuseyear"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_advanceuseyear"]);
- obj.am_buyordept = dr["am_buyordept"].ToString();
- obj.am_storageordept = dr["am_storageordept"].ToString();
- obj.am_purpose = dr["am_purpose"].ToString();
- obj.am_dept_id = ((dr["am_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_dept_id"]);
- obj.am_useaddress = dr["am_useaddress"].ToString();
- obj.am_usestate = ((dr["am_usestate"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_usestate"]);
- obj.am_bookerid = ((dr["am_bookerid"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_bookerid"]);
- obj.am_remark = dr["am_remark"].ToString();
- obj.am_registertime = ((dr["am_registertime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["am_registertime"]);
- obj.am_isscrap = ((dr["am_isscrap"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_isscrap"]);
- return obj;
- }
- /// <summary>
- /// 根据ID,返回一个assetmanage实体对象
- /// </summary>
- /// <param name="am_id">am_id</param>
- /// <returns>assetmanage实体对象</returns>
- public assetmanage Select(int am_id)
- {
- return this.Select(am_id, false, false);
- }
- /// <summary>
- /// 根据ID,返回一个assetmanage实体对象
- /// </summary>
- /// <param name="am_id">am_id</param>
- /// <param name="bParentTable">将assetmanage对象设置与父表关联</param>
- /// <param name="bChildrenTable">将assetmanage对象设置与子表关联</param>
- /// <returns>assetmanage实体对象</returns>
- public assetmanage Select(int am_id, bool bParentTable, bool bChildrenTable)
- {
- assetmanage obj = null;
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int)
- };
- param[0].Value = am_id;
- string sqlCommand = "assetmanageSelect";
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
- {
- while (dr.Read())
- {
- obj = this.Select(dr);
- }
- }
- this.Select(obj, bParentTable, bChildrenTable);
- return obj;
- }
- /// <summary>
- /// 将assetmanage实体对象设置与父表和子表关联
- /// </summary>
- /// <param name="obj">assetmanage实体对象</param>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- public void Select(assetmanage obj, bool bParentTable, bool bChildrenTable)
- {
- //关联的主表
- if (bParentTable)
- {
- obj.department = departmentBLL.Select(obj.am_dept_id);
- }
- //关联的子表集合
- if (bChildrenTable)
- {
- }
- }
- #endregion
- #region 父表
- /// <summary>
- /// 设置实体对象(assetmanage)的父表对象
- /// </summary>
- /// <param name="assetmanage">实体对象</param>
- public void department(assetmanage assetmanage)
- {
- assetmanage.department = departmentBLL.Select(assetmanage.am_dept_id);
- }
- #endregion
- #region 子表
- #endregion
- #region 查询
- /// <summary>
- /// 得到数据表assetmanage所有记录
- /// </summary>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select()
- {
- return this.Select(false, false);
- }
- /// <summary>
- /// 得到数据表assetmanage所有记录
- /// </summary>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select(bool bParentTable, bool bChildrenTable)
- {
- IList<assetmanage> list = new List<assetmanage>();
- string sqlCommand = "assetmanageSelectAll";
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand))
- {
- while (dr.Read())
- {
- list.Add(this.Select(dr));
- }
- }
- foreach (assetmanage obj in list)
- {
- this.Select(obj, bParentTable, bChildrenTable);
- }
- return list;
- }
- /// <summary>
- /// 得到数据表assetmanage满足查询条件的记录
- /// </summary>
- /// <param name="where">查询条件</param>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select(string where)
- {
- return this.Select(where, false, false);
- }
- /// <summary>
- /// 得到数据表assetmanage满足查询条件的记录
- /// </summary>
- /// <param name="where">查询条件</param>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select(string where, bool bParentTable, bool bChildrenTable)
- {
- IList<assetmanage> list = new List<assetmanage>();
- SqlParameter[] param ={
- new SqlParameter("@where",SqlDbType.VarChar,8000)
- };
- param[0].Value = where;
- string sqlCommand = "assetmanageSelectByParams";
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
- {
- while (dr.Read())
- {
- list.Add(this.Select(dr));
- }
- }
- foreach (assetmanage obj in list)
- {
- this.Select(obj, bParentTable, bChildrenTable);
- }
- return list;
- }
- /// <summary>
- /// 得到数据表ArticalInfo满足外键字段查询条件的记录
- /// </summary>
- /// <param name="foreignFieldName">外键字段名称</param>
- /// <param name="foreignFieldValue">外键字段值</param>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select(string foreignFieldName, int foreignFieldValue)
- {
- return this.Select(foreignFieldName, foreignFieldValue, false, false);
- }
- /// <summary>
- /// 得到数据表ArticalInfo满足外键字段查询条件的记录
- /// </summary>
- /// <param name="foreignFieldName">外键字段名称</param>
- /// <param name="foreignFieldValue">外键字段值</param>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select(string foreignFieldName, int foreignFieldValue, bool bParentTable, bool bChildrenTable)
- {
- return this.Select(string.Format("{0}='{1}'", foreignFieldName, foreignFieldValue), bParentTable, bChildrenTable);
- }
- /// <summary>
- /// 得到数据表assetmanage满足查询条件的记录数
- /// </summary>
- /// <param name="where">查询条件</param>
- /// <param name="recordCount">记录数</param>
- public void Select(string where, out int recordCount)
- {
- string sqlCommand = "assetmanageCountByWhere";
- SqlParameter[] param ={
- new SqlParameter("@where",SqlDbType.VarChar,8000),
- new SqlParameter("@recordCount",SqlDbType.Int)
- };
- param[0].Value = where;
- param[1].Direction = ParameterDirection.Output;
- SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- recordCount = Convert.ToInt32(param[1].Value);
- }
- /// <summary>
- /// 得到数据表assetmanage满足查询条件的分页记录
- /// </summary>
- /// <param name="pageSize">每页显示记录数</param>
- /// <param name="pageIndex">当前显示第几页</param>
- /// <param name="where">查询条件</param>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select(int pageSize, int pageIndex, string where)
- {
- return this.Select(pageSize, pageIndex, where, false, false);
- }
- /// <summary>
- /// 得到数据表assetmanage满足查询条件的分页记录
- /// </summary>
- /// <param name="pageSize">每页显示记录数</param>
- /// <param name="pageIndex">当前显示第几页</param>
- /// <param name="where">查询条件</param>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select(int pageSize, int pageIndex, string where, bool bParentTable, bool bChildrenTable)
- {
- IList<assetmanage> list = new List<assetmanage>();
- string sqlCommand = "assetmanageSelectByPagerParams";
- SqlParameter[] param ={
- new SqlParameter("@pageSize",SqlDbType.Int),
- new SqlParameter("@pageIndex",SqlDbType.Int),
- new SqlParameter("@where",SqlDbType.VarChar,8000)
- };
- param[0].Value = pageSize;
- param[1].Value = pageIndex;
- param[2].Value = where;
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
- {
- while (dr.Read())
- {
- list.Add(this.Select(dr));
- }
- }
- foreach (assetmanage obj in list)
- {
- this.Select(obj, bParentTable, bChildrenTable);
- }
- return list;
- }
- /// <summary>
- /// 得到数据表assetmanage满足查询条件记录
- /// </summary>
- /// <param name="commandType">命令类型</param>
- /// <param name="sqlCommand">SQL命令</param>
- /// <param name="SqlParameter[]">命令参数数组</param>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select(CommandType commandType, string sqlCommand, params SqlParameter[] param)
- {
- return this.Select(false, false, commandType, sqlCommand, param);
- }
- /// <summary>
- /// 得到数据表assetmanage满足查询条件记录
- /// </summary>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <param name="commandType">命令类型</param>
- /// <param name="sqlCommand">SQL命令</param>
- /// <param name="SqlParameter[]">命令参数数组</param>
- /// <returns>结果集</returns>
- public IList<assetmanage> Select(bool bParentTable, bool bChildrenTable, CommandType commandType, string sqlCommand, params SqlParameter[] param)
- {
- IList<assetmanage> list = new List<assetmanage>();
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, commandType, sqlCommand, param))
- {
- while (dr.Read())
- {
- list.Add(this.Select(dr));
- }
- }
- foreach (assetmanage obj in list)
- {
- this.Select(obj, bParentTable, bChildrenTable);
- }
- return list;
- }
- /// <summary>
- /// 根据主键检测是否存在该条记录
- /// </summary>
- /// <param name="am_id">am_id</param>
- /// <returns>存在/不存在</returns>
- public bool Exists(int am_id)
- {
- SqlParameter[] param ={
- new SqlParameter("@am_id",SqlDbType.Int)
- };
- param[0].Value = am_id;
- string sqlCommand = "assetmanageIsExist";
- int a = Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param));
- if (a > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- #endregion
- #endregion
- }
- }