private void AtualizaDataSource()
 {
     using (var oDB = new CLancamento.CLancamentoClient())
     {
         lancamentoBindingSource.DataSource = oDB.SelecionarTodosAsync().Result.ToList();
     }
 }
 private async void AtualizaDataSourceAsync()
 {
     using (var oDB = new CLancamento.CLancamentoClient())
     {
         lancamentoBindingSource.DataSource = await oDB.SelecionarTodosAsync();
     }
 }
 private void lancamentoBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 {
     if (ValidaCampos())
     {
         using (var oDB = new CLancamento.CLancamentoClient())
         {
             var oLancamento = new CLancamento.Lancamento();
             oLancamento.ContaCredito = txtContaCredito.Text;
             oLancamento.DataLancamento = dtpLancamento.Value;
             oLancamento.Descricao = txtDescricao.Text;
             oLancamento.Valor = decimal.Parse(txtValor.Text);
             if (Inserir)
             {
                 var result = MensagemErro.Erro(oDB.InserirAsync(oLancamento).Result);
                 if (result)
                     MensagemAviso.MensagemUsuario(1, "Lançamento no Plano de Contas");
             }
             else
             {
                 oLancamento.Numero = int.Parse(txtNumero.Text);
                 var result = MensagemErro.Erro(oDB.AlterarAsync(oLancamento).Result);
                 if (result)
                     MensagemAviso.MensagemUsuario(2, "Lançamento no Plano de Contas");
             }
         }
         AtualizaDataSource();
         Inserir = false;
         toolStripButton1.Enabled = true;
         bindingNavigatorAddNewItem.Enabled = true;
         bindingNavigatorDeleteItem.Enabled = true;
         lancamentoBindingNavigatorSaveItem.Enabled = false;
         SelecionaCampos(false);
     }
 }
Пример #4
0
 private void AtualizaDataSource()
 {
     using (var oDB = new CLancamento.CLancamentoClient())
     {
         lancamentoBindingSource.DataSource = oDB.SelecionarTodosAsync().Result.ToList();
     }
 }
Пример #5
0
 private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
 {
     if (MensagemAviso.MensagemUsuario(3, null))
     {
         using (var oDB = new CLancamento.CLancamentoClient())
         {
             var result = MensagemErro.Erro(oDB.ExcluirAsync(Convert.ToInt32(txtNumero.Text)).Result);
             if (result)
             {
                 MensagemAviso.MensagemUsuario(4, "Lançamento no Plano de Contas");
             }
         }
     }
 }
Пример #6
0
 private bool ValidaCampos()
 {
     using (var oDB = new CPagamento.CPagamentoClient())
     {
         if (oDB.PagamentoExiste(Convert.ToInt32(txtPagamento.Text)) == false)
         {
             MessageBox.Show("O Pagamento não existe", "Aviso",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                             MessageBoxDefaultButton.Button1);
             return(false);
         }
     }
     using (var oDB = new CLancamento.CLancamentoClient())
     {
         if (oDB.LancamentoExiste(Convert.ToInt32(txtLancamento.Text)) == false)
         {
             MessageBox.Show("O Lançamento não existe", "Aviso",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                             MessageBoxDefaultButton.Button1);
             return(false);
         }
     }
     if (txtDescricao.Text == "")
     {
         MessageBox.Show("O campo Descrição é de preenchimento obrigatório", "Aviso",
                         MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                         MessageBoxDefaultButton.Button1);
         return(false);
     }
     else if (txtValor.Text == "")
     {
         MessageBox.Show("O campo Valor Previsto é de preenchimento obrigatório", "Aviso",
                         MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                         MessageBoxDefaultButton.Button1);
         return(false);
     }
     else if (txtPagamento.Text == "")
     {
         MessageBox.Show("O campo Pagamento é de preenchimento obrigatório", "Aviso",
                         MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                         MessageBoxDefaultButton.Button1);
         return(false);
     }
     return(true);
 }
Пример #7
0
 private void lancamentoBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 {
     if (ValidaCampos())
     {
         using (var oDB = new CLancamento.CLancamentoClient())
         {
             var oLancamento = new CLancamento.Lancamento();
             oLancamento.ContaCredito   = txtContaCredito.Text;
             oLancamento.DataLancamento = dtpLancamento.Value;
             oLancamento.Descricao      = txtDescricao.Text;
             oLancamento.Valor          = decimal.Parse(txtValor.Text);
             if (Inserir)
             {
                 var result = MensagemErro.Erro(oDB.InserirAsync(oLancamento).Result);
                 if (result)
                 {
                     MensagemAviso.MensagemUsuario(1, "Lançamento no Plano de Contas");
                 }
             }
             else
             {
                 oLancamento.Numero = int.Parse(txtNumero.Text);
                 var result = MensagemErro.Erro(oDB.AlterarAsync(oLancamento).Result);
                 if (result)
                 {
                     MensagemAviso.MensagemUsuario(2, "Lançamento no Plano de Contas");
                 }
             }
         }
         AtualizaDataSource();
         Inserir = false;
         toolStripButton1.Enabled                   = true;
         bindingNavigatorAddNewItem.Enabled         = true;
         bindingNavigatorDeleteItem.Enabled         = true;
         lancamentoBindingNavigatorSaveItem.Enabled = false;
         SelecionaCampos(false);
     }
 }
 private bool ValidaCampos()
 {
     using (var oDB = new CPagamento.CPagamentoClient())
     {
         if (oDB.PagamentoExiste(Convert.ToInt32(txtPagamento.Text)) == false)
         {
             MessageBox.Show("O Pagamento não existe", "Aviso",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                             MessageBoxDefaultButton.Button1);
             return false;
         }
     }
     using (var oDB = new CLancamento.CLancamentoClient())
     {
         if (oDB.LancamentoExiste(Convert.ToInt32(txtLancamento.Text)) == false)
         {
             MessageBox.Show("O Lançamento não existe", "Aviso",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                             MessageBoxDefaultButton.Button1);
             return false;
         }
     }
     if (txtDescricao.Text == "")
     {
         MessageBox.Show("O campo Descrição é de preenchimento obrigatório", "Aviso",
                         MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                         MessageBoxDefaultButton.Button1);
         return false;
     }
     else if (txtValor.Text == "")
     {
         MessageBox.Show("O campo Valor Previsto é de preenchimento obrigatório", "Aviso",
                         MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                         MessageBoxDefaultButton.Button1);
         return false;
     }
     else if (txtPagamento.Text == "")
     {
         MessageBox.Show("O campo Pagamento é de preenchimento obrigatório", "Aviso",
                         MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                         MessageBoxDefaultButton.Button1);
         return false;
     }
     return true;
 }
 private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
 {
     if (MensagemAviso.MensagemUsuario(3, null))
     {
         using (var oDB = new CLancamento.CLancamentoClient())
         {
             var result = MensagemErro.Erro(oDB.ExcluirAsync(Convert.ToInt32(txtNumero.Text)).Result);
             if (result)
                 MensagemAviso.MensagemUsuario(4, "Lançamento no Plano de Contas");
         }
     }
 }