コード例 #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public webs_YueyxShop.Model.ProductReplyBase DataRowToModel(DataRow row)
 {
     webs_YueyxShop.Model.ProductReplyBase model=new webs_YueyxShop.Model.ProductReplyBase();
     if (row != null)
     {
         if(row["pr_ID"]!=null && row["pr_ID"].ToString()!="")
         {
             model.pr_ID=int.Parse(row["pr_ID"].ToString());
         }
         if(row["pc_ID"]!=null && row["pc_ID"].ToString()!="")
         {
             model.pc_ID=int.Parse(row["pc_ID"].ToString());
         }
         if(row["pr_Content"]!=null)
         {
             model.pr_Content=row["pr_Content"].ToString();
         }
         if(row["pr_CreatedBy"]!=null && row["pr_CreatedBy"].ToString()!="")
         {
             model.pr_CreatedBy= new Guid(row["pr_CreatedBy"].ToString());
         }
         if(row["pr_CreatedOn"]!=null && row["pr_CreatedOn"].ToString()!="")
         {
             model.pr_CreatedOn=DateTime.Parse(row["pr_CreatedOn"].ToString());
         }
         if(row["pr_StatusCode"]!=null && row["pr_StatusCode"].ToString()!="")
         {
             model.pr_StatusCode=int.Parse(row["pr_StatusCode"].ToString());
         }
         if(row["pr_IsDel"]!=null && row["pr_IsDel"].ToString()!="")
         {
             if((row["pr_IsDel"].ToString()=="1")||(row["pr_IsDel"].ToString().ToLower()=="true"))
             {
                 model.pr_IsDel=true;
             }
             else
             {
                 model.pr_IsDel=false;
             }
         }
     }
     return model;
 }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public webs_YueyxShop.Model.ProductReplyBase GetModel(int pr_ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 pr_ID,pc_ID,pr_Content,pr_CreatedBy,pr_CreatedOn,pr_StatusCode,pr_IsDel from ProductReplyBase ");
            strSql.Append(" where pr_ID=@pr_ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@pr_ID", SqlDbType.Int,4)
            };
            parameters[0].Value = pr_ID;

            webs_YueyxShop.Model.ProductReplyBase model=new webs_YueyxShop.Model.ProductReplyBase();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }