/// <summary> /// 更新一条数据 /// </summary> public bool Update(Lythen.Model.role_vs_subject model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update role_vs_subject set "); strSql.Append("sub_list=@sub_list"); strSql.Append(" where role_id=@role_id "); SqlParameter[] parameters = { new SqlParameter("@sub_list", SqlDbType.VarChar, 100), new SqlParameter("@role_id", SqlDbType.Int, 4) }; parameters[0].Value = model.sub_list; parameters[1].Value = model.role_id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Lythen.Model.role_vs_subject model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into role_vs_subject("); strSql.Append("role_id,sub_list)"); strSql.Append(" values ("); strSql.Append("@role_id,@sub_list)"); SqlParameter[] parameters = { new SqlParameter("@role_id", SqlDbType.Int, 4), new SqlParameter("@sub_list", SqlDbType.VarChar, 100) }; parameters[0].Value = model.role_id; parameters[1].Value = model.sub_list; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Lythen.Model.role_vs_subject DataRowToModel(DataRow row) { Lythen.Model.role_vs_subject model = new Lythen.Model.role_vs_subject(); if (row != null) { if (row["role_id"] != null && row["role_id"].ToString() != "") { model.role_id = int.Parse(row["role_id"].ToString()); } if (row["sub_list"] != null) { model.sub_list = row["sub_list"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Lythen.Model.role_vs_subject GetModel(int role_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 role_id,sub_list from role_vs_subject "); strSql.Append(" where role_id=@role_id "); SqlParameter[] parameters = { new SqlParameter("@role_id", SqlDbType.Int, 4) }; parameters[0].Value = role_id; Lythen.Model.role_vs_subject model = new Lythen.Model.role_vs_subject(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }