public void Alterar(Usuario oCliente) { string sql = ""; try { string[] parametrosNomes = new string[7]; parametrosNomes[0] = "@Id"; parametrosNomes[1] = "@Nome"; parametrosNomes[4] = "@Email"; parametrosNomes[5] = "@Senha"; string[] parametrosValores = new string[7]; parametrosValores[0] = oCliente.Id.ToString(); parametrosValores[1] = oCliente.nome; // parametrosValores[4] = oCliente.email; parametrosValores[5] = oCliente.senha; sql = "UPDATE Usuario SET Nome=@Nome,Email=@Email , Senha=@Senha Where Id=@Id"; AcessoDB.CRUD(sql, parametrosNomes, parametrosValores); } catch (Exception ex) { throw ex; } }
private void btnExcluir_Click(object sender, EventArgs e) { int codJogo = Convert.ToInt32(txtId.Text); AcessoDB.DeletarJogo(codJogo); CarregaDados(); }
protected override void OnAppearing() { base.OnAppearing(); using (var dados = new AcessoDB()) { lstHistorico.ItemsSource = dados.GetAbastecimentos(); } }
public void CarregaDados() { try { IQueryable <TB_Jogo> Jogos = AcessoDB.GetJogosQueryable(); dataGridView1.DataSource = Jogos; } catch (Exception) { throw; } }
private void btnPesquisar_Click(object sender, EventArgs e) { try { int codJogo = Convert.ToInt32(txtId.Text); TB_Jogo jogo = AcessoDB.GetJogo(codJogo); preencheControles(jogo); } catch (Exception) { MessageBox.Show("Ocorreu um erro ao pesquisar"); } }
public DataTable Fill() { string sql = "SELECT * FROM NATIONALITY"; try { return(AcessoDB.GetDataTable(sql)); } catch (Exception ex) { throw ex; } }
async void BtnDeletar_Clicked(object sender, EventArgs e) { bool resposta = await DisplayAlert("Deletar", "Deseja mesmo deletar esse abastecimento?", "Sim", "Não"); if (resposta) { using (var dados = new AcessoDB()) { dados.DeletarAbastecimento(codAbastecimento); await Navigation.PopModalAsync(); } } }
public DataTable ExibirTodos() { string sql = "SELECT * FROM Usuario"; try { return(AcessoDB.GetDataTable(sql)); } catch (Exception ex) { throw ex; } }
public DataTable Consultar(string nome) { string sql = "SELECT Id,Nome FROM Usuario WHERE Nome LIKE '" + nome + "%'" + " ORDER BY Nome"; try { return(AcessoDB.GetDataTable(sql)); } catch (Exception ex) { throw ex; } }
public DataTable ConsultarPorID(int id) { string sql = "SELECT Id,Nome,Email,Senha FROM Usuario WHERE Id = " + id; try { return(AcessoDB.GetDataTable(sql)); } catch (Exception ex) { throw ex; } }
public List <Usuario> Exibir() { try { string sql = "SELECT * FROM Usuarios"; DataTable tabela = new DataTable(); tabela = AcessoDB.GetDataTable(sql); return(GetListaUsuario(tabela)); } catch (Exception ex) { throw ex; } }
public Usuario GetUserId(int id) { try { string sql = "SELECT Id,Nome,Email,Senha FROM User WHERE Id = " + id; DataTable tabela = new DataTable(); tabela = AcessoDB.GetDataTable(sql); return(GetUsuario(tabela)); } catch (Exception ex) { throw ex; } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { try { int codJogo = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value); TB_Jogo jogo = AcessoDB.GetJogo(codJogo); preencheControles(jogo); jogo = null; } catch (Exception) { MessageBox.Show("Ocorreu um erro ao carregar este jogo"); } }
protected void EditarClicked(object sender, EventArgs e) { var cliente = new Cliente { Nome = this.NomeCliente.Text, Email = this.EmailCliente.Text, Usuario = this.UsuarioCliente.Text, Senha = this.SenhaCliente.Text }; using (var dados = new AcessoDB()) { dados.AtualizarCliente(cliente); } }
private void BtnAlterar_Click(object sender, EventArgs e) { TB_Jogo jogo = AcessoDB.GetJogo(Convert.ToInt32(txtId.Text)); jogo.ds_nome = txtNome.Text; jogo.ds_categoria = txtCategoria.Text; try { AcessoDB.InserirAlterarJogo(jogo); MessageBox.Show("Jogo alterado com sucesso"); CarregaDados(); } catch (Exception ex) { MessageBox.Show("Ocorreu um erro"); } }
private void BtnIncluir_Click(object sender, EventArgs e) { TB_Jogo jogo = new TB_Jogo(); jogo.ds_nome = txtNome.Text; jogo.ds_categoria = txtCategoria.Text; jogo.dt_dataCriacao = DateTime.Now; try { AcessoDB.InserirAlterarJogo(jogo); MessageBox.Show("Jogo inserido com sucesso"); CarregaDados(); } catch (Exception ex) { MessageBox.Show("Ocorreu um erro"); } }
public void Excluir(Usuario oCliente) { string sql = ""; try { string[] parametrosNomes = new string[1]; parametrosNomes[0] = "@Id"; string[] parametrosValores = new string[1]; parametrosValores[0] = oCliente.Id.ToString(); sql = "DELETE FROM Usuario Where Id=@Id"; AcessoDB.CRUD(sql, parametrosNomes, parametrosValores); } catch (Exception ex) { throw ex; } }
private void BtnSalvar_Clicked(object sender, EventArgs e) { using (var dados = new AcessoDB()) { var abastecimento = new Abastecimento { Id = dados.UltimoCodigo() + 1, Data = this.dtAbastecimento.Date.ToString("dd/MM/yyyy"), Preco = Convert.ToDouble(this.entryPreco.Text), Valor = Convert.ToDouble(this.entryValor.Text), Quilometragem = Convert.ToDouble(this.entryQuilometragem.Text), Litro = Convert.ToDouble(this.entryLitros.Text), Posto = this.entryPosto.Text, }; dados.InserirAbastecimento(abastecimento); Navigation.PushModalAsync(new NavigationPage(new Detalhes(dados.UltimoCodigo()))); } }
protected override void OnAppearing() { base.OnAppearing(); using (var dados = new AcessoDB()) { Abastecimento abastecimento = dados.GetAbastecimento(codAbastecimento); double kmL; lblData.Text = "Data do abastecimento: " + abastecimento.Data; lblLitro.Text = "Litros abastecidos: " + abastecimento.Litro.ToString(); lblPosto.Text = "Posto: " + abastecimento.Posto; lblPreco.Text = "Preço da gasolina no dia: " + abastecimento.Preco.ToString(); lblValor.Text = "Valor abastecido: " + abastecimento.Valor.ToString(); lblQuilometragem.Text = "Quilometragem desde o abastecimento anterior: " + abastecimento.Quilometragem.ToString(); kmL = abastecimento.Quilometragem / abastecimento.Litro; lblKmL.Text = "Você fez " + kmL.ToString() + "Km/l"; } }
public void Insert(NationalityDTO oNationality) { string sql = ""; try { string[] parameters = new string[0]; string[] parametersValues = new string[0]; parameters[0] = "@nationality"; parametersValues[0] = oNationality.nationality; //sql = "INSERT INTO Nationality (nationality) values (@nationality)"; sql = "spNationality_INS"; AcessoDB.CRUD(sql, parameters, parametersValues); } catch (Exception ex) { throw ex; } }
public void Update(NationalityDTO oNationality) { string sql = ""; try { string[] parameters = new string[2]; string[] parametersValues = new string[2]; parameters[0] = "@ID"; parameters[1] = "@nationality"; parametersValues[0] = oNationality.id.ToString(); parametersValues[1] = oNationality.nationality; sql = "UPDATE Nationality SET nationality = @nationality where ID = @ID "; //sql = "spNationality_INS"; AcessoDB.CRUD(sql, parameters, parametersValues, false); } catch (Exception ex) { throw ex; } }
public void Incluir(Usuario oCliente) { string sql = ""; try { string[] parametrosNomes = new string[3]; parametrosNomes[0] = "@Nome"; parametrosNomes[1] = "@Email"; parametrosNomes[2] = "@Senha"; string[] parametrosValores = new string[3]; parametrosValores[0] = oCliente.nome; parametrosValores[1] = oCliente.email; parametrosValores[2] = oCliente.senha; sql = "INSERT INTO Usuarios(Nome,Email,Senha) values (@Nome,@Email,@Senha)"; AcessoDB.CRUD(sql, parametrosNomes, parametrosValores); } catch (Exception ex) { throw ex; } }
public CompraService(AcessoDB _context) { this._context = _context; }