/// <summary> /// 得到一个对象实体 /// </summary> public TtNum1.Model.GroupBuying DataRowToModel(DataRow row) { TtNum1.Model.GroupBuying model=new TtNum1.Model.GroupBuying(); if (row != null) { if(row["GB_ID"]!=null && row["GB_ID"].ToString()!="") { model.GB_ID=int.Parse(row["GB_ID"].ToString()); } if(row["GB_GoodsID"]!=null && row["GB_GoodsID"].ToString()!="") { model.GB_GoodsID=int.Parse(row["GB_GoodsID"].ToString()); } if(row["GB_GroupPrice"]!=null && row["GB_GroupPrice"].ToString()!="") { model.GB_GroupPrice=decimal.Parse(row["GB_GroupPrice"].ToString()); } if(row["GB_OfferDate"]!=null && row["GB_OfferDate"].ToString()!="") { model.GB_OfferDate=DateTime.Parse(row["GB_OfferDate"].ToString()); } if(row["GB_StopDate"]!=null && row["GB_StopDate"].ToString()!="") { model.GB_StopDate=DateTime.Parse(row["GB_StopDate"].ToString()); } if(row["GB_TotalNumber"]!=null && row["GB_TotalNumber"].ToString()!="") { model.GB_TotalNumber=int.Parse(row["GB_TotalNumber"].ToString()); } if(row["GB_participantsNumber"]!=null && row["GB_participantsNumber"].ToString()!="") { model.GB_participantsNumber=int.Parse(row["GB_participantsNumber"].ToString()); } if(row["GB_State"]!=null) { model.GB_State=row["GB_State"].ToString(); } if(row["GB_PictureUrl"]!=null) { model.GB_PictureUrl=row["GB_PictureUrl"].ToString(); } if(row["GB_Note"]!=null) { model.GB_Note=row["GB_Note"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public TtNum1.Model.GroupBuying GetModel(int GB_ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" GB_ID,GB_GoodsID,GB_GroupPrice,GB_OfferDate,GB_StopDate,GB_TotalNumber,GB_participantsNumber,GB_State,GB_PictureUrl,GB_Note "); strSql.Append(" from GroupBuying "); strSql.Append(" where GB_ID="+GB_ID+"" ); TtNum1.Model.GroupBuying model=new TtNum1.Model.GroupBuying(); DataSet ds=DbHelperSQL.Query(strSql.ToString()); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public TtNum1.Model.GroupBuying GetModel(int GB_ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" GB_ID,GB_GoodsID,GB_GroupPrice,GB_OfferDate,GB_StopDate,GB_TotalNumber,GB_participantsNumber,GB_State,GB_PictureUrl,GB_Note "); strSql.Append(" from GroupBuying "); strSql.Append(" where GB_ID="+GB_ID+"" ); TtNum1.Model.GroupBuying model=new TtNum1.Model.GroupBuying(); DataSet ds=DbHelperSQL.Query(strSql.ToString()); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["GB_ID"]!=null && ds.Tables[0].Rows[0]["GB_ID"].ToString()!="") { model.GB_ID=int.Parse(ds.Tables[0].Rows[0]["GB_ID"].ToString()); } if(ds.Tables[0].Rows[0]["GB_GoodsID"]!=null && ds.Tables[0].Rows[0]["GB_GoodsID"].ToString()!="") { model.GB_GoodsID=int.Parse(ds.Tables[0].Rows[0]["GB_GoodsID"].ToString()); } if(ds.Tables[0].Rows[0]["GB_GroupPrice"]!=null && ds.Tables[0].Rows[0]["GB_GroupPrice"].ToString()!="") { model.GB_GroupPrice=decimal.Parse(ds.Tables[0].Rows[0]["GB_GroupPrice"].ToString()); } if(ds.Tables[0].Rows[0]["GB_OfferDate"]!=null && ds.Tables[0].Rows[0]["GB_OfferDate"].ToString()!="") { model.GB_OfferDate=DateTime.Parse(ds.Tables[0].Rows[0]["GB_OfferDate"].ToString()); } if(ds.Tables[0].Rows[0]["GB_StopDate"]!=null && ds.Tables[0].Rows[0]["GB_StopDate"].ToString()!="") { model.GB_StopDate=DateTime.Parse(ds.Tables[0].Rows[0]["GB_StopDate"].ToString()); } if(ds.Tables[0].Rows[0]["GB_TotalNumber"]!=null && ds.Tables[0].Rows[0]["GB_TotalNumber"].ToString()!="") { model.GB_TotalNumber=int.Parse(ds.Tables[0].Rows[0]["GB_TotalNumber"].ToString()); } if(ds.Tables[0].Rows[0]["GB_participantsNumber"]!=null && ds.Tables[0].Rows[0]["GB_participantsNumber"].ToString()!="") { model.GB_participantsNumber=int.Parse(ds.Tables[0].Rows[0]["GB_participantsNumber"].ToString()); } if(ds.Tables[0].Rows[0]["GB_State"]!=null && ds.Tables[0].Rows[0]["GB_State"].ToString()!="") { model.GB_State=ds.Tables[0].Rows[0]["GB_State"].ToString(); } if(ds.Tables[0].Rows[0]["GB_PictureUrl"]!=null && ds.Tables[0].Rows[0]["GB_PictureUrl"].ToString()!="") { model.GB_PictureUrl=ds.Tables[0].Rows[0]["GB_PictureUrl"].ToString(); } if(ds.Tables[0].Rows[0]["GB_Note"]!=null && ds.Tables[0].Rows[0]["GB_Note"].ToString()!="") { model.GB_Note=ds.Tables[0].Rows[0]["GB_Note"].ToString(); } return model; } else { return null; } }