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);
     }
 }
Beispiel #2
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);
     }
 }