Example #1
0
        public ObservableCollection <BarChart> Pessoas(mReportPessoas reports, bool periodo)
        {
            ObservableCollection <BarChart> _chart = new ObservableCollection <BarChart>();

            _chart.Clear();

            if (periodo)
            {
                List <KeyValuePair <string, int> > Sexo    = new List <KeyValuePair <string, int> >();
                List <KeyValuePair <string, int> > Perfil  = new List <KeyValuePair <string, int> >();
                List <KeyValuePair <string, int> > Negocio = new List <KeyValuePair <string, int> >();
                List <KeyValuePair <string, int> > Setor   = new List <KeyValuePair <string, int> >();

                foreach (KeyValuePair <string, int> x in reports.Sexo)
                {
                    Sexo.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value));
                }

                foreach (KeyValuePair <string, int> x in reports.Perfil)
                {
                    Perfil.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value));
                }

                foreach (KeyValuePair <string, int> x in reports.Negocio)
                {
                    Negocio.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value));
                }

                foreach (KeyValuePair <string, int> x in reports.Setor)
                {
                    Setor.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value));
                }

                if (Perfil.Count > 0)
                {
                    BarChart bc = new BarChart();

                    bc.Title       = string.Format("Periodo entre {0} e {1}", reports.Periodo[0], reports.Periodo[1]);
                    bc.ItemsSource = Perfil;

                    _chart.Add(bc);
                }

                if (Negocio.Count > 0)
                {
                    BarChart bc = new BarChart();

                    bc.Title       = string.Format("Pessoas / Potencial Empreendedor");
                    bc.ItemsSource = Negocio;

                    _chart.Add(bc);
                }

                if (Sexo.Count > 0)
                {
                    BarChart bc = new BarChart();

                    bc.Title       = string.Format("Pessoas / Sexo");
                    bc.ItemsSource = Sexo;

                    _chart.Add(bc);
                }

                if (Setor.Count > 0)
                {
                    BarChart bc = new BarChart();

                    bc.Title       = string.Format("Pessoas / Setor");
                    bc.ItemsSource = Setor;

                    _chart.Add(bc);
                }
            }

            return(_chart);
        }
Example #2
0
        private FlowDocument PreviewInTable(mReportPessoas obj)
        {
            try
            {
                FlowDocument flow = new FlowDocument();

                flow.ColumnGap  = 0;
                flow.Background = Brushes.White;
                //flow.ColumnWidth = 8.5 * 96.0;
                //flow.ColumnWidth =  96.0 * 8.5;
                //flow.PageHeight = 11.5 * 96.0;
                //flow.PageWidth = 8.5 * 96.0;
                flow.PageHeight    = 768;
                flow.PageWidth     = 1104;
                flow.ColumnWidth   = 1104;
                flow.FontFamily    = new FontFamily("Segoe UI");
                flow.FontSize      = 11;
                flow.PagePadding   = new Thickness(40, 20, 40, 20);
                flow.TextAlignment = TextAlignment.Left;

                Paragraph pH = new Paragraph(new Run(new mFlowHeader().NameOrg));
                pH.Typography.Capitals = FontCapitals.SmallCaps;
                pH.Foreground          = Brushes.Black;
                pH.FontSize            = 16;
                pH.FontWeight          = FontWeights.Bold;
                pH.Margin = new Thickness(0);

                Paragraph pH1 = new Paragraph(new Run(new mFlowHeader().SloganOrg));
                pH1.Foreground = Brushes.Black;
                pH1.FontSize   = 9;
                pH1.Margin     = new Thickness(1, 0, 0, 0);

                Paragraph pH2 = new Paragraph(new Run(new mFlowHeader().DepOrg));
                pH2.Typography.Capitals = FontCapitals.SmallCaps;
                pH2.Foreground          = Brushes.Black;
                pH2.FontWeight          = FontWeights.Bold;
                pH2.FontSize            = 12;
                pH2.Margin = new Thickness(0, 10, 0, 0);

                Paragraph pH3 = new Paragraph(new Run(new mFlowHeader().SetorOrg));
                pH3.Typography.Capitals = FontCapitals.SmallCaps;
                pH3.FontWeight          = FontWeights.Bold;
                pH3.Foreground          = Brushes.Black;
                pH3.Margin = new Thickness(0, 0, 0, 20);

                flow.Blocks.Add(pH);
                flow.Blocks.Add(pH1);
                flow.Blocks.Add(pH2);
                flow.Blocks.Add(pH3);

                #region Tabela
                Table tb = new Table();
                tb.CellSpacing     = 0;
                tb.BorderThickness = new Thickness(0.5);
                tb.BorderBrush     = Brushes.Black;

                foreach (KeyValuePair <string, int> x in obj.Perfil)
                {
                    tb.Columns.Add(new TableColumn()
                    {
                        Width = GridLength.Auto
                    });
                }

                TableRowGroup rg = new TableRowGroup();

                string f = string.Empty;
                foreach (string filtro in Filtros)
                {
                    f += filtro;
                }

                TableRow pheader = new TableRow();
                pheader.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("PERFIL DE PESSOAS ATENDIDAS ENTRE {0} {1}", Parametros()[0], Parametros()[1])))
                {
                    Padding = new Thickness(5)
                })
                {
                    ColumnSpan = obj.Perfil.Count, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                });

                tb.RowGroups.Add(rg);

                TableRow header = new TableRow();
                rg.Rows.Add(pheader);
                rg.Rows.Add(header);
                rg.Foreground = Brushes.Black;

                foreach (KeyValuePair <string, int> x in obj.Perfil)
                {
                    header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(x.Key)))
                    {
                        Padding = new Thickness(5)
                    })
                    {
                        BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                    });
                }

                if (obj != null)
                {
                    TableRow row = new TableRow();
                    rg.Foreground = Brushes.Black;
                    rg.Rows.Add(row);

                    foreach (KeyValuePair <string, int> x in obj.Perfil)
                    {
                        row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString()))
                        {
                            Padding = new Thickness(5)
                        })
                        {
                            BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                        });
                    }
                }

                flow.Blocks.Add(tb);
                #endregion

                #region Tabela 1
                Table tb1 = new Table();
                tb1.Foreground      = Brushes.Black;
                tb1.CellSpacing     = 0;
                tb1.BorderThickness = new Thickness(0.5);
                tb1.BorderBrush     = Brushes.Black;

                tb1.Columns.Add(new TableColumn()
                {
                    Width = GridLength.Auto
                });
                tb1.Columns.Add(new TableColumn()
                {
                    Width = new GridLength(100)
                });

                TableRowGroup rg1 = new TableRowGroup();
                rg1.Foreground = Brushes.Black;

                TableRow hcnae = new TableRow();
                hcnae.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(string.Format("PESSOAS POR SEXO"))))
                {
                    Padding = new Thickness(5)
                })
                {
                    ColumnSpan = 2, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                });

                tb1.RowGroups.Add(rg1);
                rg1.Rows.Add(hcnae);

                if (obj != null)
                {
                    foreach (KeyValuePair <string, int> x in obj.Sexo)
                    {
                        TableRow row = new TableRow();
                        rg1.Foreground = Brushes.Black;
                        rg1.Rows.Add(row);
                        row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key))
                        {
                            Padding = new Thickness(5)
                        })
                        {
                            BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                        });
                        row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString()))
                        {
                            Padding = new Thickness(5)
                        })
                        {
                            BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                        });
                    }
                }

                flow.Blocks.Add(tb1);
                #endregion

                #region Tabela 2
                Table tb2 = new Table();
                tb2.Foreground      = Brushes.Black;
                tb2.CellSpacing     = 0;
                tb2.BorderThickness = new Thickness(0.5);
                tb2.BorderBrush     = Brushes.Black;

                tb2.Columns.Add(new TableColumn()
                {
                    Width = GridLength.Auto
                });
                tb2.Columns.Add(new TableColumn()
                {
                    Width = new GridLength(100)
                });

                TableRowGroup rg2 = new TableRowGroup();

                TableRow tbairro = new TableRow();
                tbairro.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(string.Format("PESSOAS POR BAIRRO"))))
                {
                    Padding = new Thickness(5)
                })
                {
                    ColumnSpan = 2, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                });

                tb2.RowGroups.Add(rg2);

                rg2.Rows.Add(tbairro);

                if (obj != null)
                {
                    foreach (KeyValuePair <string, int> x in obj.Setor)
                    {
                        TableRow row = new TableRow();
                        rg2.Foreground = Brushes.Black;
                        rg2.Rows.Add(row);
                        row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key))
                        {
                            Padding = new Thickness(5)
                        })
                        {
                            BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                        });
                        row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString()))
                        {
                            Padding = new Thickness(5)
                        })
                        {
                            BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                        });
                    }
                }

                flow.Blocks.Add(tb2);
                #endregion

                Paragraph r = new Paragraph();
                r.Margin   = new Thickness(0, 0, 0, 0);
                r.FontSize = 10;

                System.Reflection.Assembly         assembly = System.Reflection.Assembly.GetExecutingAssembly();
                System.Diagnostics.FileVersionInfo fvi      = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
                string version = fvi.FileVersion;

                //r.Inlines.Add(lrodape);
                r.Inlines.Add(new Run(AppDomain.CurrentDomain.FriendlyName.ToUpper()));
                r.Inlines.Add(new Run(" / V" + version + " / "));
                r.Inlines.Add(new Bold(new Run(Account.Logged.Nome)));
                r.Inlines.Add(new Run(" / " + DateTime.Now.ToString("dd.MM.yyyy")));
                r.Inlines.Add(new Run(" / " + DateTime.Now.ToLongTimeString()));

                flow.Blocks.Add(r);

                return(flow);
            }
            catch
            {
                return(new FlowDocument());
            }
        }