Beispiel #1
0
 private void ProcurarAgendamentos()
 {
     SuperMsgBox.ColorButtons();
     foreach (var item in
              dgvCalendario.Rows.OfType <DataGridViewRow>()
              .Select(r => (CalendarioItem)r.DataBoundItem)
              .Where(r => !r.Agendado)
              .OrderBy(r => r.Data))
     {
         if (!ProcurarAgendamento(item))
         {
             break;
         }
     }
     SuperMsgBox.Reset();
 }
Beispiel #2
0
        private bool ProcurarAgendamento(CalendarioItem item)
        {
            const string header     = "Procurar Agendamento";
            var          mes        = (CalendarioMes)toolStripComboBoxMes.SelectedItem;
            var          itemFolder = Path.Combine(_folder, item.Pagamento.ToString());

            if (Directory.Exists(itemFolder))
            {
                var files = GetComprovanteFiles(itemFolder, mes);
                if (files.Any())
                {
                    var frm  = new frmComprovantePDF(item.Descricao, _folder, files);
                    var resp = frm.ShowDialog();
                    if (resp != DialogResult.Yes)
                    {
                        return(resp != DialogResult.Cancel);
                    }

                    item.Agendado      = true;
                    item.AgendadoData  = frm.Comprovante.Agendamento;
                    item.PagamentoData = frm.Comprovante.Pagamento;
                    item.Valor         = frm.Comprovante.Valor;
                    return(resp != DialogResult.Cancel);
                }
                else
                {
                    var resp = SuperMsgBox.Show($"{item.Descricao}:\n\n\tComprovante de agendamento não encontrado.\n\nMarcar como agendado?",
                                                header, SuperMsgBox.Buttons.YesNoCancel, SuperMsgBox.Icon.Question);

                    item.Agendado = resp == DialogResult.Yes;
                    return(resp != DialogResult.Cancel);
                }
            }
            if (SuperMsgBox.Show($"Folder para '{item.Pagamento}' não existe.\n\n{itemFolder}\n\nCria?",
                                 header, SuperMsgBox.Buttons.YesNo,
                                 SuperMsgBox.Icon.Question) == DialogResult.Yes)
            {
                Directory.CreateDirectory(itemFolder);
            }
            return(true);
        }
Beispiel #3
0
        private void ProcurarPagamentos()
        {
            const string header     = "Procurar Pagamento";
            var          mes        = (CalendarioMes)toolStripComboBoxMes.SelectedItem;
            var          pagamentos = _ctx.Balance.Where(b => b.Valor < 0 &&
                                                         b.Data.Year == mes.Ano &&
                                                         b.Data.Month == mes.Mes12).ToList();
            var naoPagos = dgvCalendario.Rows.OfType <DataGridViewRow>()
                           .Select(r => (CalendarioItem)r.DataBoundItem)
                           .Where(r => r.Agendado && !r.Pago && r.PagamentoData <= DateTime.Today &&
                                  (r.Pagamento.Descricao != null || r.Pagamento.Valor != null || r.Valor != null))
                           .OrderBy(r => r.Data);

            SuperMsgBox.ColorButtons();

            foreach (var item in naoPagos)
            {
                var ip    = item.Pagamento;
                var valor = -1 * (item.Valor == null || item.Valor == 1 ? ip.Valor : item.Valor);
                IEnumerable <BalanceItem> found;
                if (item.Descricao != null && valor != null)
                {
                    found = pagamentos.Where(p => p.Grupo == ip.Grupo &&
                                             p.Categoria == ip.Categoria &&
                                             p.SubCategoria == ip.SubCategoria &&
                                             p.Valor == valor);
                }
                else if (item.Descricao != null)
                {
                    found = pagamentos.Where(p => p.Grupo == ip.Grupo &&
                                             p.Categoria == ip.Categoria &&
                                             p.SubCategoria == ip.SubCategoria);
                }
                else
                {
                    found = pagamentos.Where(p => p.Valor == valor);
                }
                if (!found.Any())
                {
                    SuperMsgBox.SetColors(Color.White, Color.FromArgb(255, 48, 0, 0), Color.FromArgb(255, 32, 0, 0));
                    SuperMsgBox.SetButtonText("OK", "Continue");
                    if (SuperMsgBox.Show($"{item.Descricao}:\n\n\tPagamento não encontrado.",
                                         header,
                                         SuperMsgBox.Buttons.OKCancel,
                                         SuperMsgBox.Icon.Question) == DialogResult.Cancel)
                    {
                        break;
                    }

                    continue;
                }

                var text = found.Select(f => f.ToString())
                           .Aggregate((i, j) => "\t" + i.ToString() + "\n" + j.ToString());
                SuperMsgBox.ResetColors();
                if (SuperMsgBox.Show($"{item.Descricao}:\n\n{text}\n\nConfirma?",
                                     header, SuperMsgBox.Buttons.YesNo, SuperMsgBox.Icon.Question) ==
                    DialogResult.No)
                {
                    continue;
                }

                item.Pago  = true;
                item.Valor = valor ?? 1;
            }
            SuperMsgBox.Reset();
        }