Example #1
0
 public void AtualizarRelatorio()
 {
     if (bsRelatorios.Count > 0)
     {
         Utils.ThreadEspera tEspera = new Utils.ThreadEspera("Inicio atualização relatorios.");
         try
         {
             (bsRelatorios.List as CamadaDados.Consulta.Cadastro.TList_Cad_Report).ForEach(p =>
             {
                 tEspera.Msg("Atualizando " + p.DS_Report.Trim() + "...");
                 try
                 {
                     FormRelPadrao.AtualizarRDC.VerificarVersaoRDC(p, true);
                 }
                 catch (Exception ex)
                 { tEspera.Msg(ex.Message.Trim()); }
             });
             System.Threading.Thread.Sleep(10000);
         }
         finally
         {
             tEspera.Fechar();
             tEspera = null;
             afterBusca();
         }
     }
     else
     {
         MessageBox.Show("Não existe relatorio para ser atualizado.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #2
0
        private void GerarArquivo()
        {
            //validar empresa
            if (CD_Empresa.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Obrigatório informar empresa.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                CD_Empresa.Focus();
                return;
            }
            //validar path
            if (path_arquivo.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Obrigatório informar path para salvar o arquivo.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                path_arquivo.Focus();
                return;
            }
            //Verificar se existe NFe sem enviar para receita no periodo
            if (new CamadaDados.Faturamento.NotaFiscal.TCD_LanFaturamento().BuscarEscalar(
                    new Utils.TpBusca[]
            {
                new Utils.TpBusca()
                {
                    vNM_Campo = "a.cd_empresa",
                    vOperador = "=",
                    vVL_Busca = "'" + CD_Empresa.Text.Trim() + "'"
                },
                new Utils.TpBusca()
                {
                    vNM_Campo = "case when a.tp_movimento = 'E' then convert(datetime, floor(convert(decimal(30,10), a.dt_saient))) else convert(datetime, floor(convert(decimal(30,10), a.dt_emissao))) end",
                    vOperador = "between",
                    vVL_Busca = "'" + new DateTime(int.Parse(cbAno.Text), int.Parse(cbMes.SelectedValue.ToString()), 1).ToString("yyyyMMdd") + "' and '" + new DateTime(int.Parse(cbAno.Text), int.Parse(cbMes.SelectedValue.ToString()), DateTime.DaysInMonth(int.Parse(cbAno.Text), int.Parse(cbMes.SelectedValue.ToString()))).ToString("yyyyMMdd") + "'"
                },
                new Utils.TpBusca()
                {
                    vNM_Campo = "a.tp_nota",
                    vOperador = "=",
                    vVL_Busca = "'P'"
                },
                new Utils.TpBusca()
                {
                    vNM_Campo = "isnull(a.st_transmitido_nfe, 'N')",
                    vOperador = "<>",
                    vVL_Busca = "'S'"
                },
                new Utils.TpBusca()
                {
                    vNM_Campo = "a.cd_modelo",
                    vOperador = "=",
                    vVL_Busca = "'55'"
                }
            }, "1") != null)
            {
                MessageBox.Show("Existe NFe não enviada para a receita no periodo.\r\n" +
                                "Obrigatorio excluir as mesmas e inutilizar os numeros para depois gerar o sintegra.",
                                "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (new CamadaDados.Faturamento.NotaFiscal.TCD_LanFaturamento().BuscarEscalar(
                    new Utils.TpBusca[]
            {
                new Utils.TpBusca()
                {
                    vNM_Campo = "a.cd_empresa",
                    vOperador = "=",
                    vVL_Busca = "'" + CD_Empresa.Text.Trim() + "'"
                },
                new Utils.TpBusca()
                {
                    vNM_Campo = "case when a.tp_movimento = 'E' then convert(datetime, floor(convert(decimal(30,10), a.dt_saient))) else convert(datetime, floor(convert(decimal(30,10), a.dt_emissao))) end",
                    vOperador = "between",
                    vVL_Busca = "'" + new DateTime(int.Parse(cbAno.Text), int.Parse(cbMes.SelectedValue.ToString()), 1).ToString("yyyyMMdd") + "' and '" + new DateTime(int.Parse(cbAno.Text), int.Parse(cbMes.SelectedValue.ToString()), DateTime.DaysInMonth(int.Parse(cbAno.Text), int.Parse(cbMes.SelectedValue.ToString()))).ToString("yyyyMMdd") + "'"
                },
                new Utils.TpBusca()
                {
                    vNM_Campo = "a.tp_nota",
                    vOperador = "=",
                    vVL_Busca = "'P'"
                },
                new Utils.TpBusca()
                {
                    vNM_Campo = "isnull(a.st_transmitido_nfe, 'N')",
                    vOperador = "=",
                    vVL_Busca = "'S'"
                },
                new Utils.TpBusca()
                {
                    vNM_Campo = "a.cd_modelo",
                    vOperador = "=",
                    vVL_Busca = "'55'"
                },
                new Utils.TpBusca()
                {
                    vNM_Campo = string.Empty,
                    vOperador = "exists",
                    vVL_Busca = "(select 1 from tb_fat_eventoNFe x " +
                                "inner join tb_fat_evento y " +
                                "on x.cd_evento = y.cd_evento " +
                                "where x.cd_empresa = a.cd_empresa " +
                                "and x.nr_lanctofiscal = a.nr_lanctofiscal " +
                                "and y.tp_evento = 'CA' " +
                                "and isnulL(x.st_registro, 'A') <> 'T')"
                }
            }, "1") != null)
            {
                MessageBox.Show("Existe NFe com evento de cancelamento não transmitido para a receita.\r\n" +
                                "Obrigatorio enviar o evento para a receita ou excluir o mesmo para depois gerar o sintegra.",
                                "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            try
            {
                Finalidades finalidade = Finalidades.NORMAL;
                if (cbFinalidade.Text.Trim().ToUpper().Equals("RETIFICAÇÃO TOTAL"))
                {
                    finalidade = Finalidades.RETIFICACAO_TOTAL;
                }
                else if (cbFinalidade.Text.Trim().ToUpper().Equals("RETIFICAÇÃO ADITIVA"))
                {
                    finalidade = Finalidades.RETIFICACAO_ADITIVA;
                }
                else if (cbFinalidade.Text.Trim().ToUpper().Equals("RETIFICAÇÃO CORRETIVA"))
                {
                    finalidade = Finalidades.RETIFICACAO_CORRETIVA;
                }
                else if (cbFinalidade.Text.Trim().ToUpper().Equals("DESFAZIMENTO"))
                {
                    finalidade = Finalidades.DESFAZIMENTO;
                }

                Utils.ThreadEspera tEspera = new Utils.ThreadEspera("Inicio processo gerar sintegra.");
                try
                {
                    CamadaNegocio.Fiscal.Sintegra.TCN_Sintegra.GerarArquivo(CD_Empresa.Text,
                                                                            new DateTime(int.Parse(cbAno.Text), int.Parse(cbMes.SelectedValue.ToString()), 1),
                                                                            new DateTime(int.Parse(cbAno.Text), int.Parse(cbMes.SelectedValue.ToString()), DateTime.DaysInMonth(int.Parse(cbAno.Text), int.Parse(cbMes.SelectedValue.ToString()))),
                                                                            finalidade,
                                                                            path_arquivo.Text,
                                                                            cbTipo10.Checked,
                                                                            cbTipo11.Checked,
                                                                            cbTipo50.Checked,
                                                                            cbTipo51.Checked,
                                                                            cbTipo53.Checked,
                                                                            cbTipo54.Checked,
                                                                            cbTipo60M.Checked,
                                                                            cbTipo60A.Checked,
                                                                            cbTipo60D.Checked,
                                                                            cbTipo60I.Checked,
                                                                            cbTipo60R.Checked,
                                                                            cbTipo70.Checked,
                                                                            cbTipo71.Checked,
                                                                            cbTipo74.Checked,
                                                                            cbTipo75.Checked,
                                                                            cbTipo90.Checked,
                                                                            tEspera);
                }
                finally
                {
                    tEspera.Fechar();
                    tEspera = null;
                }
                MessageBox.Show("Arquivo gerado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro gerar arquivo: " + ex.Message);
            }
        }
Example #3
0
 private void FaturarLote()
 {
     using (TFProcLoteContrato fProc = new TFProcLoteContrato())
     {
         if (fProc.ShowDialog() == DialogResult.OK)
         {
             if (fProc.lContratos != null)
             {
                 Utils.ThreadEspera tEspera = new Utils.ThreadEspera("Inicio processamento lote.");
                 string             ret     = string.Empty;
                 try
                 {
                     ret = CamadaNegocio.Servicos.TCN_Contrato.ProcessarLote(fProc.lContratos, fProc.Dt_referencia, tEspera, null);
                 }
                 finally
                 {
                     tEspera.Fechar();
                     tEspera = null;
                 }
                 MessageBox.Show("Lote processado com sucesso." + (string.IsNullOrEmpty(ret) ? string.Empty : "\r\nOs seguintes contratos não foram processados:\r\n" + ret.Trim()), "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 CamadaDados.Faturamento.NotaFiscal.TList_RegLanFaturamento lLote = new CamadaDados.Faturamento.NotaFiscal.TList_RegLanFaturamento();
                 //Buscar CfgNfe para a empresa
                 CamadaDados.Faturamento.Cadastros.TList_CfgNfe lCfgNfe =
                     CamadaNegocio.Faturamento.Cadastros.TCN_CfgNfe.Buscar(fProc.lContratos[0].Cd_empresa,
                                                                           string.Empty,
                                                                           string.Empty,
                                                                           null);
                 if (lCfgNfe.Count.Equals(0))
                 {
                     MessageBox.Show("Não existe configuração para envio de NFS-e para a empresa " + fProc.lContratos[0].Cd_empresa.Trim() + ".",
                                     "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     fProc.lContratos.ForEach(p =>
                     {
                         if (p.lNF.Count > 0)
                         {
                             if (p.lNF[0].Cd_modelo.Trim().Equals("55"))
                             {
                                 lLote.Add(CamadaNegocio.Faturamento.NotaFiscal.TCN_LanFaturamento.BuscarNF(p.lNF[0].Cd_empresa, p.lNF[0].Nr_lanctofiscalstr, null));
                             }
                         }
                         if (lLote.Count.Equals(50))
                         {
                             NFES.TGerarRPS.CriarArquivoRPS(lCfgNfe[0], lLote);
                             MessageBox.Show("Lote RPS enviado com sucesso. Aguarde alguns segundos e consulte o status do lote.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             lLote.Clear();
                         }
                     });
                     if (lLote.Count > 0)
                     {
                         NFES.TGerarRPS.CriarArquivoRPS(lCfgNfe[0], lLote);
                         MessageBox.Show("Lote RPS enviado com sucesso. Aguarde alguns segundos e consulte o status do lote.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                 }
                 //Imprimir boletos
                 CamadaDados.Financeiro.Bloqueto.blListaTitulo lBloq = new CamadaDados.Financeiro.Bloqueto.blListaTitulo();
                 fProc.lContratos.ForEach(p =>
                 {
                     if (p.lNF.Count > 0)
                     {
                         if (p.lNF[0].Duplicata.Count > 0)
                         {
                             CamadaNegocio.Financeiro.Bloqueto.TCN_Titulo.Buscar(p.lNF[0].Cd_empresa,
                                                                                 p.lNF[0].Duplicata[0].Nr_lancto,
                                                                                 decimal.Zero,
                                                                                 decimal.Zero,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 decimal.Zero,
                                                                                 decimal.Zero,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 false,
                                                                                 0,
                                                                                 null).ForEach(v => lBloq.Add(v));
                         }
                     }
                 });
                 if (lBloq.Count > 0)
                 {
                     FormRelPadrao.TCN_LayoutBloqueto.Imprime_Bloqueto(false,
                                                                       lBloq,
                                                                       false,
                                                                       true,
                                                                       false,
                                                                       false,
                                                                       string.Empty,
                                                                       null,
                                                                       "BLOQUETO(S) CONTRATO SERVIÇO",
                                                                       string.Empty,
                                                                       false);
                 }
             }
         }
     }
 }