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