Exemplo n.º 1
0
        private void frmClassificacao_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!_ctx.ModifiedAny)
            {
                return;
            }

            var alteracao = _ctx.ModifiedCount == 1 ?
                            "Existe 1 alteração pendente" :
                            $"Existem {_ctx.ModifiedCount} alterações pendentes";

            switch (MessageBox.Show($"{alteracao}. Salvar?",
                                    this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
            {
            case DialogResult.Yes:
                _ctx.SaveChanges();
                break;

            case DialogResult.No:
                break;

            case DialogResult.Cancel:
                e.Cancel = true;
                break;
            }
        }
Exemplo n.º 2
0
        private void frmInvestimentos_FormClosing(object sender, FormClosingEventArgs e)
        {
            Settings.Default.InvestimentosUltimaConta = (int)toolStripComboBoxConta.ComboBox.SelectedValue;
            Settings.Default.Save();

            if (!_ctx.ChangeTracker.HasChanges())
            {
                return;
            }

            switch (MessageBox.Show($"{_ctx.TextoSalvar()}?", @"Investimentos",
                                    MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
            {
            case DialogResult.Yes:
                _ctx.SaveChanges();
                break;

            case DialogResult.Cancel:
                e.Cancel = true;
                break;

            default:
                break;     // do nothing
            }
        }
Exemplo n.º 3
0
        private void LerLinhasParaDatabase(IEnumerable <string> linhas)
        {
            var ativos = _ctx.Ativos;
            var serie  = from linha in linhas.Where(l => l.StartsWith("01") && l.Substring(24, 3) == "010")
                         join ativo in ativos
                         on linha.Substring(12, 12).Trim() equals ativo.Codigo
                         select new SerieHistorica(linha);

            _ctx.SeriesHistoricas.AddRange(serie.Except(_ctx.SeriesHistoricas));
            if (_ctx.AddedAny)
            {
                _ctx.SaveChanges();
            }
        }
Exemplo n.º 4
0
        private bool SalvarExtratoLido()
        {
            if (!_conta.ExtratoHasAddToDB)
            {
                return(true);
            }
            var retorno = true;

            switch (MessageBox.Show($"Salvar {_conta.ExtratoAddToDBCount} itens?",
                                    "Leitor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
            {
            case DialogResult.Yes:
                try {
                    _conta.ExtratoParaBalance();
                    _ctx.SaveChanges();
                }
                catch {
                    // Ignore exception
                }
                bsExtrato.ResetBindings(false);
                toolStripButtonSalvar.Enabled = false;

                break;

            case DialogResult.No:
                break;

            case DialogResult.Cancel:
                retorno = false;
                break;
            }
            if (retorno)
            {
                _conta.Extrato.Clear();
            }

            return(retorno);
        }