private StringBuilder GetById()
        {
            var nameProc = $"{ParamtersInput.Prefixos.Procedure}S_{NomeTabela.TratarNomeTabela().ToUpper()}_ID";

            var get = new StringBuilder();

            get.Append($"	public {NomeTabela} GetById(int id) throws Exception{N}");
            get.Append($"	{{{N}");
            get.Append($"		try{{{N}");
            get.Append($"			BeginNewStatement(Proc.{nameProc}, \"{ParamtersInput.DataBase}\");{N}");
            get.Append(
                $"			AddParamter(new Paramter(\"P_{ListaAtributosTabela.First().FIELD_NAME}\", java.sql.Types.NUMERIC, id));{N}{N}");
            get.Append($"			ResultSet rs = super.ExecuteReader();{N}{N}");
            get.Append($"			if(rs.next()){{{N}");
            get.Append($"				{NomeTabela} resposta = new {NomeTabela}();{N}");
            foreach (var att in ListaAtributosTabela)
            {
                get.Append(
                    $"				resposta.set{att.FIELD_NAME}(rs.get{JavaTypesFirebird.GetTypeAtribute(att)}(\"{att.FIELD_NAME}\"));{N}");
            }
            get.Append($"				return resposta;{N}");
            get.Append($"			}};{N}");
            get.Append($"			return null;{N}");
            get.Append($"		}}{N}");
            get.Append($"		catch (Exception ex){{{N}");
            get.Append($"			throw ex;{N}");
            get.Append($"		}}{N}");
            get.Append($"		finally {{{N}");
            get.Append($"			desconecta();{N}");
            get.Append($"		}}{N}");
            get.Append($"	}}{N}");
            return(get);
        }
Beispiel #2
0
        private string parametrosQuery(bool full)
        {
            if (full == false)
            {
                var semit = ListaAtributosTabela.Where(x => x.FIELD_NAME != ListaAtributosTabela.First().FIELD_NAME);
                return("{ " + string.Join(", ", semit.Select(e => e.FIELD_NAME + ": " + "body." + e.FIELD_NAME)) + " }");
            }

            return("{ " + string.Join(", ",
                                      ListaAtributosTabela.Select(e => e.FIELD_NAME + ": " + "body." + e.FIELD_NAME)) + " }");
        }
Beispiel #3
0
        private StringBuilder GetById()
        {
            var get = new StringBuilder();

            get.Append($"    	public IDataReader GetById(int ID){N}");
            get.Append($"    	{{{N}");
            get.Append(
                $"    	 	var sql = $\"SELECT * FROM {NomeTabela} WHERE {ListaAtributosTabela.First().FIELD_NAME} = {{ ID }}\";{N}");
            get.Append($"    	 	return ExecuteReader(sql);{N}");
            get.Append($"    	}}{N}");
            return(get);
        }
Beispiel #4
0
        private StringBuilder Delete()
        {
            var get = new StringBuilder();

            get.Append($"    	public void Delete(int ID){N}");
            get.Append($"    	{{{N}");
            get.Append(
                $"    	 	var sql = $\"DELETE FROM {NomeTabela} WHERE {ListaAtributosTabela.First().FIELD_NAME} = {{ ID }}\";{N}");
            get.Append($"    	 	ExecuteNonResult(sql); {N}");
            get.Append($"    	}}{N}");
            return(get);
        }
Beispiel #5
0
        private StringBuilder Update()
        {
            var get = new StringBuilder();

            get.Append($"    	public void Update({NomeTabela.ToFirstCharToUpper()}Model entidade){N}");
            get.Append($"    	{{{N}");
            get.Append($"    	 	var sql = $\"UPDATE {NomeTabela} SET \" {N}");
            get.Append(UpdateParams());
            get.Append(
                $"    	 	+$\"WHERE {ListaAtributosTabela.First().FIELD_NAME} = {{ entidade.{ListaAtributosTabela.First().FIELD_NAME}}}\"; {N}");
            get.Append($"    	 	ExecuteNonResult(sql); {N}");
            get.Append($"    	}}{N}");
            return(get);
        }
Beispiel #6
0
        public string GerarClasse()
        {
            var template   = Tratamentos.PathTemplate();
            var connection = new MySqlConnectionStringModel(ParamtersInput.ConnectionString);

            var p = String.Format(template,
                                  connection.host, connection.user,
                                  connection.database, connection.password,
                                  connection.port,
                                  NomeTabela.ToLower(),
                                  parametrosQuery(false),
                                  parametrosQuery(false),
                                  ListaAtributosTabela.First().COLUMN_NAME);

            return(p);
        }
Beispiel #7
0
        private StringBuilder GetById()
        {
            var get = new StringBuilder();

            get.Append($"    getById: function (id, callback) {{{N}");
            get.Append(
                $"        oracleDb.beginProcedureById({ParamtersInput.ConnectionString.TratarNomeBase()}, \"{NomeTabela.TratarNomePackage()}.{ParamtersInput.Prefixos.Procedure + "S_" + NomeTabela.TratarNomeTabela() + "_ID"}\",{N}");
            get.Append($"            {{{N}");
            get.Append(
                $"                P_CURSORSELECT: {{ type: oracleDb.type(\"CURSOR\"), dir: oracleDb.type(\"BIND_OUT\") }},{N}");
            get.Append($"                P_{ListaAtributosTabela.First().COLUMN_NAME}: id,   {N}");
            get.Append($"            }}, function (err, result) {{  {N}");
            get.Append($"                callback(err, result);{N}");
            get.Append($"            }});{N}");
            get.Append($"    }},{N}");
            return(get);
        }
Beispiel #8
0
        private StringBuilder Delete()
        {
            var get = new StringBuilder();

            get.Append($"    delete: function (id, callback) {{ {N}");
            get.Append(
                $"        oracleDb.executeProcedure({ParamtersInput.ConnectionString.TratarNomeBase()}, \"{NomeTabela.TratarNomePackage()}.{ParamtersInput.Prefixos.Procedure + "D_" + NomeTabela.TratarNomeTabela()}\",{N}");
            get.Append($"            {{{N}");
            get.Append(
                $"                P_RESULT: {{ dir: oracleDb.type(\"BIND_OUT\"), type: oracleDb.type(\"STRING\") }}, {N}");
            get.Append($"                P_{ListaAtributosTabela.First().COLUMN_NAME}: id,{N}");
            get.Append($"            }}, \"P_RESULT\",{N}");
            get.Append($"            function (err, result) {{ {N}");
            get.Append($"                callback(err, result);{N}");
            get.Append($"            }});{N}");
            get.Append($"    }},{N}");
            return(get);
        }
Beispiel #9
0
        private StringBuilder Delete()
        {
            var get = new StringBuilder();

            get.Append($"        delete: (id) => {{ {N}");
            get.Append(
                $"                return Firebird.executeString(`DELETE FROM {NomeTabela.ToLower()} WHERE {ListaAtributosTabela.First().FIELD_NAME} = ${{id}}`);{N}");
            get.Append($"        }},{N}");
            return(get);
        }
Beispiel #10
0
        private StringBuilder Delete()
        {
            var get = new StringBuilder();

            get.Append($"    delete: (id) => {{ {N}");
            get.Append($"        return new Promise((resolve, reject) => {{{N}");
            get.Append(
                $"            mysql.executeString({baseDb}, \"DELETE FROM {NomeTabela.ToLower()} WHERE {ListaAtributosTabela.First().COLUMN_NAME} =\" + id,{N}");
            get.Append($"                (err, result) => err ? reject(err) : resolve(result));{N}");
            get.Append($"        }});{N}");
            get.Append($"    }},{N}");
            return(get);
        }
Beispiel #11
0
        private StringBuilder Update()
        {
            var get = new StringBuilder();

            get.Append($"    update: (body) => {{ {N}");
            get.Append($"        return new Promise((resolve, reject) => {{{N}");
            get.Append(
                $"            mysql.execute({baseDb}, \"UPDATE {NomeTabela.ToLower()} SET ? WHERE {ListaAtributosTabela.First().COLUMN_NAME} =\" + body.{ListaAtributosTabela.First().COLUMN_NAME}, {parametrosQuery(true)},{N}");
            get.Append($"                (err, result) => err ? reject(err) : resolve(result));{N}");
            get.Append($"        }});{N}");
            get.Append($"    }},{N}");
            return(get);
        }
Beispiel #12
0
        private StringBuilder Add()
        {
            var get = new StringBuilder();

            get.Append($"	public void Add({NomeTabela} entidade) throws Exception{N}");
            get.Append($"	{{{N}");
            get.Append($"		try{{{N}");
            get.Append(
                $"			PreparedStatement conn = BeginNewStatement(\"INSERT INTO {NomeTabela} ({string.Join(", ", ListaAtributosTabela.Where(e => e.COLUMN_NAME != ListaAtributosTabela.First().COLUMN_NAME).Select(e => e.COLUMN_NAME))}) values ({string.Join(", ", ListaAtributosTabela.Where(e => e.COLUMN_NAME != ListaAtributosTabela.First().COLUMN_NAME).Select(q => "?"))})\");{N}");

            for (var index = 1; index < ListaAtributosTabela.Count; index++)
            {
                var att = ListaAtributosTabela[index];
                get.Append(
                    $"			conn.set{JavaTypesSQL.GetTypeAtribute(att).ToFirstCharToUpper()}({index}, entidade.get{att.COLUMN_NAME.ToFirstCharToUpper()}());{N}");
            }

            get.Append($"			conn.execute();{N}");
            get.Append($"			commit();{N}");
            get.Append($"		}}{N}");
            get.Append($"		catch (Exception ex){{{N}");
            get.Append($"			throw ex;{N}");
            get.Append($"		}}{N}");
            get.Append($"		finally {{{N}");
            get.Append($"			desconecta();{N}");
            get.Append($"		}}{N}");
            get.Append($"	}}{N}");
            return(get);
        }
Beispiel #13
0
        private StringBuilder GetById()
        {
            var get = new StringBuilder();

            get.Append($"	public {NomeTabela} GetById(int ID) throws Exception{N}");
            get.Append($"	{{{N}");
            get.Append($"		try{{{N}");
            get.Append(
                $"			PreparedStatement conn = BeginNewStatement(\"SELECT * FROM {NomeTabela} WHERE {ListaAtributosTabela.First().COLUMN_NAME} =\"+ ID);{N}");
            get.Append($"			ResultSet rs = conn.executeQuery();{N}");
            get.Append($"			if(rs.next()){{{N}");
            get.Append($"				{NomeTabela} resposta = new {NomeTabela}();{N}");
            foreach (var att in ListaAtributosTabela)
            {
                get.Append(
                    $"				resposta.set{att.COLUMN_NAME.ToFirstCharToUpper()}(rs.get{JavaTypesSQL.GetTypeAtribute(att).ToFirstCharToUpper()}(\"{att.COLUMN_NAME}\"));{N}");
            }
            get.Append($"				return resposta;{N}");
            get.Append($"			}}{N}");
            get.Append($"			return null;{N}");
            get.Append($"		}}{N}");
            get.Append($"		catch (Exception ex){{{N}");
            get.Append($"			throw ex;{N}");
            get.Append($"		}}{N}");
            get.Append($"		finally {{{N}");
            get.Append($"			desconecta();{N}");
            get.Append($"		}}{N}");
            get.Append($"	}}{N}");
            return(get);
        }
Beispiel #14
0
        private StringBuilder Delete()
        {
            var get = new StringBuilder();

            get.Append($"	public void Delete(int ID) throws Exception{N}");
            get.Append($"	{{{N}");
            get.Append($"		try{{{N}");
            get.Append(
                $"			PreparedStatement conn = BeginNewStatement(\"DELETE FROM {NomeTabela} WHERE {ListaAtributosTabela.First().COLUMN_NAME} = ?\");{N}");
            get.Append($"			conn.setInt({1}, ID);{N}");
            get.Append($"			conn.execute();{N}");
            get.Append($"			commit();{N}");
            get.Append($"		}}{N}");
            get.Append($"		catch (Exception ex){{{N}");
            get.Append($"			throw ex;{N}");
            get.Append($"		}}{N}");
            get.Append($"		finally {{{N}");
            get.Append($"			desconecta();{N}");
            get.Append($"		}}{N}");
            get.Append($"	}}{N}");
            get.Append($"}}{N}");
            return(get);
        }
Beispiel #15
0
        private StringBuilder Update()
        {
            var get = new StringBuilder();

            get.Append($"	public void Update({NomeTabela} entidade) throws Exception{N}");
            get.Append($"	{{{N}");
            get.Append($"		try{{{N}");
            get.Append(
                $"			PreparedStatement conn = BeginNewStatement(\"UPDATE {NomeTabela} SET {string.Join(", ", ListaAtributosTabela.Where(e => e.FIELD_NAME != ListaAtributosTabela.First().FIELD_NAME).Select(e => e.FIELD_NAME + " = ?"))} WHERE {ListaAtributosTabela.First().FIELD_NAME} = \" +  entidade.get{ListaAtributosTabela.First().FIELD_NAME.ToFirstCharToUpper()}());{N}");
            for (var index = 1; index < ListaAtributosTabela.Count; index++)
            {
                var att = ListaAtributosTabela[index];
                get.Append(
                    $"			conn.set{JavaTypesFirebird.GetTypeAtribute(att).ToFirstCharToUpper()}({index}, entidade.get{att.FIELD_NAME.ToFirstCharToUpper()}());{N}");
            }

            get.Append($"			conn.execute();{N}");
            get.Append($"			commit();{N}");
            get.Append($"		}}{N}");
            get.Append($"		catch (Exception ex){{{N}");
            get.Append($"			throw ex;{N}");
            get.Append($"		}}{N}");
            get.Append($"		finally {{{N}");
            get.Append($"			desconecta();{N}");
            get.Append($"		}}{N}");
            get.Append($"	}}{N}");
            return(get);
        }
Beispiel #16
0
        private StringBuilder Update()
        {
            var get = new StringBuilder();

            get.Append($"        update: (body) => {{ {N}");
            get.Append(
                $"                return oracle.executeObject(`UPDATE {NomeTabela} SET ? WHERE {ListaAtributosTabela.First().COLUMN_NAME} = ${{body.{ListaAtributosTabela.First().COLUMN_NAME}}}`, {parametrosQuery(true)});{N}");
            get.Append($"        }},{N}");
            return(get);
        }
Beispiel #17
0
        private StringBuilder Delete()
        {
            var get = new StringBuilder();

            get.Append($"        delete: (id) => {{ {N}");
            get.Append(
                $"                return oracle.executeString(`DELETE FROM {NomeTabela} WHERE {ListaAtributosTabela.First().COLUMN_NAME} = ${{id}}`);{N}");
            get.Append($"        }},{N}");
            return(get);
        }