Пример #1
0
        private void QueryDatabase()
        {
            var balance = new ObservableListSource <BalanceItem>(
                ContaAtual.BalanceFiltrado(
                    _dtpInicio.Value, _dtpTermino.Value,
                    (string)toolStripComboBoxGrupo.SelectedItem,
                    true, _sort));

            bsBalance.DataSource = balance.Any() ? balance.ToBindingList() : null;
            EnableSaveButtons();
        }
Пример #2
0
        private void CarregarDados(bool recarregarListaDeAtivos = false)
        {
            if (ContaAtual == null)
            {
                return;
            }

            if (recarregarListaDeAtivos)
            {
                _acoes.Remove(a => a.ContaId > 0);
                _acoes.AddRange(ContaAtual.AcoesNaoZerado);
                bsCotacoes.DataSource = _acoes;
            }
            else
            {
                bsCotacoes.Sort = "Codigo";
                dgvCotacoes.Refresh();
            }
            dgvTotal.Refresh();

            AtualizarGrafico();

            toolStripStatusLabelAtualizadoEm.Text = $@"Atualizado em: {DateTime.Now}";
            toolStripStatusLabelErros.Text        = $@"Erros: {Erros}";

            // Alerta de venda
            if (_acoes.Any(a => a.AlertaVenda >= 1.00m && a.AlertaVenda < 1.004m))
            {
                var x = _acoes.Where(a => a.AlertaVenda > 1.00m && a.AlertaVenda < 1.004m)
                        .Select(a => $"{a.Codigo} - Compra: {a.ValorMedioCompra:c2} - Atual: {a.LastTrade:c2}");
                var popup = new PopupNotifier
                {
                    Size           = new Size(450, 75 * x.Count()),
                    Delay          = 10000,
                    Image          = Resources.alert_icon,
                    HeaderColor    = Color.Red,
                    TitleColor     = Color.Red,
                    TitleFont      = new Font("Segoe UI Semibold", 18),
                    TitlePadding   = new Padding(10),
                    TitleText      = "Alerta de Venda de Ações",
                    ContentFont    = new Font("Segoe UI", 14),
                    ContentText    = x.Aggregate((current, next) => current + "\n" + next),
                    ContentPadding = new Padding(10)
                };
                popup.Popup();
            }

            // Resize if number of Ativos changes
            var oldHeight = (int)tableLayoutPanel1.RowStyles[0].Height;
            var newHeight = dgvCotacoes.ColumnHeadersHeight +
                            (dgvCotacoes.RowTemplate.Height + 2) *
                            Math.Min(10, bsCotacoes.Count);

            if (oldHeight == newHeight)
            {
                return;
            }

            tableLayoutPanel1.RowStyles[0].Height = newHeight;
            Height = Height - oldHeight + newHeight;
        }