private async void AtualizaDataSourceAsync() { using (var oDB = new CAgencia.CAgenciaClient()) { pesquisaAgenciaBindingSource.DataSource = await oDB.SelecionarTodosViewAsync(); } }
private bool ValidaCampos() { using (var oDB = new CAgencia.CAgenciaClient()) { if (oDB.AgenciaExiste(Convert.ToInt32(txtAgencia.Text)) == false) { MessageBox.Show("O Banco não existe", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return false; } } if (txtAgencia.Text == "") { MessageBox.Show("O campo Agência é de preenchimento obrigatório", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return false; } else if (txtConta.Text == "") { MessageBox.Show("O campo Conta é de preenchimento obrigatório", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return false; } if (txtLimite.Text == "") { MessageBox.Show("O campo Limite é de preenchimento obrigatório", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return false; } return true; }
private void AtualizaDataSource() { using (var oDB = new CAgencia.CAgenciaClient()) { agenciaBindingSource.DataSource = oDB.SelecionarTodosAsync().Result.ToList(); } }
private async void AtualizaDataSourcePesquisaAsync() { using (var oDB = new CAgencia.CAgenciaClient()) { if (toolStripComboBox1.SelectedItem != null && toolStripTextBox1.Text != "") { lancamentoBindingSource.DataSource = await oDB.SelecionarTodosViewCriterioAsync(toolStripTextBox1.Text, toolStripComboBox1.SelectedItem.ToString()); } if (toolStripTextBox1.Text == "") { AtualizaDataSourceAsync(); } } }
private void agenciaBindingNavigatorSaveItem_Click(object sender, EventArgs e) { if (ValidaCampos()) { using (var oDB = new CAgencia.CAgenciaClient()) { var oAgencia = new CAgencia.Agencia(); oAgencia.Banco = int.Parse(txtBanco.Text); oAgencia.Cidade = txtCidade.Text; oAgencia.Email = txtEmail.Text; oAgencia.Endereco = txtEndereco.Text; oAgencia.Gerente = txtGerente.Text; oAgencia.Telefone = txtTelefone.Text; if (Inserir) { var result = MensagemErro.Erro(oDB.InserirAsync(oAgencia).Result); if (result) MensagemAviso.MensagemUsuario(1, "Agência"); } else { oAgencia.ID = Convert.ToInt32(txtID.Text); var result = MensagemErro.Erro(oDB.AlterarAsync(oAgencia).Result); if (result) MensagemAviso.MensagemUsuario(2, "Agência"); } } AtualizaDataSource(); toolStripButton1.Enabled = true; bindingNavigatorAddNewItem.Enabled = true; bindingNavigatorDeleteItem.Enabled = true; Inserir = false; agenciaBindingNavigatorSaveItem.Enabled = false; SelecionaCampos(false); } }
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (MensagemAviso.MensagemUsuario(3, null)) { using (var oDB = new CAgencia.CAgenciaClient()) { var result = MensagemErro.Erro(oDB.ExcluirAsync(Convert.ToInt32(txtID.Text)).Result); if (result) MensagemAviso.MensagemUsuario(4, "Agência"); } AtualizaDataSource(); } }