public static DataSet SelectId(int esp_codigo) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataDadapter; objConnection = Mapped.Connection(); string sql = "select * from esp_esportes where esp_codigo = ?esp_codigo"; objCommand = Mapped.Command(sql, objConnection); objCommand.Parameters.Add(Mapped.Parameter("?esp_codigo", esp_codigo)); objDataDadapter = Mapped.Adapter(objCommand); objDataDadapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
public static int Insert(string sqlInsert) { int retorno = 0; try { IDbConnection conexao; IDbCommand objCommand; string sql = "INSERT INTO cpi_criterio_pi(cpi_codigo, cge_codigo, pri_codigo, adi_codigo, cpi_peso, cpi_usuario) VALUES" + sqlInsert; conexao = Mapped.Connection(); objCommand = Mapped.Command(sql, conexao); objCommand.ExecuteNonQuery(); conexao.Close(); objCommand.Dispose(); conexao.Dispose(); } catch (Exception e) { retorno = -2; } return(retorno); }
public static int Insert(string sqlInsert) { int retorno = 0; try { IDbConnection conexao; IDbCommand objCommand; string sql = "INSERT INTO eve_eventos(eve_codigo, pri_codigo, eve_data, eve_tipo, eve_usuario) VALUES" + sqlInsert; conexao = Mapped.Connection(); objCommand = Mapped.Command(sql, conexao); objCommand.ExecuteNonQuery(); conexao.Close(); objCommand.Dispose(); conexao.Dispose(); } catch (Exception e) { retorno = -2; } return(retorno); }
public bool Insert(Produto produto) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "insert INTO pro_produto(cat_id ,pro_nome ,pro_descricao ,pro_dimensao,pro_valor,pro_tempo) VALUES(?categoria,?nome,?descricao,?dimensao,?valor,?tempo)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?categoria", produto.Categoria)); objCommand.Parameters.Add(Mapped.Parameter("?nome", produto.Nome)); objCommand.Parameters.Add(Mapped.Parameter("?descricao", produto.Descricao)); objCommand.Parameters.Add(Mapped.Parameter("?dimensao", produto.Dimensao)); objCommand.Parameters.Add(Mapped.Parameter("?valor", produto.Valor)); objCommand.Parameters.Add(Mapped.Parameter("?tempo", produto.Tempo)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
public static string selectDriverNome(int id) { DataSet ds = new DataSet(); IDbConnection conexao; IDbCommand command; IDataAdapter dataAdapter; conexao = Mapped.Connection(); string query = "select mot_nome as nome from motorista where mot_id = ?mod_id;"; command = Mapped.Command(query, conexao); dataAdapter = Mapped.Adapter(command); command.Parameters.Add(Mapped.Parameter("?mod_id", id)); dataAdapter.Fill(ds); conexao.Close(); conexao.Dispose(); command.Dispose(); return(ds.Tables[0].Rows[0]["nome"].ToString()); }
//métodos //insert public bool Insert(Emprestimo emprestimo) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "INSERT INTO emp_emprestimo ( emp_data, emp_tipo, emp_valor, emp_qntdParcela, emp_valorParcela, emp_status, emp_id) VALUES(?DataEMP, ?TipoEMP, ?ValorEMP, ?QntdParcela, ?ValorParcela, ?Status, ?Id)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?DataEMP", emprestimo.DataEMP)); objCommand.Parameters.Add(Mapped.Parameter("?TipoEMP", emprestimo.TipoEMP)); objCommand.Parameters.Add(Mapped.Parameter("?ValorEMP", emprestimo.ValorEMP)); objCommand.Parameters.Add(Mapped.Parameter("?QntdParcela", emprestimo.QntdParcela)); objCommand.Parameters.Add(Mapped.Parameter("?ValorParcela", emprestimo.ValorParcela)); objCommand.Parameters.Add(Mapped.Parameter("?Status", emprestimo.Status)); objCommand.Parameters.Add(Mapped.Parameter("?Id", emprestimo.Id)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
public static DataSet SelectUltimaPartidaCriada(Pef_Pessoa_Fisica pef) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataDadapter; objConnection = Mapped.Connection(); string sql = "select par_codigo from par_partidas where pef_codigo_adm = ?pef_codigo order by par_codigo desc;"; objCommand = Mapped.Command(sql, objConnection); objCommand.Parameters.Add(Mapped.Parameter("?pef_codigo", pef.Pef_codigo)); objDataDadapter = Mapped.Adapter(objCommand); objDataDadapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
//excluir denuncia public static int Delete(int codigo) { int retorno = 0; try { IDbConnection objConexao; // Abre a conexao IDbCommand objCommand; // Cria o comando string sql = "delete from den_denuncias where den_codigo = ?den_codigo"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?den_codigo", codigo)); // PK objCommand.ExecuteNonQuery(); // utilizado quando cdigo não tem retorno, como seria o caso do SELECT objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); } catch (Exception e) { retorno = -2; } return(retorno); }
public static DataSet SelectId(int id) { DataSet ds = new DataSet(); IDbConnection objConexao; IDbCommand objCommand; IDataAdapter objDataAdapter; //string sql = "select emp_nome as NOME, emp_rua as RUA from emp_empresa order by emp_nome"; //string sql = "select emp_nome, emp_rua from emp_empresa order by emp_nome"; string sql = "@select mot.mot_id, mxc.mxc_id from mxc_motorista_tipo_contato mxc inner join mot_motorista mot on mot.mot_id = mxc.mot_id inner join tpc_tipo_contato tpc on tpc.tpc_id = mxc.tpc_id where mot.mot_id = ?id "; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?id", id)); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); return(ds); }
public static DataSet SelectAll() { DataSet ds = new DataSet(); IDbConnection objConexao; IDbCommand objCommand; IDataAdapter objDataAdapter; //string sql = "select emp_nome as NOME, emp_rua as RUA from emp_empresa order by emp_nome"; //string sql = "select emp_nome, emp_rua from emp_empresa order by emp_nome"; string sql = "select * from tpc_tipo_contato"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); return(ds); }
//update public bool Update(Compras compra) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "UPDATE tbl_compra SET compra_descricao=?descricao, compra_qtd=?quantidade, valor_compra=?valor WHERE compra_id=?id"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?descricao", compra.descricao)); objCommand.Parameters.Add(Mapped.Parameter("?valor", compra.compravalor)); objCommand.Parameters.Add(Mapped.Parameter("?quantidade", compra.compraqtd)); objCommand.Parameters.Add(Mapped.Parameter("?id", compra.compraid)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); }
public MateriaPrima VerificaDupicidadeNome(string nome) { MateriaPrima obj = null; System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; System.Data.IDataReader objDataReader; objConexao = Mapped.Connection(); objCommand = Mapped.Command("SELECT * FROM map_materiaprima WHERE map_nome =?nome", objConexao); objCommand.Parameters.Add(Mapped.Parameter("?nome", nome)); objDataReader = objCommand.ExecuteReader(); while (objDataReader.Read()) { obj = new MateriaPrima(); obj.Nome = Convert.ToString(objDataReader["map_nome"]); } objDataReader.Close(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); objDataReader.Dispose(); return(obj); }
//delete public bool Delete(int id) { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "DELETE FROM mov_movimentacao WHERE mov_id = ?mov_id"; try { objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?mov_id", id)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(true); } catch (Exception e) { return(false); } }
public static DataSet SelectPassageiros() { DataSet ds = new DataSet(); IDbConnection objConexao; IDbCommand objCommand; IDataAdapter objDataAdapter; //string sql = "select emp_nome as NOME, emp_rua as RUA from emp_empresa order by emp_nome"; //string sql = "select emp_nome, emp_rua from emp_empresa order by emp_nome"; string sql = "select usu_tipo, pes_nome, pes_sexo, pes_cidade, usu_email from usu_usuario usu inner join pes_pessoa pes where pes.pes_id = usu.pes_id and usu_tipo = 'Passageiro';"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); return(ds); }
public static DataSet SelectEspCodigo(int par_codigo) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataDadapter; objConnection = Mapped.Connection(); string sql = "select esp_codigo from par_partidas where par_codigo = ?par_codigo "; objCommand = Mapped.Command(sql, objConnection); objCommand.Parameters.Add(Mapped.Parameter("?par_codigo", par_codigo)); objDataDadapter = Mapped.Adapter(objCommand); objDataDadapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
public static DataSet SelectLogin(string cnpj, string pwd) { DataSet ds = new DataSet(); IDbConnection objConnection; IDbCommand objCommand; IDataAdapter objDataDadapter; objConnection = Mapped.Connection(); string sql = "select * from pej_pessoa_juridica where pej_cnpj = ?pej_cnpj and pej_senha = ?pej_senha"; objCommand = Mapped.Command(sql, objConnection); objCommand.Parameters.Add(Mapped.Parameter("?pej_cnpj", cnpj)); objCommand.Parameters.Add(Mapped.Parameter("?pej_senha", pwd)); objDataDadapter = Mapped.Adapter(objCommand); objDataDadapter.Fill(ds); objConnection.Close(); objCommand.Dispose(); objConnection.Dispose(); return(ds); }
//INSERE UM NOVO ORCAMENTO NO BANCO DE DADOS public bool Insert(DateTime data, string email, string total, int id) { System.Data.IDbConnection objConn; System.Data.IDbCommand objCommand; string sql = "INSERT INTO orcamento(orc_data_inicio, orc_email, orc_total_orcamento, fun_id)" + "VALUES (?data, ?email, ?total, ?id);"; objConn = Mapped.Connection(); objCommand = Mapped.Command(sql, objConn); objCommand.Parameters.Add(Mapped.Parameter("?data", data)); objCommand.Parameters.Add(Mapped.Parameter("?email", email)); objCommand.Parameters.Add(Mapped.Parameter("?total", total)); objCommand.Parameters.Add(Mapped.Parameter("?id", id)); objCommand.ExecuteNonQuery(); objConn.Close(); objCommand.Dispose(); objConn.Dispose(); return(true); }
public static DataSet selectDriver2(int id) { DataSet ds = new DataSet(); IDbConnection conexao; IDbCommand command; IDataAdapter dataAdapter; conexao = Mapped.Connection(); string query = "select motorista.mot_id, motorista.mot_nome, motorista.mot_genero ,motorista.mot_datanasciment, usuario.usu_email from motorista inner join usuario on motorista.usu_id = usuario.usu_id where motorista.mot_id = ?mot_id"; command = Mapped.Command(query, conexao); dataAdapter = Mapped.Adapter(command); command.Parameters.Add(Mapped.Parameter("?mot_id", id)); dataAdapter.Fill(ds); conexao.Close(); conexao.Dispose(); command.Dispose(); return(ds); }
public DataSet SelectAll() { DataSet ds = new DataSet(); System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; System.Data.IDataAdapter objDataAdapter; string sql = "select tbl_categoriadespesas.CAD_DESCRICAO, tbl_despesas.DES_DESCRICAO, tbl_despesas.DES_CUSTO, tbl_despesas.DES_DATADESPESA, tbl_categoriadespesas.CAD_CODIGO, tbl_despesas.CAD_CODIGO from tbl_despesas inner join tbl_categoriadespesas on tbl_despesas.CAD_CODIGO = tbl_categoriadespesas.CAD_CODIGO"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); return(ds); }
public static DataSet SelectSolicitacao(int id) { DataSet ds = new DataSet(); IDbConnection objConexao; IDbCommand objCommand; IDataAdapter objDataAdapter; string sql = "select sol_id, pes_nome, sol_origem, sol_datainicio, sol_datafim, sol_destino, sol_descricao from sol_solicitacao sol inner join pas_passageiro pas on pas.pas_id = sol.pas_id inner join usu_usuario usu on pas.usu_id = usu.usu_id inner join pes_pessoa pes on pes.pes_id = usu.pes_id where sol.pas_id = ?id"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?id", id)); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); return(ds); }
// GET api/<controller> public IEnumerable <Equipamento> Get() { DataSet ds = new DataSet(); DataTable dt = new DataTable(); IDbConnection objConexao; IDbCommand objCommand; IDataAdapter objDataAdapter; objConexao = Mapped.Connection(); objCommand = Mapped.Command("SELECT equ_id, equ_nome, equi_patrimonio, e.tie_id TIPO, equ_status, STA_NOME, TIE_NOME FROM EQU_EQUIPAMENTOS e " + "INNER JOIN TIE_tipo_EQUIPAMENTOS tie ON tie.TIE_ID = e.tie_id " + "INNER JOIN sta_status status ON status.STA_ID = e.equ_status", objConexao); objDataAdapter = Mapped.Adapter(objCommand); objDataAdapter.Fill(ds); dt = ds.Tables[0]; List <Equipamento> data = dt.AsEnumerable() .Select(r => new Equipamento { Id = r.Field <int>("equ_id"), Nome = r.Field <string>("equ_nome"), Patrimonio = r.Field <string>("equi_patrimonio"), Tipo = new TipoEquipamento { ID = r.Field <Int32>("TIPO"), Nome = r.Field <string>("TIE_NOME") }, Status = new Status { Id = r.Field <Int32>("equ_status"), Nome = r.Field <string>("STA_NOME") } }) .ToList(); return(data); }
public static int Update(ser_servicos ser) { int retorno = 0; try { //Correto IDbConnection objConexao; //Abrir a conexão IDbCommand objCommand; // Criar e executar os comandos string sql = "update ser_servicos set ser_datafim = ?ser_datafim, ser_origem = ?ser_origem, ser_datainicio = ?ser_datainicio, ser_destino = ?ser_destino, ser_descricao = ?ser_descricao, ser_lugares = ?ser_lugares, tra_id = ?tra_id where ser_id = ?ser_id"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?ser_id", ser.Ser_id)); objCommand.Parameters.Add(Mapped.Parameter("?ser_datacadastro", ser.Ser_datacadastro)); //objCommand.Parameters.Add(Mapped.Parameter("?ser_nome", ser.Ser_nome)); objCommand.Parameters.Add(Mapped.Parameter("?ser_datafim", ser.Ser_datafim)); objCommand.Parameters.Add(Mapped.Parameter("?ser_origem", ser.Ser_origem)); objCommand.Parameters.Add(Mapped.Parameter("?ser_datainicio", ser.Ser_datainicio)); objCommand.Parameters.Add(Mapped.Parameter("?ser_destino", ser.Ser_destino)); objCommand.Parameters.Add(Mapped.Parameter("?ser_descricao", ser.Ser_descricao)); objCommand.Parameters.Add(Mapped.Parameter("?ser_lugares", ser.Ser_lugares)); objCommand.Parameters.Add(Mapped.Parameter("?tra_id", ser.Tra_id.Tra_id)); objCommand.ExecuteNonQuery(); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); } catch (Exception) { //erro retorno = -2; } return(retorno); }
public int Insert(Fornecedor fornecedor) { int retorno = 0; try { System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; string sql = "INSERT INTO for_fornecedor(for_nome,for_cnpj,for_nome_contato,for_endereco,for_cidade,for_estado,for_telefone,for_email) VALUES(?nome, ?cnpj, ?nomeContato, ?endereco, ?cidade, ?estado, ?telefone, ?email )"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?nome", fornecedor.Nome)); objCommand.Parameters.Add(Mapped.Parameter("?cnpj", fornecedor.Cnpj)); objCommand.Parameters.Add(Mapped.Parameter("?nomeContato", fornecedor.NomeContato)); objCommand.Parameters.Add(Mapped.Parameter("?endereco", fornecedor.Endereco)); objCommand.Parameters.Add(Mapped.Parameter("?cidade", fornecedor.Cidade)); objCommand.Parameters.Add(Mapped.Parameter("?estado", fornecedor.Estado)); objCommand.Parameters.Add(Mapped.Parameter("?telefone", fornecedor.Telefone)); objCommand.Parameters.Add(Mapped.Parameter("?email", fornecedor.Email)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); } catch (MySql.Data.MySqlClient.MySqlException) { retorno = -1; } catch (Exception) { retorno = -2; } return(retorno); }
public static int ValidaSenha(string senha) { int verificacao = 0; IDbConnection objconexao; IDbCommand objCommand; IDataReader objDataReader; string sql = "Select per_senha, per_descricao from per_perfil where per_senha=sha1(?senha) and per_descricao=1;"; objconexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objconexao); //string criptografada = Funcoes.Criptografar(senha, "SHA1"); objCommand.Parameters.Add(Mapped.Parameter("?SENHA", senha)); objDataReader = objCommand.ExecuteReader(); while (objDataReader.Read()) { //if (objDataReader["per_descricao"].ToString() == "") se é nulo ele nem entra no while então isso era desnecessário //{ // verificacao = -2; //} if (Convert.ToInt32(objDataReader["per_descricao"]) == 1) { verificacao = 1; } } objDataReader.Close(); objconexao.Close(); objconexao.Dispose(); objCommand.Dispose(); objDataReader.Dispose(); return(verificacao); //retorna o valor do resultado da verificação feita acima }
public static int ValidarAdmCoord(Professor prof) { string matricula = prof.Matricula; //pega matrícula do objeto professor obtido do método Professor.Validar int verificacao = 0; //string verificaLogin = ""; //bool adm = false; //int proadmcodigo = 0; //int promatricula = 0; IDbConnection objconexao; IDbCommand objCommand; IDataReader objDataReader; string sql = "Select per_matricula, per_descricao from per_perfil where per_matricula = ?per_matricula;"; objconexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objconexao); //string criptografada = Funcoes.Criptografar(senha, "SHA1"); objCommand.Parameters.Add(Mapped.Parameter("?per_matricula", matricula)); objDataReader = objCommand.ExecuteReader(); while (objDataReader.Read()) { if (Convert.ToInt32(objDataReader["per_descricao"]) == 2) { verificacao = 2; } } objDataReader.Close(); objconexao.Close(); objconexao.Dispose(); objCommand.Dispose(); objDataReader.Dispose(); return(verificacao); //retorna o valor do resultado da verificação feita acima }
public Mod_modelos Select(int codigo) { try { Mod_modelos objModelos = null; IDbConnection objConexao; IDbCommand objcommand; IDataReader objDatareader; objConexao = Mapped.Connection(); objcommand = Mapped.Command("select * from mod_modelos where mod_codigo = ?mod_codigo", objConexao); objcommand.Parameters.Add(Mapped.Parameter("?codigoModelo", codigo)); objDatareader = objcommand.ExecuteReader(); while (objDatareader.Read()) { objModelos = new Mod_modelos(); //variavel questão (array)???? objModelos.CodigoModelo = Convert.ToInt32(objDatareader["mod_codigo"]); objModelos.EventoCodigo = Convert.ToInt32(objDatareader["eve_codigo"]); objModelos.EventoNome = objDatareader["eve_nome"].ToString(); objModelos.NomeModelo = objDatareader["mod_nome"].ToString(); objModelos.TipoModelo = objDatareader["mod_tipo"].ToString(); objModelos.AtivoModelo = Convert.ToBoolean(objDatareader["mod_ativo"]); objModelos.EditarModelo = Convert.ToBoolean(objDatareader["mod_editar"]); } objDatareader.Close(); objConexao.Close(); objcommand.Dispose(); objConexao.Dispose(); objDatareader.Dispose(); return(objModelos); } catch (Exception e) { return(null); } }
public Despesas Select(int codigo) { Despesas despesa = null; IDbCommand objCommand; IDbConnection objConexao; IDataReader objDataReader; string sql = "SELECT * FROM DES_DESPESA WHERE DES_CODIGO = ?codigo"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?codigo", codigo)); objDataReader = objCommand.ExecuteReader(); while (objDataReader.Read()) { despesa = new Despesas(); despesa.Codigo = Convert.ToInt32(objDataReader["DES_CODIGO"]); despesa.Valor = Convert.ToDecimal(objDataReader["DES_VALOR"]); despesa.Data = Convert.ToDateTime(objDataReader["DES_DATA"]); despesa.Obs = Convert.ToString(objDataReader["DES_OBS"]); TipoDespesa tipo = new TipoDespesa(); tipo.Codigo = Convert.ToInt32(objDataReader["TID_CODIGO"]); despesa.TipoDespesa = tipo; } objConexao.Close(); objDataReader.Close(); objConexao.Dispose(); objCommand.Dispose(); objDataReader.Dispose(); return(despesa); }
public static DataSet BuscarNomeDoArquivoPorIdDaMissaoUsuario(int idMissaoUsuario) { try { DataSet ds = new DataSet(); IDbConnection objConexao; IDbCommand objCommand; IDataAdapter dataAdapter; objConexao = Mapped.Connection(); string query = ""; query += " SELECT "; query += " mus_arquivo "; query += " FROM "; query += " missao_usuario "; query += " WHERE "; query += " mus_id = ?id "; objCommand = Mapped.Command(query, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?id", idMissaoUsuario)); dataAdapter = Mapped.Adapter(objCommand); dataAdapter.Fill(ds); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); return(ds); } catch (Exception ex) { throw ex; } }
public static int RedefinirSenhaContato(string email) { int codigo = 0; DataSet ds = null; try { ds = new DataSet(); IDbConnection objConexao; IDbCommand objComando; IDataReader objReader; objConexao = Mapped.Connection(); string sql = "select * from con_contato where con_valor = ?email"; objComando = Mapped.Command(sql, objConexao); objComando.Parameters.Add(Mapped.Parameter("?email", email)); objReader = objComando.ExecuteReader(); while (objReader.Read()) { codigo = Convert.ToInt32(objReader["pes_cod"]); } objConexao.Close(); objComando.Dispose(); objConexao.Dispose(); } catch (Exception e) { ds = null; } return(codigo); }
//select public Cliente Select(int id) { Cliente obj = null; System.Data.IDbConnection objConexao; System.Data.IDbCommand objCommand; System.Data.IDataReader objDataReader; objConexao = Mapped.Connection(); objCommand = Mapped.Command("SELECT * FROM tbl_cliente WHERE cli_id=?id", objConexao); objCommand.Parameters.Add(Mapped.Parameter("?id", id)); objDataReader = objCommand.ExecuteReader(); while (objDataReader.Read()) { obj = new Cliente(); obj.Id = Convert.ToInt32(objDataReader["cli_id"]); obj.Nome = Convert.ToString(objDataReader["cli_nome"]); obj.Cpf = Convert.ToString(objDataReader["cli_cpf"]); obj.Telefone = Convert.ToString(objDataReader["cli_telefone"]); obj.Email = Convert.ToString(objDataReader["cli_email"]); obj.Logradouro = Convert.ToString(objDataReader["cli_logradouro"]); obj.Bairro = Convert.ToString(objDataReader["cli_bairro"]); obj.Numero = Convert.ToString(objDataReader["cli_numero"]); obj.Estado = Convert.ToString(objDataReader["cli_estado"]); obj.Cidade = Convert.ToString(objDataReader["cli_cidade"]); } objDataReader.Close(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); objDataReader.Dispose(); return(obj); }