public string GetMaxUserCode(int tenantId) { var sql = "SELECT TOP 1 UserCode FROM Sys_Users WHERE TenantId=" + tenantId + " ORDER BY usercode DESC"; var code = _dataAccess.ExecuteScalar(sql); if (code != null) { int num; if (int.TryParse(code.ToString().TrimStart('0'), out num)) { num = num + 1; return(num.ToString().PadLeft(6, '0')); } } return("000001"); }
public static string GetConfigValue(int tenantId, string section, string name, string defaultValue = "") { string sql = "SELECT ConfigValue FROM Sys_TenantConfig WHERE TenantId=@tid AND ConfigName=@name AND ConfigSection=@section"; object value = _dataAccess.ExecuteScalar(sql, new[] { new SqlParameter("@tid", tenantId), new SqlParameter("@name", name), new SqlParameter("@section", section) }); if (value == null || value == DBNull.Value) { return(defaultValue); } return(value.ToString()); }
/// <summary> /// 获取某人关注了多少人 /// </summary> /// <param name="userId"></param> /// <returns></returns> public int GetAttentionCount(int userId) { var sql = "SELECT COUNT(*) FROM Int_Relationship WHERE UserId=" + userId; return((int)_dataAccess.ExecuteScalar(sql)); }