/// <summary> /// 更新一条数据 /// </summary> public bool Update(UserVsRoleModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update UserVsRole set "); strSql.Append(" RoleName = @RoleName , "); strSql.Append(" RoleUserId = @RoleUserId , "); strSql.Append(" RoleMemo = @RoleMemo , "); strSql.Append(" RoleLv = @RoleLv "); strSql.Append(" where RoleName=@RoleName and RoleUserId=@RoleUserId and RoleMemo=@RoleMemo and RoleLv=@RoleLv "); SqlParameter[] parameters = { new SqlParameter("@RoleName", SqlDbType.VarChar, 50), new SqlParameter("@RoleUserId", SqlDbType.VarChar, 50), new SqlParameter("@RoleMemo", SqlDbType.VarChar, 500), new SqlParameter("@RoleLv", SqlDbType.Int, 4) }; parameters[0].Value = model.RoleName; parameters[1].Value = model.RoleUserId; parameters[2].Value = model.RoleMemo; parameters[3].Value = model.RoleLv; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(UserVsRoleModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into UserVsRole("); strSql.Append("RoleName,RoleUserId,RoleMemo,RoleLv"); strSql.Append(") values ("); strSql.Append("@RoleName,@RoleUserId,@RoleMemo,@RoleLv"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@RoleName", SqlDbType.VarChar, 50), new SqlParameter("@RoleUserId", SqlDbType.VarChar, 50), new SqlParameter("@RoleMemo", SqlDbType.VarChar, 500), new SqlParameter("@RoleLv", SqlDbType.Int, 4) }; parameters[0].Value = model.RoleName; parameters[1].Value = model.RoleUserId; parameters[2].Value = model.RoleMemo; parameters[3].Value = model.RoleLv; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }