public static bool Alterar(Cargos cargo) { try { using (OracleCommand c = ConexaoOracle.ObterConexao().CreateCommand()) { c.CommandType = System.Data.CommandType.Text; c.CommandText = "UPDATE cargos SET nome=:nome, salario=:salario, descricao=:descricao WHERE cargoid = :codigo"; c.Parameters.Add("nome", OracleType.VarChar).Value = cargo.getNome(); c.Parameters.Add("salario", OracleType.Float).Value = cargo.getSalario(); c.Parameters.Add("descricao", OracleType.VarChar).Value = cargo.getDescricao(); c.Parameters.Add("codigo", OracleType.Int32).Value = cargo.getCargoId(); c.ExecuteNonQuery(); return true; } } catch (OracleException e) { throw e; } }
public static bool Inserir(Cargos cargo) { try { using (OracleCommand c = ConexaoOracle.ObterConexao().CreateCommand()) { c.CommandType = System.Data.CommandType.Text; c.CommandText = "INSERT INTO cargos values(CARGOS_SEQ.NEXTVAL, :nome, :salario, :descricao)"; c.Parameters.Add("nome", OracleType.VarChar).Value = cargo.getNome(); c.Parameters.Add("salario", OracleType.Float).Value = cargo.getSalario(); c.Parameters.Add("descricao", OracleType.VarChar).Value = cargo.getDescricao(); c.ExecuteNonQuery(); return true; } } catch (OracleException e) { throw e; } }