public virtual T GetLastAdded() { T obj = null; DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName, null, new QueryBuilder().OrderBy(idName, false).Limit(1)); if (dt.Rows.Count > 0) { obj = (T)Activator.CreateInstance(typeof(T), dt.Rows[0]); } return(obj); }
public virtual T Show(int id) { T obj = null; DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ONE, tableName, new Param(idName, id)); if (dt.Rows.Count > 0) { obj = (T)Activator.CreateInstance(typeof(T), dt.Rows[0]); } return(obj); }
public virtual T Update(int id, params Param[] @params) { FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.UPDATE, tableName, new Param(idName, id), null, @params); DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ONE, tableName, new Param(idName, id)); T obj = null; if (dt.Rows.Count > 0) { obj = (T)Activator.CreateInstance(typeof(T), dt.Rows[0]); } return(obj); }
public bool UserHaveRole(User user, Role role) { DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName, null, new QueryBuilder().Where("userId").EqualsTo("@userId").And("roleId").EqualsTo("@roleId"), new Param("userId", user.id), new Param("roleId", role.id)); if (dt.Rows.Count == 0) { return(false); } return(true); }
public bool MemberFamilyExists(Member member, Family family) { DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName, null, new QueryBuilder().Where("memberId").EqualsTo(member.id).And("familyId").EqualsTo(family.id)); if (dt.Rows.Count > 0) { return(true); } else { return(false); } }
public virtual List <T> ShowAll(params Param[] parameters) { List <T> objects = new List <T>(); DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { objects.Add((T)Activator.CreateInstance(typeof(T), r)); } } return(objects); }
public Family ShowMembersFamily(Member member) { FamiliesController fc = new FamiliesController(); Family family = null; if (member == null) { return(null); } DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName, null, new QueryBuilder().Where("memberId").EqualsTo(member.id) ); if (dt.Rows.Count > 0) { family = fc.Show((int)dt.Rows[0]["familyId"]); } return(family); }
public List <GivingType> ShowUnused(Giving giving) { List <GivingType> givingTypes = new List <GivingType>(); DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName, null, new QueryBuilder().Where(idName).NotIn( new QueryBuilder().Select("GivingItems", idName).Where("givingId").EqualsTo(giving.id) ).And("isActive").EqualsTo(true) ); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { givingTypes.Add(new GivingType(r)); } } return(givingTypes); }
public List <Role> ShowUsersRoles(User user) { List <Role> roles = new List <Role>(); DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName, null, new QueryBuilder().Where("userId").EqualsTo("@userId"), new Param("userId", user.id)); if (dt.Rows.Count == 0) { return(null); } foreach (DataRow r in dt.Rows) { Role role = new Role(Convert.ToInt32(r["roleId"])); if (role == null) { continue; } roles.Add(role); } return(roles); }
public override List <GivingItem> ShowAll(params Param[] @params) { List <GivingItem> givingItems = new List <GivingItem>(); if (@params.Length != 1) { return(givingItems); } QueryBuilder qb = new QueryBuilder().Where(@params[0].name).EqualsTo(@params[0].value); DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName, null, qb); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { givingItems.Add(new GivingItem(r)); } } return(givingItems); }
public List <Member> ShowFamilyMembers(Family family) { MembersController mc = new MembersController(); List <Member> members = new List <Member>(); if (family == null) { return(members); } DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName, null, new QueryBuilder().Where("familyId").EqualsTo(family.id) ); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { members.Add(mc.Show((Convert.ToInt32(r["memberId"])))); } } return(members); }
public virtual void Delete(int id) { FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.DELETE, tableName, new Param(idName, id)); }
public virtual void Add(params Param[] @params) { FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.CREATE, tableName, null, null, @params); }
public void AddRoleToUser(Role role, User user) { FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.CREATE, tableName, null, null, new Param("roleId", role.id), new Param("userId", user.id)); }