Beispiel #1
0
        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"];
            }
        }
Beispiel #2
0
        public int save(UserGroupVo userGroup)
        {
            load(userGroup, userGroup.NAME);

            if (userGroup.ID == 0)
            {
                return(insert(userGroup));
            }
            else
            {
                return(update(userGroup));
            }
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        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());
            }
        }
Beispiel #5
0
        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());
            }
        }
Beispiel #6
0
        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());
            }
        }