/// <summary> /// 得到一个对象实体 /// </summary> public webs_YueyxShop.Model.ProductRecommendDetail DataRowToModel(DataRow row) { webs_YueyxShop.Model.ProductRecommendDetail model=new webs_YueyxShop.Model.ProductRecommendDetail(); if (row != null) { if(row["prd_ID"]!=null && row["prd_ID"].ToString()!="") { model.prd_ID=int.Parse(row["prd_ID"].ToString()); } if(row["prt_ID"]!=null && row["prt_ID"].ToString()!="") { model.prt_ID=int.Parse(row["prt_ID"].ToString()); } if(row["p_ID"]!=null && row["p_ID"].ToString()!="") { model.p_ID=int.Parse(row["p_ID"].ToString()); } if(row["prd_Status"]!=null && row["prd_Status"].ToString()!="") { if((row["prd_Status"].ToString()=="1")||(row["prd_Status"].ToString().ToLower()=="true")) { model.prd_Status=true; } else { model.prd_Status=false; } } if(row["prd_IsDelete"]!=null && row["prd_IsDelete"].ToString()!="") { if((row["prd_IsDelete"].ToString()=="1")||(row["prd_IsDelete"].ToString().ToLower()=="true")) { model.prd_IsDelete=true; } else { model.prd_IsDelete=false; } } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public webs_YueyxShop.Model.ProductRecommendDetail GetModel(int prd_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 prd_ID,prt_ID,p_ID,prd_Status,prd_IsDelete from ProductRecommendDetail "); strSql.Append(" where prd_ID=@prd_ID "); SqlParameter[] parameters = { new SqlParameter("@prd_ID", SqlDbType.Int,4) }; parameters[0].Value = prd_ID; webs_YueyxShop.Model.ProductRecommendDetail model = new webs_YueyxShop.Model.ProductRecommendDetail(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }