/// <summary> /// 得到一个对象实体 /// </summary> public SmartLaw.Model.News DataRowToModel(DataRow row) { SmartLaw.Model.News model=new SmartLaw.Model.News(); if (row != null) { if(row["AutoID"]!=null && row["AutoID"].ToString()!="") { model.AutoID=long.Parse(row["AutoID"].ToString()); } if(row["Title"]!=null) { model.Title=row["Title"].ToString(); } if(row["CategoryID"]!=null && row["CategoryID"].ToString()!="") { model.CategoryID=long.Parse(row["CategoryID"].ToString()); } if(row["Contents"]!=null) { model.Contents=row["Contents"].ToString(); } if(row["Publisher"]!=null) { model.Publisher=row["Publisher"].ToString(); } if(row["DataSource"]!=null) { model.DataSource=row["DataSource"].ToString(); } if(row["DataType"]!=null) { model.DataType=row["DataType"].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["Checked"] != null) { model.Checked = int.Parse(row["Checked"].ToString()); } if(row["Checker"]!=null) { model.Checker=row["Checker"].ToString(); } if (row["CheckMemo"] != null) { model.CheckMemo = row["CheckMemo"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public SmartLaw.Model.News GetModel(long AutoID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select AutoID,Title,CategoryID,Contents,Publisher,DataSource,DataType,LastModifyTime,IsValid,Checked,Checker,CheckMemo from News"); strSql.Append(" where AutoID=@AutoID limit 1"); MySqlParameter[] parameters = { new MySqlParameter("@AutoID", MySqlDbType.Int64) }; parameters[0].Value = AutoID; SmartLaw.Model.News model=new SmartLaw.Model.News(); DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }