/// <summary> /// 得到一个对象实体 /// </summary> public webs_YueyxShop.Model.vm_GPDetails DataRowToModel(DataRow row) { webs_YueyxShop.Model.vm_GPDetails model=new webs_YueyxShop.Model.vm_GPDetails(); if (row != null) { if(row["gp_ID"]!=null && row["gp_ID"].ToString()!="") { model.gp_ID=int.Parse(row["gp_ID"].ToString()); } if(row["p_ID"]!=null && row["p_ID"].ToString()!="") { model.p_ID=int.Parse(row["p_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; } } if(row["p_Name"]!=null) { model.p_Name=row["p_Name"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public webs_YueyxShop.Model.vm_GPDetails GetModel(int id) { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 gp_ID,p_ID,gp_StartTime,gp_EndTime,gp_pCount,gp_pPric,gp_CreateOn,gp_CreateBy,gp_StatusCode,gp_IsDel,p_Name,gp_Logo,gp_Slogan,gp_SaleCount from vm_GPDetails "); strSql.Append(" where gp_id="+id); SqlParameter[] parameters = { }; webs_YueyxShop.Model.vm_GPDetails model=new webs_YueyxShop.Model.vm_GPDetails(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }