Ejemplo n.º 1
0
        static void InitDetailsBasedonXRTableRepeatingRowHeader(XtraReport rep, ReportGeneratorType kind, int columnWidth)
        {
            Font      font            = new Font("Tahoma", 9.75f);
            DataTable dataTable       = ((DataSet)rep.DataSource).Tables[0];
            int       processedPage   = 0;
            int       usablePageWidth = rep.PageWidth - (rep.Margins.Left + rep.Margins.Right);

            List <int> columnsWidth = null;

            if (kind == ReportGeneratorType.FixedColumnWidth)
            {
                columnsWidth = DefineColumnsWidth(columnWidth, dataTable.Columns.Count);
            }
            else
            {
                columnsWidth = GetColumnsBestFitWidth(dataTable, font);
            }

            XRTable tableHeader = null;
            XRTable tableDetail = null;

            InitNewTableInstancesAt(rep, font, out tableHeader, out tableDetail, new PointF(0, 0));
            tableHeader.BeginInit();
            tableDetail.BeginInit();
            int i = 1;

            AddCellsToTables(tableHeader, tableDetail, dataTable.Columns[0], columnsWidth[0], true);
            int remainingSpace = usablePageWidth - columnsWidth[0];

            do
            {
                if (columnsWidth[i] > remainingSpace)
                {
                    processedPage++;
                    tableHeader.WidthF = usablePageWidth - remainingSpace;
                    tableDetail.WidthF = usablePageWidth - remainingSpace;
                    tableHeader.EndInit();
                    tableDetail.EndInit();
                    InitNewTableInstancesAt(rep, font, out tableHeader, out tableDetail, new PointF(usablePageWidth * processedPage, 0));
                    tableHeader.BeginInit();
                    tableDetail.BeginInit();
                    AddCellsToTables(tableHeader, tableDetail, dataTable.Columns[0], columnsWidth[0], true);
                    remainingSpace = usablePageWidth - columnsWidth[0];
                }
                else
                {
                    AddCellsToTables(tableHeader, tableDetail, dataTable.Columns[i], columnsWidth[i], false);
                    remainingSpace -= columnsWidth[i];
                    i++;
                }
            }while(i < columnsWidth.Count);
            tableHeader.WidthF = usablePageWidth - remainingSpace;
            tableDetail.WidthF = usablePageWidth - remainingSpace;
            tableHeader.EndInit();
            tableDetail.EndInit();
        }
Ejemplo n.º 2
0
        public XRTable CreateXRTable(DataTable dt)
        {
            int     cellsInRow = 3;
            int     rowsCount  = 3;
            float   rowHeight  = 25f;
            XRTable table      = new XRTable();

            table.Borders = DevExpress.XtraPrinting.BorderSide.All;
            table.BeginInit();

            for (int i = 0; i < rowsCount; i++)
            {
                XRTableRow row = new XRTableRow();
                row.HeightF = rowHeight;
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    XRTableCell cell = new XRTableCell();
                    if (j == 1)
                    {
                        cell.Text = @"tên cán bộ";
                    }

                    cell.Text = dt.Rows[0][j].ToString();
                    row.Cells.Add(cell);
                    table.Rows.Add(row);
                }
            }

            table.BeforePrint += new PrintEventHandler(table_BeforePrint);
            //.AdjustSize();
            table.EndInit();
            return(table);
        }
Ejemplo n.º 3
0
        public XRTable CreateXRTable()
        {
            // Create an empty table and set its size.
            XRTable table = new XRTable();

            table.Size = new Size(300, 100);

            // Start table initialization.
            table.BeginInit();

            // Enable table borders to see its boundaries.
            table.BorderWidth = 2;
            table.Borders     = DevExpress.XtraPrinting.BorderSide.All;

            // Create a table row.
            XRTableRow row = new XRTableRow();

            // Create two table cells.
            XRTableCell cell0 = new XRTableCell();
            XRTableCell cell1 = new XRTableCell();

            // Construct the table.
            row.Cells.Add(cell0);
            row.Cells.Add(cell1);
            table.Rows.Add(row);

            // Finish table initialization.
            table.EndInit();

            return(table);
        }
Ejemplo n.º 4
0
        private void printHeader(Dictionary <string, string> parameters)
        {
            if (parameters.Count == 0)
            {
                return;
            }


            XRTable table = new XRTable();

            table.BeginInit();


            table.LocationF = new PointF(0, 0);
            int        count = 0;
            XRTableRow row   = new XRTableRow();

            foreach (KeyValuePair <string, string> item in parameters)
            {
                XRTableCell cell = new XRTableCell();

                cell.Text = item.Key;

                cell.BackColor = Color.Gray;
                cell.ForeColor = Color.White;

                XRTableCell valueCell = new XRTableCell();

                valueCell.Text = item.Value;

                row.Cells.Add(cell);
                row.Cells.Add(valueCell);

                count++;
                if (count % 4 == 0)
                {
                    table.Rows.Add(row);
                    row = new XRTableRow();
                }
            }
            if (count % 4 != 0)
            {
                for (int i = 0; i < (4 - (count % 4)) * 2; i++)
                {
                    XRTableCell cell = new XRTableCell();



                    row.Cells.Add(cell);
                }
                table.Rows.Add(row);
            }
            table.BeforePrint += new PrintEventHandler(table_BeforePrint);
            table.AdjustSize();
            table.EndInit();



            this.PageHeader.Controls.Add(table);
        }
        public static XRTable GetHeaderTable(List <string> fields, float tableSize)
        {
            var table = new XRTable();

            table.BeginInit();

            table.LocationF = new DevExpress.Utils.PointFloat(0F, 0F);
            table.Borders   = DevExpress.XtraPrinting.BorderSide.All;

            var   tableRow = new XRTableRow();
            float cellSize = tableSize / fields.Count;

            foreach (var field in fields)
            {
                var cell = new XRTableCell()
                {
                    Text      = field,
                    WidthF    = cellSize,
                    BackColor = System.Drawing.Color.Gray
                };
                tableRow.Cells.Add(cell);
            }

            table.Rows.Add(tableRow);

            table.AdjustSize();

            table.EndInit();

            return(table);
        }
Ejemplo n.º 6
0
        public XRTable CreateXRTable()
        {
            int   cellsInRow = 3;
            int   rowsCount  = 3;
            float rowHeight  = 25f;

            XRTable table = new XRTable();

            table.Borders = DevExpress.XtraPrinting.BorderSide.All;
            table.BeginInit();

            for (int i = 0; i < rowsCount; i++)
            {
                XRTableRow row = new XRTableRow();
                row.HeightF = rowHeight;
                for (int j = 0; j < cellsInRow; j++)
                {
                    XRTableCell cell = new XRTableCell();
                    row.Cells.Add(cell);
                }
                table.Rows.Add(row);
            }

            table.BeforePrint += new PrintEventHandler(table_BeforePrint);
            table.AdjustSize();
            table.EndInit();
            return(table);
        }
Ejemplo n.º 7
0
        void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            var     schedule = (Schedule_Report)GetCurrentRow();
            XRTable table    = new XRTable()
            {
                SizeF = new System.Drawing.SizeF(xrPanel2.WidthF, 25F)
            };

            table.BeginInit();
            XRTableRow row = new XRTableRow();

            row.KeepTogether = false;

            foreach (var shift in schedule.ShiftPlans)
            {
                XRTableCell cell = new XRTableCell {
                    WidthF = xrPanel2.WidthF / schedule.ShiftPlans.Count
                };
                row.Cells.Add(cell);

                CreateShiftPlanTables(cell, shift, ShiftPlan_Report.GetTrackedResources(shift).ToList());
            }
            table.Rows.Add(row);
            table.EndInit();

            xrPanel2.KeepTogether = false;
            xrPanel2.Controls.Clear();
            xrPanel2.Controls.Add(table);
        }
        private void AddContent(DataTable table)
        {
            XRTable dynamicTable = XRTable.CreateTable(
                new Rectangle(0,
                              0,
                              TableWidth,
                              20),
                1,
                0);

            dynamicTable.Width = TableWidth;
            dynamicTable.Rows.FirstRow.Width = TableWidth;
            dynamicTable.Borders             = DevExpress.XtraPrinting.BorderSide.All;
            dynamicTable.BorderWidth         = 1;
            int i = 0;

            dynamicTable.BeginInit();
            foreach (DataColumn dc in table.Columns)
            {
                XRTableCell cell = new XRTableCell();

                XRBinding binding = new XRBinding("Text", table, table.Columns[i].ColumnName);
                cell.DataBindings.Add(binding);
                cell.CanGrow = false;
                cell.Width   = 100;
                cell.Text    = dc.ColumnName;
                dynamicTable.Rows.FirstRow.Cells.Add(cell);
                i++;
            }
            dynamicTable.Font = new Font("Verdana", 8F);
            dynamicTable.EndInit();
            Detail.HeightF = 20f;
            Detail.Controls.Add(dynamicTable);
        }
        public void DataxrCrossTabChange()
        {
            string    projectnostring = ProjectNOxrLabel.Text.Split('-')[1] + '-' + ProjectNOxrLabel.Text.Split('-')[2];
            var       costoffer       = SQLMethod.Count_Costofferform(projectnostring);
            var       grammar         = $"USE [PurchaseProcessSystemDB] Select ProjectName as '名稱',ProjectUnit as '單位',ProjectAmount as '數量',Remark as '備註' FROM Costofferform Where ProjectCode = '{projectnostring}'";
            DataTable dataTable       = SQLMethod.OutPutTable(grammar);

            // Create a table and add it to the detail band.
            XRTable xRTable = new XRTable();

            Detail.Controls.Add(xRTable);
            int numRows = dataTable.Rows.Count;
            int numCols = dataTable.Columns.Count;

            xRTable.BeginInit();
            for (int i = 0; i < numRows; i++)
            {
                XRTableRow xRTableRow = new XRTableRow();
                xRTable.Rows.Add(xRTableRow);
                for (int j = 0; j < numCols; j++)
                {
                    XRTableCell xRTableCell = new XRTableCell();
                    xRTable.Rows[i].Cells.Add(xRTableCell);
                    xRTableCell.Text = dataTable.Rows[i][j].ToString();
                }
            }
            xRTable.HeightF       = 38 * numRows;
            xRTable.WidthF        = 777;
            xRTable.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            xRTable.Borders       = DevExpress.XtraPrinting.BorderSide.All;
            xRTable.EndInit();
        }
Ejemplo n.º 10
0
        public XRTable CreateXRTable()
        {
            int cellsInRow = 3;
            int rowsCount = 31;
            float rowHeight = 100f;

            XRTable table = new XRTable();
            table.Borders = DevExpress.XtraPrinting.BorderSide.All;
            table.BeginInit();

            for (int i = 0; i < rowsCount; i++)
            {
                XRTableRow row = new XRTableRow();
                row.HeightF = rowHeight;
                for (int j = 0; j < cellsInRow; j++)
                {
                    XRTableCell cell = new XRTableCell();
                    row.Cells.Add(cell);
                }
                table.Rows.Add(row);
            }

            table.BeforePrint += new PrintEventHandler(table_BeforePrint);
            table.EndInit();
            return table;
        }
        public static XRTable GetTableBoundToData(List <string> fields, float tableSize)
        {
            var table = new XRTable();

            table.BeginInit();

            table.LocationF = new DevExpress.Utils.PointFloat(0F, 0F);
            table.Borders   = DevExpress.XtraPrinting.BorderSide.Left
                              | DevExpress.XtraPrinting.BorderSide.Right
                              | DevExpress.XtraPrinting.BorderSide.Bottom;

            var   tableRow = new XRTableRow();
            float cellSize = tableSize / fields.Count;

            foreach (var field in fields)
            {
                var cell = new XRTableCell()
                {
                    Text   = field,
                    WidthF = cellSize
                };
                cell.ExpressionBindings.Add(new ExpressionBinding("Text", $"[{field}]"));
                tableRow.Cells.Add(cell);
            }

            table.Rows.Add(tableRow);

            table.AdjustSize();
            table.EndInit();

            return(table);
        }
Ejemplo n.º 12
0
        public XRTable EncabezadoMesesXRTable()
        {
            int   lnColumasDinamicas = (1 + Math.Abs((Convert.ToDateTime(FechaInicial.Value).Month - Convert.ToDateTime(FechaFinal.Value).Month) + 12 * (Convert.ToDateTime(FechaInicial.Value).Year - Convert.ToDateTime(FechaFinal.Value).Year)));
            int   lnFilasDinamicas   = 2;
            float lfAlturaFila       = 22;

            XRTable loTabladetalle = new XRTable();

            loTabladetalle.Borders = DevExpress.XtraPrinting.BorderSide.None;
            loTabladetalle.BeginInit();

            for (int lnFila = 1; lnFila < lnFilasDinamicas; lnFila++)
            {
                XRTableRow row = new XRTableRow();
                row.HeightF = lfAlturaFila;
                for (int lnColumna = 1; lnColumna < lnColumasDinamicas + 1; lnColumna++)
                {
                    XRTableCell cell = new XRTableCell();
                    cell.Width = 120;
                    cell.Text  = Convert.ToDateTime(FechaInicial.Value).AddMonths(lnColumna - 1).ToString("MMMM", CultureInfo.CreateSpecificCulture("es-MX")).ToUpper().Substring(0, 3) + ". " + Convert.ToDateTime(FechaInicial.Value).Year;
                    cell.Name  = "xrAgrupadoMeses" + lnColumna;
                    cell.StylePriority.UseTextAlignment = false;
                    cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                    row.Cells.Add(cell);
                }
                loTabladetalle.Rows.Add(row);
            }
            loTabladetalle.BeforePrint += new PrintEventHandler(EncabezadoMesesXRTable_BeforePrint);
            loTabladetalle.AdjustSize();
            loTabladetalle.EndInit();
            return(loTabladetalle);
        }
Ejemplo n.º 13
0
        static void InitDetailsBasedonXRTableWithoutRepeatingRowHeader(XtraReport rep, ReportGeneratorType kind, int columnWidth)
        {
            Font    font     = new Font("Tahoma", 9.75f);
            DataSet ds       = ((DataSet)rep.DataSource);
            int     colCount = ds.Tables[0].Columns.Count;
            int     colWidth = 0;



            XRTable tableHeader = null;
            XRTable tableDetail = null;

            InitNewTableInstancesAt(rep, font, out tableHeader, out tableDetail, new PointF(0, 0));


            List <int> columnsWidth = null;

            switch (kind)
            {
            case ReportGeneratorType.FixedColumnWidth:
                colWidth          = columnWidth;
                tableHeader.Width = columnWidth * colCount;
                tableDetail.Width = columnWidth * colCount;
                break;

            case ReportGeneratorType.BestFitColumns:
                columnsWidth      = GetColumnsBestFitWidth(ds.Tables[0], font);
                colWidth          = 0;
                tableHeader.Width = GetTotalWidth(columnsWidth);
                tableDetail.Width = tableHeader.Width;
                break;

            default:
                colWidth          = (rep.PageWidth - (rep.Margins.Left + rep.Margins.Right)) / colCount;
                tableHeader.Width = (rep.PageWidth - (rep.Margins.Left + rep.Margins.Right));
                tableDetail.Width = (rep.PageWidth - (rep.Margins.Left + rep.Margins.Right));
                break;
            }

            tableHeader.BeginInit();
            tableDetail.BeginInit();
            // Create table cells, fill the header cells with text, bind the cells to data
            for (int i = 0; i < colCount; i++)
            {
                AddCellsToTables(tableHeader, tableDetail, ds.Tables[0].Columns[i], kind == ReportGeneratorType.BestFitColumns ? columnsWidth[i] : colWidth, i == 0 ? true : false);
            }
            tableDetail.EndInit();
            tableHeader.EndInit();
            // Place the table onto a report's Detail band
        }
Ejemplo n.º 14
0
        XRTable CreateTable(XRTableRow sourceRow, float height)
        {
            XRTable    table          = new XRTable();
            XRTableRow headerTableRow = new XRTableRow();

            table.BeginInit();
            table.Rows.Add(headerTableRow);
            foreach (XRTableCell cell in sourceRow.Cells)
            {
                CopyCell(cell, headerTableRow);
            }
            table.Borders   = DevExpress.XtraPrinting.BorderSide.All;
            table.LocationF = new PointF(0, height);
            table.AdjustSize();
            table.EndInit();
            return(table);
        }
Ejemplo n.º 15
0
        private void CreateMasterReportControls(XtraReport report)
        {
            XRTable tbl = new XRTable();

            tbl.BeginInit();
            XRTableRow row = new XRTableRow();

            row.HeightF = 40;
            SqlDataSource ds              = report.DataSource as SqlDataSource;
            string        dataMember      = report.DataMember;
            ITable        categoriesTable = ds.Result[dataMember] as ITable;

            foreach (IColumn col in categoriesTable.Columns)
            {
                if (col.Type == typeof(byte[]))
                {
                    continue;
                }
                XRTableCell cell = new XRTableCell();
                cell.DataBindings.Add(new XRBinding("Text", null, string.Format("{0}.{1}", dataMember, col.Name)));
                if (col.Name == "CategoryName")
                {
                    cell.Font = new System.Drawing.Font(cell.Font.FontFamily, 14f, System.Drawing.FontStyle.Underline | System.Drawing.FontStyle.Bold);
                    cell.DataBindings.Add(new XRBinding("Tag", null, string.Format("{0}.{1}", dataMember, "CategoryID")));
                    cell.ForeColor   = System.Drawing.Color.Blue;
                    cell.NavigateUrl = " ";
                }
                row.Cells.Add(cell);
            }
            tbl.Rows.Add(row);
            tbl.BeforePrint += tbl_BeforePrint;
            tbl.AdjustSize();
            tbl.EndInit();
            DetailBand detailBand = null;

            if (report.Bands[BandKind.Detail] == null)
            {
                report.Bands.Add(new DetailBand());
            }
            detailBand           = report.Bands[BandKind.Detail] as DetailBand;
            detailBand.HeightF   = tbl.HeightF + 2;
            detailBand.PageBreak = PageBreak.AfterBand;
            detailBand.Controls.Add(tbl);
        }
Ejemplo n.º 16
0
        public XRTable DetalleVentaXRTable()
        {
            int   lnColumasDinamicas        = (1 + Math.Abs((Convert.ToDateTime(FechaInicial.Value).Month - Convert.ToDateTime(FechaFinal.Value).Month) + 12 * (Convert.ToDateTime(FechaInicial.Value).Year - Convert.ToDateTime(FechaFinal.Value).Year))) * 2;
            int   lnFilasDinamicas          = 2;
            int   lnIndicadorColumnaDetalle = 1;
            float lfAlturaFila = 22;

            XRTable loTabladetalle = new XRTable();

            loTabladetalle.Borders = DevExpress.XtraPrinting.BorderSide.None;
            loTabladetalle.BeginInit();

            for (int lnFila = 1; lnFila < lnFilasDinamicas; lnFila++)
            {
                XRTableRow row = new XRTableRow();
                row.HeightF = lfAlturaFila;
                for (int lnColumna = 1; lnColumna < lnColumasDinamicas + 1; lnColumna++)
                {
                    loBinding = "Query.AGRUPADOR" + lnIndicadorColumnaDetalle + "_ART_CANTIDAD";
                    if (lnColumna % 2 == 0)
                    {
                        loBinding = "Query.AGRUPADOR" + lnIndicadorColumnaDetalle + "_IMPORTE";
                        lnIndicadorColumnaDetalle = lnIndicadorColumnaDetalle + 1;
                    }
                    XRTableCell cell = new XRTableCell();
                    cell.Width = 60;
                    cell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                        new DevExpress.XtraReports.UI.XRBinding("Text", null, loBinding, "{0:n2}")
                    });
                    cell.Name = "xrAgrupado" + lnColumna;
                    cell.StylePriority.UseTextAlignment = false;
                    cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
                    row.Cells.Add(cell);
                }
                loTabladetalle.Rows.Add(row);
            }
            loTabladetalle.BeforePrint += new PrintEventHandler(DetalleVentaXRTable_BeforePrint);
            loTabladetalle.AdjustSize();
            loTabladetalle.EndInit();
            return(loTabladetalle);
        }
Ejemplo n.º 17
0
        public XRTable EncabezadoPzasImporteXRTable()
        {
            int   lnColumasDinamicas        = (1 + Math.Abs((Convert.ToDateTime(FechaInicial.Value).Month - Convert.ToDateTime(FechaFinal.Value).Month) + 12 * (Convert.ToDateTime(FechaInicial.Value).Year - Convert.ToDateTime(FechaFinal.Value).Year))) * 2;
            int   lnFilasDinamicas          = 2;
            int   lnIndicadorColumnaDetalle = 1;
            float lfAlturaFila = 22;

            XRTable loTabladetalle = new XRTable();

            loTabladetalle.Borders = DevExpress.XtraPrinting.BorderSide.None;
            loTabladetalle.BeginInit();

            for (int lnFila = 1; lnFila < lnFilasDinamicas; lnFila++)
            {
                XRTableRow row = new XRTableRow();
                row.HeightF = lfAlturaFila;
                for (int lnColumna = 1; lnColumna < lnColumasDinamicas + 1; lnColumna++)
                {
                    loBinding = "PIEZAS";
                    if (lnColumna % 2 == 0)
                    {
                        loBinding = "IMPORTE";
                        lnIndicadorColumnaDetalle = lnIndicadorColumnaDetalle + 1;
                    }
                    XRTableCell cell = new XRTableCell();
                    cell.Width = 60;
                    cell.Text  = loBinding;
                    cell.Name  = "xrAgrupadoPzasImporte" + lnColumna;
                    cell.StylePriority.UseTextAlignment = false;
                    cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                    row.Cells.Add(cell);
                }
                loTabladetalle.Rows.Add(row);
            }
            loTabladetalle.BeforePrint += new PrintEventHandler(EncabezadoPzasImporteXRTable_BeforePrint);
            loTabladetalle.AdjustSize();
            loTabladetalle.EndInit();
            return(loTabladetalle);
        }
        private void AddHeaders(DataTable table)
        {
            XRTable headers = XRTable.CreateTable(
                new Rectangle(0,
                              0,
                              TableWidth,
                              20),
                1,
                0);

            headers.BeginInit();
            foreach (DataColumn dc in table.Columns)
            {
                XRTableCell cell = new XRTableCell();
                cell.CanGrow   = false;
                cell.Width     = 100;
                cell.Text      = dc.ColumnName;
                cell.BackColor = Color.LightGray;
                headers.Rows.FirstRow.Cells.Add(cell);
            }
            headers.HeightF = 100f;
            headers.EndInit();
            ReportHeader.Controls.Add(headers);
        }
Ejemplo n.º 19
0
        private XRTable createDetailTable(IEnumerable<ReportRataSoggettoDTO> dataSource, float locationY)
        {
            // ================================
            // Creazione tabella
            // ================================
            var table = new XRTable
            {
                Borders = BorderSide.All,
                BorderWidth = 1f,
                BorderColor = Color.LightGray,
                LocationF = new PointFloat(10F, locationY)
            };
            if (!string.IsNullOrEmpty(_impostazioniReport.BorderColor))
                table.BorderColor = ColorTranslator.FromHtml(_impostazioniReport.BorderColor);

            table.BeginInit();

            var columns = _pianoRatealeHelper.GetColumnList(_report, null, _parameters, _numeroPagina);

            // ------------------------------------------------------
            //  Raggruppamento per unità immobiliare
            // ------------------------------------------------------
            IList<IGrouping<int, ReportRataSoggettoDTO>> dataSourceByUnitaImmobiliare = !_parameters.TotalePerPersona ? dataSource.OrderBy(item => item.OrdineUnitaImmobiliare).ThenByDescending(item => item.TipoNominativo).GroupBy(item => item.IdUnitaImmobiliare).ToList() : dataSource.OrderBy(item => item.Nominativo).ThenByDescending(item => item.TipoNominativo).GroupBy(item => item.IdPersona).ToList();

            var nominativoPrecedente = string.Empty;
            var idPersonaPrecedente = 0;

            foreach (var dataSourceUnitaImmobiliare in dataSourceByUnitaImmobiliare)
            {
                // ------------------------------------------------------
                //  Raggruppamento Proprietario/Conduttore
                // ------------------------------------------------------
                var indexNominativo = 0;
                var idSoggettoCondominioPrecedente = 0;

                var dataSourceByNominativo = dataSourceUnitaImmobiliare.GroupBy(item => item.IdSoggettoCondominio.ToString(CultureInfo.InvariantCulture).PadLeft(5, '0')).ToList();
                foreach (var dataSourceNominativo in dataSourceByNominativo)
                {
                    var itemNominativo = dataSourceNominativo.OrderBy(item => item.NumeroRata).FirstOrDefault();
                    if (itemNominativo != null)
                    {
                        var isArrotondamenti = itemNominativo.OrdineUnitaImmobiliare == int.MaxValue;

                        if (_parameters.TotalePerPersona && idPersonaPrecedente > 0 && idPersonaPrecedente != itemNominativo.IdPersona)
                        {
                            addRowTotale(table, idPersonaPrecedente, TipoTotale.Nominativo, nominativoPrecedente);
                            indexNominativo = 0;
                        }
                        nominativoPrecedente = itemNominativo.Nominativo;
                        idPersonaPrecedente = itemNominativo.IdPersona;

                        var detailRow = new XRTableRow { Width = table.Width };
                        if (_impostazioniReport.RowHeight != null)
                            detailRow.HeightF = _impostazioniReport.RowHeight.Value;
                        if (_impostazioniReport.ArrotondamentiRowHeight != null)
                            detailRow.HeightF = _impostazioniReport.ArrotondamentiRowHeight.Value;


                        table.Rows.Add(detailRow);
                        foreach (var tableColumn in columns)
                        {
                            if (!tableColumn.Hidden && (!isArrotondamenti || tableColumn.ColumnType == ColumnTypeEnum.Nominativo || tableColumn.ColumnType == ColumnTypeEnum.Conto) && (tableColumn.Order != 9997 || _numeroPagina == null || tableColumn.PrintPage == _numeroPagina))
                            {
                                var cell = new XRTableCell();

                                if (!_impostazioniReport.BorderInsideGroup)
                                    setCellBorder(cell, dataSourceByNominativo.Count, indexNominativo);

                                cell.WidthF = tableColumn.Width;
                                cell.Font = GetFont(tableColumn.FontName, tableColumn.FontSize, getFontStyle(tableColumn.FontStyle));
                                
                                if (isArrotondamenti)
                                {
                                    var arrotondamentiFont = GetFont(tableColumn.FontName, tableColumn.FontSize, getFontStyle(tableColumn.FontStyle));
                                    if (!string.IsNullOrEmpty(_impostazioniReport.TotaleFontStyle) && !string.IsNullOrEmpty(_impostazioniReport.ArrotondamentiFontName) && _impostazioniReport.ArrotondamentiFontSize != null)
                                    {
                                        var fontSize = _impostazioniReport.ArrotondamentiFontSize.Value;
                                        if (Math.Abs(fontSize) < _pianoRatealeHelper.GetTolerance())
                                            fontSize = 8;
                                        arrotondamentiFont = GetFont(_impostazioniReport.ArrotondamentiFontName, fontSize, getFontStyle(_impostazioniReport.ArrotondamentiFontStyle));
                                    }
                                    cell.Font = arrotondamentiFont;
                                }

                                if (tableColumn.ColumnType == ColumnTypeEnum.OrdineUnita)
                                {
                                    if (indexNominativo == 0 || _impostazioniReport.OrdineUnitaAllRows)
                                    {
                                        cell.Text = itemNominativo.OrdineUnitaImmobiliare.ToString(CultureInfo.InvariantCulture);
                                        cell.TextAlignment = TextAlignment.MiddleRight;
                                        cell.Padding = getPaddingInfo();
                                    }

                                    if (_impostazioniReport.BorderInsideGroup)
                                        setCellBorder(cell, dataSourceByNominativo.Count, indexNominativo);
                                }

                                if (tableColumn.ColumnType == ColumnTypeEnum.Nominativo)
                                {
                                    if ((!_parameters.TotalePerPersona && itemNominativo.IdSoggettoCondominio != idSoggettoCondominioPrecedente) || _parameters.TotalePerPersona || isArrotondamenti)
                                        cell.Text = itemNominativo.Nominativo;
                                    cell.TextAlignment = TextAlignment.MiddleLeft;
                                    if (itemNominativo.OrdineUnitaImmobiliare == int.MaxValue)
                                    {
                                        cell.TextAlignment = TextAlignment.MiddleRight;
                                        cell.WidthF = _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.OrdineUnita) +
                                                      _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.Nominativo) +
                                                      _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.ProprietaConduzione) +
                                                      _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.Interno) +
                                                      _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.Piano) +
                                                      _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.TipoUnita) +
                                                      _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.Subalterno);
                                    }

                                    cell.Padding = getPaddingInfo();
                                }

                                if (itemNominativo.OrdineUnitaImmobiliare != int.MaxValue)
                                {
                                    if (tableColumn.ColumnType == ColumnTypeEnum.TipoUnita)
                                    {
                                        if (itemNominativo.IdSoggettoCondominio != idSoggettoCondominioPrecedente)
                                            cell.Text = itemNominativo.TipoUnitaImmobiliare;
                                        cell.TextAlignment = TextAlignment.MiddleLeft;
                                        cell.Padding = getPaddingInfo();
                                    }

                                    if (tableColumn.ColumnType == ColumnTypeEnum.Subalterno)
                                    {
                                        if (itemNominativo.IdSoggettoCondominio != idSoggettoCondominioPrecedente)
                                            cell.Text = itemNominativo.SubalternoUnitaImmobiliare;
                                        cell.TextAlignment = TextAlignment.MiddleLeft;
                                        cell.Padding = getPaddingInfo();
                                    }

                                    if (tableColumn.ColumnType == ColumnTypeEnum.Interno)
                                    {
                                        if (itemNominativo.IdSoggettoCondominio != idSoggettoCondominioPrecedente)
                                            cell.Text = itemNominativo.InternoUnitaImmobiliare;
                                        cell.TextAlignment = TextAlignment.MiddleLeft;
                                        cell.Padding = getPaddingInfo();
                                    }

                                    if (tableColumn.ColumnType == ColumnTypeEnum.Piano)
                                    {
                                        if (itemNominativo.IdSoggettoCondominio != idSoggettoCondominioPrecedente)
                                            cell.Text = itemNominativo.PianoUnitaImmobiliare;
                                        cell.TextAlignment = TextAlignment.MiddleRight;
                                        cell.Padding = getPaddingInfo();
                                    }

                                    if (tableColumn.ColumnType == ColumnTypeEnum.ProprietaConduzione)
                                    {
                                        cell.Text = itemNominativo.TipoNominativo.Substring(0, 1).ToUpper();
                                        cell.TextAlignment = TextAlignment.MiddleLeft;
                                        cell.Padding = getPaddingInfo();
                                    }
                                }

                                if (tableColumn.ColumnType == ColumnTypeEnum.Conto)
                                {
                                    cell.TextAlignment = TextAlignment.MiddleRight;
                                    cell.Padding = getPaddingInfo();

                                    var importo = dataSourceNominativo.Where(item => item.NumeroRata == tableColumn.Order).Sum(item => item.Importo);
                                    if (importo != 0)
                                        cell.Text = importo.ToString("c");
                                }

                                detailRow.Cells.Add(cell);                                
                            }
                        }

                        idSoggettoCondominioPrecedente = itemNominativo.IdSoggettoCondominio;
                    }
                    indexNominativo++;
                }
            }

            // Ultimo totale
            if (_parameters.TotalePerPersona && idPersonaPrecedente > 0)
                addRowTotale(table, idPersonaPrecedente, TipoTotale.Nominativo, nominativoPrecedente);

            table.BeforePrint += tableDetailBeforePrint;

            table.AdjustSize();
            table.EndInit();

            return table;
        }
Ejemplo n.º 20
0
        private XRTable createRiepilogoTable(decimal importo, float locationY)
        {
            // ================================
            // Creazione tabella
            // ================================
            var marginTop = 30;
            if (_impostazioniReport.RiepilogoTopMargin != null)
                marginTop = _impostazioniReport.RiepilogoTopMargin.Value;

            var fontRiepilogo = GetFont(_impostazioniReport.FontName, _impostazioniReport.FontSize, FontStyle.Bold);
            if(!string.IsNullOrEmpty(_impostazioniReport.RiepilogoFontName) && _impostazioniReport.RiepilogoFontSize != null)
                fontRiepilogo = GetFont(_impostazioniReport.RiepilogoFontName, _impostazioniReport.RiepilogoFontSize.Value, getFontStyle(_impostazioniReport.RiepilogoFontStyle));

            var fontImportoRiepilogo = (Font)fontRiepilogo.Clone();
            if (!string.IsNullOrEmpty(_impostazioniReport.ImportoRiepilogoFontName) && _impostazioniReport.ImportoRiepilogoFontSize != null)
                fontImportoRiepilogo = GetFont(_impostazioniReport.ImportoRiepilogoFontName, _impostazioniReport.ImportoRiepilogoFontSize.Value, getFontStyle(_impostazioniReport.ImportoRiepilogoFontStyle));

            var table = new XRTable
            {
                Borders = BorderSide.None,
                LocationF = new PointFloat(10F, locationY + marginTop),
                Font = fontRiepilogo,
                Width = 800
            };

            table.BeginInit();

            //if (_parameters.TipoRendiconto == TipoRendiconto.Consuntivo)
            //{
            //    var row = new XRTableRow();
            //    table.Rows.Add(row);

            //    var cellPrompt = new XRTableCell
            //    {
            //        Text = "Saldo Attuale: ",
            //        Font = fontRiepilogo,
            //        TextAlignment = TextAlignment.MiddleLeft,
            //        Padding = new PaddingInfo(5,5,5,5),
            //        Borders = BorderSide.Bottom | BorderSide.Left | BorderSide.Top
            //    };

            //    if (!string.IsNullOrEmpty(_impostazioniReport.RiepilogoText))
            //        cellPrompt.Text = _impostazioniReport.RiepilogoText;

            //    row.Cells.Add(cellPrompt);

            //    var cellValue = new XRTableCell
            //    {
            //        Text = importo.ToString("C"),
            //        Font = fontImportoRiepilogo,
            //        TextAlignment = TextAlignment.MiddleRight,
            //        Padding = new PaddingInfo(5, 5, 5, 5),
            //        Borders = BorderSide.Bottom | BorderSide.Right | BorderSide.Top
            //    };
            //    row.Cells.Add(cellValue);

            //}

            table.AdjustSize();
            table.EndInit();

            return table;
        }
Ejemplo n.º 21
0
        private void addRowHeader(XRTable table)
        {
            // ================================
            // Header Row
            // ================================
            var headerRow = new XRTableRow();
            if(!_parameters.StampaMillesimi.GetValueOrDefault())
                headerRow.Borders = BorderSide.All;
            if (_impostazioniReport.HeaderRowHeight != null)
                headerRow.HeightF = _impostazioniReport.HeaderRowHeight.Value;

            var headerFont = GetFont(_impostazioniReport.FontName, _impostazioniReport.FontSize, getFontStyle(_impostazioniReport.FontStyle));
            if (!string.IsNullOrEmpty(_impostazioniReport.HeaderFontStyle) && !string.IsNullOrEmpty(_impostazioniReport.HeaderFontName) && _impostazioniReport.HeaderFontSize != null)
                headerFont = GetFont(_impostazioniReport.HeaderFontName, _impostazioniReport.HeaderFontSize.Value, getFontStyle(_impostazioniReport.HeaderFontStyle));

            var headerAlignment = TextAlignment.TopCenter;
            if (_impostazioniReport.HeaderAlignment != null)
                headerAlignment = GetTextAlignment(_impostazioniReport.HeaderAlignment);

            var columns = _ripartoHelper.GetColumnList(_report, null, _parameters, _numeroPagina, _parameters.StampaMillesimi.GetValueOrDefault());
            foreach (var tableColumn in columns)
            {
                if (!tableColumn.Hidden && (tableColumn.Order != 9997 || _numeroPagina == null || tableColumn.PrintPage == _numeroPagina))
                {
                    var cell = new XRTableCell
                    {
                        Font = headerFont,
                        Text = tableColumn.Description,
                        TextAlignment = headerAlignment,
                        WidthF = tableColumn.Width
                    };

                    if (tableColumn.ColumnType == ColumnTypeEnum.Conto)
                        cell.BackColor = ColorTranslator.FromHtml(_impostazioniReport.HeaderBackColor);

                    if (_parameters.StampaMillesimi.GetValueOrDefault() && !tableColumn.HideMillesimi)
                    {
                        var tableMillesimi = new XRTable {Borders = BorderSide.None};
                        tableMillesimi.BeginInit();
                        _tablesMillesimi.Add(tableMillesimi);
                        var row1 = new XRTableRow {HeightF = headerRow.HeightF};
                        var cell1 = new XRTableCell
                        {
                            Text = cell.Text,
                            Borders = BorderSide.Bottom,
                            TextAlignment = headerAlignment,
                            Padding = getPaddingInfo(),
                            CanGrow = true,
                            WordWrap = true
                        };

                        cell1.BeforePrint += cell1_BeforePrint;

                        row1.Cells.Add(cell1);
                        tableMillesimi.Rows.Add(row1);

                        var row2 = new XRTableRow {HeightF = headerRow.HeightF };

                        // Cell MILLESIMO
                        // --------------------
                        var cellMillesimo = new XRTableCell
                        {
                            Text = tableColumn.DescriptionMillesimi,
                            TextAlignment = headerAlignment,
                            Borders = BorderSide.Right,
                            Padding = getPaddingInfo()
                        };
                        row2.Cells.Add(cellMillesimo);

                        // Cell IMPORTO
                        // --------------------
                        var cellImporto = new XRTableCell
                        {
                            Borders = BorderSide.Right,
                            Text = tableColumn.DescriptionImporto,
                            TextAlignment = headerAlignment,
                            Padding = getPaddingInfo()
                        };
                        row2.Cells.Add(cellImporto);

                        // Add ROW
                        // --------------------
                        tableMillesimi.Rows.Add(row2);

                        cell.Text = string.Empty;
                        cell.Padding = new PaddingInfo(0, 0, 0, 0);

                        cellMillesimo.WidthF = tableColumn.WidthMillesimi.GetValueOrDefault();
                        cellImporto.WidthF = tableColumn.Width;
                        cell.WidthF = tableColumn.Width + tableColumn.WidthMillesimi.GetValueOrDefault();

                        cell1.Width = cell.Width;

                        cell1.BackColor = cell.BackColor;
                        cellImporto.BackColor = cell.BackColor;
                        cellMillesimo.BackColor = cell.BackColor;

                        tableMillesimi.Width = cell.Width;
                        cell.Controls.Add(tableMillesimi);

                        tableMillesimi.AdjustSize();
                        tableMillesimi.EndInit();
                    }
                    else
                        cell.Padding = getPaddingInfo();

                    headerRow.Cells.Add(cell);
                }

            }

            table.Rows.Add(headerRow);
        }
Ejemplo n.º 22
0
        private XRTable createHeaderTable()
        {
            // ================================
            // Creazione tabella
            // ================================
            var table = new XRTable
            {
                Borders = BorderSide.Top | BorderSide.Left | BorderSide.Right,
                BorderWidth = 1f,
                BorderColor = Color.LightGray
            };
            if (!string.IsNullOrEmpty(_impostazioniReport.BorderColor))
                table.BorderColor = ColorTranslator.FromHtml(_impostazioniReport.BorderColor);
            table.BeginInit();

            addRowHeader(table);

            table.BeforePrint += tableHeaderBeforePrint;
            table.AdjustSize();
            table.EndInit();

            return table;
        }
Ejemplo n.º 23
0
    public void buildDynamicReport(DataSet ds, PageHeaderBand PageHeader, DetailBand Detail)
    {
        // create a table to display header
        XRTable tableHeader = new XRTable();
        tableHeader.BeginInit();

        tableHeader.Width = (this.PageWidth - (this.Margins.Left + this.Margins.Right));
        XRTableRow headerRow = new XRTableRow();
        tableHeader.Rows.Add(headerRow);
        XRTable tableDetail = new XRTable();
        tableDetail.BeginInit();

        tableDetail.Width = (this.PageWidth - (this.Margins.Left + this.Margins.Right));

        XRTable tableDetail2 = new XRTable();
        tableDetail2.BeginInit();
        tableDetail.Height = 20;
        tableDetail.Width = (this.PageWidth - (this.Margins.Left + this.Margins.Right));

        XRTableRow detailRow = new XRTableRow();

        // add detailRow into tableDetails
        tableDetail.Rows.Add(detailRow);

        // loop table headercell and table detailCell
        int i = 0;
        for (i = 0; i < ds.Tables[1].Rows.Count; i++)
        {
            XRTableCell headerCell = new XRTableCell();
            headerCell.Width = Int32.Parse(ds.Tables[1].Rows[i][5].ToString());
            headerCell.Text = ds.Tables[1].Rows[i][3].ToString();
            headerCell.StyleName = ds.Tables[1].Rows[i]["style"].ToString();
            XRTableCell detailCell = new XRTableCell();
            detailCell.StyleName = ds.Tables[1].Rows[i]["style"].ToString();
            detailCell.DataBindings.Add("Text", null, ds.Tables[1].Rows[i]["fieldname"].ToString());

            if (i == 0)
            {
                headerCell.Borders = BorderSide.Left | BorderSide.Top | BorderSide.Bottom;
                detailCell.Borders = BorderSide.Left | BorderSide.Top | BorderSide.Bottom;
            }
            else
            {
                headerCell.Borders = BorderSide.All;
                detailCell.Borders = BorderSide.All;
            }
            headerRow.Cells.Add(headerCell);
            detailRow.Cells.Add(detailCell);
        }

        tableDetail.EndInit();
        tableHeader.EndInit();

        PageHeader.Controls.Add(tableHeader);
        Detail.Controls.Add(tableDetail);

        //this.DataSource = ds;
    }
        public void InitializeBandsUsingXRTable(XtraReport report)
        {
            var ds       = (report.DataSource as DataSet);
            int colCount = ds.Tables[0].Columns.Count;
            int colWidth = (report.PageWidth - (report.Margins.Left + report.Margins.Right)) / colCount;

            // Create a table header.
            var tableHeader = new XRTable();

            tableHeader.Height = 20;
            tableHeader.Width  = (report.PageWidth - (report.Margins.Left + report.Margins.Right));

            var headerRow = new XRTableRow();

            headerRow.Width = tableHeader.Width;
            tableHeader.Rows.Add(headerRow);

            tableHeader.BeginInit();

            // Create a table body.
            var tableBody = new XRTable();

            tableBody.Height = 20;
            tableBody.Width  = (report.PageWidth - (report.Margins.Left + report.Margins.Right));

            var bodyRow = new XRTableRow();

            bodyRow.Width = tableBody.Width;
            tableBody.Rows.Add(bodyRow);
            tableBody.EvenStyleName = "EvenStyle";
            tableBody.OddStyleName  = "OddStyle";

            tableBody.BeginInit();

            // Initialize table header and body cells.
            for (int i = 0; i < colCount; i++)
            {
                var headerCell = new XRTableCell();
                headerCell.Width = colWidth;
                headerCell.Text  = ds.Tables[0].Columns[i].Caption;

                var bodyCell = new XRTableCell();
                bodyCell.Width = colWidth;
                bodyCell.DataBindings.Add("Text", null, ds.Tables[0].Columns[i].Caption);

                if (i == 0)
                {
                    headerCell.Borders = BorderSide.Left | BorderSide.Top | BorderSide.Bottom;
                    bodyCell.Borders   = BorderSide.Left | BorderSide.Top | BorderSide.Bottom;
                }
                else
                {
                    headerCell.Borders = BorderSide.All;
                    bodyCell.Borders   = BorderSide.All;
                }

                headerRow.Cells.Add(headerCell);
                bodyRow.Cells.Add(bodyCell);
            }

            tableHeader.EndInit();
            tableBody.EndInit();

            // Add the table header and body to the corresponding report bands.
            report.Bands[BandKind.PageHeader].Controls.Add(tableHeader);
            report.Bands[BandKind.Detail].Controls.Add(tableBody);
        }
        private void CreateDetailBand(XtraReportBase report, DataTable templateTable, String dataMember, Color backColor, bool useStyles)
        {
            DetailBand detail = new DetailBand();

            report.Bands.Add(detail);
            detail.HeightF = 0;

            // Creating Header and Detail Tables
            XRTable headerTable = new XRTable();

            report.Bands[BandKind.ReportHeader].Controls.Add(headerTable);

            XRTable detailTable = new XRTable();

            detail.Controls.Add(detailTable);

            detailTable.BeginInit();
            headerTable.BeginInit();

            XRTableRow headerRow = new XRTableRow();

            headerTable.Rows.Add(headerRow);

            XRTableRow detailRow = new XRTableRow();

            detailTable.Rows.Add(detailRow);

            int        colCount   = templateTable.Columns.Count;
            XtraReport rootReport = report.RootReport;
            int        pageWidth  = (rootReport.PageWidth - (rootReport.Margins.Left + rootReport.Margins.Right));
            float      colWidth   = pageWidth / colCount;

            //Creating an XRTableCell for each column in the corresponding DataTable
            for (int i = 0; i < colCount; i++)
            {
                XRTableCell headerCell = new XRTableCell();
                headerRow.Cells.Add(headerCell);
                headerCell.WidthF  = colWidth;
                headerCell.Text    = templateTable.Columns[i].Caption;
                headerCell.Borders = DevExpress.XtraPrinting.BorderSide.All;

                XRTableCell detailCell = new XRTableCell();
                detailRow.Cells.Add(detailCell);
                detailCell.WidthF = colWidth;
                string actualDM = string.Empty;
                if (dataMember == string.Empty)
                {
                    actualDM = templateTable.Columns[i].Caption;
                }
                else
                {
                    actualDM = string.Format("{0}.{1}", dataMember, templateTable.Columns[i].Caption);
                }
                detailCell.DataBindings.Add("Text", null, actualDM);
                detailCell.Borders = DevExpress.XtraPrinting.BorderSide.All;
            }

            headerTable.EndInit();
            detailTable.EndInit();

            headerTable.LocationF = new PointF(0, report.Bands[BandKind.ReportHeader].HeightF);
            headerTable.WidthF    = pageWidth;
            headerTable.Font      = new Font(headerTable.Font, FontStyle.Bold);

            detailTable.LocationF = new PointF(0, 0);
            detailTable.WidthF    = pageWidth;
            detailTable.BackColor = backColor;
            //Applying styles if necessary
            if (useStyles)
            {
                detailTable.EvenStyleName = "EvenStyle";
                detailTable.OddStyleName  = "OddStyle";
            }
        }
Ejemplo n.º 26
0
        private void CreateDetailReport(XtraReport report, string dataMember)
        {
            // Create a detail report band and bind it to data.
            DetailReportBand detailReportBand = new DetailReportBand();

            report.Bands.Add(detailReportBand);
            detailReportBand.DataSource = report.DataSource;
            detailReportBand.DataMember = dataMember;

            // ---------Add a header to the detail report.---------------
            ReportHeaderBand detailReportHeader = new ReportHeaderBand();

            detailReportBand.Bands.Add(detailReportHeader);

            XRTable tableHeader = new XRTable();

            tableHeader.BeginInit();
            tableHeader.Rows.Add(new XRTableRow());

            //tableHeader.Borders = BorderSide.All;
            tableHeader.BorderColor   = Color.DarkGray;
            tableHeader.Font          = new Font("Tahoma", 9, System.Drawing.FontStyle.Bold);
            tableHeader.Padding       = 10;
            tableHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;

            XRTableCell cellHeader1 = new XRTableCell();

            cellHeader1.Text = "";
            XRTableCell cellHeader2 = new XRTableCell();

            cellHeader2.Text = "Hours";
            XRTableCell cellHeader3 = new XRTableCell();

            cellHeader3.Text = "Salary";
            //cellHeader2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            XRTableCell cellHeader4 = new XRTableCell();

            cellHeader4.Text = "Exp. Hours";
            XRTableCell cellHeader5 = new XRTableCell();

            cellHeader5.Text = "Time In";
            XRTableCell cellHeader6 = new XRTableCell();

            cellHeader6.Text = "Time Out";
            XRTableCell cellHeader7 = new XRTableCell();

            cellHeader7.Text = "Breaks";
            XRTableCell cellHeader8 = new XRTableCell();

            cellHeader8.Text = "Status";

            tableHeader.Rows[0].Cells.AddRange(new XRTableCell[] { cellHeader1, cellHeader2, cellHeader3, cellHeader4, cellHeader5, cellHeader6, cellHeader7, cellHeader8 });
            detailReportHeader.Height = tableHeader.Height;
            detailReportHeader.Controls.Add(tableHeader);

            // Adjust the table width.
            tableHeader.BeforePrint += tableHeader_BeforePrint;
            tableHeader.EndInit();

            //------------ Create the Header (TimeLogs Listing) detail band.--------------
            XRTable tableDetail = new XRTable();

            tableDetail.BeginInit();

            tableDetail.Rows.Add(new XRTableRow());
            tableDetail.Borders       = ((DevExpress.XtraPrinting.BorderSide)(BorderSide.Top | BorderSide.Left | BorderSide.Right | BorderSide.Bottom));
            tableDetail.BorderColor   = Color.DarkGray;
            tableDetail.Font          = new Font("Tahoma", 9);
            tableDetail.Padding       = 10;
            tableDetail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;

            XRTableCell cellDetail1 = new XRTableCell();

            cellDetail1.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".WeekDay")
            });
            cellDetail1.WidthF = 108f;

            XRTableCell cellDetail2 = new XRTableCell();

            cellDetail2.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".TotalHours")
            });

            XRTableCell cellDetail3 = new XRTableCell();

            cellDetail3.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".TotalSalary")
            });
            //cellDetail3.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;

            XRTableCell cellDetail4 = new XRTableCell();

            cellDetail4.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".ExpectedHoursString")
            });
            //cellDetail4.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;

            XRTableCell cellDetail5 = new XRTableCell();

            cellDetail5.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".TimeIn")
            });
            //cellDetail5.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            cellDetail5.EvaluateBinding += DateTimeFormatting_EvaluateBinding;

            XRTableCell cellDetail6 = new XRTableCell();

            cellDetail6.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".TimeOut")
            });
            cellDetail6.EvaluateBinding += DateTimeFormatting_EvaluateBinding;

            XRTableCell cellDetail7 = new XRTableCell();

            cellDetail7.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".Breaks")
            });

            XRTableCell cellDetail8 = new XRTableCell();

            cellDetail8.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".Status")
            });
            cellDetail8.Font             = new Font("Tahoma", 8, FontStyle.Regular);
            cellDetail8.EvaluateBinding += CellDetail8_EvaluateBinding;

            tableDetail.Rows[0].Cells.AddRange(new XRTableCell[] { cellDetail1, cellDetail2, cellDetail3, cellDetail4, cellDetail5, cellDetail6, cellDetail7, cellDetail8 });

            DetailBand detailBand = new DetailBand();

            detailBand.Height = tableDetail.Height;
            detailReportBand.Bands.Add(detailBand);
            detailBand.Controls.Add(tableDetail);

            // Adjust the table width.
            tableDetail.BeforePrint += tableDetail_BeforePrint;
            tableDetail.EndInit();

            //---------Add a footer to the detail report.-------------
            ReportFooterBand detailReportFooter = new ReportFooterBand();

            detailReportBand.Bands.Add(detailReportFooter);

            XRTable tableFooter = new XRTable();

            tableFooter.BeginInit();
            tableFooter.Rows.Add(new XRTableRow());

            //tableHeader.Borders = BorderSide.All;
            tableFooter.BorderColor   = Color.DarkGray;
            tableFooter.Font          = new Font("Tahoma", 9, System.Drawing.FontStyle.Bold);
            tableFooter.Padding       = 10;
            tableFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            tableFooter.Borders       = ((DevExpress.XtraPrinting.BorderSide)(BorderSide.Top | BorderSide.Left | BorderSide.Right | BorderSide.Bottom));

            XRSummary summary1 = new XRSummary();

            summary1.Func             = SummaryFunc.Sum;
            summary1.Running          = SummaryRunning.Report;
            summary1.IgnoreNullValues = true;
            //summary1.FormatString = "Total: {0}";

            XRTableCell cellFooter1 = new XRTableCell();

            cellFooter1.Text   = "";
            cellFooter1.WidthF = 108f;

            XRTableCell cellFooter2 = new XRTableCell();

            cellFooter2.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".TotalHours")
            });
            cellHeader2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            cellFooter2.Summary       = summary1;

            XRSummary summary2 = new XRSummary();

            summary2.Running          = SummaryRunning.Report;
            summary2.Func             = SummaryFunc.Sum;
            summary2.IgnoreNullValues = true;
            //summary2.FormatString = "Total: {0:$0.00}";

            XRTableCell cellFooter3 = new XRTableCell();

            cellFooter3.DataBindings.AddRange(new XRBinding[] {
                new XRBinding("Text", report.DataSource, dataMember + ".TotalSalary")
            });
            cellFooter3.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            cellFooter3.Summary       = summary2;

            XRTableCell cellFooter4 = new XRTableCell();

            cellFooter4.Text = "";
            XRTableCell cellFooter5 = new XRTableCell();

            cellFooter5.Text = "";
            XRTableCell cellFooter6 = new XRTableCell();

            cellFooter6.Text = "";
            XRTableCell cellFooter7 = new XRTableCell();

            cellFooter7.Text = "";
            XRTableCell cellFooter8 = new XRTableCell();

            cellFooter8.Text = "";

            tableFooter.Rows[0].Cells.AddRange(new XRTableCell[] { cellFooter1, cellFooter2, cellFooter3, cellFooter4, cellFooter5, cellFooter6, cellFooter7, cellFooter8 });
            detailReportFooter.Height = tableFooter.Height;
            detailReportFooter.Controls.Add(tableFooter);

            // Adjust the table width.
            tableFooter.BeforePrint += tableHeader_BeforePrint; //just copy from tableHeader
            tableFooter.EndInit();
        }
Ejemplo n.º 27
0
        private void Build()
        {
            this.PaperKind = PaperKind.A4;
            try
            {
                var query = _reportData[0].Values.Keys.First();
                xrLabel2.Text = query.content.StartsWith("@") ? "Паспорт" : query.form.name;
            }
            catch { }
            var headerTable = new XRTable
            {
                Borders = BorderSide.Left | BorderSide.Right,
                BorderColor = Color.FromArgb(245, 245, 245),
                Font = new Font("Segoe UI", 9),
                BackColor = Color.FromArgb(37, 116, 169),
                ForeColor = Color.FromArgb(245, 245, 245),
                LocationF = new PointFloat(0F, 0F),
                WidthF = this.PageWidth - this.Margins.Left - this.Margins.Right
            };
            var headerRow = new XRTableRow
            {
                HeightF = 64
            };
            var fstCell = new XRTableCell
            {
                Text = "Образовательная орг.",
                TextAlignment = TextAlignment.MiddleCenter
            };
            headerRow.Cells.Add(fstCell);

            foreach (var pair in _reportData[0].Values) //шапка таблицы с заголовками запросов
            {
                var cell = new XRTableCell();
                cell.Text = pair.Key.title;
                cell.TextAlignment = TextAlignment.MiddleCenter;
                headerRow.Cells.Add(cell);
            }
            headerTable.Rows.Add(headerRow);

            if (headerTable.Rows.FirstRow.Cells[0].WidthF <= 100)
            {
                this.Landscape = true;
                headerTable.WidthF = this.PageWidth - Margins.Left - Margins.Right;
            }

            this.PageHeader.Controls.Add(headerTable);

            var table = new XRTable
            {
                Borders = BorderSide.All,
                ForeColor = Color.FromArgb(59, 59, 59),
                BorderColor = Color.FromArgb(37, 116, 169),
                LocationF = new PointFloat(0F, 0F),
                WidthF = this.PageWidth - this.Margins.Left - this.Margins.Right
            };
            table.BeginInit();

            var summaryRow = new XRTableRow
            {
                BackColor = Color.FromArgb(37, 116, 169),
                ForeColor = Color.FromArgb(245, 245, 245),
                Font = new Font("Segoe UI", 9)
            };
            var sumFstCell = new XRTableCell
            {
                Text = "Итого",
                TextAlignment = TextAlignment.MiddleLeft
            };
            summaryRow.Cells.Add(sumFstCell);

            for (var i = 0; i < _reportData[0].Values.Count; i++) //считается итого
            {
                var sum = 0;
                for (var j = 0; j < _reportData.Count; j++)
                {
                    var arr = new object[_reportData[j].Values.Values.Count];
                    _reportData[j].Values.Values.CopyTo(arr, 0);
                    var strVal = (string)arr[i];
                    int intVal;
                    sum += Int32.TryParse(strVal, out intVal) ? intVal : 0;
                }
                var cell = new XRTableCell
                {
                    Text = sum.ToString(),
                    TextAlignment = TextAlignment.MiddleCenter
                };
                summaryRow.Cells.Add(cell);
            }
            var grouped = _reportData.GroupBy(t => t.GroupHead);
            foreach (var group in grouped)
            {
                if (!string.IsNullOrEmpty(group.Key))
                {
                    var groupRow = new XRTableRow() { HeightF = 32 };
                    var cell = new XRTableCell
                    {
                        Text = group.Key,
                        TextAlignment = TextAlignment.MiddleCenter
                    };
                    groupRow.Cells.Add(cell);
                    table.Rows.Add(groupRow);
                }
                foreach (var data in group)
                {
                    var row = new XRTableRow { HeightF = 32 };
                    var cell1 = new XRTableCell
                    {
                        Text = data.Head,
                        TextAlignment = TextAlignment.MiddleLeft
                    };
                    row.Cells.Add(cell1);

                    foreach (var pair in data.Values)
                    {
                        var cell3 = new XRTableCell
                        {
                            Text = (string)pair.Value,
                            TextAlignment = TextAlignment.MiddleCenter
                        };
                        row.Cells.Add(cell3);
                    }
                    table.Rows.Add(row);
                }
            }
            table.Rows.Add(summaryRow);
            table.EndInit();
            this.Detail.Controls.Add(table);
        }
Ejemplo n.º 28
0
        //-----------------------------------------------------------------------------------------------------------------------------------------//

        public RepKargoPlani(DataTable p_TableResult)
        {
            // Initialize
            InitializeComponent();

            // DateTime
            txtDateTime.Text = DateTime.Now.ToString(alfaDate.DTFormat);

            // Version
            txtVersion.Text = alfaVer.GetAppVersion();

            // Operator
            txtOperator.Text = alfaSession.FullName;

            // Create rowHeader
            DataRow rowHeader = p_TableResult.NewRow();

            foreach (DataColumn col in p_TableResult.Columns)
            {
                // Assign Text
                rowHeader[col.ColumnName] = col.ColumnName;
            }

            // Add to Table
            p_TableResult.Rows.InsertAt(rowHeader, 0);

            //========================================== Create XRTable ========================================//

            int p_Padding    = 10;
            int p_TableWidth = this.PageWidth - this.Margins.Left - this.Margins.Right - p_Padding * 2;
            int p_ColWidth   = p_TableWidth / p_TableResult.Columns.Count;

            // Create Dynamic XRTable
            XRTable repTable = XRTable.CreateTable(new Rectangle(p_Padding, 2, p_TableWidth, 40), 1, 0);

            repTable.BorderWidth         = 2;
            repTable.Width               = p_TableWidth;
            repTable.Rows.FirstRow.Width = p_TableWidth;
            repTable.Font    = new Font("Tahoma", 10, FontStyle.Bold);
            repTable.Borders = DevExpress.XtraPrinting.BorderSide.All;

            // Begin
            repTable.BeginInit();

            foreach (DataColumn col in p_TableResult.Columns)
            {
                // Create Cell
                XRTableCell cell = new XRTableCell();

                // Binding
                XRBinding binding = new XRBinding("Text", this.DataSource, col.ColumnName);

                // Cell Properties
                cell.TextAlignment = TextAlignment.MiddleCenter;
                cell.DataBindings.Add(binding);
                cell.Text      = col.ColumnName;
                cell.Width     = p_ColWidth;
                cell.Multiline = true;
                cell.CanShrink = false;
                cell.CanGrow   = false;

                // Add Cell
                repTable.Rows.FirstRow.Cells.Add(cell);
            }

            // Add to Detail
            Detail.Controls.Add(repTable);

            repTable.BeforePrint += new System.Drawing.Printing.PrintEventHandler(repTable_BeforePrint);

            // Adjust
            repTable.AdjustSize();

            // Begin
            repTable.EndInit();



            //========================================== Create XRTable ========================================//
        }
    public TestReport(string tableName)
    {
        InitializeComponent();
        //
        // TODO: Add constructor logic here
        //

        this.Bands.Add(new PageHeaderBand());

        DevExpress.DataAccess.Sql.SqlDataSource dataSource = new DevExpress.DataAccess.Sql.SqlDataSource("nwind");
        string queryString = string.Format("SELECT * FROM {0}", tableName);

        DevExpress.DataAccess.Sql.SelectQuery parameterQuery = DevExpress.DataAccess.Sql.SelectQueryFluentBuilder
                                                               .AddTable(tableName)
                                                               .SelectAllColumns()
                                                               .Build(tableName);
        dataSource.Queries.Add(parameterQuery);
        dataSource.RebuildResultSchema();
        dataSource.Fill();
        int rowCount = ((IList)dataSource.Result[tableName]).Count;

        XRLabel label = new XRLabel();

        label.Width = 500;
        label.Font  = new System.Drawing.Font("Verdana", 10F, FontStyle.Bold);
        this.Bands[BandKind.PageHeader].Controls.Add(label);

        if (rowCount > 0)
        {
            int padding    = 10;
            int tableWidth = this.PageWidth - this.Margins.Left - this.Margins.Right - padding * 2;

            XRTable dynamicTable = XRTable.CreateTable(
                new Rectangle(padding,                    // rect X
                              2,                          // rect Y
                              tableWidth,                 // width
                              40),                        // height
                1,                                        // table row count
                0);                                       // table column count

            dynamicTable.Width = tableWidth;
            dynamicTable.Rows.FirstRow.Width = tableWidth;
            dynamicTable.Borders             = DevExpress.XtraPrinting.BorderSide.All;
            dynamicTable.BorderWidth         = 1;

            dynamicTable.BeginInit();
            foreach (DevExpress.DataAccess.Sql.DataApi.IColumn dc in dataSource.Result[tableName].Columns)
            {
                XRTableCell cell = new XRTableCell();

                ExpressionBinding binding = new ExpressionBinding("BeforePrint", "Text", dc.Name);
                cell.ExpressionBindings.Add(binding);
                cell.CanGrow = false;
                cell.Width   = 100;
                cell.Text    = dc.Name;
                dynamicTable.Rows.FirstRow.Cells.Add(cell);
            }
            dynamicTable.Font = new System.Drawing.Font("Verdana", 8F);
            dynamicTable.EndInit();
            Detail.Controls.Add(dynamicTable);

            label.Text = string.Format("Data table: {0}", tableName);

            this.DataSource = dataSource;
            this.DataMember = tableName;
        }
        else
        {
            label.Text = string.Format("There's no data to display or the table doesn't exist.");
        }
    }
Ejemplo n.º 30
0
        private void CreateDetailReport(XtraReport report, string dataMember)
        {
            // Create a detail report band and bind it to data.
            DetailReportBand detailReportBand = new DetailReportBand();

            report.Bands.Add(detailReportBand);
            detailReportBand.DataSource = report.DataSource;
            detailReportBand.DataMember = dataMember;

            // Add a header to the detail report.
            ReportHeaderBand detailReportHeader = new ReportHeaderBand();

            detailReportBand.Bands.Add(detailReportHeader);

            XRTable tableHeader = new XRTable();

            tableHeader.BeginInit();
            tableHeader.Rows.Add(new XRTableRow());
            tableHeader.Borders       = BorderSide.All;
            tableHeader.BorderColor   = Color.DarkGray;
            tableHeader.Font          = new Font("Tahoma", 10, System.Drawing.FontStyle.Bold);
            tableHeader.Padding       = 10;
            tableHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;

            XRTableCell cellHeader1 = new XRTableCell();

            cellHeader1.Text = "Product Name";
            XRTableCell cellHeader2 = new XRTableCell();

            cellHeader2.Text          = "Unit Price";
            cellHeader2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;

            tableHeader.Rows[0].Cells.AddRange(new XRTableCell[] { cellHeader1, cellHeader2 });
            detailReportHeader.Height = tableHeader.Height;
            detailReportHeader.Controls.Add(tableHeader);

            // Adjust the table width.
            tableHeader.BeforePrint += tableHeader_BeforePrint;
            tableHeader.EndInit();

            // Create a detail band.
            XRTable tableDetail = new XRTable();

            tableDetail.BeginInit();
            tableDetail.Rows.Add(new XRTableRow());
            tableDetail.Borders       = BorderSide.Left | BorderSide.Right | BorderSide.Bottom;
            tableDetail.BorderColor   = Color.DarkGray;
            tableDetail.Font          = new Font("Tahoma", 10);
            tableDetail.Padding       = 10;
            tableDetail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;

            XRTableCell cellDetail1 = new XRTableCell();
            XRTableCell cellDetail2 = new XRTableCell();

            cellDetail2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            if (Settings.Default.UserDesignerOptions.DataBindingMode == DataBindingMode.Bindings)
            {
                cellDetail1.DataBindings.Add("Text", report.DataSource, dataMember + ".ProductName");
                cellDetail2.DataBindings.Add("Text", report.DataSource, dataMember + ".UnitPrice", "{0:$0.00}");
            }
            else
            {
                cellDetail1.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "[ProductName]"));
                cellDetail2.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text",
                                                                         "FormatString('{0:$0.00}', [UnitPrice])"));
            }

            tableDetail.Rows[0].Cells.AddRange(new XRTableCell[] { cellDetail1, cellDetail2 });

            DetailBand detailBand = new DetailBand();

            detailBand.Height = tableDetail.Height;
            detailReportBand.Bands.Add(detailBand);
            detailBand.Controls.Add(tableDetail);

            // Adjust the table width.
            tableDetail.BeforePrint += tableDetail_BeforePrint;
            tableDetail.EndInit();

            // Create and assign different odd and even styles.
            XRControlStyle oddStyle  = new XRControlStyle();
            XRControlStyle evenStyle = new XRControlStyle();

            oddStyle.BackColor = Color.WhiteSmoke;
            oddStyle.StyleUsing.UseBackColor = true;
            oddStyle.Name = "OddStyle";

            evenStyle.BackColor = Color.White;
            evenStyle.StyleUsing.UseBackColor = true;
            evenStyle.Name = "EvenStyle";

            report.StyleSheet.AddRange(new XRControlStyle[] { oddStyle, evenStyle });

            tableDetail.OddStyleName  = "OddStyle";
            tableDetail.EvenStyleName = "EvenStyle";
        }
        private void AddMultipleFields(DragEventArgs e, DataInfo[] droppedData, XRControl parentControl, ISelectionService selectSvc)
        {
            XRTableCell headerCell;
            XRControl   parent = BandViewSvc.GetControlByScreenPoint(new Point(e.X, e.Y));

            if (parent == null)
            {
                return;
            }
            SizeF size = new SizeF(100F * droppedData.Length, 25F);

            if (parentControl is DetailBand)
            {
                size.Width = CalculateWidth(parentControl);
            }

            XRTable detailTable = new XRTable()
            {
                Name = "DetailTable"
            };

            detailTable.BeginInit();
            XRTableRow detailRow = new XRTableRow();

            detailTable.Rows.Add(detailRow);

            this.droppedControl = detailTable;
            detailTable.SizeF   = size;

            Host.Container.Add(detailTable);
            Host.Container.Add(detailRow);

            for (int i = 0; i < droppedData.Length; i++)
            {
                XRTableCell cell       = new XRTableCell();
                string      expression = ExpressionBindingHelper.NormalizeDataMember(droppedData[i].Member, parent.Report.DataMember);
                cell.ExpressionBindings.Add(
                    new ExpressionBinding("Text",
                                          expression));
                detailRow.Cells.Add(cell);
                Host.Container.Add(cell);
            }
            detailTable.EndInit();

            PointF dropPoint = GetDragDropLocation(e, detailTable, parentControl);

            this.DropXRControl(parentControl, new PointF(0, dropPoint.Y));
            selectSvc.SetSelectedComponents(new XRControl[] { detailTable });
            if ((parentControl is DetailBand))
            {
                PageHeaderBand band = null;
                if ((parentControl as DetailBand).Report.Bands.OfType <PageHeaderBand>().FirstOrDefault() != null)
                {
                    band = (parentControl as DetailBand).Report.Bands[BandKind.PageHeader] as PageHeaderBand;
                }
                else
                {
                    band = new PageHeaderBand();
                    (parentControl as DetailBand).Report.Bands.Add(band);
                    Host.Container.Add(band);
                }

                XRTable headerTable = new XRTable()
                {
                    Name = "HeaderTable"
                };
                headerTable.BeginInit();

                XRTableRow headerRow = new XRTableRow();
                headerTable.Rows.Add(headerRow);

                headerTable.SizeF = size;

                Host.Container.Add(headerTable);
                Host.Container.Add(headerRow);

                for (int i = 0; i < droppedData.Length; i++)
                {
                    headerCell = CreateTableCell(Host, headerRow, droppedData[i].DisplayName);
                }
                headerTable.Borders = BorderSide.All;
                headerTable.EndInit();

                band.Controls.Add(headerTable);
                headerTable.LocationF = droppedControl.LocationF;
            }
        }
Ejemplo n.º 32
0
/*
        void table_Draw(object sender, DrawEventArgs e)
        {
            // Set the value to be added to the width of the table's border.
            var dx = GraphicsUnitConverter.Convert(5, GraphicsUnit.Pixel, e.UniGraphics.PageUnit);

            // Get the object's current bounds and increase them.
            var rect = e.Bounds;
            rect.Inflate(dx / 2, dx / 2);
            
            // Store the old clip region.
            var oldBounds = e.UniGraphics.ClipBounds;
            
            // Set the new clip region and draw the borders' rectangle.
            e.UniGraphics.ClipBounds = rect;
            e.UniGraphics.DrawRectangle(new Pen(Brushes.Black, dx), rect);
            
            // Restore the old clip region.
            e.UniGraphics.ClipBounds = oldBounds;
        } 
*/

        private void addRowTotale(XRTable table, int? id, TipoTotale tipoTotale, string descrizione = null)
        {
            // ================================
            // Creazione tabella
            // ================================
            if(descrizione == null)
                table.BeginInit();

            var totaleRow = new XRTableRow { Width = table.Width };
            if (!string.IsNullOrEmpty(_impostazioniReport.BorderColor))
                totaleRow.BorderColor = ColorTranslator.FromHtml(_impostazioniReport.BorderColor);

            if (_impostazioniReport.TotaleRowHeight != null)
                totaleRow.HeightF = _impostazioniReport.TotaleRowHeight.Value;
            table.Rows.Add(totaleRow);

            var totaleFont = GetFont(_impostazioniReport.FontName, _impostazioniReport.FontSize, getFontStyle(_impostazioniReport.FontStyle));
            if (!string.IsNullOrEmpty(_impostazioniReport.TotaleFontStyle) && !string.IsNullOrEmpty(_impostazioniReport.TotaleFontName) && _impostazioniReport.TotaleFontSize != null)
                totaleFont = GetFont(_impostazioniReport.TotaleFontName, _impostazioniReport.TotaleFontSize.Value, getFontStyle(_impostazioniReport.TotaleFontStyle));

            const TextAlignment footerAlignment = TextAlignment.MiddleRight;

            var dataSource = _dataSource;
            var labelPrompt = "Totale Generale";
            if (tipoTotale == TipoTotale.Stabile)
            {
                dataSource = _dataSource.Where(item => item.IdStabile == id).ToList();
                var dataSourceLabel = dataSource.FirstOrDefault();
                if(dataSourceLabel != null)
                    labelPrompt = dataSourceLabel.DescrizioneStabile;
            }
            else if (tipoTotale == TipoTotale.Scala)
            {
                dataSource = _dataSource.Where(item => item.IdGruppoStabile == id).ToList();
                var dataSourceLabel = dataSource.FirstOrDefault();
                if (dataSourceLabel != null)
                    labelPrompt = dataSourceLabel.DescrizioneGruppoStabile;
            }
            else if (tipoTotale == TipoTotale.Nominativo)
            {
                dataSource = _dataSource.Where(item => item.IdPersona == id).ToList();
                labelPrompt = "Totale nominativo";
                if (!string.IsNullOrEmpty(descrizione))
                    labelPrompt = string.Format("Totale {0}", descrizione);
            }
            else if (tipoTotale == TipoTotale.SenzaArrotondamenti)
            {
                dataSource = _dataSource.Where(item => item.OrdineUnitaImmobiliare != int.MaxValue).ToList();
                labelPrompt = "Totale senza arrotondamenti";
            }

            var columns = _pianoRatealeHelper.GetColumnList(_report, null, _parameters, _numeroPagina);

            var cellPrompt = new XRTableCell();
            totaleRow.Cells.Add(cellPrompt);

            cellPrompt.Text = labelPrompt;
            cellPrompt.TextAlignment = footerAlignment;
            cellPrompt.Padding = getPaddingInfo();
            cellPrompt.WidthF = _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.OrdineUnita) +
                          _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.Nominativo) +
                          _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.ProprietaConduzione) +
                          _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.Interno) +
                          _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.Piano) +
                          _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.TipoUnita) +
                          _pianoRatealeHelper.GetColumnWidth(columns, ColumnTypeEnum.Subalterno);

            cellPrompt.BackColor = ColorTranslator.FromHtml(_impostazioniReport.TotaleBackColor);
            cellPrompt.Font = totaleFont;

            foreach (var tableColumn in columns.Where(item => item.ColumnType == ColumnTypeEnum.Conto))
            {
                if (!tableColumn.Hidden && (_numeroPagina == null || tableColumn.PrintPage == _numeroPagina))
                {
                    var cell = new XRTableCell
                    {
                        BackColor = ColorTranslator.FromHtml(_impostazioniReport.TotaleBackColor),
                        Font = totaleFont,
                        WidthF = tableColumn.Width,
                        CanGrow = true
                    };

                    cell.TextAlignment = TextAlignment.MiddleRight;
                    cell.Padding = getPaddingInfo();

                    var importo = dataSource.Where(item => item.NumeroRata == tableColumn.Order).Sum(item => item.Importo);
                    if (importo != 0)
                        cell.Text = importo.ToString("c");

                    totaleRow.Cells.Add(cell); 
                }

            }

            if (descrizione == null)
            {
                table.AdjustSize();
                table.EndInit();
            }
        }
Ejemplo n.º 33
0
        private XRTable CreateTasksTable(ShiftPlanTask_Report task, float tableWidth)
        {
            XRTable table = new XRTable();

            table.BeginInit();
            table.BorderWidth   = 1;
            table.WidthF        = tableWidth;
            table.Borders       = BorderSide.All;
            table.BorderColor   = Color.FromArgb(195, 197, 197);
            table.TextAlignment = TextAlignment.MiddleLeft;
            table.Font          = new Font("Arial", 8, FontStyle.Regular);
            table.KeepTogether  = true;

            XRTableRow  row;
            XRTableCell cell;

            string workOrder    = " [" + task.WorkOrder + "]";
            var    locationsstr = String.Join(",", task.Locations.Select(x => x.Location).ToList());
            string description  = !String.IsNullOrEmpty(task.WorkOrder) ? task.Description + workOrder : task.Description;

            description = description + " " + locationsstr;

            string compperccolor           = "#ebf3fb";
            string completionPercentagestr = task.CompletionPercentage == null ? "" : task.CompletionPercentage.ToString();
            var    completionPercentage    = task.CompletionPercentage == null ? null : task.CompletionPercentage;

            if (completionPercentage != null)
            {
                if (completionPercentage >= 100)
                {// green
                    compperccolor = "#7eff70";
                }
                if (completionPercentage < 100 && completionPercentage >= 80)
                {// yelow
                    compperccolor = "#ffe561";
                }
                if (completionPercentage < 80 && completionPercentage >= 0)
                {// red
                    compperccolor = "#ff5d47";
                }
            }
            var compcolor = completionPercentage != null?ColorTranslator.FromHtml(compperccolor) : _LightBlue;

            if (String.IsNullOrEmpty(task.TypeColor))
            {
                row = new XRTableRow
                {
                    HeightF      = 25F,
                    Padding      = new PaddingInfo(5, 5, 5, 5),
                    KeepTogether = true
                };

                row.Cells.Add(new XRTableCell
                {
                    Text          = task.Priority,
                    WidthF        = 45F,
                    TextAlignment = TextAlignment.MiddleCenter,
                    BackColor     = Color.FromArgb(238, 235, 235),
                    Font          = new Font("Arial", 8, FontStyle.Bold),
                    KeepTogether  = true
                });

                cell = new XRTableCell()
                {
                    KeepTogether = true
                };
                var icons = new List <string>();

                // Tags
                icons.AddRange(TagUtil.GetTagsForPrinting(task.Tags, new List <Tag>()));

                var descHtml = "<div style=\"padding: 0; margin: 0; font-size: 10pt; font-family: Calibri; font-weight: bold\">" + description + "&nbsp;" + string.Join("&nbsp;", icons) + "</div>";
                var descRt   = new XRRichText
                {
                    Padding        = new PaddingInfo(2, 2, 2, 2),
                    TopF           = 2,
                    LeftF          = 2,
                    WidthF         = tableWidth - 135F - 4,
                    HeightF        = 21,
                    Html           = descHtml,
                    Borders        = BorderSide.None,
                    CanGrow        = true,
                    AnchorVertical = VerticalAnchorStyles.None,
                    KeepTogether   = true
                };

                cell.Controls.Add(descRt);
                cell.WidthF = tableWidth - 135f;
                row.Cells.Add(cell);
                cell.BackColor = Color.FromArgb(248, 248, 248);
                //row.Cells.Add(new XRTableCell { Text = description, WidthF = tableWidth - 45F, BackColor = Color.FromArgb(248, 248, 248) });
                row.Cells.Add(new XRTableCell
                {
                    Text          = task.TargetAndUnitShortCode,
                    WidthF        = 45F,
                    TextAlignment = TextAlignment.MiddleCenter,
                    BackColor     = Color.FromArgb(238, 235, 235),
                    Font          = new Font("Arial", 8, FontStyle.Bold),
                    KeepTogether  = true
                });
                row.Cells.Add(new XRTableCell
                {
                    Text          = completionPercentagestr,
                    BackColor     = compcolor,
                    WidthF        = 45F,
                    TextAlignment = TextAlignment.MiddleCenter,
                    Font          = new Font("Arial", 8, FontStyle.Bold),
                    KeepTogether  = true
                });

                table.Rows.Add(row);
            }
            else
            {
                BorderSide topBorders = BorderSide.All;
                row = new XRTableRow
                {
                    HeightF      = 25F,
                    Padding      = new PaddingInfo(5, 5, 5, 5),
                    KeepTogether = true
                };

                row.Cells.Add(new XRTableCell
                {
                    WidthF       = 10F,
                    BackColor    = ColorTranslator.FromHtml("#" + task.TypeColor),
                    Borders      = topBorders,
                    KeepTogether = true
                });
                row.Cells.Add(new XRTableCell
                {
                    Text          = task.Priority,
                    WidthF        = 35F,
                    TextAlignment = TextAlignment.MiddleCenter,
                    BackColor     = Color.FromArgb(238, 235, 235),
                    Font          = new Font("Arial", 8, FontStyle.Bold),
                    KeepTogether  = true
                });

                cell = new XRTableCell()
                {
                    KeepTogether = true
                };
                var icons = new List <string>();
                if (task.Shadow)
                {
                    icons.Add("<img src=\"/content/images/shared/shadow-task.png\" style=\"width: 16px; height: 12px; vertical-align: middle\">");
                }
                //if (task.Priority.IndexOf("S", StringComparison.OrdinalIgnoreCase) > -1)
                //   icons.Add("<img src=\"" + Settings.GetSettings().Host.TrimEnd('/') + "/workspace/build/production/Fewzion/resources/images/shared/statutory-red.png\" style=\"width: 12px; height: 12px; vertical-align: middle\">");
                //if (task.Source == "Mainstay")
                //    icons.Add("<img src=\"" + Settings.GetSettings().Host.TrimEnd('/') + "/workspace/build/production/Fewzion/resources/images/shared/mainstay.png\" style=\"width: 12px; height: 12px; vertical-align: middle\">");


                // Tags
                icons.AddRange(TagUtil.GetTagsForPrinting(task.Tags, new List <Tag>()));

                var descHtml = "<div style=\"padding: 0; margin: 0; font-size: 10pt; font-family: Calibri; font-weight: bold\">" + description + "&nbsp;" + string.Join("&nbsp;", icons) + "</div>";
                var descRt   = new XRRichText
                {
                    Padding        = new PaddingInfo(2, 2, 2, 2),
                    TopF           = 2,
                    LeftF          = 2,
                    WidthF         = tableWidth - 135F - 4,
                    HeightF        = 21,
                    Html           = descHtml,
                    Borders        = BorderSide.None,
                    CanGrow        = true,
                    AnchorVertical = VerticalAnchorStyles.None,
                    KeepTogether   = true
                };
                cell.Controls.Add(descRt);
                cell.WidthF    = tableWidth - 135f;
                cell.BackColor = Color.FromArgb(248, 248, 248);
                row.Cells.Add(cell);

                //row.Cells.Add(new XRTableCell { Text = description, WidthF = tableWidth - 45F, BackColor = Color.FromArgb(248, 248, 248) });
                row.Cells.Add(new XRTableCell
                {
                    Text          = task.TargetAndUnitShortCode,
                    WidthF        = 45F,
                    TextAlignment = TextAlignment.MiddleCenter,
                    BackColor     = Color.FromArgb(238, 235, 235),
                    Font          = new Font("Arial", 8, FontStyle.Bold),
                    KeepTogether  = true
                });
                row.Cells.Add(new XRTableCell
                {
                    Text         = completionPercentagestr,
                    WidthF       = 45F, TextAlignment = TextAlignment.MiddleCenter,
                    BackColor    = compcolor,
                    Font         = new Font("Arial", 8, FontStyle.Bold),
                    KeepTogether = true
                });

                table.Rows.Add(row);
            }

            table.EndInit();

            return(table);
        }
Ejemplo n.º 34
0
        public static void CreateReport(XtraReport report, string[] fields)
        {
            PageHeaderBand pageHeader = new PageHeaderBand()
            {
                HeightF = 23, Name = "pageHeaderBand"
            };
            int     tableWidth  = report.PageWidth - report.Margins.Left - report.Margins.Right;
            XRTable headerTable = XRTable.CreateTable(
                new Rectangle(0,                    // rect X
                              0,                    // rect Y
                              tableWidth,           // width
                              40),                  // height
                1,                                  // table row count
                0);                                 // table column count

            headerTable.Borders             = DevExpress.XtraPrinting.BorderSide.All;
            headerTable.BackColor           = Color.Gainsboro;
            headerTable.Font                = new Font("Verdana", 10, FontStyle.Bold);
            headerTable.Rows.FirstRow.Width = tableWidth;
            headerTable.BeginInit();
            foreach (string field in fields)
            {
                XRTableCell cell = new XRTableCell();
                cell.Width         = 100;
                cell.Text          = field;
                cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                headerTable.Rows.FirstRow.Cells.Add(cell);
            }
            headerTable.EndInit();
            headerTable.AdjustSize();
            pageHeader.Controls.Add(headerTable);



            DetailBand detail = new DetailBand()
            {
                HeightF = 23, Name = "detailBand"
            };
            XRTable detailTable = XRTable.CreateTable(
                new Rectangle(0,                // rect X
                              0,                // rect Y
                              tableWidth,       // width
                              40),              // height
                1,                              // table row count
                0);                             // table column count



            detailTable.Width = tableWidth;
            detailTable.Rows.FirstRow.Width = tableWidth;
            detailTable.Borders             = DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right | DevExpress.XtraPrinting.BorderSide.Bottom;
            detailTable.BeginInit();
            foreach (string field in fields)
            {
                XRTableCell       cell    = new XRTableCell();
                ExpressionBinding binding = new ExpressionBinding("BeforePrint", "Text", String.Format("[{0}]", field));
                cell.ExpressionBindings.Add(binding);
                cell.Width         = 100;
                cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
                if (field.Contains("Date"))
                {
                    cell.TextFormatString = "{0:MM/dd/yyyy}";
                }
                detailTable.Rows.FirstRow.Cells.Add(cell);
            }
            detailTable.Font = new Font("Verdana", 8F);
            detailTable.EndInit();
            detailTable.AdjustSize();
            detail.Controls.Add(detailTable);
            report.Bands.AddRange(new Band[] { detail, pageHeader });
        }
Ejemplo n.º 35
0
/*
        void table_Draw(object sender, DrawEventArgs e)
        {
            // Set the value to be added to the width of the table's border.
            var dx = GraphicsUnitConverter.Convert(5, GraphicsUnit.Pixel, e.UniGraphics.PageUnit);

            // Get the object's current bounds and increase them.
            var rect = e.Bounds;
            rect.Inflate(dx / 2, dx / 2);
            
            // Store the old clip region.
            var oldBounds = e.UniGraphics.ClipBounds;
            
            // Set the new clip region and draw the borders' rectangle.
            e.UniGraphics.ClipBounds = rect;
            e.UniGraphics.DrawRectangle(new Pen(Brushes.Black, dx), rect);
            
            // Restore the old clip region.
            e.UniGraphics.ClipBounds = oldBounds;
        } 
*/

        private void addRowTotale(XRTable table, int? id, TipoTotale tipoTotale, string descrizione = null)
        {
            // ================================
            // Creazione tabella
            // ================================
            if(descrizione == null)
                table.BeginInit();

            var totaleRow = new XRTableRow { Width = table.Width };
            if (!string.IsNullOrEmpty(_impostazioniReport.BorderColor))
                totaleRow.BorderColor = ColorTranslator.FromHtml(_impostazioniReport.BorderColor);

            if (_impostazioniReport.TotaleRowHeight != null)
                totaleRow.HeightF = _impostazioniReport.TotaleRowHeight.Value;
            table.Rows.Add(totaleRow);

            var totaleFont = GetFont(_impostazioniReport.FontName, _impostazioniReport.FontSize, getFontStyle(_impostazioniReport.FontStyle));
            if (!string.IsNullOrEmpty(_impostazioniReport.TotaleFontStyle) && !string.IsNullOrEmpty(_impostazioniReport.TotaleFontName) && _impostazioniReport.TotaleFontSize != null)
                totaleFont = GetFont(_impostazioniReport.TotaleFontName, _impostazioniReport.TotaleFontSize.Value, getFontStyle(_impostazioniReport.TotaleFontStyle));

            const TextAlignment footerAlignment = TextAlignment.MiddleRight;

            var dataSource = _dataSource;
            var labelPrompt = "Totale Generale";
            if (tipoTotale == TipoTotale.Stabile)
            {
                dataSource = _dataSource.Where(item => item.IdStabile == id).ToList();
                var dataSourceLabel = dataSource.FirstOrDefault();
                if(dataSourceLabel != null)
                    labelPrompt = dataSourceLabel.DescrizioneStabile;
            }
            else if (tipoTotale == TipoTotale.Scala)
            {
                dataSource = _dataSource.Where(item => item.IdGruppoStabile == id).ToList();
                var dataSourceLabel = dataSource.FirstOrDefault();
                if (dataSourceLabel != null)
                    labelPrompt = dataSourceLabel.DescrizioneGruppoStabile;
            }
            else if (tipoTotale == TipoTotale.Nominativo)
            {
                dataSource = _dataSource.Where(item => item.IdPersona == id).ToList();
                labelPrompt = "Totale nominativo";
                if (!string.IsNullOrEmpty(descrizione))
                    labelPrompt = $"Totale {descrizione}";
            }
            else if (tipoTotale == TipoTotale.SenzaArrotondamenti)
            {
                dataSource = _dataSource.Where(item => item.OrdineUnitaImmobiliare != int.MaxValue).ToList();
                labelPrompt = "Totale senza arrotondamenti";
            }

            var columns = _ripartoHelper.GetColumnList(_report, null, _parameters, _numeroPagina, _parameters.StampaMillesimi.GetValueOrDefault());

            var cellPrompt = new XRTableCell();
            totaleRow.Cells.Add(cellPrompt);

            cellPrompt.Text = labelPrompt;
            cellPrompt.TextAlignment = footerAlignment;
            cellPrompt.Padding = getPaddingInfo();
            cellPrompt.WidthF = _ripartoHelper.GetColumnWidth(columns, ColumnTypeEnum.OrdineUnita) +
                          _ripartoHelper.GetColumnWidth(columns, ColumnTypeEnum.Nominativo) +
                          _ripartoHelper.GetColumnWidth(columns, ColumnTypeEnum.ProprietaConduzione) +
                          _ripartoHelper.GetColumnWidth(columns, ColumnTypeEnum.Interno) +
                          _ripartoHelper.GetColumnWidth(columns, ColumnTypeEnum.Piano) +
                          _ripartoHelper.GetColumnWidth(columns, ColumnTypeEnum.TipoUnita) +
                          _ripartoHelper.GetColumnWidth(columns, ColumnTypeEnum.Subalterno);

            cellPrompt.BackColor = ColorTranslator.FromHtml(_impostazioniReport.TotaleBackColor);
            cellPrompt.Font = totaleFont;

            foreach (var tableColumn in columns.Where(item => item.ColumnType == ColumnTypeEnum.Conto))
            {
                if (!tableColumn.Hidden && (_numeroPagina == null || tableColumn.PrintPage == _numeroPagina))
                {
                    var cell = new XRTableCell
                    {
                        BackColor = ColorTranslator.FromHtml(_impostazioniReport.TotaleBackColor),
                        Font = totaleFont,
                        WidthF = tableColumn.Width,
                        CanGrow = true
                    };

                    if (_parameters.StampaMillesimi.GetValueOrDefault() && !tableColumn.HideMillesimi)
                    {
                        var tableMillesimi = new XRTable { Borders = BorderSide.None };
                        var row = new XRTableRow();
                        tableMillesimi.BeginInit();

                        // Cell MILLESIMO
                        // -------------
                        var cellMillesimo = new XRTableCell
                        {
                            BackColor = ColorTranslator.FromHtml(_impostazioniReport.TotaleBackColor),
                            Font = totaleFont,
                            WidthF = tableColumn.Width
                        };

                        var millesimo = dataSource.Where(item => item.OrdineConto == tableColumn.Order).Sum(item => item.Millesimi).GetValueOrDefault();
                        if (millesimo != 0)
                            cellMillesimo.Text = (millesimo * 1000).ToString("#0,000");

                        cellMillesimo.Borders = BorderSide.Right;
                        cellMillesimo.TextAlignment = TextAlignment.MiddleRight;
                        cellMillesimo.Padding = getPaddingInfo();
                        row.Cells.Add(cellMillesimo);

                        // Cell IMPORTO
                        // -------------
                        var cellImporto = new XRTableCell
                        {
                            Borders = BorderSide.None,
                            BackColor = ColorTranslator.FromHtml(_impostazioniReport.TotaleBackColor),
                            Font = totaleFont,
                            WidthF = tableColumn.Width
                        };

                        var importo = dataSource.Where(item => item.OrdineConto == tableColumn.Order).Sum(item => item.Importo.GetValueOrDefault());
                        if (importo != 0)
                            cellImporto.Text = importo.ToString("c");

                        cellImporto.TextAlignment = TextAlignment.MiddleRight;
                        cellImporto.Padding = getPaddingInfo();
                        row.Cells.Add(cellImporto);

                        // Add ROW
                        // -------------
                        tableMillesimi.Rows.Add(row);

                        cell.Text = string.Empty;
                        cell.Padding = new PaddingInfo(0, 0, 0, 0);

                        cellMillesimo.WidthF = tableColumn.WidthMillesimi.GetValueOrDefault();
                        cellImporto.WidthF = tableColumn.Width;
                        cell.WidthF = tableColumn.Width + tableColumn.WidthMillesimi.GetValueOrDefault();

                        tableMillesimi.Width = cell.Width;
                        cell.Controls.Add(tableMillesimi);

                        tableMillesimi.AdjustSize();
                        tableMillesimi.EndInit();
                    }
                    else
                    {
                        cell.TextAlignment = TextAlignment.MiddleRight;
                        cell.Padding = getPaddingInfo();

                        decimal importo;
                        if(tableColumn.Order != 9997)
                            importo = dataSource.Where(item => item.OrdineConto == tableColumn.Order).Sum(item => item.Importo.GetValueOrDefault());
                        else
                        {
                            importo = dataSource.Where(item => item.OrdineConto == 9994).Sum(item => item.Importo.GetValueOrDefault()) +
                                                dataSource.Where(item => item.OrdineConto == 9993).Sum(item => item.Importo.GetValueOrDefault());
                        }
                        if (importo != 0)
                            cell.Text = importo.ToString("c");

                    }

                    totaleRow.Cells.Add(cell); 
                }

            }

            if (descrizione == null)
            {
                table.AdjustSize();
                table.EndInit();
            }
        }
        private XtraReport CreateReport()
        {
            Access97ConnectionParameters parameters = new Access97ConnectionParameters(@"|DataDirectory|\nwind.mdb", "", "");
            SqlDataSource ds = new SqlDataSource(parameters);

            SelectQuery query = SelectQueryFluentBuilder.AddTable("Products").SelectAllColumns().Build("Products");

            ds.Queries.Add(query);
            ds.RebuildResultSchema();


            XtraReport report = new XtraReport()
            {
                DataSource = ds,
                DataMember = query.Name
            };


            float actualPageWidth = report.PageWidth - (report.Margins.Left + report.Margins.Right);
            int   colCount        = 3;
            float colWidth        = actualPageWidth / colCount;

            XRTable tableDetail = new XRTable()
            {
                HeightF = 25f,
                WidthF  = actualPageWidth
            };

            tableDetail.BeginInit();

            XRTableRow detailRow = new XRTableRow();

            detailRow.WidthF = tableDetail.WidthF;
            tableDetail.Rows.Add(detailRow);

            XRTableCell detailCell = new XRTableCell()
            {
                WidthF = colWidth
            };

            detailCell.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "[ProductName]"));
            detailRow.Cells.Add(detailCell);

            detailCell = new XRTableCell()
            {
                WidthF = colWidth
            };
            detailCell.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "[QuantityPerUnit]"));
            detailRow.Cells.Add(detailCell);

            detailCell = new XRTableCell()
            {
                WidthF = colWidth
            };
            detailCell.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "[UnitPrice]"));
            detailRow.Cells.Add(detailCell);

            tableDetail.EndInit();

            report.Bands.Add(new DetailBand()
            {
                HeightF = 25f
            });
            report.Bands[BandKind.Detail].Controls.Add(tableDetail);

            return(report);
        }
Ejemplo n.º 37
0
        private XRTable CreateXRTable(int cellsInRow, int rowsCount)
        {
            float rowHeight = 25f;

            XRTable table = new XRTable();

            table.Borders = DevExpress.XtraPrinting.BorderSide.All;
            table.BeginInit();

            foreach (var list in TreatmentsList)
            {
                var Treatments = list.Treatments.ToList();

                //add Header
                XRTableRow rowHeader = new XRTableRow();
                rowHeader.HeightF = rowHeight;
                XRTableCell cellHeader = new XRTableCell();
                cellHeader.Borders = (DevExpress.XtraPrinting.BorderSide.None);
                cellHeader.Font    = new System.Drawing.Font("Times New Roman", 11.25f, FontStyle.Bold);
                if (list.isAOKConfirmedTreatments)
                {
                    cellHeader.Text = "Übersicht abgerechneter Behandlungen des Monats " + SelectedMonth;
                }
                else
                {
                    cellHeader.Text = "Übersicht noch nicht abgerechneter Behandlungen des Monats " + SelectedMonth;
                }
                rowHeader.Cells.Add(cellHeader);
                table.Rows.Add(rowHeader);

                rowHeader          = new XRTableRow();
                rowHeader.HeightF  = rowHeight;
                cellHeader         = new XRTableCell();
                cellHeader.Borders = (DevExpress.XtraPrinting.BorderSide.Bottom);
                cellHeader.Text    = " ";
                rowHeader.Cells.Add(cellHeader);
                table.Rows.Add(rowHeader);

                //add tableHeader
                XRTableRow rowTableHeader = new XRTableRow();
                rowHeader.HeightF = rowHeight;
                for (int j = 0; j < cellsInRow; j++)
                {
                    XRTableCell cellTableHeader = new XRTableCell();
                    cellTableHeader.Borders = (DevExpress.XtraPrinting.BorderSide.All);
                    cellTableHeader.Font    = new System.Drawing.Font("Times New Roman", 11.25f, FontStyle.Bold);
                    switch (j)
                    {
                    case 0:
                        cellTableHeader.Text = "Injektionsdatum";
                        break;

                    case 1:
                        cellTableHeader.Text = "Name";
                        break;

                    case 2:
                        cellTableHeader.Text = "Vorname";
                        break;

                    case 3:
                        cellTableHeader.Text = "Geburtsdatum";
                        break;

                    case 4:
                        cellTableHeader.Text = "Medikament";
                        break;
                    }
                    rowTableHeader.Cells.Add(cellTableHeader);
                }
                table.Rows.Add(rowTableHeader);

                double summ = 0;
                foreach (var treatment in Treatments)
                {
                    XRTableRow row = new XRTableRow();
                    row.HeightF = rowHeight;
                    for (int j = 0; j < cellsInRow; j++)
                    {
                        XRTableCell cell = new XRTableCell();
                        cell.Borders = (DevExpress.XtraPrinting.BorderSide.All);
                        cell.Font    = new System.Drawing.Font("Times New Roman", 11.25f, FontStyle.Regular);
                        switch (j)
                        {
                        case 0:
                            cell.Text = treatment.Date;
                            break;

                        case 1:
                            cell.Text = treatment.LastName;
                            break;

                        case 2:
                            cell.Text = treatment.FirstName;
                            break;

                        case 3:
                            cell.Text = treatment.Birthday;
                            break;

                        case 4:
                            cell.Text = treatment.Article;
                            break;
                        }
                        row.Cells.Add(cell);
                    }
                    table.Rows.Add(row);
                    row         = new XRTableRow();
                    row.HeightF = rowHeight;
                    table.Rows.Add(row);//empty row

                    foreach (var item in treatment.GPOS)
                    {
                        XRTableRow row1 = new XRTableRow();
                        row1.HeightF = rowHeight;
                        XRTableCell cell = new XRTableCell();
                        if (treatment.GPOS[treatment.GPOS.Count - 1].ID == item.ID)
                        {
                            cell.Borders = (DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right | DevExpress.XtraPrinting.BorderSide.Bottom);
                        }
                        else
                        {
                            cell.Borders = (DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right);
                        }
                        row1.Cells.Add(cell);
                        for (int j = 0; j < 3; j++)
                        {
                            cell         = new XRTableCell();
                            cell.Borders = (DevExpress.XtraPrinting.BorderSide.All);
                            cell.Font    = new System.Drawing.Font("Times New Roman", 11.25f, FontStyle.Regular);
                            switch (j)
                            {
                            case 0:
                                cell.Text = item.Number;
                                break;

                            case 1:
                                cell.Text = item.Text;
                                break;

                            case 2:
                                cell.Text = "+ " + item.Price.ToString("0.##") + " €";
                                summ     += item.Price;
                                break;
                            }
                            row1.Cells.Add(cell);
                        }
                        table.Rows.Add(row1);
                        cell = new XRTableCell();
                        if (treatment.GPOS[treatment.GPOS.Count - 1].ID == item.ID)
                        {
                            cell.Borders = (DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right | DevExpress.XtraPrinting.BorderSide.Bottom);
                        }
                        else
                        {
                            cell.Borders = (DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right);
                        }
                        row1.Cells.Add(cell);
                        table.Rows.Add(row);
                    }
                }
                XRTableRow rowSumme = new XRTableRow();
                rowSumme.HeightF = rowHeight;

                XRTableCell cellSumme = new XRTableCell();
                cellSumme.Borders = (DevExpress.XtraPrinting.BorderSide.All);
                rowSumme.Cells.Add(cellSumme);

                cellSumme         = new XRTableCell();
                cellSumme.Borders = (DevExpress.XtraPrinting.BorderSide.All);
                rowSumme.Cells.Add(cellSumme);

                cellSumme         = new XRTableCell();
                cellSumme.Borders = (DevExpress.XtraPrinting.BorderSide.All);
                cellSumme.Font    = new System.Drawing.Font("Times New Roman", 11.25f, FontStyle.Bold);
                cellSumme.Text    = "SUMME";
                rowSumme.Cells.Add(cellSumme);


                cellSumme         = new XRTableCell();
                cellSumme.Borders = (DevExpress.XtraPrinting.BorderSide.All);
                cellSumme.Font    = new System.Drawing.Font("Times New Roman", 11.25f, FontStyle.Bold);
                cellSumme.Text    = "=" + summ.ToString("0.##") + " €";
                rowSumme.Cells.Add(cellSumme);

                cellSumme         = new XRTableCell();
                cellSumme.Borders = (DevExpress.XtraPrinting.BorderSide.All);
                rowSumme.Cells.Add(cellSumme);

                table.Rows.Add(rowSumme);

                //Add 2 emty rows
                for (int i = 0; i < 2; i++)
                {
                    rowHeader          = new XRTableRow();
                    rowHeader.HeightF  = rowHeight;
                    cellHeader         = new XRTableCell();
                    cellHeader.Borders = (DevExpress.XtraPrinting.BorderSide.None);
                    cellHeader.Text    = " ";
                    rowHeader.Cells.Add(cellHeader);
                    table.Rows.Add(rowHeader);
                }
            }
            table.BeforePrint += new PrintEventHandler(table_BeforePrint);
            table.EndInit();
            return(table);
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            DetailBand     detailBand = new DetailBand();
            PageFooterBand pageFooter = new PageFooterBand();
            PageHeaderBand pageHeader = new PageHeaderBand();
            XtraReport     xtraReport = new XtraReport();

            XRRichText red_header = new XRRichText();

            red_header.SizeF = new SizeF(1000, 0F);
            red_header.Rtf   = "{\\rtf1\\deff0 \\stshfdbch3\\stshfloch2\\stshfhich2\\stshfbi1{\\fonttbl{\\f0 Calibri;}{\\fbiminor\\f1 Times New Roman;}{\\fhiminor\\f2 Calibri;}{\\fdbminor\\f3 Times New Roman;}{\\f4 Arial;}{\\f5 Times New Roman;}}{\\colortbl ;\\red0\\green0\\blue255 ;}{\\*\\defchp \\fcs1\\f1\\fcs1\\f1\\hich\\af2\\loch\\af2\\dbch\\af3\\cgrid1\\fs22}{\\stylesheet {\\ql\\fcs1\\f1\\fcs1\\f1\\hich\\af2\\loch\\af2\\dbch\\af3\\fs22 Normal;}{\\s1\\sbasedon0\\snext1\\ql\\sl275\\slmult1\\sa100\\tqc\\tx4513\\tqr\\tx9026\\fcs1\\f4\\fcs1\\f4\\dbch\\af5\\hich\\af4\\loch\\af4\\fs20 header;}{\\*\\cs2\\fcs1\\f1\\fcs1\\f1\\hich\\af2\\loch\\af2\\dbch\\af3\\fs22 Default Paragraph Font;}{\\*\\cs3\\sbasedon2\\fcs1\\f1\\fcs1\\f1\\hich\\af2\\loch\\af2\\dbch\\af3\\fs22 Line Number;}{\\*\\cs4\\fcs1\\f1\\fcs1\\f1\\hich\\af2\\loch\\af2\\dbch\\af3\\fs22\\ul\\cf1 Hyperlink;}{\\*\\ts5\\tsrowd\\fcs1\\f1\\fcs1\\f1\\hich\\af2\\loch\\af2\\dbch\\af3\\fs22\\ql\\tscellpaddfl3\\tscellpaddl108\\tscellpaddfb3\\tscellpaddfr3\\tscellpaddr108\\tscellpaddft3\\tsvertalt\\cltxlrtb Normal Table;}{\\*\\ts6\\tsrowd\\sbasedon5\\fcs1\\f1\\fcs1\\f1\\hich\\af2\\loch\\af2\\dbch\\af3\\fs22\\ql\\trbrdrt\\brdrs\\brdrw10\\trbrdrl\\brdrs\\brdrw10\\trbrdrb\\brdrs\\brdrw10\\trbrdrr\\brdrs\\brdrw10\\trbrdrh\\brdrs\\brdrw10\\trbrdrv\\brdrs\\brdrw10\\tscellpaddfl3\\tscellpaddl108\\tscellpaddfr3\\tscellpaddr108\\tsvertalt\\cltxlrtb Table Simple 1;}}{\\*\\listoverridetable}{\\info{\\creatim\\yr2020\\mo7\\dy6\\hr16\\min58}{\\version1}}\\nouicompat\\splytwnine\\htmautsp\\alntblind\\expshrtn\\spltpgpar\\nogrowautofit\\utinl\\sectd\\trowd\\irow0\\irowband-1\\lastrow\\trgaph108\\trbrdrb\\brdrs\\brdrw10\\trleft-87\\trrh1275\\trftsWidth3\\trwWidth8925\\trpaddfl3\\trpaddl108\\trpaddfb3\\trpaddfr3\\trpaddr108\\trpaddft3\\tbllkhdrcols\\tbllkhdrrows\\tbllknocolband\\tblindtype3\\tblind21\\clvertalc\\clbrdrt\\brdrnone\\clbrdrl\\brdrnone\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrnone\\cltxlrtb\\clftsWidth3\\clwWidth2505\\clpadfb3\\clpadfl3\\clpadfr3\\clpadr108\\clpadft3\\clpadt108\\cellx2418\\clvertalt\\clbrdrt\\brdrnone\\clbrdrl\\brdrnone\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrnone\\cltxlrtb\\clftsWidth3\\clwWidth2310\\clpadfb3\\clpadfl3\\clpadfr3\\clpadr108\\clpadft3\\clpadt108\\cellx4728\\clvertalt\\clbrdrt\\brdrnone\\clbrdrl\\brdrnone\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrnone\\cltxlrtb\\clftsWidth3\\clwWidth2175\\clpadfb3\\clpadfl3\\clpadfr3\\clpadr108\\clpadft3\\clpadt108\\cellx6903\\clvertalt\\clbrdrt\\brdrnone\\clbrdrl\\brdrnone\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrnone\\cltxlrtb\\clftsWidth3\\clwWidth1935\\clpadfb3\\clpadfl3\\clpadfr3\\clpadr108\\clpadft3\\clpadt108\\cellx8838\\pard\\plain\\ql\\intbl\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs14\\par\\pard\\plain\\ql\\intbl\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs14\\cell\\pard\\plain\\ql\\intbl\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\par\\pard\\plain\\ql\\intbl{\\fcs1\\af1\\alang3081\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang3081\\langfe3081\\langnp3081\\langfenp3081\\b\\cf0 xxx}{\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\cf0 Office}\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\par\\pard\\plain\\ql\\intbl\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\par\\pard\\plain\\ql\\intbl{\\fcs1\\af5\\alang1025\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\cf0 Xxxxxx Xxxxx,  \\line Xxxxxxxx, Xxxxxxxxx\\line Xxxxxxxx, Xxxxxxxxx\\line Xxxxxxxx, Xxxxxxxxx\\line xxx x\\line xxx x\\line xxx x}{\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang3081\\langfe3081\\langnp3081\\langfenp3081\\cf0 \\line }\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\cell\\pard\\plain\\ql\\intbl\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\par\\pard\\plain\\ql\\intbl{\\fcs1\\af1\\alang3081\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang3081\\langfe3081\\langnp3081\\langfenp3081\\b\\cf0 xxx}{\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\cf0 Office}\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\par\\pard\\plain\\ql\\intbl\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\par\\pard\\plain\\ql\\intbl{\\fcs1\\af5\\alang1025\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\cf0 Xxxxxx Xxxxx,  \\line Xxxxxxxx, Xxxxxxxxx\\line Xxxxxxxx, Xxxxxxxxx\\line Xxxxxxxx, Xxxxxxxxx\\line xxx x\\line xxx x\\line xxx x}\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\cell\\pard\\plain\\ql\\intbl\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\par\\pard\\plain\\ql\\intbl{\\fcs1\\af1\\alang3081\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang3081\\langfe3081\\langnp3081\\langfenp3081\\b\\cf0 xxx}{\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\cf0 Office}\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\par\\pard\\plain\\ql\\intbl{\\fcs1\\af1\\ltrch\\fcs0\\loch\\af2\\dbch\\af3\\hich\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\cf0 \\~}\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\par\\pard\\plain\\ql\\intbl{\\fcs1\\af5\\alang1025\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\cf0 Xxxxxx Xxxxx,  \\line Xxxxxxxx, Xxxxxxxxx\\line Xxxxxxxx, Xxxxxxxxx\\line Xxxxxxxx, Xxxxxxxxx\\line xxx x\\line xxx x\\line xxx x}\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\par\\pard\\plain\\ql\\intbl\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\par\\pard\\plain\\qr\\intbl\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs16\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\b\\cell\\trowd\\irow0\\irowband-1\\lastrow\\trgaph108\\trbrdrb\\brdrs\\brdrw10\\trleft-87\\trrh1275\\trftsWidth3\\trwWidth8925\\trpaddfl3\\trpaddl108\\trpaddfb3\\trpaddfr3\\trpaddr108\\trpaddft3\\tbllkhdrcols\\tbllkhdrrows\\tbllknocolband\\tblindtype3\\tblind21\\clvertalc\\clbrdrt\\brdrnone\\clbrdrl\\brdrnone\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrnone\\cltxlrtb\\clftsWidth3\\clwWidth2505\\clpadfb3\\clpadfl3\\clpadfr3\\clpadr108\\clpadft3\\clpadt108\\cellx2418\\clvertalt\\clbrdrt\\brdrnone\\clbrdrl\\brdrnone\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrnone\\cltxlrtb\\clftsWidth3\\clwWidth2310\\clpadfb3\\clpadfl3\\clpadfr3\\clpadr108\\clpadft3\\clpadt108\\cellx4728\\clvertalt\\clbrdrt\\brdrnone\\clbrdrl\\brdrnone\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrnone\\cltxlrtb\\clftsWidth3\\clwWidth2175\\clpadfb3\\clpadfl3\\clpadfr3\\clpadr108\\clpadft3\\clpadt108\\cellx6903\\clvertalt\\clbrdrt\\brdrnone\\clbrdrl\\brdrnone\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrnone\\cltxlrtb\\clftsWidth3\\clwWidth1935\\clpadfb3\\clpadfl3\\clpadfr3\\clpadr108\\clpadft3\\clpadt108\\cellx8838\\row\\pard\\plain\\ql\\fcs1\\af1\\ltrch\\fcs0\\hich\\af2\\dbch\\af3\\loch\\f2\\fs22\\lang1033\\langfe1033\\langnp1033\\langfenp1033\\par{\\*\\themedata \r\n504b03041400020008000000210201159325ae000000270100000b0000005f72656c732f2e72656c738d8f310ec2300c45af1279a76e1910424dbbb07460415c204a9d34a24da224457036068ec415c8d82206164b5ffe7efffbfd7cd5ed7d1ad98d4234\r\nce72a88a121859e97a63358739a9cd1edaa63ed3285276c4c1f8c8f2898d1c8694fc0131ca8126110be7c9e68d72611229cba0d10b79159a705b963b0c4b06ac99aceb3984aeaf805d1e9efe613ba58ca4a393f34436fd88f87264b2089a12879499848b\r\n791236b70c454e00864d8dab779b0f504b0304140002000800000021027f624aeb730000007b0000001c0000007468656d652f7468656d652f7468656d654d616e616765722e786d6c0d8cc10d83300c005789fc2f4e7954554460820e61810991888392\r\nb465b73e3a5257a89fa7d3ddeff31da633ede6c5a5c62c1eae9d05c332e7254af0f06cebe50ed338906b1b277e9050e062b491eac8c3d6dae110ebac966a970f16756b2e899a6209b8147aeb2bedd85b7bc34451c0e0f807504b03041400020008000000\r\n21020a5d705ea60000000c010000270000007468656d652f7468656d652f5f72656c732f7468656d654d616e616765722e786d6c2e72656c738dcf3d0ec2300c05e0ab44dea95b068450d32e2c5d11178852278d687e94a408cec6c091b8021113951818\r\n9fecf7597e3d9e6d7fb333bb524cc63b0e4d55032327fd689ce6b064b5d943dfb5279a452e1b693221b1527189c39473382026399115a9f2815c99281fadc825468d41c88bd084dbbade61fc36606db261e41087b10176be07fac7f64a1949472f174b2e\r\nff3881b974a980226aca1c3eb1a90a030cbb16573f756f504b0304140002000800000021026d52debf9f050000fd1b0000160000007468656d652f7468656d652f7468656d65312e786d6ced594f6fdb3614ff2a84eead2c5b729da06e113b76bb356983\r\nc4ebd0232dd3126b4a14483aa96f437b1c30605837ec3260b71d866d015a608765d887c9d661eb807c8551b42c5136d5244d566c587cb045eaf7deeffde17b22e5939f7eb979fb4944c03e621cd3b86d39d76b1640b14f47380edad6548cafb5acdbb76e\r\nc27511a20801098ef93a6c5ba110c9ba6d735f4e437e9d262896f7c6944550c8210bec118307524944ec7aadd6b42388630bc430426debc1788c7d0406a94a2b57de23f22b163c9df009dbf315a32ea1b0a38993fef019ef1206f621695b9267440f06e8\r\n89b000815cc81b6daba63e16b06fddb47329222a8435c1befa2c043389d1a4ae045930cc259dbebb7663b360a8cf195681bd5eafdb730a8d0a017d5f7aebac80dd7ecbe9e45a35d4fc72557bb7e6d5dc25018da1b122b0d6e974bcb5b240a3107057045a\r\nb5a6bb512f0bb88580b7ea4367a3db6d9605bc42a0b922d0bfb1d6749704142a24389eacc0d3cc1629ca31634aee1af12d896fe56ba180d9da4a9b2b8845d5ba8be063cafa12a0b20c058e819825680c7d89ebc268c830540c701d41ed5636e7f3d5b994\r\n0e709fe144b4adf713280ba4c09c1c7d7772f4029c1c1d1e3f7d79fcf4c7e367cf8e9ffe6092bc0be340977cfdcda77f7df511f8f3c5d7af9f7f5e21c07581dfbefff8d79f3fab400a1df9ea8bc3df5f1ebefaf2933fbe7d6ec26f3038d4f1031c210eee\r\na303b04ba3d43f03051ab2738a0c42884b2230945013b227c212f2fe0c1223b083ca317cc8645b3022ef4c1f97ecdd0bd9546013f25e189590db94920e65669fee293acda7691c54f0b3a90edc8570df48df5dca726f9ac8958d8d4abb212a99ba4364e2\r\n61806224407a8f4e1032c93dc2b814df6dec33cae95880471874203607668087c22c751747324133a38d32eba5086d3f041d4a8c049b68bf0c95150289512922a568de81530123b3d530223a740b8ad068e8de8cf9a5c07321931e2042416f8438370a3d\r\n60b392c9f7a06c51e615b04d665119ca049e18a15b90521dba4927dd104689d96e1c873af83d3e912b16821d2acc76d072cda4639910185767fe2146e29cc5fe010e42f36249ef4c99b146102dd7e88c8c218a170f80522b8f70fca6be4eb06cec577d7d\r\na9af6fc8879db19e96bb7925f03fdac337e134de41699d5cb5f0ab167ed5c2df50e1ff44e32e7ab5adefd6959ea872eb3ec684ec8919415b5c75792e5d1cf5e5a41a28a1fca89084f272c15702060caa6bc0a8f8108b702f8489e4711445c033dd010709\r\ne5f28862552a57275e2cbd56735e7e4c957028b6e9683edf289d5f73456a14709daa91aa382b5de3c645e99c39f28c7c8e57c1e7bd99cfd6622acb08c0f47d84d3ac6766721f12344aa33f572d3041bbc81799be45ae2e3d6f3c84239425ce317be634ce\r\n1ac9d6e981d4f8d61a17e53b4be67442b78ad0bb8cd4d54e4b9dbd5ab9242e8fc08134d3ab7b16f0a344eae4693b832488db962f32874e2df665b72b56ac53ab76bb4492302e36210fe762ea56feee272eecae7b6eaaee02869bbad419c91b2de7dd93db\r\ncb0944e3b14c7cc54c31cceed1a9406c2f1c1d802199b25d282d77e74b6a84b97c78d41703268bd3cd565bb9e8b3c5bffc2e292b0a48921066eda9a5e77a8e57d7b9116aa4d9675718ff96be342ed117efffec4bba7ce526b83152a735b9356010a4ebb4\r\n6d5126422adb4d1262bfcfe466429149c3803c06aafe44d277e2a9b1687fd1afec859279770b42b18b03c0b06c71226408ed88ccd353b4398b76989547a629eb2db9c13c99ff0ed13e2283b4729b69082c10e60d248b85022e27ce36d5d830e8ff9b3744\r\n6ed586e8941d4341e59e6783e2eaed5e7b0aac5dd48a733e6deb156ed7bdb33f6d13799e01e9976ce498f9a4d8fe0ea87ac416fb4db924afb5b252cc2787d2ea96ee5faaeb5d6eaf8ab4b4aa56c1a5ee53b5f837aae27f0ae1dbc7df3384df3b57f4edd5\r\n62b6b593901a2dfdb7b698b9f537504b030414000200080000002102e9278183ee00000010020000130000005b436f6e74656e745f54797065735d2e786d6cad914d4ec3301085af62795bc54e5920849274012cf959708191334e2ce21fd993aa9c8d05\r\n47e20a4cd382102a48486c2cd9efcdfb66c66f2fafcd66e727b1c55c5c0cad5cab5a0a0c26f62e0cad9cc9561772d3358fcf098b606b28ad1c89d2a5d6c58ce8a1a89830b06263f6407ccd834e609e60407d56d7e7dac44018a8a27d86ec9a6bb4304f24\r\n6e76fc7cc0669c8a145707e39ed54a486972068875bd0dfd374a752428ae5c3c6574a9acd820853e8958a41f091f85f7bc89ec7a140f90e90e3cdb34f198f8f55cabdfc34eb41bad7506fb6866cf256a8959fd097a0b81e7cdff833e867d76a097ffedde\r\n01504b010214001400020008000000210201159325ae000000270100000b00000000000000000000000000000000005f72656c732f2e72656c73504b01021400140002000800000021027f624aeb730000007b0000001c00000000000000000000000000\r\nd70000007468656d652f7468656d652f7468656d654d616e616765722e786d6c504b01021400140002000800000021020a5d705ea60000000c0100002700000000000000000000000000840100007468656d652f7468656d652f5f72656c732f7468656d\r\n654d616e616765722e786d6c2e72656c73504b01021400140002000800000021026d52debf9f050000fd1b000016000000000000000000000000006f0200007468656d652f7468656d652f7468656d65312e786d6c504b01021400140002000800000021\r\n02e9278183ee000000100200001300000000000000000000000000420800005b436f6e74656e745f54797065735d2e786d6c504b050600000000050005005d010000610900000000}{\\*\\colorschememapping 3c3f786d6c2076657273696f6e3d22312e\r\n302220656e636f64696e673d227574662d38223f3e3c613a636c724d617020786d6c6e733a613d22687474703a2f2f736368656d61732e6f70656e786d6c666f726d6174732e6f72672f64726177696e676d6c2f323030362f6d61696e22206267313d22\r\n6c743122207478313d22646b3122206267323d226c743222207478323d22646b322220616363656e74313d22616363656e74312220616363656e74323d22616363656e74322220616363656e74333d22616363656e74332220616363656e74343d226163\r\n63656e74342220616363656e74353d22616363656e74352220616363656e74363d22616363656e74362220686c696e6b3d22686c696e6b2220666f6c486c696e6b3d22666f6c486c696e6b22202f3e}}";
            pageHeader.Controls.Add(red_header);

            xtraReport.Landscape  = true;
            xtraReport.ReportUnit = ReportUnit.TenthsOfAMillimeter;

            xtraReport.Bands.Add(detailBand);
            xtraReport.Bands.Add(pageFooter);
            xtraReport.Bands.Add(pageHeader);

            xtraReport.Margins.Left   = 50;
            xtraReport.Margins.Right  = 50;
            xtraReport.Margins.Top    = 10;
            xtraReport.Margins.Bottom = 10;
            pageFooter.Height         = 50;
            pageHeader.Height         = 50;

            XRPageInfo xRPageInfo = new XRPageInfo()
            {
                StartPageNumber = 1,
                Format          = "Page {0} of {1}"
            };

            xRPageInfo.Font = new Font("Arial", 8, FontStyle.Regular);
            pageFooter.Controls.Add(xRPageInfo);

            float aval_width = xtraReport.PageWidth - xtraReport.Margins.Left - xtraReport.Margins.Right;

            String line;

            System.IO.StreamReader file = new System.IO.StreamReader(@".\..\..\data_for_hidden_text.txt");

            XRTable table = new XRTable();

            table.Font         = new Font("Arial", 12, FontStyle.Regular);
            table.KeepTogether = true;
            table.SizeF        = new SizeF(1000, 0F);
            table.Borders      = DevExpress.XtraPrinting.BorderSide.All;
            table.BeginInit();
            int line_number = 0;

            while ((line = file.ReadLine()) != null)
            {
                line_number++;
                XRTableRow row = new XRTableRow();

                XRTableCell cell = new XRTableCell();
                cell.Text   = $"HRS-2XS-IRC-005 l{line_number}";
                cell.WidthF = 220;
                row.Cells.Add(cell);

                cell        = new XRTableCell();
                cell.WidthF = 580;
                XRRichText richtext = new XRRichText();
                richtext.Html     = ConvertHexToString(line, System.Text.Encoding.ASCII);
                richtext.Borders  = (DevExpress.XtraPrinting.BorderSide)BorderSide.None;
                richtext.Location = new Point(0, 0);
                richtext.Size     = cell.Size;
                cell.Controls.Add(richtext);
                row.Cells.Add(cell);

                table.Rows.Add(row);
            }

            table.LocationF = new PointF(0, 0);
            detailBand.Controls.Add(table);
            table.EndInit();
            String fileName = Directory.GetCurrentDirectory() + "reportWithHiddenText.pdf";

            xtraReport.ExportToPdf(fileName);
            System.Diagnostics.Process.Start(fileName, "");
            MessageBox.Show($"reportWithHiddenText.pdf has been created and saved to \n\n {fileName}");
        }
Ejemplo n.º 39
0
        public void InitDetailsBasedonXRTable()
        {
            DataSet ds       = ((DataSet)rep.DataSource);
            int     colCount = ds.Tables[0].Columns.Count;
            int     colWidth = (rep.PageWidth - (rep.Margins.Left + rep.Margins.Right)) / colCount;

            // Create a table to represent headers
            XRTable tableHeader = new XRTable();

            tableHeader.Height        = 25;
            tableHeader.Width         = (rep.PageWidth - (rep.Margins.Left + rep.Margins.Right));
            tableHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            tableHeader.Font          = new Font(tableHeader.Font.FontFamily, 12.0f, FontStyle.Bold);
            XRTableRow headerRow = new XRTableRow();

            headerRow.Width = tableHeader.Width;
            tableHeader.Rows.Add(headerRow);

            tableHeader.BeginInit();

            // Create a table to display data
            XRTable tableDetail = new XRTable();

            tableDetail.Height = 50;
            tableDetail.Width  = (rep.PageWidth - (rep.Margins.Left + rep.Margins.Right));
            XRTableRow detailRow = new XRTableRow();

            detailRow.Width = tableDetail.Width;
            tableDetail.Rows.Add(detailRow);
            tableDetail.EvenStyleName = "EvenStyle";
            tableDetail.OddStyleName  = "OddStyle";
            tableDetail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            tableDetail.Font          = new Font(tableDetail.Font.FontFamily, 11.0f, FontStyle.Regular);
            tableDetail.BeginInit();

            // Create table cells, fill the header cells with text, bind the cells to data
            for (int i = 0; i < colCount; i++)
            {
                XRTableCell headerCell = new XRTableCell();
                headerCell.Width = colWidth;

                headerCell.Text = ds.Tables[0].Columns[i].Caption;

                XRTableCell detailCell = new XRTableCell();
                detailCell.Width = colWidth;
                detailCell.DataBindings.Add("Text", null, ds.Tables[0].Columns[i].Caption);

                if (ds.Tables[0].Columns[i].Caption == "TÊN ĐỐI TÁC")
                {
                    headerCell.Width = colWidth + 70;
                    detailCell.Width = colWidth + 70;
                }

                if (i == 0)
                {
                    headerCell.Borders = DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Bottom;
                    detailCell.Borders = DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Bottom;
                }
                else
                {
                    headerCell.Borders = DevExpress.XtraPrinting.BorderSide.All;
                    detailCell.Borders = DevExpress.XtraPrinting.BorderSide.All;
                }

                // Place the cells into the corresponding tables
                headerRow.Cells.Add(headerCell);
                detailRow.Cells.Add(detailCell);
            }
            tableHeader.EndInit();
            tableDetail.EndInit();
            // Place the table onto a report's Detail band
            rep.Bands[BandKind.PageHeader].Controls.Add(tableHeader);
            rep.Bands[BandKind.Detail].Controls.Add(tableDetail);
        }