/* 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(); } }
/* 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(); } }