예제 #1
0
        private void BtnImpRecibo_Click(object sender, EventArgs e)
        {
            string sSQL = "SELECT TOP 1 T1.ID_PESSOA,T7.Vencimento, T1.NumDocumento+' NFe: '+rtrim(T9.FormNF) as NumDocumento, T1.VlrTotal as VlrOriginal, T1.PESSOA AS RazaoSocial, RTRIM(T1.Endereco) + ',' + RTRIM(T1.Numero) " +
                          " + ' ' + RTRIM(T1.Complemento) AS ENDERECO, T1.Cep, T1.Bairro, T1.Cidade, T3.Sigla, T1.CNPJCPF as Cnpj," +
                          " T4.FormaPgto,T1.Fone,T8.Vendedor,' ' as Documento,T0.IMAGEM AS LOGO," +
                          " T6.Filial as NomeFilial, RTRIM(T6.Endereco) + ',' + RTRIM(T6.Numero) + ' ' + RTRIM(T6.Complemento) AS ENDFILIAL, T6.Cep AS CepFilial, T6.Bairro as BairroFilial,T6.Cidade as CidFilial,T6.Fone1 AS FoneFilial,T6.Cnpj as CnpjFilial,T6.Insc_UF as InscFilial" +
                          " FROM  MvVenda AS T1 " +
                          " LEFT OUTER JOIN Pessoas AS T2 ON T2.Id_Pessoa = T1.Id_Pessoa " +
                          " LEFT OUTER JOIN Estados AS T3 ON T3.Id_Uf = T2.Id_Uf" +
                          " LEFT OUTER JOIN FormaPagamento AS T4 ON T4.Id_FormaPgto = T1.Id_FormaPgto" +
                          " LEFT OUTER JOIN Empresa_Filial as T6 on T6.Id_Filial=t1.Id_Filial" +
                          " LEFT OUTER JOIN LancFinanceiro as T7 on T7.Id_Venda=T1.Id_Venda" +
                          " LEFT OUTER JOIN Vendedores as T8 on T8.Id_Vendedor=T1.Id_Vendedor" +
                          " LEFT OUTER JOIN MVVENDA AS T9 ON (T9.ID_VENDA=T1.ID_VENDA)" +
                          " LEFT OUTER JOIN TABIMAGENS AS T0 ON (T0.ID_CHAVE=T6.ID_FILIAL AND T0.TABELA='FILIAL')" +
                          "  WHERE T1.ID_VENDA=" + NumPedido.Value.ToString();

            FrmRelatorios FrmRel = new FrmRelatorios();

            Relatorios.RelRecibo RelRec = new Relatorios.RelRecibo();
            DataSet TabRel = new DataSet();

            TabRel = Controle.ConsultaTabela(sSQL);
            RelRec.SetDataSource(TabRel.Tables[0]);
            FrmRel.cryRepRelatorio.ReportSource = RelRec;
            FrmRel.ShowDialog();
        }
예제 #2
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            CadVeic.LerDados(Mapa.IdVeiculo);

            string sSql = "SELECT T1.ID_VENDA,T1.NUMDOCUMENTO,T1.FORMNF,T2.RAZAOSOCIAL,RTRIM(T1.ENDERECO)+','+RTRIM(T1.NUMERO)+' '+RTRIM(T1.COMPLEMENTO) AS ENDERECO," +
                          " T1.FONE,T1.CEP,T1.BAIRRO,T1.CIDADE,T3.ENTREGADOR,T4.VENDEDOR,T5.FORMAPGTO,T1.ID_VDMASTER,T1.VLRTOTAL,T7.VENCIMENTO,T7.VLRORIGINAL,T1.PREVENTREGA,T8.DOCUMENTO FROM MAPAENTREGAITENS MP" +
                          " LEFT JOIN MVVENDA  T1 ON (T1.ID_VENDA=MP.ID_VENDA)" +
                          " LEFT JOIN PESSOAS T2 ON (T2.ID_PESSOA=T1.ID_PESSOA)" +
                          " LEFT JOIN ENTREGADORES T3 ON (T3.ID_ENTREGADOR=T1.ID_ENTREGADOR)" +
                          " LEFT JOIN VENDEDORES T4 ON (T4.ID_VENDEDOR=T1.ID_VENDEDOR)" +
                          " LEFT JOIN FORMAPAGAMENTO T5 ON (T5.ID_FORMAPGTO=T1.ID_FORMAPGTO)" +
                          " LEFT JOIN LANCFINANCEIRO T7 ON (T7.ID_VENDA=T1.ID_VENDA)" +
                          " LEFT JOIN TIPODOCUMENTO T8 ON (T8.ID_DOCUMENTO=T7.ID_TIPODOCUMENTO)" +
                          " WHERE MP.STATUS=0 AND MP.ID_MAPA=" + Mapa.IdMapa.ToString();

            sSql = sSql + " ORDER BY T2.RAZAOSOCIAL,T1.ID_VENDA";

            BtnImprimir.Enabled = false;
            FrmRelatorios FrmRel = new FrmRelatorios();

            Relatorios.RelMapEntrega RelMapa = new Relatorios.RelMapEntrega();
            DataSet TabRel = new DataSet();

            TabRel = Controle.ConsultaTabela(sSql);
            RelMapa.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
            FrmRel.cryRepRelatorio.ReportSource = RelMapa;
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelMapa.Section2.ReportObjects["LblFilial"])).Text     = FrmPrincipal.LstFilial.Text.Trim();
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelMapa.Section5.ReportObjects["LblRodaPe"])).Text     = FrmPrincipal.Rel_RodaPe;
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelMapa.Section2.ReportObjects["LblPeriodo"])).Text    = "Mapa: " + string.Format("{0:D5}", Mapa.IdMapa) + "   Veiculo: " + CadVeic.Veiculo.ToString().Trim() + "  Placa: " + CadVeic.Placa.ToString().Trim();
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelMapa.Section2.ReportObjects["LblConferente"])).Text = "Conferente: " + Mapa.Conferente.Trim();

            FrmRel.ShowDialog();
            BtnImprimir.Enabled = true;
        }
예제 #3
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            FrmRelatorios FrmRel = new FrmRelatorios();

            Relatorios.RelCotacao RelCotacao = new Relatorios.RelCotacao();
            DataSet TabRel = new DataSet();

            TabRel = Controle.ConsultaTabela(MvCotacao.SqlRelatorio(MvCotacao.IdCotacao));
            //RelCotacao.SetDataSource(TabRel);
            RelCotacao.SetDataSource(TabRel.Tables[0]);
            FrmRel.cryRepRelatorio.ReportSource = RelCotacao;
            FrmRel.ShowDialog();
        }
예제 #4
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            BtnImprimir.Enabled = false;
            FrmRelatorios FrmRel = new FrmRelatorios();

            Relatorios.RelPedCompra RelPedCompra = new Relatorios.RelPedCompra();
            DataSet TabRel = new DataSet();

            TabRel = Controle.ConsultaTabela(MvPedCompra.SqlRelatorio(MvPedCompra.IdDocumento));
            RelPedCompra.SetDataSource(TabRel.Tables[0]);
            FrmRel.cryRepRelatorio.ReportSource = RelPedCompra;
            //((CrystalDecisions.CrystalReports.Engine.TextObject)(RelPedCompra.Section2.ReportObjects["LblFilial"])).Text = FrmPrincipal.LstFilial.Text.Trim();
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelPedCompra.Section5.ReportObjects["LblRodaPe"])).Text = FrmPrincipal.Rel_RodaPe;
            FrmRel.ShowDialog();
            BtnImprimir.Enabled = true;
        }
예제 #5
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            BtnImprimir.Enabled = false;
            FrmRelatorios FrmRel = new FrmRelatorios();

            Relatorios.RelMovChequePre RelCheque = new Relatorios.RelMovChequePre();
            DataSet TabRel = new DataSet();

            TabRel = Controle.ConsultaTabela(sSQLFiltro + " ORDER BY T1.DTVENCIMENTO");
            RelCheque.SetDataSource(TabRel.Tables[0]);
            FrmRel.cryRepRelatorio.ReportSource = RelCheque;
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelCheque.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelCheque.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
            FrmRel.ShowDialog();
            BtnImprimir.Enabled = true;
        }
예제 #6
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            if (StaFormEdicao)
            {
                MessageBox.Show("Cadastro do Mapa de Produção em edição", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (Mapa.IdMapa > 0)
                {
                    if (Mapa.Status == 0)
                    {
                        MessageBox.Show("Mapa em Aberto", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    string sSql = "SELECT T1.Id_Mapa,T1.Data,T1.Observacao,T1.Qtde,T1.Status,T2.Produto,T2.QtdeFabrica,T2.Observacao AS ObsProduto,T1.LOTE FROM MapaProducao T1" +
                                  " LEFT JOIN Producao T2 ON (T2.Id_Producao=T1.Id_ProdProducao) Where T1.Id_Mapa=" + Mapa.IdMapa.ToString();

                    string sSql2 = "SELECT T1.Id_Produto,t2.Referencia,t2.Descricao,T1.QTDE FROM MapaProducaoItens T1" +
                                   " LEFT JOIN Produtos t2 on (t2.Id_Produto=T1.Id_Produto) Where T1.Id_Mapa=" + Mapa.IdMapa.ToString();

                    string sSql3 = "SELECT T1.Id_Produto,t2.Referencia,t2.Descricao,T1.QTDE,T1.QtdeExtra FROM MapaProducaoProdutos T1" +
                                   " LEFT JOIN Produtos t2 on (t2.Id_Produto=T1.Id_Produto) Where T1.Id_Mapa=" + Mapa.IdMapa.ToString();

                    FrmRelatorios FrmRel = new FrmRelatorios();
                    Relatorios.RelMapaProducao Rel001 = new Relatorios.RelMapaProducao();
                    DataSet TabRel  = new DataSet();
                    DataSet TabRel1 = new DataSet();
                    DataSet TabRel2 = new DataSet();
                    TabRel  = Controle.ConsultaTabela(sSql);
                    TabRel1 = Controle.ConsultaTabela(sSql2);
                    TabRel2 = Controle.ConsultaTabela(sSql3);
                    Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                    Rel001.Database.Tables[1].SetDataSource(TabRel1.Tables[0]);
                    Rel001.Database.Tables[2].SetDataSource(TabRel2.Tables[0]);
                    FrmRel.cryRepRelatorio.ReportSource = Rel001;
                    ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text = FrmPrincipal.Rel_RodaPe;
                    FrmRel.ShowDialog();
                    Rel001.Dispose();
                }
            }
        }
예제 #7
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            if (int.Parse(LstFilial.SelectedValue.ToString()) == 0)
            {
                MessageBox.Show("Favor Informar a Filial", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string sSQL = "SELECT T5.Fantasia AS Filial,T4.Departamento,T4.Responsavel,T3.Grupo,T2.Custo,T1.* FROM PREVCUSTOS T1 " +
                          " LEFT JOIN CentroCusto T2 ON (T1.ID_CUSTO=T2.Id_Custo)" +
                          " LEFT JOIN GrupoCCusto T3 ON (T3.Id_GrpCusto=T2.Id_GrpCusto)" +
                          " LEFT JOIN Departamentos T4 ON (T4.Id_Departamento=T1.Id_Departamento)" +
                          " LEFT JOIN Empresa_Filial T5 ON (T5.Id_Filial=T1.ID_FILIAL)" +
                          " WHERE T1.ANO=" + TxtAno.Value.ToString();

            if (int.Parse(LstDepart.SelectedValue.ToString()) > 0)
            {
                sSQL = sSQL + " AND T1.ID_Departamento=" + LstDepart.SelectedValue.ToString();
            }

            if (int.Parse(LstCusto.SelectedValue.ToString()) > 0)
            {
                sSQL = sSQL + " AND T1.ID_Custo=" + LstCusto.SelectedValue.ToString();
            }

            sSQL = sSQL + " ORDER BY T4.Departamento,T3.Grupo,T2.Custo";

            BtnImprimir.Enabled = false;
            FrmRelatorios FrmRel = new FrmRelatorios();

            Relatorios.RelPrevCustos Rel001 = new Relatorios.RelPrevCustos();
            DataSet TabRel = new DataSet();

            TabRel = Controle.ConsultaTabela(sSQL);
            Rel001.SetDataSource(TabRel.Tables[0]);
            FrmRel.cryRepRelatorio.ReportSource = Rel001;
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblFilial"])).Text  = LstFilial.Text.Trim();
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Ano:" + TxtAno.Value.ToString();
            FrmRel.ShowDialog();
            BtnImprimir.Enabled = true;
        }
예제 #8
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            if (GridDados.CurrentRow == null)
            {
                MessageBox.Show("Não existe Registro para Imprimir", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            string NumVendas = "";
            string NumImp    = "";

            for (int I = 0; I <= GridDados.RowCount - 1; I++)
            {
                if (NumVendas == "")
                {
                    NumVendas = GridDados.Rows[I].Cells[0].Value.ToString();
                    NumImp    = GridDados.Rows[I].Cells[0].Value.ToString();
                }
                else
                {
                    NumVendas = NumVendas + "," + GridDados.Rows[I].Cells[0].Value.ToString();
                    NumImp    = NumImp + " / " + GridDados.Rows[I].Cells[0].Value.ToString();
                }
            }
            string sSQL = "SELECT T2.ID_PRODUTO,T2.REFERENCIA,T2.DESCRICAO,T2.LOCESTRUA,T2.PALETE, SUM(T1.QTDE) AS QTDE FROM MVVENDAITENS T1 " +
                          " LEFT JOIN PRODUTOS T2 ON (T2.ID_PRODUTO=T1.ID_PRODUTO)" +
                          "  WHERE T1.TIPOITEM='S' AND T1.ID_VENDA IN (" + NumVendas + ")" +
                          " GROUP BY T2.ID_PRODUTO,T2.REFERENCIA,T2.DESCRICAO,T2.LOCESTRUA,T2.PALETE" +
                          " ORDER BY T2.DESCRICAO";
            FrmRelatorios FrmRel = new FrmRelatorios();

            Relatorios.RelSeparacaoPrd Rel001 = new Relatorios.RelSeparacaoPrd();
            DataSet TabRel = new DataSet();

            TabRel = Controle.ConsultaTabela(sSQL);
            Rel001.SetDataSource(TabRel.Tables[0]);
            FrmRel.cryRepRelatorio.ReportSource = Rel001;
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblRodaPe"])).Text = FrmPrincipal.Rel_RodaPe;
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblVendas"])).Text = "Vendas: " + NumImp;
            FrmRel.ShowDialog();
        }
예제 #9
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            string sSql = "SELECT T4.Grupo,T3.Referencia,T3.Descricao,T1.Qtde,T1.SALDOESTOQUE,T2.* FROM BalancoItens T1" +
                          " LEFT JOIN Balanco T2 ON (T2.Id_Balanco=T1.Id_Balanco)" +
                          " LEFT JOIN Produtos T3 ON (T3.Id_Produto=T1.Id_Produto)" +
                          " LEFT JOIN GRUPOProduto T4 ON (T4.ID_GRUPO=T3.Id_Grupo)" +
                          " WHERE T1.ID_BALANCO=" + MvBalanco.IdBalanco.ToString();

            sSql = sSql + " ORDER BY T4.GRUPO,T3.DESCRICAO";

            BtnImprimir.Enabled = false;
            FrmRelatorios FrmRel = new FrmRelatorios();

            Relatorios.RelBalanco RelMapa = new Relatorios.RelBalanco();
            DataSet TabRel = new DataSet();

            TabRel = Controle.ConsultaTabela(sSql);
            RelMapa.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
            FrmRel.cryRepRelatorio.ReportSource = RelMapa;
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelMapa.Section2.ReportObjects["LblFilial"])).Text = FrmPrincipal.LstFilial.Text.Trim();
            ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelMapa.Section5.ReportObjects["LblRodaPe"])).Text = FrmPrincipal.Rel_RodaPe;
            FrmRel.ShowDialog();
            BtnImprimir.Enabled = true;
        }
예제 #10
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            if (LstPesqEntregador.SelectedValue.ToString() == "0")
            {
                MessageBox.Show("Selecione um Entregador", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string sSql = "SELECT T1.ID_VENDA,T1.NUMDOCUMENTO,T1.FORMNF,T2.RAZAOSOCIAL,RTRIM(T1.ENDERECO)+','+RTRIM(T1.NUMERO)+' '+RTRIM(T1.COMPLEMENTO) AS ENDERECO," +
                              " T1.FONE,T1.CEP,T1.BAIRRO,T1.CIDADE,T3.ENTREGADOR,T4.VENDEDOR,T5.FORMAPGTO,T1.ID_VDMASTER,T1.VLRTOTAL,T7.VENCIMENTO,T7.VLRORIGINAL,T1.PREVENTREGA,T8.DOCUMENTO FROM MVVENDA T1" +
                              " LEFT JOIN PESSOAS T2 ON (T2.ID_PESSOA=T1.ID_PESSOA)" +
                              " LEFT JOIN ENTREGADORES T3 ON (T3.ID_ENTREGADOR=T1.ID_ENTREGADOR)" +
                              " LEFT JOIN VENDEDORES T4 ON (T4.ID_VENDEDOR=T1.ID_VENDEDOR)" +
                              " LEFT JOIN FORMAPAGAMENTO T5 ON (T5.ID_FORMAPGTO=T1.ID_FORMAPGTO)" +
                              " LEFT JOIN LANCFINANCEIRO T7 ON (T7.ID_VENDA=T1.ID_VENDA)" +
                              " LEFT JOIN TIPODOCUMENTO T8 ON (T8.ID_DOCUMENTO=T7.ID_TIPODOCUMENTO)" +
                              " WHERE ((T1.STATUS = 2) OR (T1.STATUS = 1 AND T1.TPVENDA IN ('BONIF','EMVF','CO','PR','AM','TROCA'))) AND T1.ID_ENTREGADOR=" + LstPesqEntregador.SelectedValue.ToString();
                if (Chk_Periodo.Checked)
                {
                    sSql = sSql + " AND T1.PREVENTREGA >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.PREVENTREGA <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103)";
                }
                sSql = sSql + " ORDER BY T2.RAZAOSOCIAL,T1.ID_VENDA";

                BtnImprimir.Enabled = false;
                FrmRelatorios            FrmRel  = new FrmRelatorios();
                Relatorios.RelMapEntrega RelMapa = new Relatorios.RelMapEntrega();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSql);
                RelMapa.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = RelMapa;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelMapa.Section2.ReportObjects["LblFilial"])).Text = FrmPrincipal.LstFilial.Text.Trim();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(RelMapa.Section5.ReportObjects["LblRodaPe"])).Text = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                BtnImprimir.Enabled = true;
            }
        }
예제 #11
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            if (Op01.Checked)
            {
                string sSql = "SELECT T3.Fantasia as Filial,T4.Departamento,T2.Nome,(T1.Valor-(SELECT ISNULL(SUM(T5.VALOR),0) FROM  MVFOLHAPAG T5 WHERE T5.Id_ProvDesc=10 AND T5.ID_FUNC=T1.ID_FUNC AND T5.MESANO=T1.MESANO)) AS VALOR" +
                              ",T1.MesAno,T2.Banco,T2.Agencia,T2.Conta FROM MVFOLHAPAG T1 " +
                              " LEFT JOIN Funcionarios T2 ON (T2.Id_Func=T1.Id_Func)" +
                              " LEFT JOIN Empresa_Filial T3 ON (T3.Id_Filial=T2.Id_FilialTrab)" +
                              " LEFT JOIN Departamentos T4 ON (T4.Id_Departamento=T2.Id_Departamento)" +
                              " WHERE T3.Id_Filial<>2 and T1.MesAno='" + string.Format("{0:D2}", LstMesEventos.SelectedIndex) + @"/" + TxtAnoEventos.Value.ToString() + "' AND T1.ID_PROVDESC=4";

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSql = sSql + " AND T2.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstFilialCtps.SelectedValue.ToString() != "0")
                {
                    sSql = sSql + " AND T2.Id_FilialReg=" + LstFilialCtps.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSql = sSql + " AND T2.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }


                sSql = sSql + " ORDER BY T3.Fantasia,T4.Departamento,T2.Nome";

                FrmRelatorios           FrmRel = new FrmRelatorios();
                Relatorios.RelRhQuizena Rel001 = new Relatorios.RelRhQuizena();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSql);
                Rel001.SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString() + "     CTPS:" + LstFilialCtps.Text;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }
            if (Op02.Checked)
            {
                string sSQL1 = "SELECT DISTINCT T3.ID_FILIAL,T3.Fantasia,T2.ID_FUNC,T2.Nome,T4.Departamento,T1.MesAno FROM MvFolhaPag T1" +
                               " LEFT JOIN Funcionarios T2 ON (T2.Id_Func=T1.Id_Func)" +
                               " LEFT JOIN Empresa_Filial T3 ON (T3.Id_Filial=T2.Id_FilialTrab)" +
                               " LEFT JOIN Departamentos T4 ON (T4.Id_Departamento=T2.Id_Departamento)" +
                               " WHERE T3.Id_Filial<>2 and T1.ID_PROVDESC<>10 AND T1.MesAno='" + string.Format("{0:D2}", LstMesEventos.SelectedIndex) + @"/" + TxtAnoEventos.Value.ToString() + "'";

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstFilialCtps.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_FilialReg=" + LstFilialCtps.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }

                sSQL1 = sSQL1 + " ORDER BY T3.Fantasia,T2.Nome";


                string sSQL2 = "SELECT T1.ID_FUNC,T3.ID_FILIAL,T3.Fantasia,T2.Nome,T4.Descricao AS NomeProvDesc,T4.ProvDesc,T1.Qtde_Ref,T1.Valor,T1.Descricao,T1.MesAno,T2.funcao FROM MvFolhaPag T1" +
                               " LEFT JOIN Funcionarios T2 ON (T2.Id_Func=T1.Id_Func)" +
                               " LEFT JOIN Empresa_Filial T3 ON (T3.Id_Filial=T2.Id_FilialTrab)" +
                               " LEFT JOIN ProventosDescontos T4 ON (T4.Id_Codigo=T1.Id_ProvDesc)" +
                               " WHERE T3.Id_Filial<>2 and T1.ID_PROVDESC<>10 AND T1.MesAno='" + string.Format("{0:D2}", LstMesEventos.SelectedIndex) + @"/" + TxtAnoEventos.Value.ToString() + "'";

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSQL2 = sSQL2 + " AND T2.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSQL2 = sSQL2 + " AND T2.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }

                sSQL2 = sSQL2 + " ORDER BY T3.Fantasia,T2.Nome,T4.ProvDesc,T4.Id_Codigo";


                FrmRelatorios            FrmRel = new FrmRelatorios();
                Relatorios.RelFgFolhaDem Rel001 = new Relatorios.RelFgFolhaDem();
                DataSet TabRel  = new DataSet();
                DataSet TabRel2 = new DataSet();
                TabRel  = Controle.ConsultaTabela(sSQL1);
                TabRel2 = Controle.ConsultaTabela(sSQL2);
                Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                Rel001.Database.Tables[1].SetDataSource(TabRel2.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString() + "     CTPS:" + LstFilialCtps.Text;;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }

            if (Op03.Checked || Op06.Checked || Op09.Checked)
            {
                string sSQL1 = "SELECT T3.ID_FILIAL,T3.Fantasia,T5.Departamento,T2.ID_FUNC,T2.Nome,T2.Banco,T2.Agencia,T2.Conta," +
                               "T2.DTADMISSAO,T2.SALARIOATUAL,T2.SALARIOCTPS," +
                               " CASE T2.TIPOCONTA WHEN 0 THEN 'CORRENTE' WHEN 1 THEN 'POUPANÇA' ELSE ' ' END AS TIPOCONTA,";

                if (Cb_Quizena.Checked)
                {
                    sSQL1 = sSQL1 + " (1 * isnull(T1.Valor,0)) as Liquido ";
                }
                else
                {
                    sSQL1 = sSQL1 + " isnull(SUM(case t4.provdesc when 0 then T1.Valor end),0)-isnull(SUM(case t4.provdesc when 1 then T1.Valor end),0) as Liquido";
                }

                sSQL1 = sSQL1 + " FROM  MvFolhaPag T1" +
                        " LEFT JOIN Funcionarios T2 ON (T2.Id_Func=T1.Id_Func)" +
                        " LEFT JOIN Empresa_Filial T3 ON (T3.Id_Filial=T2.Id_FilialTrab)" +
                        " LEFT JOIN ProventosDescontos T4 ON (T4.Id_Codigo=T1.Id_ProvDesc)" +
                        " LEFT JOIN Departamentos T5 ON (T5.Id_Departamento=T2.Id_Departamento)" +
                        " WHERE T3.Id_Filial<>2 and T1.ID_PROVDESC<>10 AND T1.MesAno='" + string.Format("{0:D2}", LstMesEventos.SelectedIndex) + @"/" + TxtAnoEventos.Value.ToString() + "'";

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstFilialCtps.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_FilialReg=" + LstFilialCtps.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }

                if (Op06.Checked || Op09.Checked)
                {
                    if (Op06.Checked)
                    {
                        sSQL1 = sSQL1 + "AND rtrim(T2.Banco)<>''";
                    }
                    else
                    {
                        sSQL1 = sSQL1 + "AND RTRIM(T2.Banco)=''";
                    }

                    if (Cb_Quizena.Checked)
                    {
                        sSQL1 = sSQL1 + "AND T1.Id_ProvDesc=4";
                    }
                }
                if (!Cb_Quizena.Checked)
                {
                    sSQL1 = sSQL1 + " Group by T3.ID_FILIAL,T3.Fantasia,T5.Departamento,T2.ID_FUNC,T2.Nome,T2.Banco,T2.Agencia,T2.Conta,T2.DTADMISSAO,T2.SALARIOATUAL,T2.SALARIOCTPS,TIPOCONTA";
                }

                FrmRelatorios FrmRel = new FrmRelatorios();
                if (LstMesEventos.SelectedIndex == 13)
                {
                    Relatorios.RelResumoFolhaPg13 Rel0013 = new Relatorios.RelResumoFolhaPg13();
                    DataSet TabRel = new DataSet();
                    TabRel = Controle.ConsultaTabela(sSQL1);
                    Rel0013.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                    FrmRel.cryRepRelatorio.ReportSource = Rel0013;
                    if (Op06.Checked || Op09.Checked)
                    {
                        if (Op06.Checked)
                        {
                            ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel0013.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString() + " Listagem (Banco)     CTPS:" + LstFilialCtps.Text;
                        }
                        else
                        {
                            ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel0013.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString() + " Listagem (Dinheiro)     CTPS:" + LstFilialCtps.Text;
                        }
                    }
                    else
                    {
                        ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel0013.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString() + "     CTPS:" + LstFilialCtps.Text;
                    }
                    FrmRel.ShowDialog();
                    Rel0013.Dispose();
                }
                else
                {
                    Relatorios.RelResumoFolhaPg Rel001 = new Relatorios.RelResumoFolhaPg();
                    DataSet TabRel = new DataSet();
                    TabRel = Controle.ConsultaTabela(sSQL1);
                    Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                    FrmRel.cryRepRelatorio.ReportSource = Rel001;

                    if (Op06.Checked)
                    {
                        ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString() + " Listagem (Banco)     CTPS:" + LstFilialCtps.Text;
                    }
                    else
                    {
                        ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString() + "     CTPS:" + LstFilialCtps.Text;
                    }
                    FrmRel.ShowDialog();
                    Rel001.Dispose();
                }
            }

            if (Op04.Checked)
            {
                string sSQL1 = "SELECT T5.Fantasia,T3.PROVDESC,CASE T3.PROVDESC WHEN 0 THEN '(P)-'+SubString(T3.Descricao,1,40) ELSE '(D)-'+SubString(T3.Descricao,1,40) END Descricao,T2.Nome,T4.Departamento,T1.Valor,T1.MesAno FROM MvFolhaPag T1" +
                               " LEFT JOIN Funcionarios T2 ON (T2.Id_Func=T1.Id_Func)" +
                               " LEFT JOIN ProventosDescontos T3 ON (T3.Id_Codigo=T1.Id_ProvDesc)" +
                               " LEFT JOIN Departamentos T4 ON (T4.Id_Departamento=T2.Id_Departamento)" +
                               " LEFT JOIN Empresa_Filial T5 ON (T5.Id_Filial=T2.Id_FilialTrab)" +
                               " WHERE T5.Id_Filial<>2 and T1.MesAno='" + string.Format("{0:D2}", LstMesEventos.SelectedIndex) + @"/" + TxtAnoEventos.Value.ToString() + "'";


                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstFilialCtps.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_FilialReg=" + LstFilialCtps.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }

                if (LstEventos.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_ProvDesc=" + LstEventos.SelectedValue.ToString();
                }

                sSQL1 = sSQL1 + " ORDER BY T2.Id_FilialTrab,T1.Id_ProvDesc,T2.NOME";

                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelRHLancEventos Rel001 = new Relatorios.RelRHLancEventos();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSQL1);
                Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString() + "     CTPS:" + LstFilialCtps.Text;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }

            if (Op05.Checked)
            {
                string sSQL1 = "SELECT ISNULL(T2.Fantasia,'  ') AS FILIAL_TRAB,T4.DEPARTAMENTO,T3.Fantasia AS FILIAL_REG,T1.Nome,T1.salarioCtps,T1.SalarioAtual,T1.AdiantSalario,T1.DtAdmissao,T1.FUNCAO FROM Funcionarios T1" +
                               " LEFT JOIN Empresa_Filial T2 ON (T2.Id_Filial=T1.Id_FilialTrab)" +
                               " LEFT JOIN Empresa_Filial T3 ON (T3.Id_Filial=T1.Id_FilialReg)" +
                               " LEFT JOIN Departamentos T4 ON (T4.Id_Departamento=T1.Id_Departamento)" +
                               " Where T3.Id_Filial<>2 and T1.DtDemissao IS NULL";

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstFilialCtps.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_FilialReg=" + LstFilialCtps.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }

                sSQL1 = sSQL1 + " ORDER BY T1.Id_FilialTrab,T1.NOME";

                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelRHListaSalarios Rel001 = new Relatorios.RelRHListaSalarios();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSQL1);
                Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                //((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString();
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }

            if (Op07.Checked)
            {
                string sSQL1 = "SELECT T5.Fantasia,T4.Departamento,T3.PROVDESC,CASE T3.PROVDESC WHEN 0 THEN '(P)-'+SubString(T3.Descricao,1,40) ELSE '(D)-'+SubString(T3.Descricao,1,40) END Descricao,IsNull(SUM(T1.Valor),0) AS TOTAL" +
                               "  FROM MvFolhaPag T1 " +
                               " LEFT JOIN Funcionarios T2 ON (T2.Id_Func=T1.Id_Func) " +
                               " LEFT JOIN ProventosDescontos T3 ON (T3.Id_Codigo=T1.Id_ProvDesc) " +
                               " LEFT JOIN Departamentos T4 ON (T4.Id_Departamento=T2.Id_Departamento) " +
                               " LEFT JOIN Empresa_Filial T5 ON (T5.Id_Filial=T2.Id_FilialTrab) " +
                               " WHERE T5.Id_Filial<>2 and T1.MesAno='" + string.Format("{0:D2}", LstMesEventos.SelectedIndex) + @"/" + TxtAnoEventos.Value.ToString() + "'";

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstFilialCtps.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_FilialReg=" + LstFilialCtps.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }

                sSQL1 = sSQL1 + " GROUP BY T5.Fantasia,T4.Departamento,T3.PROVDESC,T3.Descricao ORDER BY 1,2,3,4";

                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelResumProvDesc Rel001 = new Relatorios.RelResumProvDesc();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSQL1);
                Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }

            if (Op08.Checked)
            {
                if (int.Parse(TxtCodFunc.Text) == 0)
                {
                    MessageBox.Show("Favor Informar Funcionario", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                string sSQL1 = "SELECT 1 as Tipo,SUBSTRING(t1.mesano,4,4) as Ano,SUBSTRING(t1.mesano,1,2) as Mes,T1.Id_ProvDesc,t2.Nome,T3.ProvDesc,T3.Descricao,T1.MesAno,t1.Descricao as ObsLanc,t1.Valor AS VlrPrevisto,isnull(T4.Valor,0) AS VLRDESCONTO  " +
                               " FROM ProvDescFunc T1" +
                               "  LEFT JOIN Funcionarios T2 ON (T2.Id_Func=T1.Id_Func)" +
                               "  LEFT JOIN ProventosDescontos T3 ON (T3.Id_Codigo=T1.Id_ProvDesc) " +
                               "  LEFT JOIN MvFolhaPag T4 ON (T4.Id_Func=T1.Id_Func AND T4.Id_ProvDesc=T1.Id_ProvDesc AND T4.MesAno=T1.MesAno AND T4.Valor=T1.Valor)" +
                               " WHERE T1.Id_Func=" + TxtCodFunc.Text +
                               "  and T1.MesAno='00/0000'";

                if (LstEventos.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_ProvDesc=" + LstEventos.SelectedValue.ToString();
                }

                sSQL1 = sSQL1 + " UNION" +
                        " SELECT 2 as Tipo,SUBSTRING(t1.mesano,4,4) as Ano,SUBSTRING(t1.mesano,1,2) as Mes,T1.Id_ProvDesc,t2.Nome,T3.ProvDesc,T3.Descricao,T1.MesAno,t1.Descricao as ObsLanc,t1.Valor AS VlrPrevisto,T4.Valor AS VLRDESCONTO  " +
                        " FROM ProvDescFunc T1" +
                        " LEFT JOIN Funcionarios T2 ON (T2.Id_Func=T1.Id_Func)" +
                        " LEFT JOIN ProventosDescontos T3 ON (T3.Id_Codigo=T1.Id_ProvDesc)   " +
                        " LEFT JOIN MvFolhaPag T4 ON (T4.Id_Func=T1.Id_Func AND T4.Id_ProvDesc=T1.Id_ProvDesc AND T4.MesAno=T1.MesAno AND T4.Valor=T1.Valor)" +
                        " WHERE T1.Id_Func=" + TxtCodFunc.Text +
                        " and T1.MesAno<>'00/0000'";
                if (LstEventos.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_ProvDesc=" + LstEventos.SelectedValue.ToString();
                }

                sSQL1 = sSQL1 + "ORDER BY T3.ProvDesc";

                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelFichaFuncProvDesc Rel001 = new Relatorios.RelFichaFuncProvDesc();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSQL1);
                Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }

            if (Op10.Checked)
            {
                string sSQL1 = "select T4.Filial,T5.Departamento,T2.Nome,SUM(T1.Valor) as Total from MvFolhaPag t1" +
                               " left join Funcionarios t2 on (t2.Id_Func=t1.Id_Func)" +
                               " left join ProventosDescontos t3 on (t3.Id_Codigo=t1.Id_ProvDesc)" +
                               " left join Empresa_Filial t4 on (t4.Id_Filial=t2.Id_FilialTrab)" +
                               " LEFT JOIN Departamentos T5 ON (T5.Id_Departamento=T2.Id_Departamento) " +
                               " WHERE T4.Id_Filial<>2 and T3.FOLHABRUTA=1 AND T1.MesAno='" + string.Format("{0:D2}", LstMesEventos.SelectedIndex) + @"/" + TxtAnoEventos.Value.ToString() + "'";

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T2.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }

                sSQL1 = sSQL1 + " GROUP BY T4.Filial,T5.Departamento,T2.Nome";

                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelResFolhaBruta Rel001 = new Relatorios.RelResFolhaBruta();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSQL1);
                Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Mes:" + LstMesEventos.Text + " ANO:" + TxtAnoEventos.Value.ToString();
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }

            if (Op11.Checked)
            {
                string sSQL1 = "select t1.*,t2.Departamento,t3.Fantasia as FilialReg,t4.Fantasia as FilialTrab,t5.RazaoSocial as NomeCompra from Funcionarios t1" +
                               " left join Departamentos t2 on (t2.Id_Departamento=t1.Id_Departamento)" +
                               " left join Empresa_Filial t3 on (t3.Id_Filial=t1.Id_FilialReg)" +
                               " left join Empresa_Filial t4 on (t4.Id_Filial=t1.Id_FilialTrab)" +
                               " left join Pessoas t5 on (t5.Id_Pessoa=t1.Id_Pessoa)";

                sSQL1 = sSQL1 + " WHERE T1.DtDemissao is null";

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstFilialCtps.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_FilialReg=" + LstFilialCtps.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }

                if (int.Parse(TxtCodFunc.Text) > 0)
                {
                    sSQL1 = sSQL1 + " AND T1.Id_Func=" + TxtCodFunc.Text;
                }


                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelFichaFuncionario Rel001 = new Relatorios.RelFichaFuncionario();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSQL1);
                Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }

            if (Op12.Checked)
            {
                string sSQL1 = "SELECT T2.Fantasia,T3.Departamento,T1.Nome," +
                               " ISNULL((SELECT P1.VALOR FROM ProvDescFunc P1 WHERE P1.ID_FUNC=T1.ID_FUNC AND P1.Id_ProvDesc=12 AND P1.MesAno='00/0000'),0) AS VLRUNIMED," +
                               " ISNULL((SELECT ISNULL(P2.VALOR,0) FROM ProvDescFunc P2 WHERE P2.ID_FUNC=T1.ID_FUNC AND P2.Id_ProvDesc=34 AND P2.MesAno='00/0000'),0) AS VLRBENFEMP FROM Funcionarios T1" +
                               " LEFT JOIN Empresa_Filial T2 ON (T2.Id_Filial=T1.Id_FilialTrab)" +
                               " LEFT JOIN Departamentos T3 ON (T3.Id_Departamento=T1.Id_Departamento)" +
                               " WHERE T1.DtDemissao is null";

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_FilialTrab=" + LstFilial.SelectedValue.ToString();
                }

                if (LstFilialCtps.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_FilialReg=" + LstFilialCtps.SelectedValue.ToString();
                }

                if (LstDepartamento.SelectedValue.ToString() != "0")
                {
                    sSQL1 = sSQL1 + " AND T1.Id_Departamento=" + LstDepartamento.SelectedValue.ToString();
                }

                if (int.Parse(TxtCodFunc.Text) > 0)
                {
                    sSQL1 = sSQL1 + " AND T1.Id_Func=" + TxtCodFunc.Text;
                }

                sSQL1 = sSQL1 + " ORDER BY T2.Fantasia,T3.Departamento,T1.Nome";


                FrmRelatorios        FrmRel = new FrmRelatorios();
                Relatorios.RelUnimed Rel001 = new Relatorios.RelUnimed();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSQL1);
                Rel001.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }
        }
예제 #12
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            BtnImprimir.Enabled = false;
            if (Op01.Checked)
            {
                string sSql = "SELECT T2.RazaoSocial, T1.DtEmissao, T1.NumNota, T1.NumFormulario, T1.VlrNota, T1.BIcms, T1.VlrIcms, T1.BIcmsSub, T1.VlrIcmsSub, T1.VlrIpi, T1.VlrFrete, " +
                              " T1.VlrSeguro, T1.VlrOutraDesp, T3.CFOP, T3.Descricao,T4.FANTASIA AS Filial" +
                              " FROM  NotaFiscal AS T1 " +
                              " LEFT OUTER JOIN Pessoas AS T2 ON T2.Id_Pessoa = T1.Id_Pessoa " +
                              " LEFT OUTER JOIN CFOP AS T3 ON T3.Id_CFOP = T1.Id_Cfop" +
                              " LEFT OUTER JOIN Empresa_Filial AS T4 ON T4.Id_Filial = T1.Id_Filial" +
                              " WHERE T1.DtEmissao >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.DtEmissao <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103)";
                if (Rb_Emitida.Checked)
                {
                    sSql = sSql + " AND T1.Status = 1 ";
                }
                if (Rb_Cancelada.Checked)
                {
                    sSql = sSql + " AND T1.Status = 2 ";
                }

                if (Rb_Form.Checked)
                {
                    sSql = sSql + " AND T1.NFE = 0 ";
                }
                else
                {
                    sSql = sSql + " AND T1.NFE = 1 ";
                }

                if (LstFilial.SelectedValue.ToString() != "0")
                {
                    sSql = sSql + " AND T1.Id_Filial=" + LstFilial.SelectedValue.ToString();
                }
                sSql = sSql + " ORDER BY T1.ID_FILIAL,T1.DTEMISSAO,T1.NumFormulario";

                FrmRelatorios             FrmRel = new FrmRelatorios();
                Relatorios.RelNotaFiscais Rel001 = new Relatorios.RelNotaFiscais();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSql);
                Rel001.SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblFilial"])).Text  = FrmPrincipal.LstFilial.Text.Trim();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }
            if (Op02.Checked) // Cupom Fiscal
            {
                string sSql = "SELECT CASE T1.STATUS WHEN 2 THEN 'CANCELADO' ELSE ' ' END AS STATUS,T1.DATA,T1.NUM_CF,T1.VLRSUBTOTAL,T1.VLRDESCONTO,T1.VLRTOTAL,T2.NUMDOCUMENTO,T2.PESSOA FROM CUPOMFISCAL T1" +
                              " LEFT JOIN MVVENDA T2 ON (T2.ID_VENDA=T1.ID_VENDA)" +
                              " WHERE T1.Data >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.Data <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103) ORDER BY T1.DATA";

                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelCupomFiscais Rel001 = new Relatorios.RelCupomFiscais();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSql);
                Rel001.SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }

            if (Op03.Checked)
            {
                if (int.Parse(TxtCodCliente.Text) == 0)
                {
                    MessageBox.Show("Favor selecionar um clinete", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                string sSql = "SELECT T2.Cnpj+' '+T2.RazaoSocial as RazaoSocial,T1.DtEmissao, T1.NumNota, T1.NumFormulario, T1.VlrNota, T1.BIcms, T1.VlrIcms, T1.BIcmsSub, T1.VlrIcmsSub, T1.VlrIpi, T1.VlrFrete, " +
                              " T1.VlrSeguro, T1.VlrOutraDesp, T3.CFOP, T3.Descricao,T4.FANTASIA AS Filial" +
                              " FROM  NotaFiscal AS T1 " +
                              " LEFT OUTER JOIN Pessoas AS T2 ON T2.Id_Pessoa = T1.Id_Pessoa " +
                              " LEFT OUTER JOIN CFOP AS T3 ON T3.Id_CFOP = T1.Id_Cfop" +
                              " LEFT OUTER JOIN Empresa_Filial AS T4 ON T4.Id_Filial = T1.Id_Filial" +
                              " WHERE T1.Status = 1 and T1.DtEmissao >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.DtEmissao <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103)";


                sSql = sSql + " AND T1.Id_Pessoa=" + TxtCodCliente.Text;
                sSql = sSql + " ORDER BY T1.ID_FILIAL,T2.RazaoSocial,T1.DTEMISSAO,T1.NumFormulario";

                FrmRelatorios             FrmRel = new FrmRelatorios();
                Relatorios.RelNotaFiscais Rel001 = new Relatorios.RelNotaFiscais();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSql);
                Rel001.SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblFilial"])).Text  = FrmPrincipal.LstFilial.Text.Trim();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }
            if (Op04.Checked) // Vendas com pendencia de Cupom Fiscal ou Nota
            {
                string sSql = "select t2.Data,t2.Pessoa,t2.NumDocumento,t3.Referencia,t3.Descricao,t1.Qtde,t1.VlrUnitario,t1.VlrTotal,t2.VlrDesconto+t2.Credito AS Desconto,t2.VlrTotal as TotalVenda from MvVendaItens t1" +
                              " left join MvVenda t2 on (t2.Id_Venda=t1.Id_Venda)" +
                              " left join Produtos t3 on (t3.Id_Produto=t1.Id_Produto)" +
                              " WHERE T2.Data >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T2.Data <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103) " +
                              " and t2.TpVenda='PV' and t2.ID_LancCF=0 AND t2.ImpNF=0" +
                              " order by t2.data,t2.NumDocumento";


                FrmRelatorios           FrmRel = new FrmRelatorios();
                Relatorios.RelVdSemCFNF Rel001 = new Relatorios.RelVdSemCFNF();
                DataSet TabRel = new DataSet();
                TabRel = Controle.ConsultaTabela(sSql);
                Rel001.SetDataSource(TabRel.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
            }

            BtnImprimir.Enabled = true;
        }
예제 #13
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            if (TxtIdVenda.Value > 0)
            {
                Vendas.LerDados(int.Parse(TxtIdVenda.Value.ToString()));
                if (Vendas.IdVenda == 0)
                {
                    MessageBox.Show("Venda não localizada", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    string sSQL = "";
                    if (!ImpBoleto && Rb_Sim.Checked)
                    {
                        sSQL = "SELECT TOP 1 T1.ID_PESSOA,T7.Vencimento, T1.NumDocumento+' NFe: '+rtrim(T9.FormNF) as NumDocumento, T1.VlrTotal as VlrOriginal, T1.PESSOA AS RazaoSocial, RTRIM(T1.Endereco) + ',' + RTRIM(T1.Numero) " +
                               " + ' ' + RTRIM(T1.Complemento) AS ENDERECO, T1.Cep, T1.Bairro, T1.Cidade, T3.Sigla, T1.CNPJCPF as Cnpj," +
                               " T4.FormaPgto,T1.Fone,T8.Vendedor,' ' as Documento,T0.IMAGEM AS LOGO," +
                               " T6.Filial as NomeFilial, RTRIM(T6.Endereco) + ',' + RTRIM(T6.Numero) + ' ' + RTRIM(T6.Complemento) AS ENDFILIAL, T6.Cep AS CepFilial, T6.Bairro as BairroFilial,T6.Cidade as CidFilial,T6.Fone1 AS FoneFilial,T6.Cnpj as CnpjFilial,T6.Insc_UF as InscFilial" +
                               " FROM  MvVenda AS T1 " +
                               " LEFT OUTER JOIN Pessoas AS T2 ON T2.Id_Pessoa = T1.Id_Pessoa " +
                               " LEFT OUTER JOIN Estados AS T3 ON T3.Id_Uf = T2.Id_Uf" +
                               " LEFT OUTER JOIN FormaPagamento AS T4 ON T4.Id_FormaPgto = T1.Id_FormaPgto" +
                               " LEFT OUTER JOIN Empresa_Filial as T6 on T6.Id_Filial=t1.Id_Filial" +
                               " LEFT OUTER JOIN LancFinanceiro as T7 on T7.Id_Venda=T1.Id_Venda" +
                               " LEFT OUTER JOIN Vendedores as T8 on T8.Id_Vendedor=T1.Id_Vendedor" +
                               " LEFT OUTER JOIN MVVENDA AS T9 ON (T9.ID_VENDA=T1.ID_VENDA)" +
                               " LEFT OUTER JOIN TABIMAGENS AS T0 ON (T0.ID_CHAVE=T6.ID_FILIAL AND T0.TABELA='FILIAL')" +
                               "  WHERE T1.ID_VENDA=" + Vendas.IdVdMaster.ToString();
                    }
                    else
                    {
                        if (ImpProm)
                        {
                            sSQL = "SELECT  T1.ID_PESSOA,T1.DataLanc, T1.Vencimento, T1.NumDocumento, T1.VlrOriginal, T2.RazaoSocial, RTRIM(T2.Endereco) + ',' + RTRIM(T2.Numero) ";
                        }
                        else
                        {
                            sSQL = "SELECT  T1.ID_PESSOA,T1.DataLanc, T1.Vencimento, T1.NumDocumento+' NFe: '+rtrim(T9.FormNF) as NumDocumento, T1.VlrOriginal, T2.RazaoSocial, RTRIM(T2.Endereco) + ',' + RTRIM(T2.Numero) ";
                        }

                        sSQL = sSQL + " + ' ' + RTRIM(T2.Complemento) AS ENDERECO, T2.Cep, T2.Bairro, T2.Cidade, T3.Sigla, T2.Cnpj, T2.Insc_UF,(((T1.VlrOriginal / 30) * 10) / 100) AS MultaBol," +
                               " T4.FormaPgto,T2.Fone,T5.Documento, RTRIM(T1.LinhaBoleto) AS LinhaDigBoleto, RTRIM(T1.CodBarraBoleto) AS CodBarraBoleto, RTRIM(T1.NossoNumero) AS NossoNumeroBoleto," +
                               " T6.FANTASIA AS Filial,T6.Juros as JuroBoleto,T6.Multa as MultaBoleto,T6.Instrucao,T7.NumAgencia,T7.Conta,T7.DigConta,T8.Vendedor,T0.IMAGEM AS LOGO, " +
                               " T6.Filial as NomeFilial, RTRIM(T6.Endereco) + ',' + RTRIM(T6.Numero) + ' ' + RTRIM(T6.Complemento) AS ENDFILIAL, T6.Cep AS CepFilial, T6.Bairro as BairroFilial,T6.Cidade as CidFilial,T6.Fone1 AS FoneFilial,T6.Cnpj as CnpjFilial,T6.Insc_UF as InscFilial" +
                               " FROM  LancFinanceiro AS T1 " +
                               " LEFT OUTER JOIN Pessoas AS T2 ON T2.Id_Pessoa = T1.Id_Pessoa " +
                               " LEFT OUTER JOIN Estados AS T3 ON T3.Id_Uf = T2.Id_Uf" +
                               " LEFT OUTER JOIN FormaPagamento AS T4 ON T4.Id_FormaPgto = T1.Id_FormaPgto" +
                               " LEFT OUTER JOIN TipoDocumento AS T5 ON T5.Id_Documento = T1.Id_TipoDocumento" +
                               " LEFT OUTER JOIN Empresa_Filial as T6 on T6.Id_Filial=t1.Id_Filial" +
                               " LEFT OUTER JOIN Bancos as T7 on T7.Id_Banco=T6.Id_Banco" +
                               " LEFT OUTER JOIN MVVENDA AS T9 ON (T9.ID_VENDA=T1.ID_VENDA)" +
                               " LEFT OUTER JOIN Vendedores as T8 on T8.Id_Vendedor=T9.Id_Vendedor" +
                               " LEFT OUTER JOIN TABIMAGENS AS T0 ON (T0.ID_CHAVE=T6.ID_FILIAL AND T0.TABELA='FILIAL')" +
                               "  WHERE T1.ID_VENDA=" + Vendas.IdVdMaster.ToString();
                    }
                    if (ImpBoleto)
                    {
                        FormaPgto.LerDados(Vendas.IdFormaPgto);
                        if (FormaPgto.PrimParcela <= 1)
                        {
                            MessageBox.Show("Boleto não pode ser impresso, Verificar a Forma de pagamento", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        BtnImprimir.Enabled = false;
                        if (Rb_BoletoA4.Checked)
                        {
                            FrmRelatorios          FrmRel    = new FrmRelatorios();
                            Relatorios.RelBoletoA4 RelBoleto = new Relatorios.RelBoletoA4();
                            DataSet TabRel = new DataSet();
                            TabRel = Controle.ConsultaTabela(sSQL);
                            RelBoleto.SetDataSource(TabRel.Tables[0]);
                            FrmRel.cryRepRelatorio.ReportSource = RelBoleto;
                            FrmRel.ShowDialog();
                        }
                        else
                        {
                            FrmRelatorios        FrmRel    = new FrmRelatorios();
                            Relatorios.RelBoleto RelBoleto = new Relatorios.RelBoleto();
                            DataSet TabRel = new DataSet();
                            TabRel = Controle.ConsultaTabela(sSQL);
                            RelBoleto.SetDataSource(TabRel.Tables[0]);
                            FrmRel.cryRepRelatorio.ReportSource = RelBoleto;
                            FrmRel.ShowDialog();
                        }
                        BtnImprimir.Enabled = true;
                    }
                    else
                    {
                        //NumeroPorExtenso Extenso = new NumeroPorExtenso(Vendas.VlrTotal);
                        if (!ImpProm)
                        {
                            FrmRelatorios        FrmRel = new FrmRelatorios();
                            Relatorios.RelRecibo RelRec = new Relatorios.RelRecibo();
                            DataSet TabRel = new DataSet();
                            TabRel = Controle.ConsultaTabela(sSQL);
                            RelRec.SetDataSource(TabRel.Tables[0]);
                            FrmRel.cryRepRelatorio.ReportSource = RelRec;
                            FrmRel.ShowDialog();
                        }
                        else
                        {
                            string sSQLPrd = "Select rtrim(T2.descricao) as Descricao from MvVendaItens t1 left join Produtos t2 on (T2.id_produto=T1.Id_Produto) where t1.id_Venda=" + Vendas.IdVdMaster.ToString();

                            FrmRelatorios             FrmRel = new FrmRelatorios();
                            Relatorios.RelPromissoria RelRec = new Relatorios.RelPromissoria();
                            DataSet TabRel    = new DataSet();
                            DataSet TabRelPrd = new DataSet();
                            TabRel    = Controle.ConsultaTabela(sSQL);
                            TabRelPrd = Controle.ConsultaTabela(sSQLPrd);
                            //RelRec.SetDataSource(TabRel.Tables[0]);
                            RelRec.Database.Tables[0].SetDataSource(TabRel.Tables[0]);
                            RelRec.Database.Tables[1].SetDataSource(TabRelPrd.Tables[0]);
                            FrmRel.cryRepRelatorio.ReportSource = RelRec;
                            FrmRel.ShowDialog();
                        }
                        BtnImprimir.Enabled = false;
                    }
                }
            }
            BtnImprimir.Enabled = true;
        }
예제 #14
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            if (Op01.Checked)
            {
                string sSql1 = "SELECT T1.ID_LANC,T4.AGENTE,T2.RAZAOSOCIAL,T1.DESCRICAO,T3.DOCUMENTO,CASE T1.TPLANC WHEN 1 THEN VALOR ELSE 0 END AS DEBITO," +
                               " CASE T1.TPLANC WHEN 2 THEN VALOR ELSE 0 END AS CREDITO FROM MVCONTACAIXA T1" +
                               " LEFT JOIN PESSOAS T2 ON (T2.ID_PESSOA=T1.ID_PESSOA)" +
                               " LEFT JOIN TIPODOCUMENTO T3 ON (T3.ID_DOCUMENTO=T1.ID_DOCUMENTO)" +
                               " LEFT JOIN AGENTECOBRADOR T4 ON (T4.ID_AGENTE=T1.ID_AGENTE)" +
                               " WHERE T1.STATUS=0 AND T1.DATA = Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.ID_CAIXA=" + LstCaixa.SelectedValue.ToString() +
                               " ORDER BY T4.AGENTE,T1.ID_LANC";

                string sSql2 = "SELECT T1.DOCUMENTO,ISNULL((SELECT TOP 1 SALDO FROM SALDOCONTACAIXA T2 WHERE T2.ID_CAIXA=" + LstCaixa.SelectedValue.ToString() +
                               " AND T2.ID_DOCUMENTO=T1.ID_DOCUMENTO AND T2.DATA < Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) ORDER BY T2.DATA DESC),0) AS SALDO FROM TIPODOCUMENTO T1" +
                               " WHERE ISNULL((SELECT TOP 1 SALDO FROM SALDOCONTACAIXA T2 WHERE T2.ID_CAIXA=" + LstCaixa.SelectedValue.ToString() +
                               " AND T2.ID_DOCUMENTO=T1.ID_DOCUMENTO AND T2.DATA < Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) ORDER BY T2.DATA DESC),0) <> 0";

                string sSql3 = "SELECT T1.DOCUMENTO,ISNULL((SELECT TOP 1 SALDO FROM SALDOCONTACAIXA T2 WHERE T2.ID_CAIXA=" + LstCaixa.SelectedValue.ToString() +
                               " AND T2.ID_DOCUMENTO=T1.ID_DOCUMENTO AND T2.DATA <= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) ORDER BY T2.DATA DESC),0) AS SALDO FROM TIPODOCUMENTO T1" +
                               " WHERE ISNULL((SELECT TOP 1 SALDO FROM SALDOCONTACAIXA T2 WHERE T2.ID_CAIXA=" + LstCaixa.SelectedValue.ToString() +
                               " AND T2.ID_DOCUMENTO=T1.ID_DOCUMENTO AND T2.DATA <= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) ORDER BY T2.DATA DESC),0) <>0 ";

                FrmRelatorios            FrmRel = new FrmRelatorios();
                Relatorios.RelLivroCaixa Rel001 = new Relatorios.RelLivroCaixa();
                DataSet Extrato = new DataSet();
                DataSet SldAnt  = new DataSet();
                DataSet Saldo   = new DataSet();
                Extrato = Controle.ConsultaTabela(sSql1);
                SldAnt  = Controle.ConsultaTabela(sSql2);
                Saldo   = Controle.ConsultaTabela(sSql3);
                Rel001.Database.Tables[0].SetDataSource(Extrato.Tables[0]);
                Rel001.Database.Tables[1].SetDataSource(SldAnt.Tables[0]);
                Rel001.Database.Tables[2].SetDataSource(Saldo.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblData"])).Text   = "Data: " + Dt1.Value.ToShortDateString();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblCaixa"])).Text  = "Caixa: " + LstCaixa.Text.Trim();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
                FrmRel.Dispose();
            }
            if (Op02.Checked) // Resumo da Receita X Despesa
            {
                string sSql = "SELECT T1.VENCIMENTO,SUM(CASE T1.PagRec WHEN 1 THEN T1.VLRORIGINAL ELSE 0 END) AS PAGAR, SUM(CASE T1.PagRec WHEN 2 THEN T1.VLRORIGINAL ELSE 0 END) AS RECEBER FROM LANCFINANCEIRO T1" +
                              " WHERE T1.STATUS=0 AND T1.VENCIMENTO >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.VENCIMENTO <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103) " +
                              " GROUP BY T1.VENCIMENTO ORDER BY T1.VENCIMENTO";

                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelResumoRecXDesp Rel001 = new Relatorios.RelResumoRecXDesp();
                DataSet Tab = new DataSet();
                Tab = Controle.ConsultaTabela(sSql);
                Rel001.Database.Tables[0].SetDataSource(Tab.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
                FrmRel.Dispose();
            }
            if (Op03.Checked) // Movimentação por Centro de Custo
            {
                string sSql = "SELECT T3.CUSTO,T4.FANTASIA AS FILIAL,T6.DEPARTAMENTO,T1.DATALANC,T2.RAZAOSOCIAL,T1.NUMDOCUMENTO,T1.NOTAFISCAL,T1.REFERENTE,T1.VENCIMENTO,T1.VLRORIGINAL,T1.DTBAIXA,T1.VLRBAIXA,T5.DOCUMENTO FROM LANCFINANCEIRO T1 " +
                              " LEFT JOIN PESSOAS T2 ON (T2.ID_PESSOA=T1.ID_PESSOA)" +
                              " LEFT JOIN CENTROCUSTO T3 ON (T3.ID_CUSTO=T1.ID_CUSTO)" +
                              " LEFT JOIN EMPRESA_FILIAL T4 ON (T4.ID_FILIAL=T1.ID_FILIAL)" +
                              " LEFT JOIN TIPODOCUMENTO T5 ON (T5.ID_DOCUMENTO=T1.ID_TIPODOCUMENTO)" +
                              " LEFT JOIN DEPARTAMENTOS T6 ON (T6.ID_DEPARTAMENTO=T1.ID_DEPARTAMENTO)";

                sSql = sSql + " WHERE T1.STATUS=1 AND T1.PAGREC=1 AND  T1.DTBAIXA >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.DTBAIXA <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103) ";

                if (int.Parse(LstFilial.SelectedValue.ToString()) > 0)
                {
                    sSql = sSql + " AND T1.ID_FILIAL=" + LstFilial.SelectedValue.ToString();
                }

                if (int.Parse(LstDepartamento.SelectedValue.ToString()) > 0)
                {
                    sSql = sSql + " AND T1.ID_DEPARTAMENTO=" + LstDepartamento.SelectedValue.ToString();
                }

                if (int.Parse(LstCusto.SelectedValue.ToString()) > 0)
                {
                    sSql = sSql + " AND T1.ID_CUSTO=" + LstCusto.SelectedValue.ToString();
                }

                sSql = sSql + " ORDER BY T1.DTBAIXA";

                FrmRelatorios             FrmRel = new FrmRelatorios();
                Relatorios.RelMovimCCusto Rel001 = new Relatorios.RelMovimCCusto();
                DataSet Tab = new DataSet();
                Tab = Controle.ConsultaTabela(sSql);
                Rel001.Database.Tables[0].SetDataSource(Tab.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
                FrmRel.Dispose();
            }
            if (Op04.Checked) // Resumo do Centro de Custo
            {
                string sSql = "SELECT T2.CUSTO,T3.FANTASIA AS FILIAL,T4.DEPARTAMENTO,SUM(T1.VLRBAIXA) AS TOTAL FROM LANCFINANCEIRO T1 " +
                              " LEFT JOIN CENTROCUSTO T2 ON (T2.ID_CUSTO=T1.ID_CUSTO) " +
                              " LEFT JOIN EMPRESA_FILIAL T3 ON (T3.ID_FILIAL=T1.ID_FILIAL) " +
                              " LEFT JOIN DEPARTAMENTOS T4 ON (T4.ID_DEPARTAMENTO=T1.ID_DEPARTAMENTO) " +
                              " WHERE T1.STATUS=1 AND T1.PAGREC=1 AND  T1.DTBAIXA >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.DTBAIXA <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103) ";

                if (int.Parse(LstFilial.SelectedValue.ToString()) > 0)
                {
                    sSql = sSql + " AND T1.ID_FILIAL=" + LstFilial.SelectedValue.ToString();
                }

                if (int.Parse(LstDepartamento.SelectedValue.ToString()) > 0)
                {
                    sSql = sSql + " AND T1.ID_DEPARTAMENTO=" + LstDepartamento.SelectedValue.ToString();
                }

                if (int.Parse(LstCusto.SelectedValue.ToString()) > 0)
                {
                    sSql = sSql + " AND T1.ID_CUSTO=" + LstCusto.SelectedValue.ToString();
                }

                sSql = sSql + "GROUP BY T2.CUSTO,T3.FANTASIA,T4.DEPARTAMENTO ORDER BY T2.CUSTO,T3.FANTASIA,T4.DEPARTAMENTO";

                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelResumoCCusto Rel001 = new Relatorios.RelResumoCCusto();
                DataSet Tab = new DataSet();
                Tab = Controle.ConsultaTabela(sSql);
                Rel001.Database.Tables[0].SetDataSource(Tab.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
                FrmRel.Dispose();
            }
            if (Op05.Checked) // Totalizador por Centro de Custo
            {
                string sSql = "SELECT T2.CUSTO,SUM(T1.VLRBAIXA) AS TOTAL FROM LANCFINANCEIRO T1 " +
                              " LEFT JOIN CENTROCUSTO T2 ON (T2.ID_CUSTO=T1.ID_CUSTO) " +
                              " WHERE T1.STATUS=1 AND T1.PAGREC=1 AND  T1.DTBAIXA >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.DTBAIXA <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103) ";

                if (int.Parse(LstFilial.SelectedValue.ToString()) > 0)
                {
                    sSql = sSql + " AND T1.ID_FILIAL=" + LstFilial.SelectedValue.ToString();
                }

                if (int.Parse(LstCusto.SelectedValue.ToString()) > 0)
                {
                    sSql = sSql + " AND T1.ID_CUSTO=" + LstCusto.SelectedValue.ToString();
                }

                sSql = sSql + "GROUP BY T2.CUSTO ORDER BY T2.CUSTO";

                FrmRelatorios             FrmRel = new FrmRelatorios();
                Relatorios.RelTotalCCusto Rel001 = new Relatorios.RelTotalCCusto();
                DataSet Tab = new DataSet();
                Tab = Controle.ConsultaTabela(sSql);
                Rel001.Database.Tables[0].SetDataSource(Tab.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;

                if (int.Parse(LstFilial.SelectedValue.ToString()) > 0)
                {
                    ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblFilial"])).Text = "Filial: " + LstFilial.Text.Trim();
                }
                else
                {
                    ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblFilial"])).Text = "Filial: Todas Filiais";
                }

                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section5.ReportObjects["LblRodaPe"])).Text  = FrmPrincipal.Rel_RodaPe;
                FrmRel.ShowDialog();
                Rel001.Dispose();
                FrmRel.Dispose();
            }
            if (Op06.Checked) // Listagem de Agendamento de CObrança
            {
                string sSql = "SELECT T1.Data,T1.DtRetorno,T3.RazaoSocial,T2.Vencimento,T2.VlrOriginal,T2.NumDocumento,T3.FONE,T3.Celular,T3.Contato,T1.Informacao FROM RegCobranca T1" +
                              "  LEFT JOIN LancFinanceiro T2 ON (T2.ID_LANC=T1.Id_PagRec)" +
                              "  LEFT JOIN Pessoas T3 ON (T3.Id_Pessoa=T2.Id_Pessoa)" +
                              " WHERE T1.DTRETORNO >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.DTRETORNO <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103) ";

                sSql = sSql + " ORDER BY T1.DTRETORNO, T3.RAZAOSOCIAL";

                FrmRelatorios            FrmRel = new FrmRelatorios();
                Relatorios.RelRetornoCob Rel001 = new Relatorios.RelRetornoCob();
                DataSet Tab = new DataSet();
                Tab = Controle.ConsultaTabela(sSql);
                Rel001.Database.Tables[0].SetDataSource(Tab.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                FrmRel.ShowDialog();
                Rel001.Dispose();
                FrmRel.Dispose();
            }
            if (Op07.Checked) // Listagem de Cobrança Realizada
            {
                string sSql = "SELECT T1.Data,T1.DtRetorno,T3.RazaoSocial,T2.Vencimento,T2.VlrOriginal,T2.NumDocumento,T3.FONE,T3.Celular,T3.Contato,T1.Informacao FROM RegCobranca T1" +
                              "  LEFT JOIN LancFinanceiro T2 ON (T2.ID_LANC=T1.Id_PagRec)" +
                              "  LEFT JOIN Pessoas T3 ON (T3.Id_Pessoa=T2.Id_Pessoa)" +
                              " WHERE T1.DATA >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T1.DATA <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103) ";

                sSql = sSql + " ORDER BY T1.DTRETORNO, T3.RAZAOSOCIAL";

                FrmRelatorios FrmRel = new FrmRelatorios();
                Relatorios.RelRegCobRealizada Rel001 = new Relatorios.RelRegCobRealizada();
                DataSet Tab = new DataSet();
                Tab = Controle.ConsultaTabela(sSql);
                Rel001.Database.Tables[0].SetDataSource(Tab.Tables[0]);
                FrmRel.cryRepRelatorio.ReportSource = Rel001;
                ((CrystalDecisions.CrystalReports.Engine.TextObject)(Rel001.Section2.ReportObjects["LblPeriodo"])).Text = "Período:" + Dt1.Value.ToShortDateString() + " a " + Dt2.Value.ToShortDateString();
                FrmRel.ShowDialog();
                Rel001.Dispose();
                FrmRel.Dispose();
            }
        }