Esempio n. 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public EffectiveReport
        (
            [NotNull] IrbisProvider provider
        )
        {
            Provider = provider;
            Context  = new ReportContext(provider);

            Header = new HeaderBand();
            Header.Cells.Add(new TextCell("КСУ",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Дата",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Сигла",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("ББК",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Назв.",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Экз.",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Руб.",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Выдач",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Выд./экз.",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Руб/выд.",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Выд/день",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Чит. эффект.",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
            Header.Cells.Add(new TextCell("Фин. эффект.",
                                          new ReportAttribute(ReportAttribute.Bold, true)));
        }
Esempio n. 2
0
        public override string ToString()
        {
            string alternateRowCss = string.Empty;

            HtmlTable table = new HtmlTable();

            if (!string.IsNullOrEmpty(Id))
            {
                table.Id = Id;
            }

            if (Css != default(GridCss))
            {
                if (!string.IsNullOrEmpty(Css.Name))
                {
                    table.Attributes["class"] = Css.Name;
                }
                alternateRowCss = Css.AlternateRow;
            }

            table.Style             = Style.TableStyle;
            table.RowStyle          = Style.RowStyle;
            table.AlternateRowStyle = Style.AlternateRowStyle;

            table.Header.Style = Style.HeaderStyle;
            table.Footer.Style = Style.FooterStyle;

            // header
            if (!string.IsNullOrEmpty(Title))
            {
                var tr = table.Header.CreateRow();
                var th = tr.CreateCell();
                th.ColumnSpan = (Columns != null && Columns.Count > 0) ?Columns.Count: 1;
                th.SetValue(Style.TitleStyle != default(HtmlStyle)?
                            (new HtmlParagragh {
                    Text = Title, Style = Style.TitleStyle
                }).ToString():
                            Title
                            );
                tr.AddCell(th);
                table.Header.AddRow(tr);
            }

            if (HeaderBand != default(TagBase))
            {
                var hbr = table.Header.CreateRow();
                var hbc = hbr.CreateCell();
                hbc.Style.TextAlign  = "left";
                hbc.Style.FontWeight = "normal";
                hbc.ColumnSpan       = (Columns != null && Columns.Count > 0) ?Columns.Count: 1;
                hbc.InnerHtml        = HeaderBand.ToString();
                hbr.AddCell(hbc);
                table.Header.AddRow(hbr);
            }

            var trh    = table.Header.CreateRow();
            int number = 0;
            int filled = 0;

            foreach (var column in Columns)
            {
                var th = trh.CreateCell();
                th.Style = column.HeaderCellStyle;

                if (column.HeaderCellColumnSpan.HasValue && column.HeaderCellColumnSpan.Value != default(int))
                {
                    th.ColumnSpan = column.HeaderCellColumnSpan;
                }

                if (!string.IsNullOrEmpty(column.HeaderText))
                {
                    th.SetValue(column.HeaderText);
                    filled += ((th.ColumnSpan.HasValue && th.ColumnSpan.Value > 0)?th.ColumnSpan.Value:1);
                }
                else if (number == filled)
                {
                    th.Attributes.Add("height", "0");
                    th.SetValue();
                    filled++;
                }
                trh.AddCell(th);
                number++;
                if (filled >= (Columns.Count))
                {
                    break;
                }
            }
            table.Header.AddRow(trh);

            // TBody
            if (DataSource == null || Columns.Count == 0)
            {
                return(table.ToString());
            }


            foreach (var data in DataSource)
            {
                var dr = table.CreateRow(alternateRowCss);
                foreach (var column in Columns)
                {
                    var dt = dr.CreateCell();
                    dr.CellStyle = column.CellStyle;
                    if (column.CellRenderFunc != null)
                    {
                        dt.SetValue(column.CellRenderFunc(data, table.RowsCount - 1));
                    }
                    else
                    {
                        dt.SetValue("");
                    }
                    dr.AddCell(dt);
                }
                table.AddRow(dr);
            }

            // Footer
            var trf = table.Footer.CreateRow();

            number = 0; filled = 0;
            foreach (var column in Columns)
            {
                var th = trf.CreateCell();
                th.Style = column.FooterCellStyle;

                if (column.FooterCellColumnSpan.HasValue && column.FooterCellColumnSpan.Value != default(int))
                {
                    th.ColumnSpan = column.FooterCellColumnSpan;
                }

                if (column.FooterRenderFunc != null)
                {
                    th.SetValue(column.FooterRenderFunc());
                    filled += ((th.ColumnSpan.HasValue && th.ColumnSpan.Value > 0)?th.ColumnSpan.Value:1);
                }
                else if (number == filled)
                {
                    th.Attributes.Add("height", "0");
                    th.SetValue();
                    filled++;
                }
                trf.AddCell(th);
                number++;
                if (filled >= (Columns.Count))
                {
                    break;
                }
            }
            table.Footer.AddRow(trf);


            if (FooterBand != default(TagBase))
            {
                var fbr = table.Footer.CreateRow();
                var fbc = fbr.CreateCell();
                fbc.Style.TextAlign  = "left";
                fbc.Style.FontWeight = "normal";
                fbc.ColumnSpan       = (Columns != null && Columns.Count > 0) ?Columns.Count: 1;
                fbc.InnerHtml        = FooterBand.ToString();
                fbr.AddCell(fbc);
                table.Footer.AddRow(fbr);
            }


            if (!string.IsNullOrEmpty(FootNote))
            {
                var tr = table.Footer.CreateRow();
                var th = tr.CreateCell();
                th.ColumnSpan = (Columns != null && Columns.Count > 0) ?Columns.Count: 1;
                th.SetValue(Style.FootNoteStyle != default(HtmlStyle)?
                            (new HtmlParagragh {
                    Text = FootNote, Style = Style.FootNoteStyle
                }).ToString():
                            FootNote
                            );
                tr.AddCell(th);
                table.Footer.AddRow(tr);
            }

            return(table.ToString());
        }