예제 #1
0
        private void fechamentoDiario()
        {
            try
            {
                selecionado = 1;

                DadosTableAdapters.CaixaTableAdapter caixa = new DadosTableAdapters.CaixaTableAdapter();
                double totalDin = 0, totalCredVista = 0, totalCredParc = 0, totalDebt = 0, descontoDevolucao = 0;
                DadosTableAdapters.DataTable2TableAdapter fechamento = new DadosTableAdapters.DataTable2TableAdapter();

                DadosTableAdapters.Observacoes_SangriaTableAdapter sangria = new DadosTableAdapters.Observacoes_SangriaTableAdapter();

                //var varProd = fechamento.relatorio();

                //instanciando e setando o tipo de página que vou utilizar
                Document doc = new Document(PageSize.A4);
                //colocando margens no pdf
                doc.SetMargins(40, 40, 40, 80);

                string aux = deData.ToString("dd-MM-yyyy") + " - " + ateData.ToString("dd-MM-yyyy");

                string caminho = @"C:\pdv\relatorios\fechamento diario-" + aux.ToString() + ".pdf";


                PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(caminho, FileMode.Create));

                doc.Open();

                Paragraph titulo = new Paragraph();
                titulo.Font      = FontFactory.GetFont("Arial", 18);
                titulo.Alignment = Element.ALIGN_CENTER;
                titulo.Add("Fechamento do dia \n\n");
                doc.Add(titulo);

                Paragraph informacao = new Paragraph();
                informacao.Font      = FontFactory.GetFont("Arial", 12, BaseColor.BLUE);
                informacao.Alignment = Element.ALIGN_LEFT;

                Paragraph metodoPagamento = new Paragraph();
                metodoPagamento.Font      = FontFactory.GetFont("Arial", 14);
                metodoPagamento.Alignment = Element.ALIGN_LEFT;

                relatorioVendas(false, doc, informacao, titulo, metodoPagamento);

                /***************************************************************************************/
                /*****************************      Devoluções     *************************************/
                /***************************************************************************************/


                doc = relatorioDevolucoes(false, doc, informacao, titulo, metodoPagamento);

                /***************************************************************************************/
                /*****************************  Vendas Canceladas  *************************************/
                /***************************************************************************************/

                doc = relatorioVendasCanceladas(false, doc, informacao, titulo);


                /***************************************************************************************/
                /*****************************     Caixa Atual     *************************************/
                /***************************************************************************************/


                /* doc = caixaAtual(false, doc, informacao, titulo);*/

                /***************************************************************************************/
                /*****************************       Sangria       *************************************/
                /***************************************************************************************/
                doc = relatorioSangria(false, doc, informacao, titulo);

                doc.Close();
                //MessageBox.Show("Relatório gerado com sucesso!");
                abrirPdf(caminho);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        public Document caixaAtual(bool tipo, Document doc = null, Paragraph informacao = null, Paragraph titulo = null)
        {
            selecionado = 6;
            string caminho = "";

            DadosTableAdapters.CaixaTableAdapter caixa = new DadosTableAdapters.CaixaTableAdapter();
            if (tipo)
            {
                Document docLimpo = new Document(PageSize.A4);

                //colocando margens no pdf
                docLimpo.SetMargins(40, 40, 40, 80);
                doc = docLimpo;
                string aux = deData.ToString("dd-MM-yyyy") + " - " + ateData.ToString("dd-MM-yyyy");

                caminho = @"C:\pdv\relatorios\caixa-" + aux.ToString() + ".pdf";


                PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(caminho, FileMode.Create));

                doc.Open();
                Paragraph tituloLimpo = new Paragraph();
                titulo           = tituloLimpo;
                titulo.Font      = FontFactory.GetFont("Arial", 18);
                titulo.Alignment = Element.ALIGN_CENTER;/*
                                                         * titulo.Add("Caixa Atual " + deData.ToString("dd/MM/yyyy") + " - " + ateData.ToString("dd/MM/yyyy") + " \n\n");
                                                         */
                titulo.Add("Caixa Atual " + DateTime.Now.ToString("dd/MM/yyyy") + " \n\n");

                doc.Add(titulo);

                Paragraph informacaoLimpo = new Paragraph();
                informacao           = informacaoLimpo;
                informacao.Font      = FontFactory.GetFont("Arial", 12, BaseColor.BLUE);
                informacao.Alignment = Element.ALIGN_LEFT;
            }

            informacao.Clear();
            var caixaAtual = caixa.pegarCaixaPorData(DateTime.Now.ToString("dd/MM/yyyy"));

            if (caixaAtual.Count > 0)
            {
                informacao.Font = FontFactory.GetFont("Arial", 14, BaseColor.GRAY);
                informacao.Clear();
                informacao.Add("\n\nCaixa Atual: R$" + Convert.ToDouble(caixaAtual[0]["valorAtual"]).ToString("F2"));
                doc.Add(informacao);
            }
            informacao.Font = FontFactory.GetFont("Arial", 14, BaseColor.GREEN);

            informacao.Clear();

            doc.Add(informacao);
            if (tipo)
            {
                doc.Close();
                abrirPdf(caminho);

                //MessageBox.Show("Relatório gerado com sucesso!");
            }
            return(doc);
        }
예제 #3
0
        public Document relatorioVendas(bool tipo = false, Document doc = null, Paragraph informacao = null, Paragraph titulo = null, Paragraph metodoPagamento = null)
        {
            selecionado = 2;
            string caminho = "";

            DadosTableAdapters.CaixaTableAdapter caixa = new DadosTableAdapters.CaixaTableAdapter();
            double totalDin = 0, totalCredVista = 0, totalCredParc = 0, totalDebt = 0, descontoDevolucao = 0;

            DadosTableAdapters.DataTable2TableAdapter fechamento = new DadosTableAdapters.DataTable2TableAdapter();

            DadosTableAdapters.Observacoes_SangriaTableAdapter sangria = new DadosTableAdapters.Observacoes_SangriaTableAdapter();
            if (tipo)
            {
                //var varProd = fechamento.relatorio();

                //instanciando e setando o tipo de página que vou utilizar
                Document docLimpo = new Document(PageSize.A4);

                //colocando margens no pdf
                docLimpo.SetMargins(40, 40, 40, 80);
                doc = docLimpo;
                string aux = deData.ToString("dd-MM-yyyy") + " - " + ateData.ToString("dd-MM-yyyy");

                caminho = @"C:\pdv\relatorios\vendas-" + aux.ToString() + ".pdf";


                PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(caminho, FileMode.Create));

                doc.Open();

                Paragraph tituloLimpo = new Paragraph();
                titulo           = tituloLimpo;
                titulo.Font      = FontFactory.GetFont("Arial", 18);
                titulo.Alignment = Element.ALIGN_CENTER;
                titulo.Add("Vendas " + deData.ToString("dd/MM/yyyy") + " - " + ateData.ToString("dd/MM/yyyy") + " \n\n");
                doc.Add(titulo);

                Paragraph informacaoLimpo = new Paragraph();
                informacao           = informacaoLimpo;
                informacao.Font      = FontFactory.GetFont("Arial", 12, BaseColor.BLUE);
                informacao.Alignment = Element.ALIGN_LEFT;

                Paragraph metodoPagamentoLimpo = new Paragraph();
                metodoPagamento           = metodoPagamentoLimpo;
                metodoPagamento.Font      = FontFactory.GetFont("Arial", 14);
                metodoPagamento.Alignment = Element.ALIGN_LEFT;
            }
            //para o dinheiro==================================================================

            /*var dinheiro = fechamento.retornarFechamentoComDevolucao("DINHEIRO", DateTime.Now.ToString("dd/MM/yyyy")
             *  , DateTime.Now.ToString("dd/MM/yyyy"));
             * if (dinheiro.Count < 1)*/
            var dinheiro = fechamento.retornarFechamentoSemDevolucao("DINHEIRO", deData.ToString("dd/MM/yyyy"), ateData.ToString("dd/MM/yyyy"));

            if (dinheiro.Count > 0)
            {
                metodoPagamento.Add("Dinheiro \n\n");
                doc.Add(metodoPagamento);

                PdfPTable table = new PdfPTable(5);
                table.AddCell("Data da venda");
                table.AddCell("Código da venda");
                table.AddCell("Tipo de pagamento");
                table.AddCell("Vendedor");
                table.AddCell("Valor da venda");

                for (int i = 0; i < dinheiro.Count(); i++)
                {
                    table.AddCell(Convert.ToDateTime(dinheiro[i]["vendData"]).ToString("dd/MM/yyyy"));
                    table.AddCell(dinheiro[i]["idVenda"].ToString());
                    table.AddCell("Dinheiro");
                    table.AddCell("Vendedor padrão");
                    table.AddCell("R$ " + Convert.ToDouble(dinheiro[i]["PagValor"]).ToString("F2"));
                    totalDin = totalDin + Convert.ToDouble(dinheiro[i]["PagValor"]);
                }
                doc.Add(table);
                informacao.Add("\n\n" + "Total Dinheiro: R$" + totalDin.ToString("F2"));
                doc.Add(informacao);
            }
            //para credito a vista ==================================================================
            PdfPTable table2 = new PdfPTable(5);

            /*var creditoVista = fechamento.retornarFechamentoComDevolucao("CREDITO A VISTA", DateTime.Now.ToString("dd/MM/yyyy")
             * , DateTime.Now.ToString("dd/MM/yyyy"));
             * if (creditoVista.Count < 1)*/
            var creditoVista = fechamento.retornarFechamentoSemDevolucao("CREDITO A VISTA", deData.ToString("dd/MM/yyyy"), ateData.ToString("dd/MM/yyyy"));

            if (creditoVista.Count > 0)
            {
                metodoPagamento.Clear();
                metodoPagamento.Add("\n\nCrédito à vista\n\n");
                doc.Add(metodoPagamento);

                table2.AddCell("Data da venda");
                table2.AddCell("Código da venda");
                table2.AddCell("Tipo de pagamento");
                table2.AddCell("Vendedor");
                table2.AddCell("Valor da venda");



                for (int i = 0; i < creditoVista.Count(); i++)
                {
                    table2.AddCell(Convert.ToDateTime(creditoVista[i]["vendData"]).ToString("dd/MM/yyyy HH:mm:ss"));
                    table2.AddCell(creditoVista[i]["idVenda"].ToString());
                    table2.AddCell("Crédito à vista");
                    table2.AddCell("Vendedor padrão");
                    table2.AddCell("R$ " + Convert.ToDouble(creditoVista[i]["PagValor"]).ToString("F2"));
                    totalCredVista = totalCredVista + Convert.ToDouble(creditoVista[i]["PagValor"]);
                }
                doc.Add(table2);
                informacao.Clear();
                informacao.Add("\n\n" + "Total Crédito à Vista: R$" + totalCredVista.ToString("F2"));
                doc.Add(informacao);
            }

            //para credito parcelado ==================================================================
            PdfPTable table3 = new PdfPTable(5);

            /* var creditoParc = fechamento.retornarFechamentoComDevolucao("CREDITO PARCELADO", DateTime.Now.ToString("dd/MM/yyyy")
             * , DateTime.Now.ToString("dd/MM/yyyy"));
             * if (creditoParc.Count < 1)*/

            var creditoParc = fechamento.retornarFechamentoSemDevolucao("CREDITO PARCELADO", deData.ToString("dd/MM/yyyy")
                                                                        , ateData.ToString("dd/MM/yyyy"));

            if (creditoParc.Count > 0)
            {
                metodoPagamento.Clear();
                metodoPagamento.Add("\n\nCrédito parcelado\n\n");
                doc.Add(metodoPagamento);

                table3.AddCell("Data da venda");
                table3.AddCell("Código da venda");
                table3.AddCell("Tipo de pagamento");
                table3.AddCell("Vendedor");
                table3.AddCell("Valor da venda");



                for (int i = 0; i < creditoParc.Count(); i++)
                {
                    table3.AddCell(Convert.ToDateTime(creditoParc[i]["vendData"]).ToString("dd/MM/yyyy HH:mm:ss"));
                    table3.AddCell(creditoParc[i]["idVenda"].ToString());
                    table3.AddCell("Crédito à vista");
                    table3.AddCell("Vendedor padrão");
                    table3.AddCell("R$ " + Convert.ToDouble(creditoParc[i]["PagValor"]).ToString("F2"));
                    totalCredParc = totalCredParc + Convert.ToDouble(creditoParc[i]["PagValor"]);
                }
                doc.Add(table3);
                informacao.Clear();
                informacao.Add("\n\n" + "Total Crédito Parcelado: R$" + totalCredParc.ToString("F2"));
                doc.Add(informacao);
            }



            //para credito débito ==================================================================
            PdfPTable table4 = new PdfPTable(5);

            /*var debito = fechamento.retornarFechamentoComDevolucao("DEBITO", DateTime.Now.ToString("dd/MM/yyyy")
             * , DateTime.Now.ToString("dd/MM/yyyy"));
             * if (debito.Count < 1)*/
            var debito = fechamento.retornarFechamentoSemDevolucao("DEBITO", deData.ToString("dd/MM/yyyy")
                                                                   , ateData.ToString("dd/MM/yyyy"));

            if (debito.Count > 0)
            {
                metodoPagamento.Clear();
                metodoPagamento.Add("\n\nDébito\n\n");
                doc.Add(metodoPagamento);

                table4.AddCell("Data da venda");
                table4.AddCell("Código da venda");
                table4.AddCell("Tipo de pagamento");
                table4.AddCell("Vendedor");
                table4.AddCell("Valor da venda");



                for (int i = 0; i < debito.Count(); i++)
                {
                    table4.AddCell(Convert.ToDateTime(debito[i]["vendData"]).ToString("dd/MM/yyyy") + " " + Convert.ToDateTime(debito[i]["vendData"]).ToString("HH:mm:ss"));
                    table4.AddCell(debito[i]["idVenda"].ToString());
                    table4.AddCell("Débito");
                    table4.AddCell("Vendedor padrão");
                    table4.AddCell("R$ " + Convert.ToDouble(debito[i]["PagValor"]).ToString("F2"));
                    totalDebt = totalDebt + Convert.ToDouble(debito[i]["PagValor"]);
                }
                doc.Add(table4);

                informacao.Clear();
                informacao.Add("\n\n" + "Total Débito: R$" + totalDebt.ToString("F2"));
                doc.Add(informacao);
            }
            informacao.Clear();

            if (tipo)
            {
                doc.Close();
                abrirPdf(caminho);
                //                MessageBox.Show("Relatório gerado com sucesso!");
            }
            return(doc);
        }