Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public webs_YueyxShop.Model.GroupPurchaseBase GetModel(int gp_ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 gp_ID,sku_ID,gp_StartTime,gp_EndTime,gp_pCount,gp_pPric,gp_CreateOn,gp_CreateBy,gp_StatusCode,gp_IsDel,gp_Logo,gp_Slogan,gp_SaleCount from GroupPurchaseBase ");
            strSql.Append(" where gp_ID=@gp_ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@gp_ID", SqlDbType.Int,4)			};
            parameters[0].Value = gp_ID;

            webs_YueyxShop.Model.GroupPurchaseBase model=new webs_YueyxShop.Model.GroupPurchaseBase();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public webs_YueyxShop.Model.GroupPurchaseBase DataRowToModel(DataRow row)
 {
     webs_YueyxShop.Model.GroupPurchaseBase model=new webs_YueyxShop.Model.GroupPurchaseBase();
     if (row != null)
     {
         if(row["gp_ID"]!=null && row["gp_ID"].ToString()!="")
         {
             model.gp_ID=int.Parse(row["gp_ID"].ToString());
         }
         if (row["sku_ID"] != null && row["sku_ID"].ToString() != "")
         {
             model.sku_ID = int.Parse(row["sku_ID"].ToString());
         }
         if(row["gp_StartTime"]!=null && row["gp_StartTime"].ToString()!="")
         {
             model.gp_StartTime=DateTime.Parse(row["gp_StartTime"].ToString());
         }
         if(row["gp_EndTime"]!=null && row["gp_EndTime"].ToString()!="")
         {
             model.gp_EndTime=DateTime.Parse(row["gp_EndTime"].ToString());
         }
         if(row["gp_pCount"]!=null && row["gp_pCount"].ToString()!="")
         {
             model.gp_pCount=int.Parse(row["gp_pCount"].ToString());
         }
         if(row["gp_pPric"]!=null && row["gp_pPric"].ToString()!="")
         {
             model.gp_pPric=decimal.Parse(row["gp_pPric"].ToString());
         }
         if(row["gp_CreateOn"]!=null && row["gp_CreateOn"].ToString()!="")
         {
             model.gp_CreateOn=DateTime.Parse(row["gp_CreateOn"].ToString());
         }
         if(row["gp_CreateBy"]!=null && row["gp_CreateBy"].ToString()!="")
         {
             model.gp_CreateBy= new Guid(row["gp_CreateBy"].ToString());
         }
         if (row["gp_StatusCode"] != null && row["gp_StatusCode"].ToString() != "")
         {
             model.gp_StatusCode = int.Parse(row["gp_StatusCode"].ToString());
         }
         if (row["gp_SaleCount"] != null && row["gp_SaleCount"].ToString() != "")
         {
             model.gp_SaleCount = int.Parse(row["gp_SaleCount"].ToString());
         }
         if (row["gp_Logo"] != null)
         {
             model.gp_Logo = row["gp_Logo"].ToString();
         }
         if (row["gp_Slogan"] != null)
         {
             model.gp_Slogan = row["gp_Slogan"].ToString();
         }
         if(row["gp_IsDel"]!=null && row["gp_IsDel"].ToString()!="")
         {
             if((row["gp_IsDel"].ToString()=="1")||(row["gp_IsDel"].ToString().ToLower()=="true"))
             {
                 model.gp_IsDel=true;
             }
             else
             {
                 model.gp_IsDel=false;
             }
         }
     }
     return model;
 }