assetmanageDAL.cs
上传用户:lishan0805
上传日期:2019-12-08
资源大小:12048k
文件大小:34k
源码类别:

OA系统

开发平台:

C#

  1. // =================================================================== 
  2. // 产品(COM.OA.SqlServerDAL)项目
  3. //====================================================================
  4. // wangyp @Copy Right 2006-2008
  5. // 文件:assetmanageDAL.cs
  6. // 项目名称:工程项目管理
  7. // 创建时间:2008-9-23
  8. // 负责人:wangyp
  9. // 先创建SqlHelper.cs文件,引用System.Configuration程序集和实体(COM.OA.Entity)、产品规则(COM.OA.IDAL)项目、引用业务逻辑(COM.OA.BLL)项目
  10. // ===================================================================
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.Data.SqlClient;
  16. using System.Text;
  17. using COM.OA.Entity;
  18. using COM.OA.IDAL;
  19. using COM.OA.BLL;
  20. namespace COM.OA.SqlServerDAL
  21. {
  22.     /// <summary>
  23.     /// 数据访问层dbo.assetmanage
  24.     /// </summary>
  25.     public partial class assetmanageDAL : IassetmanageDAL
  26.     {
  27.         #region 构造函数
  28.         /// <summary>
  29.         /// 数据层实例化
  30.         /// </summary>
  31.         public assetmanageDAL()
  32.         {
  33.         }
  34.         #endregion
  35.         #region -----------实例化接口函数-----------
  36.         #region 添加
  37.         /// <summary>
  38.         /// 向数据库中插入一条新记录
  39.         /// </summary>
  40.         /// <param name="assetmanage">assetmanage实体对象</param>
  41.         /// <returns></returns>
  42.         public int Insert(assetmanage assetmanage)
  43.         {
  44.             string sqlCommand = "assetmanageInsert";
  45.             int res;
  46.             SqlParameter[] param ={
  47. new SqlParameter("@am_id",SqlDbType.Int),
  48. new SqlParameter("@am_assetname",SqlDbType.VarChar),
  49. new SqlParameter("@am_number",SqlDbType.VarChar),
  50. new SqlParameter("@am_measureunit",SqlDbType.VarChar),
  51. new SqlParameter("@am_scalar",SqlDbType.Int),
  52. new SqlParameter("@am_spectype",SqlDbType.VarChar),
  53. new SqlParameter("@am_leavefactorynumber",SqlDbType.VarChar),
  54. new SqlParameter("@am_artletternumber",SqlDbType.VarChar),
  55. new SqlParameter("@am_buyprice",SqlDbType.Float),
  56. new SqlParameter("@am_installcost",SqlDbType.Float),
  57. new SqlParameter("@am_depreciationcost",SqlDbType.Float),
  58. new SqlParameter("@am_betvalue",SqlDbType.Float),
  59. new SqlParameter("@am_production",SqlDbType.VarChar),
  60. new SqlParameter("@am_productiondate",SqlDbType.DateTime),
  61. new SqlParameter("@am_deliverusetime",SqlDbType.DateTime),
  62. new SqlParameter("@am_advanceuseyear",SqlDbType.Int),
  63. new SqlParameter("@am_buyordept",SqlDbType.VarChar),
  64. new SqlParameter("@am_storageordept",SqlDbType.VarChar),
  65. new SqlParameter("@am_purpose",SqlDbType.VarChar),
  66. new SqlParameter("@am_dept_id",SqlDbType.Int),
  67. new SqlParameter("@am_useaddress",SqlDbType.VarChar),
  68. new SqlParameter("@am_usestate",SqlDbType.Int),
  69. new SqlParameter("@am_bookerid",SqlDbType.Int),
  70. new SqlParameter("@am_remark",SqlDbType.VarChar),
  71. new SqlParameter("@am_registertime",SqlDbType.DateTime),
  72. new SqlParameter("@am_isscrap",SqlDbType.Int)
  73. };
  74.             param[0].Direction = ParameterDirection.Output;
  75.             param[1].Value = assetmanage.am_assetname;
  76.             param[2].Value = assetmanage.am_number;
  77.             param[3].Value = assetmanage.am_measureunit;
  78.             param[4].Value = assetmanage.am_scalar;
  79.             param[5].Value = assetmanage.am_spectype;
  80.             param[6].Value = assetmanage.am_leavefactorynumber;
  81.             param[7].Value = assetmanage.am_artletternumber;
  82.             param[8].Value = assetmanage.am_buyprice;
  83.             param[9].Value = assetmanage.am_installcost;
  84.             param[10].Value = assetmanage.am_depreciationcost;
  85.             param[11].Value = assetmanage.am_betvalue;
  86.             param[12].Value = assetmanage.am_production;
  87.             param[13].Value = assetmanage.am_productiondate;
  88.             param[14].Value = assetmanage.am_deliverusetime;
  89.             param[15].Value = assetmanage.am_advanceuseyear;
  90.             param[16].Value = assetmanage.am_buyordept;
  91.             param[17].Value = assetmanage.am_storageordept;
  92.             param[18].Value = assetmanage.am_purpose;
  93.             param[19].Value = assetmanage.am_dept_id;
  94.             param[20].Value = assetmanage.am_useaddress;
  95.             param[21].Value = assetmanage.am_usestate;
  96.             param[22].Value = assetmanage.am_bookerid;
  97.             param[23].Value = assetmanage.am_remark;
  98.             param[24].Value = assetmanage.am_registertime;
  99.             param[25].Value = assetmanage.am_isscrap;
  100.             res = SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  101.             assetmanage.am_id = ((param[0].Value) == DBNull.Value) ? 0 : Convert.ToInt32(param[0].Value);
  102.             return res;
  103.         }
  104.         /// <summary>
  105.         /// 向数据库中插入一条新记录。带事务
  106.         /// </summary>
  107.         /// <param name="sp">事务对象</param>
  108.         /// <param name="assetmanage">assetmanage实体对象</param>
  109.         /// <returns></returns>
  110.         public int Insert(SqlTransaction sp, assetmanage assetmanage)
  111.         {
  112.             string sqlCommand = "assetmanageInsert";
  113.             int res;
  114.             SqlParameter[] param ={
  115. new SqlParameter("@am_id",SqlDbType.Int),
  116. new SqlParameter("@am_assetname",SqlDbType.VarChar),
  117. new SqlParameter("@am_number",SqlDbType.VarChar),
  118. new SqlParameter("@am_measureunit",SqlDbType.VarChar),
  119. new SqlParameter("@am_scalar",SqlDbType.Int),
  120. new SqlParameter("@am_spectype",SqlDbType.VarChar),
  121. new SqlParameter("@am_leavefactorynumber",SqlDbType.VarChar),
  122. new SqlParameter("@am_artletternumber",SqlDbType.VarChar),
  123. new SqlParameter("@am_buyprice",SqlDbType.Float),
  124. new SqlParameter("@am_installcost",SqlDbType.Float),
  125. new SqlParameter("@am_depreciationcost",SqlDbType.Float),
  126. new SqlParameter("@am_betvalue",SqlDbType.Float),
  127. new SqlParameter("@am_production",SqlDbType.VarChar),
  128. new SqlParameter("@am_productiondate",SqlDbType.DateTime),
  129. new SqlParameter("@am_deliverusetime",SqlDbType.DateTime),
  130. new SqlParameter("@am_advanceuseyear",SqlDbType.Int),
  131. new SqlParameter("@am_buyordept",SqlDbType.VarChar),
  132. new SqlParameter("@am_storageordept",SqlDbType.VarChar),
  133. new SqlParameter("@am_purpose",SqlDbType.VarChar),
  134. new SqlParameter("@am_dept_id",SqlDbType.Int),
  135. new SqlParameter("@am_useaddress",SqlDbType.VarChar),
  136. new SqlParameter("@am_usestate",SqlDbType.Int),
  137. new SqlParameter("@am_bookerid",SqlDbType.Int),
  138. new SqlParameter("@am_remark",SqlDbType.VarChar),
  139. new SqlParameter("@am_registertime",SqlDbType.DateTime),
  140. new SqlParameter("@am_isscrap",SqlDbType.Int)
  141. };
  142.             param[0].Direction = ParameterDirection.Output;
  143.             param[1].Value = assetmanage.am_assetname;
  144.             param[2].Value = assetmanage.am_number;
  145.             param[3].Value = assetmanage.am_measureunit;
  146.             param[4].Value = assetmanage.am_scalar;
  147.             param[5].Value = assetmanage.am_spectype;
  148.             param[6].Value = assetmanage.am_leavefactorynumber;
  149.             param[7].Value = assetmanage.am_artletternumber;
  150.             param[8].Value = assetmanage.am_buyprice;
  151.             param[9].Value = assetmanage.am_installcost;
  152.             param[10].Value = assetmanage.am_depreciationcost;
  153.             param[11].Value = assetmanage.am_betvalue;
  154.             param[12].Value = assetmanage.am_production;
  155.             param[13].Value = assetmanage.am_productiondate;
  156.             param[14].Value = assetmanage.am_deliverusetime;
  157.             param[15].Value = assetmanage.am_advanceuseyear;
  158.             param[16].Value = assetmanage.am_buyordept;
  159.             param[17].Value = assetmanage.am_storageordept;
  160.             param[18].Value = assetmanage.am_purpose;
  161.             param[19].Value = assetmanage.am_dept_id;
  162.             param[20].Value = assetmanage.am_useaddress;
  163.             param[21].Value = assetmanage.am_usestate;
  164.             param[22].Value = assetmanage.am_bookerid;
  165.             param[23].Value = assetmanage.am_remark;
  166.             param[24].Value = assetmanage.am_registertime;
  167.             param[25].Value = assetmanage.am_isscrap;
  168.             res = SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  169.             assetmanage.am_id = ((param[0].Value) == DBNull.Value) ? 0 : Convert.ToInt32(param[0].Value);
  170.             return res;
  171.         }
  172.         #endregion
  173.         #region 更新
  174.         /// <summary>
  175.         /// 向数据表assetmanage更新一条记录
  176.         /// </summary>
  177.         /// <param name="assetmanage">assetmanage实体对象</param>
  178.         /// <returns></returns>
  179.         public int Update(assetmanage assetmanage)
  180.         {
  181.             string sqlCommand = "assetmanageUpdate";
  182.             SqlParameter[] param ={
  183. new SqlParameter("@am_id",SqlDbType.Int),
  184. new SqlParameter("@am_assetname",SqlDbType.VarChar),
  185. new SqlParameter("@am_number",SqlDbType.VarChar),
  186. new SqlParameter("@am_measureunit",SqlDbType.VarChar),
  187. new SqlParameter("@am_scalar",SqlDbType.Int),
  188. new SqlParameter("@am_spectype",SqlDbType.VarChar),
  189. new SqlParameter("@am_leavefactorynumber",SqlDbType.VarChar),
  190. new SqlParameter("@am_artletternumber",SqlDbType.VarChar),
  191. new SqlParameter("@am_buyprice",SqlDbType.Float),
  192. new SqlParameter("@am_installcost",SqlDbType.Float),
  193. new SqlParameter("@am_depreciationcost",SqlDbType.Float),
  194. new SqlParameter("@am_betvalue",SqlDbType.Float),
  195. new SqlParameter("@am_production",SqlDbType.VarChar),
  196. new SqlParameter("@am_productiondate",SqlDbType.DateTime),
  197. new SqlParameter("@am_deliverusetime",SqlDbType.DateTime),
  198. new SqlParameter("@am_advanceuseyear",SqlDbType.Int),
  199. new SqlParameter("@am_buyordept",SqlDbType.VarChar),
  200. new SqlParameter("@am_storageordept",SqlDbType.VarChar),
  201. new SqlParameter("@am_purpose",SqlDbType.VarChar),
  202. new SqlParameter("@am_dept_id",SqlDbType.Int),
  203. new SqlParameter("@am_useaddress",SqlDbType.VarChar),
  204. new SqlParameter("@am_usestate",SqlDbType.Int),
  205. new SqlParameter("@am_bookerid",SqlDbType.Int),
  206. new SqlParameter("@am_remark",SqlDbType.VarChar),
  207. new SqlParameter("@am_registertime",SqlDbType.DateTime),
  208. new SqlParameter("@am_isscrap",SqlDbType.Int)
  209. };
  210.             param[0].Value = assetmanage.am_id;
  211.             param[1].Value = assetmanage.am_assetname;
  212.             param[2].Value = assetmanage.am_number;
  213.             param[3].Value = assetmanage.am_measureunit;
  214.             param[4].Value = assetmanage.am_scalar;
  215.             param[5].Value = assetmanage.am_spectype;
  216.             param[6].Value = assetmanage.am_leavefactorynumber;
  217.             param[7].Value = assetmanage.am_artletternumber;
  218.             param[8].Value = assetmanage.am_buyprice;
  219.             param[9].Value = assetmanage.am_installcost;
  220.             param[10].Value = assetmanage.am_depreciationcost;
  221.             param[11].Value = assetmanage.am_betvalue;
  222.             param[12].Value = assetmanage.am_production;
  223.             param[13].Value = assetmanage.am_productiondate;
  224.             param[14].Value = assetmanage.am_deliverusetime;
  225.             param[15].Value = assetmanage.am_advanceuseyear;
  226.             param[16].Value = assetmanage.am_buyordept;
  227.             param[17].Value = assetmanage.am_storageordept;
  228.             param[18].Value = assetmanage.am_purpose;
  229.             param[19].Value = assetmanage.am_dept_id;
  230.             param[20].Value = assetmanage.am_useaddress;
  231.             param[21].Value = assetmanage.am_usestate;
  232.             param[22].Value = assetmanage.am_bookerid;
  233.             param[23].Value = assetmanage.am_remark;
  234.             param[24].Value = assetmanage.am_registertime;
  235.             param[25].Value = assetmanage.am_isscrap;
  236.             return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  237.         }
  238.         /// <summary>
  239.         /// 向数据表assetmanage更新一条记录。带事务
  240.         /// </summary>
  241.         /// <param name="sp">事务对象</param>
  242.         /// <param name="assetmanage">assetmanage实体对象</param>
  243.         /// <returns></returns>
  244.         public int Update(SqlTransaction sp, assetmanage assetmanage)
  245.         {
  246.             string sqlCommand = "assetmanageUpdate";
  247.             SqlParameter[] param ={
  248. new SqlParameter("@am_id",SqlDbType.Int),
  249. new SqlParameter("@am_assetname",SqlDbType.VarChar),
  250. new SqlParameter("@am_number",SqlDbType.VarChar),
  251. new SqlParameter("@am_measureunit",SqlDbType.VarChar),
  252. new SqlParameter("@am_scalar",SqlDbType.Int),
  253. new SqlParameter("@am_spectype",SqlDbType.VarChar),
  254. new SqlParameter("@am_leavefactorynumber",SqlDbType.VarChar),
  255. new SqlParameter("@am_artletternumber",SqlDbType.VarChar),
  256. new SqlParameter("@am_buyprice",SqlDbType.Float),
  257. new SqlParameter("@am_installcost",SqlDbType.Float),
  258. new SqlParameter("@am_depreciationcost",SqlDbType.Float),
  259. new SqlParameter("@am_betvalue",SqlDbType.Float),
  260. new SqlParameter("@am_production",SqlDbType.VarChar),
  261. new SqlParameter("@am_productiondate",SqlDbType.DateTime),
  262. new SqlParameter("@am_deliverusetime",SqlDbType.DateTime),
  263. new SqlParameter("@am_advanceuseyear",SqlDbType.Int),
  264. new SqlParameter("@am_buyordept",SqlDbType.VarChar),
  265. new SqlParameter("@am_storageordept",SqlDbType.VarChar),
  266. new SqlParameter("@am_purpose",SqlDbType.VarChar),
  267. new SqlParameter("@am_dept_id",SqlDbType.Int),
  268. new SqlParameter("@am_useaddress",SqlDbType.VarChar),
  269. new SqlParameter("@am_usestate",SqlDbType.Int),
  270. new SqlParameter("@am_bookerid",SqlDbType.Int),
  271. new SqlParameter("@am_remark",SqlDbType.VarChar),
  272. new SqlParameter("@am_registertime",SqlDbType.DateTime),
  273. new SqlParameter("@am_isscrap",SqlDbType.Int)
  274. };
  275.             param[0].Value = assetmanage.am_id;
  276.             param[1].Value = assetmanage.am_assetname;
  277.             param[2].Value = assetmanage.am_number;
  278.             param[3].Value = assetmanage.am_measureunit;
  279.             param[4].Value = assetmanage.am_scalar;
  280.             param[5].Value = assetmanage.am_spectype;
  281.             param[6].Value = assetmanage.am_leavefactorynumber;
  282.             param[7].Value = assetmanage.am_artletternumber;
  283.             param[8].Value = assetmanage.am_buyprice;
  284.             param[9].Value = assetmanage.am_installcost;
  285.             param[10].Value = assetmanage.am_depreciationcost;
  286.             param[11].Value = assetmanage.am_betvalue;
  287.             param[12].Value = assetmanage.am_production;
  288.             param[13].Value = assetmanage.am_productiondate;
  289.             param[14].Value = assetmanage.am_deliverusetime;
  290.             param[15].Value = assetmanage.am_advanceuseyear;
  291.             param[16].Value = assetmanage.am_buyordept;
  292.             param[17].Value = assetmanage.am_storageordept;
  293.             param[18].Value = assetmanage.am_purpose;
  294.             param[19].Value = assetmanage.am_dept_id;
  295.             param[20].Value = assetmanage.am_useaddress;
  296.             param[21].Value = assetmanage.am_usestate;
  297.             param[22].Value = assetmanage.am_bookerid;
  298.             param[23].Value = assetmanage.am_remark;
  299.             param[24].Value = assetmanage.am_registertime;
  300.             param[25].Value = assetmanage.am_isscrap;
  301.             return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  302.         }
  303.         #endregion
  304.         #region 删除
  305.         /// <summary>
  306.         /// 删除数据表assetmanage中的一条记录
  307.         /// </summary>
  308.         /// <param name="am_id">am_id</param>
  309.         /// <returns></returns>
  310.         public int Delete(int am_id)
  311.         {
  312.             string sqlCommand = "assetmanageDelete";
  313.             SqlParameter[] param ={
  314. new SqlParameter("@am_id",SqlDbType.Int)
  315. };
  316.             param[0].Value = am_id;
  317.             return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  318.         }
  319.         /// <summary>
  320.         /// 删除数据表assetmanage中的一条记录
  321.         /// </summary>
  322.         /// <param name="assetmanage">assetmanage实体对象</param>
  323.         /// <returns></returns>
  324.         public int Delete(assetmanage assetmanage)
  325.         {
  326.             string sqlCommand = "assetmanageDelete";
  327.             SqlParameter[] param ={
  328. new SqlParameter("@am_id",SqlDbType.Int)
  329. };
  330.             param[0].Value = assetmanage.am_id;
  331.             return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  332.         }
  333.         /// <summary>
  334.         /// 删除数据表assetmanage中的一条记录,带事务
  335.         /// </summary>
  336.         /// <param name="sp">事务对象</param>
  337.         /// <param name="am_id">am_id</param>
  338.         /// <returns></returns>
  339.         public int Delete(SqlTransaction sp, int am_id)
  340.         {
  341.             string sqlCommand = "assetmanageDelete";
  342.             SqlParameter[] param ={
  343. new SqlParameter("@am_id",SqlDbType.Int)
  344. };
  345.             param[0].Value = am_id;
  346.             return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  347.         }
  348.         /// <summary>
  349.         /// 删除数据表assetmanage中的一条记录,带事务
  350.         /// </summary>
  351.         /// <param name="sp">事务对象</param>
  352.         /// <param name="assetmanage">assetmanage实体对象</param>
  353.         /// <returns></returns>
  354.         public int Delete(SqlTransaction sp, assetmanage assetmanage)
  355.         {
  356.             string sqlCommand = "assetmanageDelete";
  357.             SqlParameter[] param ={
  358. new SqlParameter("@am_id",SqlDbType.Int)
  359. };
  360.             param[0].Value = assetmanage.am_id;
  361.             return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  362.         }
  363.         #endregion
  364.         #region 实体对象
  365.         /// <summary>
  366.         /// 得到assetmanage实体对象
  367.         /// </summary>
  368.         /// <param name="row">row</param>
  369.         /// <returns>assetmanage实体对象</returns>
  370.         public assetmanage Select(DataRow row)
  371.         {
  372.             assetmanage obj = new assetmanage();
  373.             if (row != null)
  374.             {
  375.                 obj.am_id = ((row["am_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_id"]);
  376.                 obj.am_assetname = row["am_assetname"].ToString();
  377.                 obj.am_number = row["am_number"].ToString();
  378.                 obj.am_measureunit = row["am_measureunit"].ToString();
  379.                 obj.am_scalar = ((row["am_scalar"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_scalar"]);
  380.                 obj.am_spectype = row["am_spectype"].ToString();
  381.                 obj.am_leavefactorynumber = row["am_leavefactorynumber"].ToString();
  382.                 obj.am_artletternumber = row["am_artletternumber"].ToString();
  383.                 obj.am_buyprice = ((row["am_buyprice"]) == DBNull.Value) ? 0 : Convert.ToDouble(row["am_buyprice"]);
  384.                 obj.am_installcost = ((row["am_installcost"]) == DBNull.Value) ? 0 : Convert.ToDouble(row["am_installcost"]);
  385.                 obj.am_depreciationcost = ((row["am_depreciationcost"]) == DBNull.Value) ? 0 : Convert.ToDouble(row["am_depreciationcost"]);
  386.                 obj.am_betvalue = ((row["am_betvalue"]) == DBNull.Value) ? 0 : Convert.ToDouble(row["am_betvalue"]);
  387.                 obj.am_production = row["am_production"].ToString();
  388.                 obj.am_productiondate = ((row["am_productiondate"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["am_productiondate"]);
  389.                 obj.am_deliverusetime = ((row["am_deliverusetime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["am_deliverusetime"]);
  390.                 obj.am_advanceuseyear = ((row["am_advanceuseyear"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_advanceuseyear"]);
  391.                 obj.am_buyordept = row["am_buyordept"].ToString();
  392.                 obj.am_storageordept = row["am_storageordept"].ToString();
  393.                 obj.am_purpose = row["am_purpose"].ToString();
  394.                 obj.am_dept_id = ((row["am_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_dept_id"]);
  395.                 obj.am_useaddress = row["am_useaddress"].ToString();
  396.                 obj.am_usestate = ((row["am_usestate"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_usestate"]);
  397.                 obj.am_bookerid = ((row["am_bookerid"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_bookerid"]);
  398.                 obj.am_remark = row["am_remark"].ToString();
  399.                 obj.am_registertime = ((row["am_registertime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["am_registertime"]);
  400.                 obj.am_isscrap = ((row["am_isscrap"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["am_isscrap"]);
  401.             }
  402.             else
  403.             {
  404.                 return null;
  405.             }
  406.             return obj;
  407.         }
  408.         /// <summary>
  409.         /// 得到assetmanage实体对象
  410.         /// </summary>
  411.         /// <param name="dr">dr</param>
  412.         /// <returns>assetmanage实体对象</returns>
  413.         public assetmanage Select(IDataReader dr)
  414.         {
  415.             assetmanage obj = new assetmanage();
  416.             obj.am_id = ((dr["am_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_id"]);
  417.             obj.am_assetname = dr["am_assetname"].ToString();
  418.             obj.am_number = dr["am_number"].ToString();
  419.             obj.am_measureunit = dr["am_measureunit"].ToString();
  420.             obj.am_scalar = ((dr["am_scalar"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_scalar"]);
  421.             obj.am_spectype = dr["am_spectype"].ToString();
  422.             obj.am_leavefactorynumber = dr["am_leavefactorynumber"].ToString();
  423.             obj.am_artletternumber = dr["am_artletternumber"].ToString();
  424.             obj.am_buyprice = ((dr["am_buyprice"]) == DBNull.Value) ? 0 : Convert.ToDouble(dr["am_buyprice"]);
  425.             obj.am_installcost = ((dr["am_installcost"]) == DBNull.Value) ? 0 : Convert.ToDouble(dr["am_installcost"]);
  426.             obj.am_depreciationcost = ((dr["am_depreciationcost"]) == DBNull.Value) ? 0 : Convert.ToDouble(dr["am_depreciationcost"]);
  427.             obj.am_betvalue = ((dr["am_betvalue"]) == DBNull.Value) ? 0 : Convert.ToDouble(dr["am_betvalue"]);
  428.             obj.am_production = dr["am_production"].ToString();
  429.             obj.am_productiondate = ((dr["am_productiondate"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["am_productiondate"]);
  430.             obj.am_deliverusetime = ((dr["am_deliverusetime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["am_deliverusetime"]);
  431.             obj.am_advanceuseyear = ((dr["am_advanceuseyear"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_advanceuseyear"]);
  432.             obj.am_buyordept = dr["am_buyordept"].ToString();
  433.             obj.am_storageordept = dr["am_storageordept"].ToString();
  434.             obj.am_purpose = dr["am_purpose"].ToString();
  435.             obj.am_dept_id = ((dr["am_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_dept_id"]);
  436.             obj.am_useaddress = dr["am_useaddress"].ToString();
  437.             obj.am_usestate = ((dr["am_usestate"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_usestate"]);
  438.             obj.am_bookerid = ((dr["am_bookerid"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_bookerid"]);
  439.             obj.am_remark = dr["am_remark"].ToString();
  440.             obj.am_registertime = ((dr["am_registertime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["am_registertime"]);
  441.             obj.am_isscrap = ((dr["am_isscrap"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["am_isscrap"]);
  442.             return obj;
  443.         }
  444.         /// <summary>
  445.         /// 根据ID,返回一个assetmanage实体对象
  446.         /// </summary>
  447.         /// <param name="am_id">am_id</param>
  448.         /// <returns>assetmanage实体对象</returns>
  449.         public assetmanage Select(int am_id)
  450.         {
  451.             return this.Select(am_id, false, false);
  452.         }
  453.         /// <summary>
  454.         /// 根据ID,返回一个assetmanage实体对象
  455.         /// </summary>
  456.         /// <param name="am_id">am_id</param>
  457.         /// <param name="bParentTable">将assetmanage对象设置与父表关联</param>
  458.         /// <param name="bChildrenTable">将assetmanage对象设置与子表关联</param>
  459.         /// <returns>assetmanage实体对象</returns>
  460.         public assetmanage Select(int am_id, bool bParentTable, bool bChildrenTable)
  461.         {
  462.             assetmanage obj = null;
  463.             SqlParameter[] param ={
  464. new SqlParameter("@am_id",SqlDbType.Int)
  465. };
  466.             param[0].Value = am_id;
  467.             string sqlCommand = "assetmanageSelect";
  468.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
  469.             {
  470.                 while (dr.Read())
  471.                 {
  472.                     obj = this.Select(dr);
  473.                 }
  474.             }
  475.             this.Select(obj, bParentTable, bChildrenTable);
  476.             return obj;
  477.         }
  478.         /// <summary>
  479.         /// 将assetmanage实体对象设置与父表和子表关联
  480.         /// </summary>
  481.         /// <param name="obj">assetmanage实体对象</param>
  482.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  483.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  484.         public void Select(assetmanage obj, bool bParentTable, bool bChildrenTable)
  485.         {
  486.             //关联的主表
  487.             if (bParentTable)
  488.             {
  489.                 obj.department = departmentBLL.Select(obj.am_dept_id);
  490.             }
  491.             //关联的子表集合
  492.             if (bChildrenTable)
  493.             {
  494.             }
  495.         }
  496.         #endregion
  497.         #region 父表
  498.         /// <summary>
  499.         /// 设置实体对象(assetmanage)的父表对象
  500.         /// </summary>
  501.         /// <param name="assetmanage">实体对象</param>
  502.         public void department(assetmanage assetmanage)
  503.         {
  504.             assetmanage.department = departmentBLL.Select(assetmanage.am_dept_id);
  505.         }
  506.         #endregion
  507.         #region 子表
  508.         #endregion
  509.         #region 查询
  510.         /// <summary>
  511.         /// 得到数据表assetmanage所有记录
  512.         /// </summary>
  513.         /// <returns>结果集</returns>
  514.         public IList<assetmanage> Select()
  515.         {
  516.             return this.Select(false, false);
  517.         }
  518.         /// <summary>
  519.         /// 得到数据表assetmanage所有记录
  520.         /// </summary>
  521.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  522.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  523.         /// <returns>结果集</returns>
  524.         public IList<assetmanage> Select(bool bParentTable, bool bChildrenTable)
  525.         {
  526.             IList<assetmanage> list = new List<assetmanage>();
  527.             string sqlCommand = "assetmanageSelectAll";
  528.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand))
  529.             {
  530.                 while (dr.Read())
  531.                 {
  532.                     list.Add(this.Select(dr));
  533.                 }
  534.             }
  535.             foreach (assetmanage obj in list)
  536.             {
  537.                 this.Select(obj, bParentTable, bChildrenTable);
  538.             }
  539.             return list;
  540.         }
  541.         /// <summary>
  542.         /// 得到数据表assetmanage满足查询条件的记录
  543.         /// </summary>
  544.         /// <param name="where">查询条件</param>
  545.         /// <returns>结果集</returns>
  546.         public IList<assetmanage> Select(string where)
  547.         {
  548.             return this.Select(where, false, false);
  549.         }
  550.         /// <summary>
  551.         /// 得到数据表assetmanage满足查询条件的记录
  552.         /// </summary>
  553.         /// <param name="where">查询条件</param>
  554.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  555.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  556.         /// <returns>结果集</returns>
  557.         public IList<assetmanage> Select(string where, bool bParentTable, bool bChildrenTable)
  558.         {
  559.             IList<assetmanage> list = new List<assetmanage>();
  560.             SqlParameter[] param ={
  561. new SqlParameter("@where",SqlDbType.VarChar,8000)
  562. };
  563.             param[0].Value = where;
  564.             string sqlCommand = "assetmanageSelectByParams";
  565.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
  566.             {
  567.                 while (dr.Read())
  568.                 {
  569.                     list.Add(this.Select(dr));
  570.                 }
  571.             }
  572.             foreach (assetmanage obj in list)
  573.             {
  574.                 this.Select(obj, bParentTable, bChildrenTable);
  575.             }
  576.             return list;
  577.         }
  578.         /// <summary>
  579.         /// 得到数据表ArticalInfo满足外键字段查询条件的记录
  580.         /// </summary>
  581.         /// <param name="foreignFieldName">外键字段名称</param>
  582.         /// <param name="foreignFieldValue">外键字段值</param>
  583.         /// <returns>结果集</returns>
  584.         public IList<assetmanage> Select(string foreignFieldName, int foreignFieldValue)
  585.         {
  586.             return this.Select(foreignFieldName, foreignFieldValue, false, false);
  587.         }
  588.         /// <summary>
  589.         /// 得到数据表ArticalInfo满足外键字段查询条件的记录
  590.         /// </summary>
  591.         /// <param name="foreignFieldName">外键字段名称</param>
  592.         /// <param name="foreignFieldValue">外键字段值</param>
  593.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  594.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  595.         /// <returns>结果集</returns>
  596.         public IList<assetmanage> Select(string foreignFieldName, int foreignFieldValue, bool bParentTable, bool bChildrenTable)
  597.         {
  598.             return this.Select(string.Format("{0}='{1}'", foreignFieldName, foreignFieldValue), bParentTable, bChildrenTable);
  599.         }
  600.         /// <summary>
  601.         /// 得到数据表assetmanage满足查询条件的记录数
  602.         /// </summary>
  603.         /// <param name="where">查询条件</param>
  604.         /// <param name="recordCount">记录数</param>
  605.         public void Select(string where, out int recordCount)
  606.         {
  607.             string sqlCommand = "assetmanageCountByWhere";
  608.             SqlParameter[] param ={
  609. new SqlParameter("@where",SqlDbType.VarChar,8000),
  610. new SqlParameter("@recordCount",SqlDbType.Int)
  611. };
  612.             param[0].Value = where;
  613.             param[1].Direction = ParameterDirection.Output;
  614.             SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  615.             recordCount = Convert.ToInt32(param[1].Value);
  616.         }
  617.         /// <summary>
  618.         /// 得到数据表assetmanage满足查询条件的分页记录
  619.         /// </summary>
  620.         /// <param name="pageSize">每页显示记录数</param>
  621.         /// <param name="pageIndex">当前显示第几页</param>
  622.         /// <param name="where">查询条件</param>
  623.         /// <returns>结果集</returns>
  624.         public IList<assetmanage> Select(int pageSize, int pageIndex, string where)
  625.         {
  626.             return this.Select(pageSize, pageIndex, where, false, false);
  627.         }
  628.         /// <summary>
  629.         /// 得到数据表assetmanage满足查询条件的分页记录
  630.         /// </summary>
  631.         /// <param name="pageSize">每页显示记录数</param>
  632.         /// <param name="pageIndex">当前显示第几页</param>
  633.         /// <param name="where">查询条件</param>
  634.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  635.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  636.         /// <returns>结果集</returns>
  637.         public IList<assetmanage> Select(int pageSize, int pageIndex, string where, bool bParentTable, bool bChildrenTable)
  638.         {
  639.             IList<assetmanage> list = new List<assetmanage>();
  640.             string sqlCommand = "assetmanageSelectByPagerParams";
  641.             SqlParameter[] param ={
  642. new SqlParameter("@pageSize",SqlDbType.Int),
  643. new SqlParameter("@pageIndex",SqlDbType.Int),
  644. new SqlParameter("@where",SqlDbType.VarChar,8000)
  645. };
  646.             param[0].Value = pageSize;
  647.             param[1].Value = pageIndex;
  648.             param[2].Value = where;
  649.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
  650.             {
  651.                 while (dr.Read())
  652.                 {
  653.                     list.Add(this.Select(dr));
  654.                 }
  655.             }
  656.             foreach (assetmanage obj in list)
  657.             {
  658.                 this.Select(obj, bParentTable, bChildrenTable);
  659.             }
  660.             return list;
  661.         }
  662.         /// <summary>
  663.         /// 得到数据表assetmanage满足查询条件记录
  664.         /// </summary>
  665.         /// <param name="commandType">命令类型</param>
  666.         /// <param name="sqlCommand">SQL命令</param>
  667.         /// <param name="SqlParameter[]">命令参数数组</param>
  668.         /// <returns>结果集</returns>
  669.         public IList<assetmanage> Select(CommandType commandType, string sqlCommand, params SqlParameter[] param)
  670.         {
  671.             return this.Select(false, false, commandType, sqlCommand, param);
  672.         }
  673.         /// <summary>
  674.         /// 得到数据表assetmanage满足查询条件记录
  675.         /// </summary>
  676.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  677.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  678.         /// <param name="commandType">命令类型</param>
  679.         /// <param name="sqlCommand">SQL命令</param>
  680.         /// <param name="SqlParameter[]">命令参数数组</param>
  681.         /// <returns>结果集</returns>
  682.         public IList<assetmanage> Select(bool bParentTable, bool bChildrenTable, CommandType commandType, string sqlCommand, params SqlParameter[] param)
  683.         {
  684.             IList<assetmanage> list = new List<assetmanage>();
  685.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, commandType, sqlCommand, param))
  686.             {
  687.                 while (dr.Read())
  688.                 {
  689.                     list.Add(this.Select(dr));
  690.                 }
  691.             }
  692.             foreach (assetmanage obj in list)
  693.             {
  694.                 this.Select(obj, bParentTable, bChildrenTable);
  695.             }
  696.             return list;
  697.         }
  698.         /// <summary>
  699.         /// 根据主键检测是否存在该条记录
  700.         /// </summary>
  701.         /// <param name="am_id">am_id</param>
  702.         /// <returns>存在/不存在</returns>
  703.         public bool Exists(int am_id)
  704.         {
  705.             SqlParameter[] param ={
  706.                                  new SqlParameter("@am_id",SqlDbType.Int)
  707.                                  };
  708.             param[0].Value = am_id;
  709.             string sqlCommand = "assetmanageIsExist";
  710.             int a = Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param));
  711.             if (a > 0)
  712.             {
  713.                 return true;
  714.             }
  715.             else
  716.             {
  717.                 return false;
  718.             }
  719.         }
  720.         #endregion
  721.         #endregion
  722.     }
  723. }