Exemple #1
0
 /// <summary>
 /// 往实体集合中添加记录
 /// </summary>
 /// <param name="list">实体列表</param>
 /// <param name="dt">表</param>
 private void LoadListData(ref IList<Model.Product_Info > list, DataTable dt)
 {
     if (dt.Rows.Count > 0)
     {
         Model.Product_Info  model;
         foreach (DataRow dr in dt.Rows)
         {
             model = new Model.Product_Info ();
             LoadEntityData(ref model, dr);
             list.Add(model);
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// 获得单个实体对象
 /// </summary>
 /// <param name="id">关键字</param>
 /// <returns>实体对象</returns>
 public Model.Product_Info SelectModel(int id)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append(@"select [Id],[JK_Titile],[jk_DateTime],[JK_Product_id],[JK_Product_img_src],[JK_Product_name],[JK_Product_datetime] from [Product_Info] ");
     strSql.Append(@" where [Id]=@id ");
     SqlParameter[] parameters = {
             new SqlParameter("@id", SqlDbType.Int,4)};
     parameters[0].Value = id;
     Model.Product_Info model = new Model.Product_Info();
     DataTable dt = DAL.SqlDataHelper.GetDataTable(strSql.ToString(), parameters);
     if (dt.Rows.Count > 0)
     {
         LoadEntityData(ref model, dt.Rows[0]);
         return model;
     }
     else
     {
         return null;
     }
 }
Exemple #3
0
 /// <summary>
 /// 获得单个实体对象
 /// </summary>
 /// <param name="whereStr">关键字</param>
 /// <returns>实体对象</returns>
 public Model.Product_Info SelectModel(string whereStr)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append(@"select [Id],[JK_Titile],[jk_DateTime],[JK_Product_id],[JK_Product_img_src],[JK_Product_name],[JK_Product_datetime] from [Product_Info] ");
     if (whereStr.Trim() != "")
     {
         strSql.Append(@" where " + whereStr);
     }
     Model.Product_Info model = new Model.Product_Info();
     DataTable dt = DAL.SqlDataHelper.GetDataTable(strSql.ToString());
     if (dt.Rows.Count > 0)
     {
         LoadEntityData(ref model, dt.Rows[0]);
         return model;
     }
     else
     {
         return null;
     }
 }
Exemple #4
0
        /// <summary>
        /// 根据条件查询实体记录
        /// </summary>
        /// <param name="whereStr">查询条件</param>
        /// <returns>实体记录</returns>
        public IList<Model.Product_Info> SelectList(int top,string whereStr)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select ");
            if(top>0)
            {
               strSql.Append(" top "+top);
            }
            strSql.Append(" [Id],[JK_Titile],[jk_DateTime],[JK_Product_id],[JK_Product_img_src],[JK_Product_name],[JK_Product_datetime] from [Product_Info] ");
            if (whereStr.Trim() != "")
            {
                strSql.Append(@" where " + whereStr);
            }
            DataTable dt = DAL.SqlDataHelper.GetDataTable(strSql.ToString());
            List<Model.Product_Info > list = null;
            if (dt.Rows.Count > 0)
            {
                list = new List<Model.Product_Info >();
                Model.Product_Info  model = null;

                foreach (DataRow dr in dt.Rows)
                {
                    model = new Model.Product_Info ();
                    LoadEntityData(ref model, dr);
                    list.Add(model);
                }
            }
            return list;
        }