/// <summary> /// 得到一个对象实体 /// </summary> public SmartLaw.Model.Category DataRowToModel(DataRow row) { SmartLaw.Model.Category model=new SmartLaw.Model.Category(); if (row != null) { if(row["AutoID"]!=null && row["AutoID"].ToString()!="") { model.AutoID=long.Parse(row["AutoID"].ToString()); } if(row["CategoryName"]!=null) { model.CategoryName=row["CategoryName"].ToString(); } if(row["ParentCategoryID"]!=null && row["ParentCategoryID"].ToString()!="") { model.ParentCategoryID=long.Parse(row["ParentCategoryID"].ToString()); } if(row["Orders"]!=null && row["Orders"].ToString()!="") { model.Orders=int.Parse(row["Orders"].ToString()); } if(row["LastModifyTime"]!=null && row["LastModifyTime"].ToString()!="") { model.LastModifyTime=DateTime.Parse(row["LastModifyTime"].ToString()); } if(row["IsValid"]!=null && row["IsValid"].ToString()!="") { if((row["IsValid"].ToString()=="1")||(row["IsValid"].ToString().ToLower()=="true")) { model.IsValid=true; } else { model.IsValid=false; } } if(row["Memo"]!=null) { model.Memo=row["Memo"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public SmartLaw.Model.Category GetModel(long AutoID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select AutoID,CategoryName,ParentCategoryID,Orders,LastModifyTime,IsValid,Memo from Category"); strSql.Append(" where AutoID=@AutoID limit 1"); MySqlParameter[] parameters = { new MySqlParameter("@AutoID", MySqlDbType.Int64) }; parameters[0].Value = AutoID; SmartLaw.Model.Category model=new SmartLaw.Model.Category(); DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }