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