Пример #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public webs_YueyxShop.Model.ProductConsultBase DataRowToModel(DataRow row)
 {
     webs_YueyxShop.Model.ProductConsultBase model = new webs_YueyxShop.Model.ProductConsultBase();
     if (row != null)
     {
         if (row["pc_ID"] != null && row["pc_ID"].ToString() != "")
         {
             model.pc_ID = int.Parse(row["pc_ID"].ToString());
         }
         if (row["sku_ID"] != null && row["sku_ID"].ToString() != "")
         {
             model.sku_ID = int.Parse(row["sku_ID"].ToString());
         }
         if (row["pc_CreatedOn"] != null && row["pc_CreatedOn"].ToString() != "")
         {
             model.pc_CreatedOn = DateTime.Parse(row["pc_CreatedOn"].ToString());
         }
         if (row["pc_Type"] != null)
         {
             model.pc_Type = row["pc_Type"].ToString();
         }
         if (row["pc_Content"] != null)
         {
             model.pc_Content = row["pc_Content"].ToString();
         }
         if (row["pc_CreatedBy"] != null && row["pc_CreatedBy"].ToString() != "")
         {
             model.pc_CreatedBy = int.Parse(row["pc_CreatedBy"].ToString());
         }
         if (row["pc_StatusCode"] != null && row["pc_StatusCode"].ToString() != "")
         {
             model.pc_StatusCode = int.Parse(row["pc_StatusCode"].ToString());
         }
         if (row["pc_huifu"] != null && row["pc_huifu"].ToString() != "")
         {
             model.pc_huifu = int.Parse(row["pc_huifu"].ToString());
         }
         if (row["pc_IsDel"] != null && row["pc_IsDel"].ToString() != "")
         {
             if ((row["pc_IsDel"].ToString() == "1") || (row["pc_IsDel"].ToString().ToLower() == "true"))
             {
                 model.pc_IsDel = true;
             }
             else
             {
                 model.pc_IsDel = false;
             }
         }
     }
     return model;
 }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public webs_YueyxShop.Model.ProductConsultBase GetModel(int pc_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 pc_ID,sku_ID,pc_CreatedOn,pc_Type,pc_Content,pc_CreatedBy,pc_StatusCode,pc_huifu,pc_IsDel from ProductConsultBase ");
            strSql.Append(" where pc_ID=@pc_ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@pc_ID", SqlDbType.Int,4)
            };
            parameters[0].Value = pc_ID;

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