//SELECIONA TODOS OS PESOS E CRITÉRIOS DO PI ATIVO E DA MATÉRIA SELECIONADA public static DataSet SelectCriteriosPesosByPI(int codPi, int codAtr) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataAdapter; objConnection = Mapped.Connection(); objCommand = Mapped.Command("SELECT CP.CPI_CODIGO, CG.CGE_NOME, CG.CGE_DESCRICAO, CP.CPI_PESO FROM CPI_CRITERIO_PI CP INNER JOIN CGE_CRITERIOS_GERAIS CG USING(CGE_CODIGO) WHERE CP.PRI_CODIGO = ?pri_codigo AND CP.ADI_CODIGO = ?adi_codigo;", objConnection); objCommand.Parameters.Add(Mapped.Parameter("?pri_codigo", codPi)); objCommand.Parameters.Add(Mapped.Parameter("?adi_codigo", codAtr)); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
public static DataSet SelectQuantidadeAvaliacoes(string cpf) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataAdapter; objConnection = Mapped.Connection(); //objCommand = Mapped.Command("select *,(SELECT f.fot_url from fot_fotos f where p.pro_codigo = f.pro_codigo limit 1) as foto from pro_produtos as p where p.sub_codigo = ?sub_codigo and p.pro_status = 1 and p.pro_moderacao_status = 1", objConnection); objCommand = Mapped.Command("select * from pro_produtos as p inner join ite_itens as i on i.pro_codigo = p.pro_codigo where p.usu_cpf_cnpj = ?usu_cpf_cnpj and i.ite_avaliacao", objConnection); objCommand.Parameters.Add(Mapped.Parameter("?usu_cpf_cnpj", cpf)); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
//metodos //insert public bool Insert(Venda venda) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "INSERT INTO tbl_vendas(ven_data, ven_tipo, cli_cpf, ped_codigo) VALUES (?dataVenda, ?tipoVenda, 1, 0)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?dataVenda", venda.DataVenda)); objCommand.Parameters.Add(Mapped.Parameter("?tipoVenda", venda.TipoVenda)); //objCommand.Parameters.Add(Mapped.Parameter("?cpfCliente", venda.CpfCliente)); //objCommand.Parameters.Add(Mapped.Parameter("?codigoPedido", venda.CodigoPedido)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
public bool InsertCamara(Recurso rec) { IDbCommand objCommand; IDbConnection objConexao; string sql = "INSERT INTO CAM_CAMARA(CAM_CAMARA) VALUE(?camara)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?camara", rec.Camara)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
//métodos //insert public bool Insert(Fornecedor fornecedor) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "INSERT INTO tbl_fornecedor(forn_nome, forn_telefone, forn_cnpj, forn_endereco) VALUES (?nome, ?telefone, ?cnpj, ?endereco)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?nome", fornecedor.Nome)); objCommand.Parameters.Add(Mapped.Parameter("?telefone", fornecedor.Telefone)); objCommand.Parameters.Add(Mapped.Parameter("?cnpj", fornecedor.CNPJ)); objCommand.Parameters.Add(Mapped.Parameter("?endereco", fornecedor.Endereco)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
//public static DataSet SelectMenu() //{ // DataSet ds = null; // try // { // ds = new DataSet(); // IDbConnection objConexao; // IDbCommand objComando; // IDataAdapter objDataAdapter; // objConexao = Mapped.Connection(); // string sql = "select men.men_descricao, pag.pag_descricao from fun_mod_pfl_men as fmp " + // "inner join fun_funcionario as fun on fun.fun_cod = fmp.fun_cod " + // "inner join men_menu as men on men.men_cod = fmp.men_cod " + // "inner join pag_paginas as pag on pag.pag_cod = men.pag_cod"; // objComando = Mapped.Command(sql, objConexao); // objDataAdapter = Mapped.Adapter(objComando); // objDataAdapter.Fill(ds); // objConexao.Close(); // objComando.Dispose(); // objConexao.Dispose(); // return ds; // } // catch // { // return ds = null; // } //} public static DataSet SelectAll(int codigo) { DataSet ds = new DataSet(); IDbConnection objConexao; IDbCommand objComando; objConexao = Mapped.Connection(); string sql = "select * from fun_mod where fun_cod=?codigo;"; objComando = Mapped.Command(sql, objConexao); objComando.Parameters.Add(Mapped.Parameter("?codigo", codigo)); objComando.ExecuteNonQuery(); objConexao.Close(); objComando.Dispose(); objConexao.Dispose(); return(ds); }
public bool Update(PendenciaAtiva pendenciaAtiva) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "UPDATE atv_pendencia SET atv_quantidade=?quantidade WHERE atv_codigo =?codigo"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?codigo", pendenciaAtiva.Codigo)); objCommand.Parameters.Add(Mapped.Parameter("?quantidade", pendenciaAtiva.Quantidade)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
public DataSet GetFornecedores(int materiaprima) { DataSet ds = new DataSet(); System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; System.Data.IDataAdapter objDataAdapter; objConexao = Mapped.Connection(); objCommand = Mapped.Command("SELECT map_nome, pes_nomeFantasia, pes_razaoSocial, pes_email FROM fmp_fornecedormateriaprima INNER JOIN map_materiaprima ON map_materiaprima.map_id=fmp_fornecedormateriaprima.map_id INNER JOIN pes_pessoas ON pes_pessoas.pes_id=fmp_fornecedormateriaprima.pes_id WHERE map_materiaprima.map_id=?materiaprima ORDER BY pes_nomeFantasia;", objConexao); objCommand.Parameters.Add(Mapped.Parameter("?materiaprima", materiaprima)); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(ds); }
//update public bool Update(Produto produto) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "UPDATE tbl_produto SET pro_nome=?nome, pro_tipo=?tipo, pro_preco=?preco WHERE pro_codigo =?codigo"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?nome", produto.Nome)); objCommand.Parameters.Add(Mapped.Parameter("?preco", produto.Preco)); objCommand.Parameters.Add(Mapped.Parameter("?codigo", produto.Codigo)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
//delete public bool Delete(int id) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "DELETE FROM tbl_cliente WHERE cli_id=?id"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?id", id)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
//SelectDDL public DataSet SelectDDL(string codigo) { DataSet ds = new DataSet(); System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; System.Data.IDataAdapter objDataAdapter; objConexao = Mapped.Connection(); objCommand = Mapped.Command("SELECT * FROM ite_itenspedido WHERE ite_guid = ?codigo", objConexao); objCommand.Parameters.Add(Mapped.Parameter("?codigo", codigo)); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(ds); }
//**********************************************************// //METODO DELETE PARA PROPRIETARIO PODER DELETAR ALGUM CLIENTE// //**********************************************************// public bool Delete(int codigo) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "DELETE FROM TBL_PESSOAS WHERE PES_CODIGO=?CODIGO"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?CODIGO", codigo)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
public static DataSet SelectAleatorioSubcategoria(int cod) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataAdapter; objConnection = Mapped.Connection(); //objCommand = Mapped.Command("select *,(SELECT f.fot_url from fot_fotos f where p.pro_codigo = f.pro_codigo limit 1) as foto from pro_produtos as p where p.sub_codigo = ?sub_codigo and p.pro_status = 1 and p.pro_moderacao_status = 1", objConnection); objCommand = Mapped.Command("select *,(SELECT f.fot_url from fot_fotos f where p.pro_codigo = f.pro_codigo limit 1) as foto from pro_produtos as p inner JOIN sub_subcategorias as s on p.sub_codigo = s.sub_codigo where s.cat_codigo = ?cat_codigo and p.pro_status = 1 and p.pro_moderacao_status = 1 and p.pro_quantidade > 0", objConnection); objCommand.Parameters.Add(Mapped.Parameter("?cat_codigo", cod)); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
public static DataSet selectProdutosInteressados(int codigo) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataAdapter; objConnection = Mapped.Connection(); //objCommand = Mapped.Command("select distinct u.sub_codigo,c.cat_codigo,c.cat_nome,p.pro_codigo,p.pro_nome,p.pro_descricao,p.pro_condicao,p.pro_preco,p.pro_medida, p.pro_quantidade ,p.pro_status ,p.pro_moderacao_status ,p.pro_acesso,p.usu_cpf_cnpj,p.mar_codigo,p.sub_codigo,(select f.fot_url from fot_fotos as f where f.pro_codigo = p.pro_codigo LIMIT 1) foto from usu_usuarios as u inner join pro_produtos as p inner join sub_subcategorias as s on s.sub_codigo = u.sub_codigo inner join cat_categorias as c on s.cat_codigo = c.cat_codigo where s.sub_codigo = ?sub_codigo;", objConnection); objCommand = Mapped.Command("select *,(SELECT f.fot_url from fot_fotos as f where f.pro_codigo = p.pro_codigo limit 1) foto from pro_produtos as p where p.sub_codigo = ?sub_codigo and p.pro_status = 1 and p.pro_moderacao_status = 1 and p.pro_quantidade > 0;", objConnection); objDataAdapter = Mapped.Adapter(objCommand); objCommand.Parameters.Add(Mapped.Parameter("?sub_codigo", codigo)); objDataAdapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
//métodos //insert public bool Insert(Despesa despesa) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "INSERT INTO tbl_despesas (des_data, des_valor, des_descricao, des_quantidade) VALUES (?data, ?valor, ?descricao, ?quantidade)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?data", despesa.Data)); objCommand.Parameters.Add(Mapped.Parameter("?valor", despesa.Valor)); objCommand.Parameters.Add(Mapped.Parameter("?descricao", despesa.Descricao)); objCommand.Parameters.Add(Mapped.Parameter("?quantidade", despesa.Quantidade)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
//métodos //insert public bool Insert(SaidaCaixa saidacaixa) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "INSERT INTO tbl_saidacaixa(cai_vendedor, cai_data, cai_preco, cai_descricao) VALUES (?vendedor, ?data, ?preco, ?descricao)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?vendedor", saidacaixa.Vendedor)); objCommand.Parameters.Add(Mapped.Parameter("?data", saidacaixa.Data)); objCommand.Parameters.Add(Mapped.Parameter("?preco", saidacaixa.Preco)); objCommand.Parameters.Add(Mapped.Parameter("?descricao", saidacaixa.Descricao)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
public static DataSet SelectByNomeProjeto(int atr, string nomeGru) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataAdapter; objConnection = Mapped.Connection(); objCommand = Mapped.Command("SELECT G.GRU_CODIGO, G.GRU_NOME_PROJETO, P.PRI_SEMESTRE, S.SAN_ANO, G.GRU_CODIGO FROM GRU_GRUPO G INNER JOIN API_ATRIBUICAO_PI A USING(PRI_CODIGO) INNER JOIN PRI_PROJETO_INTER P USING(PRI_CODIGO) INNER JOIN SAN_SEMESTRE_ANO S USING(SAN_CODIGO) WHERE GRU_NOME_PROJETO LIKE concat('%',?nomeGru,'%') AND GRU_FINALIZADO = 1 AND ADI_CODIGO = ?ADI_CODIGO;", objConnection); objCommand.Parameters.Add(Mapped.Parameter("?adi_codigo", atr)); objCommand.Parameters.Add(Mapped.Parameter("?nomeGru", nomeGru)); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
public static DataSet SelectBySemestreAno(int atr, int CodSan) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataAdapter; objConnection = Mapped.Connection(); objCommand = Mapped.Command("SELECT G.GRU_CODIGO, G.GRU_NOME_PROJETO, P.PRI_SEMESTRE, S.SAN_ANO FROM GRU_GRUPO G INNER JOIN API_ATRIBUICAO_PI A USING(PRI_CODIGO) INNER JOIN PRI_PROJETO_INTER P USING(PRI_CODIGO) INNER JOIN SAN_SEMESTRE_ANO S USING(SAN_CODIGO) WHERE GRU_FINALIZADO = 1 AND ADI_CODIGO = ?ADI_CODIGO AND SAN_CODIGO = ?SAN_CODIGO;", objConnection); objCommand.Parameters.Add(Mapped.Parameter("?adi_codigo", atr)); objCommand.Parameters.Add(Mapped.Parameter("?san_codigo", CodSan)); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
//inserir pedido produto public bool Vincular(int idproduto, int idmesas, int quantidade) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "INSERT INTO tbl_pp(id_produto, mesas_id, pp_quantidade) VALUES (?produto, ?mesas, ?quantidade)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?produto", idproduto)); objCommand.Parameters.Add(Mapped.Parameter("?mesas", idmesas)); objCommand.Parameters.Add(Mapped.Parameter("?quantidade", quantidade)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
//SelectPeriodo public DataSet SelectPeriodo(string dataInicio, string dataFinal) { DataSet ds = new DataSet(); System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; System.Data.IDataAdapter objDataAdapter; objConexao = Mapped.Connection(); objCommand = Mapped.Command("SELECT * FROM ven_venda WHERE VEN_DATA BETWEEN (?dataInicio) AND (?dataFinal)", objConexao); objDataAdapter = Mapped.Adapter(objCommand); objCommand.Parameters.Add(Mapped.Parameter("?dataInicio", dataInicio)); objCommand.Parameters.Add(Mapped.Parameter("?dataFinal", dataFinal)); objDataAdapter.Fill(ds); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(ds); }
public static DataSet Select(string cpf) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataAdapter; objConnection = Mapped.Connection(); //objCommand = Mapped.Command("SELECT men_visivel,men_codigo, men_conteudo, men_respondida, men_data, men_lida, pro_codigo,case when tme_codigo='2' then 'Pergunta de produto' when tme_codigo='3' then 'resposta do produto' when tme_codigo='4' then 'Produto atualizado' when tme_codigo='5' then 'Produto Aprovado' when tme_codigo='6' then 'Produto recusado' else 'Equipe Garimpo' end tme_codigo, men_pergunta_codigo, pro_codigo, men_cpf_pergunta, usu_cpf_cnpj from men_mensagens where usu_cpf_cnpj = ?usu_cpf_cnpj order by men_data desc", objConnection); objCommand = Mapped.Command("SELECT u.sub_codigo,m.men_visivel,m.men_codigo, m.men_conteudo, m.men_respondida, m.men_data, m.men_lida, m.pro_codigo,case when m.tme_codigo = '2' then 'Pergunta de produto' when m.tme_codigo = '3' then 'resposta do produto' when m.tme_codigo = '4' then 'Produto atualizado' when m.tme_codigo = '5' then 'Produto Aprovado' when m.tme_codigo = '6' then 'Produto recusado' when m.tme_codigo = '7' then 'Produto Alterado' when m.tme_codigo = '8' then 'Denúncia de Produto' else 'Equipe Garimpo' end tme_codigo, m.men_pergunta_codigo, m.pro_codigo, m.men_cpf_pergunta, m.usu_cpf_cnpj from men_mensagens as m inner JOIN usu_usuarios as u on u.usu_cpf_cnpj = m.usu_cpf_cnpj where m.usu_cpf_cnpj = ?usu_cpf_cnpj order by men_data desc", objConnection); objDataAdapter = Mapped.Adapter(objCommand); objCommand.Parameters.Add(Mapped.Parameter("?usu_cpf_cnpj", cpf)); objDataAdapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
public static void Update(tpc_tipo_contato tpc) { //Correto IDbConnection objConexao; //Abrir a conexão IDbCommand objCommand; // Criar e executar os comandos string sql = "update tpc_tipo_contato set tpc_descricao = ?tpc_descricao where tpc_id = ?tpc_id"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("tpc_id", tpc.Tpc_id)); objCommand.Parameters.Add(Mapped.Parameter("tpc_descricao", tpc.Tpc_descricao)); objCommand.ExecuteNonQuery(); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); }
//delete public bool Delete(int id) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "DELETE FROM tbl_produto WHERE pro_codigo=?codigo"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?codigo", id)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
public static Perfil Select(int pfl_cod) { Perfil pfl = null; try { IDbConnection objConexao; IDbCommand objComando; IDataReader objReader; objConexao = Mapped.Connection(); string sql = "select * from pfl_perfil where pfl_cod = ?pfl_cod"; objComando = Mapped.Command(sql, objConexao); objComando.Parameters.Add(Mapped.Parameter("?pfl_cod", pfl_cod)); //objComando.Parameters.Add(Mapped.Parameter("?senha", senha)); objReader = objComando.ExecuteReader(); while (objReader.Read()) { pfl = new Perfil(); pfl.Pfl_cod = Convert.ToInt32(objReader["pfl_cod"]); pfl.Pfl_descricao = Convert.ToString(objReader["pfl_descricao"]); pfl.Pfl_imagem = Convert.ToString(objReader["pfl_imagem"]); if (objReader["cod_fun"] == DBNull.Value) { pfl.Cod_fun = null; } else { pfl.Cod_fun = Convert.ToInt32(objReader["cod_fun"]); } } objConexao.Close(); objComando.Dispose(); objConexao.Dispose(); return(pfl); } catch { return(pfl = null); } }
public static Departamento Select(int dep_cod) { Departamento dep = null; try { IDbConnection objConexao; IDbCommand objComando; IDataReader objReader; objConexao = Mapped.Connection(); string sql = "select * from dep_departamento where dep_cod=?dep_cod;"; objComando = Mapped.Command(sql, objConexao); objComando.Parameters.Add(Mapped.Parameter("?dep_cod", dep_cod)); objReader = objComando.ExecuteReader(); while (objReader.Read()) { dep = new Departamento(); dep.Dep_cod = Convert.ToInt32(objReader["dep_cod"]); dep.Dep_descricao = Convert.ToString(objReader["dep_descricao"]); dep.Dep_nome = Convert.ToString(objReader["dep_nome"]); dep.Dep_ativo = Convert.ToString(objReader["dep_ativo"]); if (objReader["cod_fun"] == DBNull.Value) { dep.Cod_fun = null; } else { dep.Cod_fun = Convert.ToInt32(objReader["cod_fun"]); } } objConexao.Close(); objComando.Dispose(); objConexao.Dispose(); return(dep); } catch { return(dep = null); } }
public Usu_Usuario SelecionarPorEmail(string email) { Usu_Usuario objUsuario = null; try { IDbConnection objConexao; IDbCommand objComando; IDataReader objDataReader; objConexao = Mapped.Connection(); objComando = Mapped.Command("select * from usu_usuario inner join pes_pessoa using(pes_codigo) where pes_email=?pes_email;", objConexao); objComando.Parameters.Add(Mapped.Parameter("?pes_email", email)); objDataReader = objComando.ExecuteReader(); while (objDataReader.Read()) { objUsuario = new Usu_Usuario(); objUsuario.Usu_codigo = Convert.ToInt32(objDataReader["usu_codigo"]); objUsuario.Usu_senha = objDataReader["usu_senha"].ToString(); objUsuario.Usu_login = Convert.ToInt32(objDataReader["usu_login"]); objUsuario.Pes_codigo = Pes_PessoaDB.Select(Convert.ToInt32(objDataReader["pes_codigo"].ToString())); objUsuario.Usu_status = Convert.ToInt32(objDataReader["usu_status"]); if (objDataReader["usu_data_acesso"] == DBNull.Value) { objUsuario.Usu_data_acesso = null; } else { objUsuario.Usu_data_acesso = Convert.ToDateTime(objDataReader["usu_data_acesso"]); } } objDataReader.Close(); objConexao.Close(); objComando.Dispose(); objConexao.Dispose(); objDataReader.Dispose(); return(objUsuario); } catch (Exception e) { return(null); } }
/// <summary> /// Metodo para selecionar um especifico item do banco, passando o codigo dele. /// </summary> /// <param name="ite_id"></param> /// <returns></returns> public static Item Select(int ped_id) { Item ite = null; try { //Instanciando as conexoes com o banco (padrão) IDbConnection objConexao; IDbCommand objComando; IDataReader objReader; objConexao = Mapped.Connection(); string sql = "select * from ite_item where ped_id=?ped_id;"; objComando = Mapped.Command(sql, objConexao); objComando.Parameters.Add(Mapped.Parameter("?ped_id", ped_id)); objReader = objComando.ExecuteReader(); // Criamos uma variavel que ira amarzenar o valor da chave estrangeira. int pedido = 0; //Este while serve para enquanto tiver registros no banco, ele ira amarzenar dentro do Objeto Item, no caso uma fez só. while (objReader.Read()) //Este Objeto Reader que é o responsavel por ler o conteudo das tabelas do banco. { ite = new Item(); //Salvando na variavel do Objeto Item a informação que encontrou naquele campo. ite.Ite_id = Convert.ToInt32(objReader["ite_id"]); ite.Ite_quantidade = Convert.ToInt32(objReader["ite_quantidade"]); pedido = Convert.ToInt32(objReader["ped_id"]); } //Encerra conexao com o banco. objConexao.Close(); objComando.Dispose(); objConexao.Dispose(); // Depois de fecharmos essa conexao, temos que mandar o valor armazenado na variavel para conseguir o valor da outra tabela // que tem chave estrangeira. ite.Pedido = PedidoDB.Select(pedido); return(ite); } catch { return(ite = null); } }
public static bool InsertMovimentacaoEstoque(Produto produto, int quantidade) { bool ok = false; try { IDbConnection objConexao; IDbCommand objComando; objConexao = Mapped.Connection(); string query = ""; query += " INSERT INTO "; query += " movestoque (mes_dhcriacao, mes_qtdentrada, mes_qtdsaida, mes_saldo, mes_descricao, pro_id, emp_id) "; query += " VALUES( "; query += " ?dataCriacao, "; query += " ?quantidadeEntrada, "; query += " 0, "; query += " ?saldo, "; query += " 'Criação do Produto', "; query += " (select max(pro_id) from produtos), "; query += " ?empresaId "; query += " ) "; objComando = Mapped.Command(query, objConexao); objComando.Parameters.Add(Mapped.Parameter("?dataCriacao", DateTime.Now)); objComando.Parameters.Add(Mapped.Parameter("?quantidadeEntrada", quantidade)); objComando.Parameters.Add(Mapped.Parameter("?saldo", quantidade)); objComando.Parameters.Add(Mapped.Parameter("?empresaId", produto.Empresa.Emp_id)); objComando.ExecuteNonQuery(); objConexao.Dispose(); objComando.Dispose(); ok = true; } catch (Exception ex) { ok = false; } return(ok); }
public Advogado Select(int codigo) { Advogado adv = null; IDbConnection objConexao; IDbCommand objCommand; IDataReader objDataReader; string sql = "SELECT CASE PES_SEXO WHEN 'F' THEN 'Feminino' WHEN 'M' THEN 'Masculino' END AS SEXO, P.* FROM PES_PESSOA P WHERE P.PES_CODIGO =?codigo"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?codigo", codigo)); objDataReader = objCommand.ExecuteReader(); while (objDataReader.Read()) { adv = new Advogado(); adv.Codigo = Convert.ToInt32(objDataReader["PES_CODIGO"]); adv.UserName = Convert.ToString(objDataReader["PES_LOGIN"]); adv.Sexo = Convert.ToString(objDataReader["SEXO"]); adv.Ativo = Convert.ToInt32(objDataReader["PES_ATIVO"]); adv.Cpf = Convert.ToString(objDataReader["PES_CPF"]); adv.Rg = Convert.ToString(objDataReader["PES_RG"]); adv.DataNascimento = Convert.ToDateTime(objDataReader["PES_DATANASCIMENTO"]);; adv.OAB = Convert.ToString(objDataReader["PES_OAB"]); Contato con = new Contato(); con.Codigo = Convert.ToInt32(objDataReader["CON_CODIGO"]); adv.ContatoPessoa = con; Endereco end = new Endereco(); end.Codigo = Convert.ToInt32(objDataReader["END_CODIGO"]); adv.Endereco = end; EstadoCivil estCivil = new EstadoCivil(); estCivil.Codigo = Convert.ToInt32(objDataReader["ECI_CODIGO"]); adv.EstadoCivil = estCivil; } objDataReader.Close(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); objDataReader.Dispose(); return(adv); }
public static Modulo Select(int mod_cod) { Modulo mod = null; try { IDbConnection objConexao; IDbCommand objComando; IDataReader objReader; objConexao = Mapped.Connection(); string sql = "select * from mod_modulo where mod_cod = ?mod_cod"; objComando = Mapped.Command(sql, objConexao); objComando.Parameters.Add(Mapped.Parameter("?mod_cod", mod_cod)); objReader = objComando.ExecuteReader(); while (objReader.Read()) { mod = new Modulo(); mod.Mod_cod = Convert.ToInt32(objReader["mod_cod"]); mod.Mod_descricao = Convert.ToString(objReader["mod_descricao"]); mod.Mod_pagina = Convert.ToString(objReader["mod_pagina"]); mod.Mod_padrao = Convert.ToInt32(objReader["mod_padrao"]); if (objReader["cod_fun"] == DBNull.Value) { mod.Cod_fun = null; } else { mod.Cod_fun = Convert.ToInt32(objReader["cod_fun"]); } } objConexao.Close(); objComando.Dispose(); objConexao.Dispose(); return(mod); } catch { return(mod = null); } }