/// <summary> /// 得到一个对象实体 /// </summary> public Gymnasium_APP.Model.CardTypeInfoModel DataRowToModel(DataRow row) { Gymnasium_APP.Model.CardTypeInfoModel model=new Gymnasium_APP.Model.CardTypeInfoModel(); if (row != null) { if(row["CardTypeID"]!=null && row["CardTypeID"].ToString()!="") { model.CardTypeID=int.Parse(row["CardTypeID"].ToString()); } if(row["CardTypeName"]!=null) { model.CardTypeName=row["CardTypeName"].ToString(); } if(row["MonthsPrice"]!=null) { model.MonthsPrice=row["MonthsPrice"].ToString(); } if(row["Months"]!=null) { model.Months=row["Months"].ToString(); } if(row["DayPrice"]!=null) { model.DayPrice=row["DayPrice"].ToString(); } if(row["DateTime"]!=null) { model.DateTime=row["DateTime"].ToString(); } if(row["TypeName"]!=null) { model.TypeName=row["TypeName"].ToString(); } if(row["CardCount"]!=null) { model.CardCount=row["CardCount"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Gymnasium_APP.Model.CardTypeInfoModel GetModel(int CardTypeID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 CardTypeID,CardTypeName,MonthsPrice,Months,DayPrice,DateTime,TypeName,CardCount from CardTypeInfo "); strSql.Append(" where CardTypeID=@CardTypeID"); SqlParameter[] parameters = { new SqlParameter("@CardTypeID", SqlDbType.Int,4) }; parameters[0].Value = CardTypeID; Gymnasium_APP.Model.CardTypeInfoModel model=new Gymnasium_APP.Model.CardTypeInfoModel(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }