Пример #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public webs_YueyxShop.Model.ProductInfoBase DataRowToModel(DataRow row)
 {
     webs_YueyxShop.Model.ProductInfoBase model=new webs_YueyxShop.Model.ProductInfoBase();
     if (row != null)
     {
         if(row["pin_ID"]!=null && row["pin_ID"].ToString()!="")
         {
             model.pin_ID=int.Parse(row["pin_ID"].ToString());
         }
         if(row["p_ID"]!=null && row["p_ID"].ToString()!="")
         {
             model.p_ID=int.Parse(row["p_ID"].ToString());
         }
         if(row["pin_Type"]!=null)
         {
             model.pin_Type=row["pin_Type"].ToString();
         }
         if(row["pin_Title"]!=null)
         {
             model.pin_Title=row["pin_Title"].ToString();
         }
         if(row["pin_Content"]!=null)
         {
             model.pin_Content=row["pin_Content"].ToString();
         }
         if(row["pin_CreatedOn"]!=null && row["pin_CreatedOn"].ToString()!="")
         {
             model.pin_CreatedOn=DateTime.Parse(row["pin_CreatedOn"].ToString());
         }
         if(row["pin_CreatedBy"]!=null && row["pin_CreatedBy"].ToString()!="")
         {
             model.pin_CreatedBy= new Guid(row["pin_CreatedBy"].ToString());
         }
         if(row["pin_ModifyOn"]!=null && row["pin_ModifyOn"].ToString()!="")
         {
             model.pin_ModifyOn=DateTime.Parse(row["pin_ModifyOn"].ToString());
         }
         if(row["pin_MoidfyBy"]!=null && row["pin_MoidfyBy"].ToString()!="")
         {
             model.pin_MoidfyBy= new Guid(row["pin_MoidfyBy"].ToString());
         }
         if(row["pin_StatusCode"]!=null && row["pin_StatusCode"].ToString()!="")
         {
             model.pin_StatusCode=int.Parse(row["pin_StatusCode"].ToString());
         }
         if(row["pin_IsDel"]!=null && row["pin_IsDel"].ToString()!="")
         {
             if((row["pin_IsDel"].ToString()=="1")||(row["pin_IsDel"].ToString().ToLower()=="true"))
             {
                 model.pin_IsDel=true;
             }
             else
             {
                 model.pin_IsDel=false;
             }
         }
     }
     return model;
 }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public webs_YueyxShop.Model.ProductInfoBase GetModel(int pin_ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 pin_ID,p_ID,pin_Type,pin_Title,pin_Content,pin_CreatedOn,pin_CreatedBy,pin_ModifyOn,pin_MoidfyBy,pin_StatusCode,pin_IsDel from ProductInfoBase ");
            strSql.Append(" where pin_ID=@pin_ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@pin_ID", SqlDbType.Int,4)			};
            parameters[0].Value = pin_ID;

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