/// <summary> /// 得到一个对象实体 /// </summary> public webs_YueyxShop.Model.vm_GroupInfo GetModel(int 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_Slogan,gp_Logo,gp_SaleCount,p_Name,sku_Price,sku_CostPrice,sku_Code,p_ID,p_Name,sku_IsDel,sku_StatusCode,p_IsDel,p_StatusCode,p_SellStatus from vm_GroupInfo "); strSql.Append(" where gp_id="+id); SqlParameter[] parameters = { }; webs_YueyxShop.Model.vm_GroupInfo model=new webs_YueyxShop.Model.vm_GroupInfo(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public webs_YueyxShop.Model.vm_GroupInfo DataRowToModel(DataRow row) { webs_YueyxShop.Model.vm_GroupInfo model=new webs_YueyxShop.Model.vm_GroupInfo(); if (row != null) { if(row["gp_ID"]!=null && row["gp_ID"].ToString()!="") { model.gp_ID=int.Parse(row["gp_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_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; } } if(row["gp_Slogan"]!=null) { model.gp_Slogan=row["gp_Slogan"].ToString(); } if(row["gp_Logo"]!=null) { model.gp_Logo=row["gp_Logo"].ToString(); } if(row["gp_SaleCount"]!=null && row["gp_SaleCount"].ToString()!="") { model.gp_SaleCount=int.Parse(row["gp_SaleCount"].ToString()); } if(row["p_ID"]!=null && row["p_ID"].ToString()!="") { model.p_ID=int.Parse(row["p_ID"].ToString()); } if (row["sku_Code"] != null && row["sku_Code"].ToString() != "") { model.sku_Code = row["sku_Code"].ToString(); } if(row["p_Name"]!=null) { model.p_Name=row["p_Name"].ToString(); } if (row["p_StatusCode"] != null && row["p_StatusCode"].ToString() != "") { model.p_StatusCode = int.Parse(row["p_StatusCode"].ToString()); } } return model; }