public void load(UserGroupVo userGroup, string name) { DataTable table = select("name = '" + name + "'"); if (table.DefaultView.Count > 0) { userGroup.ID = (int)table.DefaultView[0]["id"]; userGroup.NAME = (string)table.DefaultView[0]["name"]; userGroup.DESCRICAO = (string)table.DefaultView[0]["descricao"]; } }
public int save(UserGroupVo userGroup) { load(userGroup, userGroup.NAME); if (userGroup.ID == 0) { return(insert(userGroup)); } else { return(update(userGroup)); } }
public void load(List <UserGroupVo> userGroups) { DataTable table = select(); for (int i = 0; i < table.DefaultView.Count; i++) { UserGroupVo userGroup = new UserGroupVo(); userGroup.ID = (int)table.DefaultView[i]["id"]; userGroup.NAME = (string)table.DefaultView[i]["[name]"]; userGroup.DESCRICAO = (string)table.DefaultView[i]["descricao"]; userGroups.Add(userGroup); } }
public int delete(UserGroupVo userGroup) { try { this.QUERY = new StringBuilder(fromDatabase); this.QUERY.AppendLine("DELETE FROM UsersGroups"); this.QUERY.AppendLine(" WHERE id = " + userGroup.ID); return(getData().DefaultView.Count); } catch (Exception e) { throw new Exception(Carralero.ExceptionControler.getFullException(e).ToString()); } }
public int update(UserGroupVo userGroup) { try { this.QUERY = new StringBuilder(fromDatabase); this.QUERY.AppendLine("UPDATE UsersGroups"); this.QUERY.AppendLine(" SET "); this.QUERY.AppendLine(" [name] = '" + userGroup.NAME + "'"); this.QUERY.AppendLine(" ,descricao = '" + userGroup + "'"); this.QUERY.AppendLine(" WHERE id = " + userGroup.ID); return(getData().DefaultView.Count); } catch (Exception e) { throw new Exception(Carralero.ExceptionControler.getFullException(e).ToString()); } }
public int insert(UserGroupVo userGroup) { try { this.QUERY = new StringBuilder(fromDatabase); this.QUERY.Append("INSERT INTO UsersGroups"); this.QUERY.AppendLine("([name], descricao)"); this.QUERY.Append("VALUES("); this.QUERY.Append("'" + userGroup.NAME + "',"); this.QUERY.Append("'" + userGroup.DESCRICAO + "'"); this.QUERY.AppendLine(")"); return(getData().DefaultView.Count); } catch (Exception e) { throw new Exception(Carralero.ExceptionControler.getFullException(e).ToString()); } }