Example #1
0
        public virtual object Clone()
        {
            var item = new ImpostazioniReport(Azienda)
            {
                ReportMargin = ReportMargin,
                DefaultFont = DefaultFont,
                HeaderFont = HeaderFont,
                HeaderBackColor = HeaderBackColor,
                HeaderRowHeight = HeaderRowHeight,
                TotaleFont = TotaleFont,
                TotaleBackColor = TotaleBackColor,
                TotaleRowHeight = TotaleRowHeight,
                ArrotondamentiFont = ArrotondamentiFont,
                ArrotondamentiBackColor = ArrotondamentiBackColor,
                ArrotondamentiRowHeight = ArrotondamentiRowHeight,
                PageInfoFont = PageInfoFont,
                MillesimiFont = MillesimiFont,
                RiepilogoFont = RiepilogoFont,
                RiepilogoTopMargin = RiepilogoTopMargin,
                RiepilogoLeftMargin = RiepilogoLeftMargin,
                RiepilogoText = RiepilogoText,
                RiepilogoRtf = RiepilogoRtf,

                IndirizzoDestinatarioTopMargin = IndirizzoDestinatarioTopMargin,
                IndirizzoDestinatarioLeftMargin = IndirizzoDestinatarioLeftMargin,
                IndirizzoDestinatarioRtf = IndirizzoDestinatarioRtf,

                IndirizzoPerConoscenzaTopMargin = IndirizzoPerConoscenzaTopMargin,
                IndirizzoPerConoscenzaLeftMargin = IndirizzoPerConoscenzaLeftMargin,
                IndirizzoPerConoscenzaRtf = IndirizzoPerConoscenzaRtf,

                PrintTotale = PrintTotale,
                NoteWidth = NoteWidth,
                NoteBorder = NoteBorder,
                NotePadding = NotePadding,
                NoteTopMargin = NoteTopMargin,
                NoteLeftMargin = NoteLeftMargin,
                ImportoRiepilogoFont = ImportoRiepilogoFont,
                BorderColor = BorderColor,
                CellPadding = CellPadding,
                HeaderAlignment = HeaderAlignment,
                Landscape = Landscape,
                FitToPage = FitToPage,
                StabilePageBreak = StabilePageBreak,
                ScalaPageBreak = ScalaPageBreak,
                StabileTotali = StabileTotali,
                ScalaTotali = ScalaTotali,
                MultiPage = MultiPage,
                MultiPageOrdered = MultiPageOrdered,
                DescrizioneContoCompleta = DescrizioneContoCompleta,
                BorderInsideGroup = BorderInsideGroup,
                PaperKind = PaperKind,
                TipoLogo = TipoLogo,
                PosizioneLogo = PosizioneLogo,
                LogoLocation = LogoLocation,
                LogoSize = LogoSize,
                ReportSize = ReportSize,
                ReportKey = ReportKey,
                RowHeight = RowHeight,
                HeaderContoFont = HeaderContoFont,
                HeaderContoBackColor = HeaderContoBackColor,
                TotaleContoFont = TotaleContoFont,
                TotaleContoBackColor = TotaleContoBackColor,
                HeaderSottoContoFont = HeaderSottoContoFont,
                HeaderSottoContoBackColor = HeaderSottoContoBackColor,
                TotaleSottoContoFont = TotaleSottoContoFont,
                TotaleSottoContoBackColor = TotaleSottoContoBackColor,
                OrdineStampaMovimenti = OrdineStampaMovimenti,
                OrdineStampaContoSottoconto = OrdineStampaContoSottoconto,
                LimitePagamenti = LimitePagamenti,
                TemplateFatturePagate = TemplateFatturePagate,
                NumeroColonne = NumeroColonne,
                DirezioneColonne = DirezioneColonne,
                Descrizione = Descrizione,
                Condominio = Condominio
            };

            return item;
        }
        private ImpostazioneReportDTO setDto(ImpostazioniReport item, IList<Conto> conti, IList<DatiBancariCondomini> banche, PianoRateale pianoRateale, IDaoFactory daoFactory)
        {
            try
            {
                if (item != null)
                {
                    const float tolerance = 0.01f;

                    var dto = new ImpostazioneReportDTO
                    {
                        ID = item.ID,
                        ReportKey = item.ReportKey,
                        FontName = item.DefaultFont.Name,
                        FontSize = item.DefaultFont.Size,
                        FontStyle = item.DefaultFont.Style,
                        Descrizione = item.Descrizione,
                        TipoLogo = item.TipoLogo,
                        PosizioneLogo = item.PosizioneLogo,
                        PaperKind = item.PaperKind,
                        Landscape = item.Landscape,
                        CellPadding = item.CellPadding,
                        CaptionBackColor = item.CaptionBackColor,
                        HeaderBackColor = item.HeaderBackColor,
                        TotaleBackColor = item.TotaleBackColor,
                        CaptionRowHeight = item.CaptionRowHeight,
                        CaptionTopMargin = item.CaptionTopMargin,
                        CaptionLeftMargin = item.CaptionLeftMargin,
                        HeaderRowHeight = item.HeaderRowHeight,
                        TotaleRowHeight = item.TotaleRowHeight,
                        ArrotondamentiRowHeight = item.ArrotondamentiRowHeight,
                        RowHeight = item.RowHeight,
                        CaptionAlignment = item.CaptionAlignment,
                        HeaderAlignment = item.HeaderAlignment,
                        BorderColor = item.BorderColor,
                        BorderInsideGroup = item.BorderInsideGroup,
                        DescrizioneContoCompleta = item.DescrizioneContoCompleta,
                        StabilePageBreak = item.StabilePageBreak,
                        ScalaPageBreak = item.ScalaPageBreak,
                        StabileTotali = item.StabileTotali,
                        ScalaTotali = item.ScalaTotali,
                        MultiPage = item.MultiPage,
                        MultiPageOrdered = item.MultiPageOrdered,
                        RiepilogoText = item.RiepilogoText,
                        RiepilogoTopMargin = item.RiepilogoTopMargin,
                        RiepilogoLeftMargin = item.RiepilogoLeftMargin,
                        RiepilogoRtf = item.RiepilogoRtf,

                        IndirizzoDestinatarioTopMargin = item.IndirizzoDestinatarioTopMargin,
                        IndirizzoDestinatarioLeftMargin = item.IndirizzoDestinatarioLeftMargin,
                        IndirizzoDestinatarioRtf = item.IndirizzoDestinatarioRtf,

                        IndirizzoPerConoscenzaTopMargin = item.IndirizzoPerConoscenzaTopMargin,
                        IndirizzoPerConoscenzaLeftMargin = item.IndirizzoPerConoscenzaLeftMargin,
                        IndirizzoPerConoscenzaRtf = item.IndirizzoPerConoscenzaRtf,

                        TestoLetteraTopMargin = item.TestoLetteraTopMargin,
                        TestoLetteraLeftMargin = item.TestoLetteraLeftMargin,
                        TestoLetteraRtf = item.TestoLetteraRtf,
                        TestoLetteraWidth = item.TestoLetteraWidth,

                        TestoUnitaImmobiliareTopMargin = item.TestoUnitaImmobiliareTopMargin,
                        TestoUnitaImmobiliareLeftMargin = item.TestoUnitaImmobiliareLeftMargin,
                        TestoUnitaImmobiliareRtf = item.TestoUnitaImmobiliareRtf,

                        FirmaLetteraTopMargin = item.FirmaLetteraTopMargin,
                        FirmaLetteraLeftMargin = item.FirmaLetteraLeftMargin,
                        FirmaLetteraRtf = item.FirmaLetteraRtf,

                        PrintTotale = item.PrintTotale,
                        TopMargin = 10,
                        BottomMargin = 10,
                        LeftMargin = 10,
                        RightMargin = 10,
                        FitToPage = item.FitToPage,
                        DateTimeFormat = item.DateTimeFormat,

                        OrdineUnitaAllRows = item.OrdineUnitaAllRows,

                        NoteBorder = item.NoteBorder,
                        NoteWidth = item.NoteWidth,
                        NotePadding = item.NotePadding,
                        NoteTopMargin = item.NoteTopMargin,
                        NoteLeftMargin = item.NoteLeftMargin,

                        HeaderContoBackColor = item.HeaderContoBackColor,
                        TotaleContoBackColor = item.TotaleContoBackColor,
                        HeaderSottoContoBackColor = item.HeaderSottoContoBackColor,
                        TotaleSottoContoBackColor = item.TotaleSottoContoBackColor,
                        TotaleStabileBackColor = item.TotaleStabileBackColor,
                        TotaleScalaBackColor = item.TotaleScalaBackColor,

                        SottoContoTotali = item.SottoContoTotali,
                        DettaglioPersonali = item.DettaglioPersonali,

                        OrdineStampaMovimenti = item.OrdineStampaMovimenti,
                        NumeroColonne = item.NumeroColonne,
                        DirezioneColonne = item.DirezioneColonne,
                        OrdineStampaContoSottoconto = item.OrdineStampaContoSottoconto,
                        LimitePagamenti = item.LimitePagamenti,
                        TemplateFatturePagate = item.TemplateFatturePagate,

                        Dettaglio = new List<ImpostazioneReportDettaglioDTO>(item.Dettaglio.Count)
                    };

                    if (dto.TestoLetteraWidth == null)
                        dto.TestoLetteraWidth = 600f;

                    if (dto.DateTimeFormat == DateTimeFormat.Undefined)
                        dto.DateTimeFormat = DateTimeFormat.ShortDateTime;

                    #region Bilancio Annuale

                    if (item.HeaderContoFont != null)
                    {
                        dto.HeaderContoFontName = item.HeaderContoFont.Name;
                        dto.HeaderContoFontSize = item.HeaderContoFont.Size;
                        dto.HeaderContoFontStyle = item.HeaderContoFont.Style;
                    }

                    if (item.TotaleContoFont != null)
                    {
                        dto.TotaleContoFontName = item.TotaleContoFont.Name;
                        dto.TotaleContoFontSize = item.TotaleContoFont.Size;
                        dto.TotaleContoFontStyle = item.TotaleContoFont.Style;
                    }

                    if (item.HeaderSottoContoFont != null)
                    {
                        dto.HeaderSottoContoFontName = item.HeaderSottoContoFont.Name;
                        dto.HeaderSottoContoFontSize = item.HeaderSottoContoFont.Size;
                        dto.HeaderSottoContoFontStyle = item.HeaderSottoContoFont.Style;
                    }

                    if (item.TotaleSottoContoFont != null)
                    {
                        dto.TotaleSottoContoFontName = item.TotaleSottoContoFont.Name;
                        dto.TotaleSottoContoFontSize = item.TotaleSottoContoFont.Size;
                        dto.TotaleSottoContoFontStyle = item.TotaleSottoContoFont.Style;
                    }

                    if (item.TotaleStabileFont != null)
                    {
                        dto.TotaleStabileFontName = item.TotaleStabileFont.Name;
                        dto.TotaleStabileFontSize = item.TotaleStabileFont.Size;
                        dto.TotaleStabileFontStyle = item.TotaleStabileFont.Style;
                    }

                    if (item.TotaleScalaFont != null)
                    {
                        dto.TotaleScalaFontName = item.TotaleScalaFont.Name;
                        dto.TotaleScalaFontSize = item.TotaleScalaFont.Size;
                        dto.TotaleScalaFontStyle = item.TotaleScalaFont.Style;
                    }

                    #endregion Bilancio Annuale

                    if (dto.RowHeight == null)
                        dto.RowHeight = 23f;
                    if (dto.TotaleRowHeight == null)
                        dto.TotaleRowHeight = 23f;
                    if (dto.CellPadding == null)
                        dto.CellPadding = 4;

                    if (dto.HeaderAlignment == null)
                        dto.HeaderAlignment = TextAlignmentEnum.TopCenter;

                    if (item.Condominio != null)
                        dto.IdCondominio = item.Condominio.ID;

                    if (item.ReportMargin != null)
                    {
                        dto.TopMargin = item.ReportMargin.Top;
                        dto.BottomMargin = item.ReportMargin.Bottom;
                        dto.LeftMargin = item.ReportMargin.Left;
                        dto.RightMargin = item.ReportMargin.Right;
                    }

                    if (item.CaptionFont != null)
                    {
                        dto.CaptionFontName = item.CaptionFont.Name;
                        dto.CaptionFontSize = item.CaptionFont.Size;
                        dto.CaptionFontStyle = item.CaptionFont.Style;
                    }

                    if (item.HeaderFont != null)
                    {
                        dto.HeaderFontName = item.HeaderFont.Name;
                        dto.HeaderFontSize = item.HeaderFont.Size;
                        dto.HeaderFontStyle = item.HeaderFont.Style;
                    }

                    if (item.TotaleFont != null)
                    {
                        dto.TotaleFontName = item.TotaleFont.Name;
                        dto.TotaleFontSize = item.TotaleFont.Size;
                        dto.TotaleFontStyle = item.TotaleFont.Style;
                    }

                    if (item.ArrotondamentiFont != null)
                    {
                        dto.ArrotondamentiFontName = item.ArrotondamentiFont.Name;
                        dto.ArrotondamentiFontSize = item.ArrotondamentiFont.Size;
                        dto.ArrotondamentiFontStyle = item.ArrotondamentiFont.Style;
                    }

                    if (item.PageInfoFont != null)
                    {
                        dto.PageInfoFontName = item.PageInfoFont.Name;
                        dto.PageInfoFontSize = item.PageInfoFont.Size;
                        dto.PageInfoFontStyle = item.PageInfoFont.Style;
                    }

                    if (item.MillesimiFont != null)
                    {
                        dto.MillesimiFontName = item.MillesimiFont.Name;
                        dto.MillesimiFontSize = item.MillesimiFont.Size;
                        dto.MillesimiFontStyle = item.MillesimiFont.Style;
                    }

                    if (item.RiepilogoFont != null)
                    {
                        dto.RiepilogoFontName = item.RiepilogoFont.Name;
                        dto.RiepilogoFontSize = item.RiepilogoFont.Size;
                        dto.RiepilogoFontStyle = item.RiepilogoFont.Style;
                    }

                    if (item.ImportoRiepilogoFont != null)
                    {
                        dto.ImportoRiepilogoFontName = item.ImportoRiepilogoFont.Name;
                        dto.ImportoRiepilogoFontSize = item.ImportoRiepilogoFont.Size;
                        dto.ImportoRiepilogoFontStyle = item.ImportoRiepilogoFont.Style;
                    }

                    #region Legenda Unità Immobiliare

                    dto.LegendaUnitaCaptionBackColor = item.LegendaUnitaCaptionBackColor;

                    dto.LegendaUnitaCodiceWidth = item.LegendaUnitaCodiceWidth;
                    dto.LegendaUnitaDescrizioneWidth = item.LegendaUnitaDescrizioneWidth;
                    dto.LegendaUnitaTipoWidth = item.LegendaUnitaTipoWidth;
                    dto.LegendaUnitaInternoWidth = item.LegendaUnitaInternoWidth;
                    dto.LegendaUnitaSubalternoWidth = item.LegendaUnitaSubalternoWidth;


                    if (item.LegendaUnitaCaptionFont != null)
                    {
                        dto.LegendaUnitaCaptionFontName = item.LegendaUnitaCaptionFont.Name;
                        dto.LegendaUnitaCaptionFontSize = item.LegendaUnitaCaptionFont.Size;
                        dto.LegendaUnitaCaptionFontStyle = item.LegendaUnitaCaptionFont.Style;
                    }

                    if (item.LegendaUnitaHeaderFont != null)
                    {
                        dto.LegendaUnitaHeaderFontName = item.LegendaUnitaHeaderFont.Name;
                        dto.LegendaUnitaHeaderFontSize = item.LegendaUnitaHeaderFont.Size;
                        dto.LegendaUnitaHeaderFontStyle = item.LegendaUnitaHeaderFont.Style;
                    }

                    if (item.LegendaUnitaTabellaFont != null)
                    {
                        dto.LegendaUnitaTabellaFontName = item.LegendaUnitaTabellaFont.Name;
                        dto.LegendaUnitaTabellaFontSize = item.LegendaUnitaTabellaFont.Size;
                        dto.LegendaUnitaTabellaFontStyle = item.LegendaUnitaTabellaFont.Style;
                    }

                    #endregion Legenda Unità Immobiliare

                    if (item.LogoLocation != null)
                    {
                        dto.LogoLocationX = item.LogoLocation.LocationX;
                        dto.LogoLocationY = item.LogoLocation.LocationY;
                    }

                    if (item.LogoSize != null)
                    {
                        dto.LogoWidth = item.LogoSize.Width;
                        dto.LogoHeight = item.LogoSize.Height;
                    }

                    if (item.ReportSize != null)
                    {
                        dto.ReportWidth = Convert.ToInt32(item.ReportSize.Width);
                        dto.ReportWidth = Convert.ToInt32(item.ReportSize.Height);
                    }

                    foreach (var impostazioniReportDettaglio in item.Dettaglio)
                    {
                        var dettaglioDTO = new ImpostazioneReportDettaglioDTO
                        {
                            ID = impostazioniReportDettaglio.ID,
                            Hidden = impostazioniReportDettaglio.Hidden,
                            ColumnType = impostazioniReportDettaglio.ColumnType,
                            Width = impostazioniReportDettaglio.Width,
                            WidthMillesimi = impostazioniReportDettaglio.WidthMillesimi,
                            PrintPage = impostazioniReportDettaglio.PrintPage,
                            OrdineConto = impostazioniReportDettaglio.OrdineConto,
                            Conto = impostazioniReportDettaglio.ColumnType.ToString(),
                            DescrizioneImporto = impostazioniReportDettaglio.DescrizioneImporto,
                            DescrizioneMillesimi = impostazioniReportDettaglio.DescrizioneMillesimi,
                            HideMillesimi = impostazioniReportDettaglio.HideMillesimi,
                            GroupName = impostazioniReportDettaglio.GroupName
                        };

                        if (impostazioniReportDettaglio.Font != null)
                        {
                            dettaglioDTO.FontName = impostazioniReportDettaglio.Font.Name;
                            if (impostazioniReportDettaglio.Font.Size > 0)
                                dettaglioDTO.FontSize = impostazioniReportDettaglio.Font.Size;
                            if (!string.IsNullOrEmpty(impostazioniReportDettaglio.Font.Style))
                                dettaglioDTO.FontStyle = impostazioniReportDettaglio.Font.Style;
                        }

                        if (impostazioniReportDettaglio.MillesimiFont != null)
                        {
                            dettaglioDTO.MillesimiFontName = impostazioniReportDettaglio.MillesimiFont.Name;
                            if (impostazioniReportDettaglio.MillesimiFont.Size > 0)
                                dettaglioDTO.MillesimiFontSize = impostazioniReportDettaglio.MillesimiFont.Size;
                            if (!string.IsNullOrEmpty(impostazioniReportDettaglio.MillesimiFont.Style))
                                dettaglioDTO.MillesimiFontStyle = impostazioniReportDettaglio.MillesimiFont.Style;
                        }

                        if (impostazioniReportDettaglio.Conto != null)
                        {
                            dettaglioDTO.IdConto = impostazioniReportDettaglio.Conto.ID;
                            dettaglioDTO.Conto = impostazioniReportDettaglio.Conto.Descrizione;
                            if (dettaglioDTO.OrdineConto.GetValueOrDefault() == 0)
                                dettaglioDTO.OrdineConto = impostazioniReportDettaglio.Conto.Ordine;

                            if (Math.Abs(impostazioniReportDettaglio.WidthMillesimi.GetValueOrDefault()) < tolerance)
                                dettaglioDTO.WidthMillesimi = 50f;
                        }
                        else if (impostazioniReportDettaglio.PianoRatealeDettaglio != null)
                        {
                            dettaglioDTO.IdConto = impostazioniReportDettaglio.PianoRatealeDettaglio.ID;
                            dettaglioDTO.Conto = impostazioniReportDettaglio.PianoRatealeDettaglio.Descrizione;
                            if (dettaglioDTO.OrdineConto.GetValueOrDefault() == 0)
                                dettaglioDTO.OrdineConto = impostazioniReportDettaglio.PianoRatealeDettaglio.Progressivo;
                        }
                        else
                        {
                            dettaglioDTO.Conto = impostazioniReportDettaglio.Nome;
                            if (string.IsNullOrEmpty(dettaglioDTO.Conto))
                                dettaglioDTO.Conto = getColumnName(impostazioniReportDettaglio.ColumnType, impostazioniReportDettaglio.OrdineConto.GetValueOrDefault());
                        }

                        if (impostazioniReportDettaglio.Banca != null)
                            dettaglioDTO.IdBanca = impostazioniReportDettaglio.Banca.ID;

                        if (Math.Abs(impostazioniReportDettaglio.Width.GetValueOrDefault()) < tolerance)
                            dettaglioDTO.Width = getColumnWidth(impostazioniReportDettaglio.ColumnType, impostazioniReportDettaglio.OrdineConto.GetValueOrDefault());

                        dto.Dettaglio.Add(dettaglioDTO);
                    }

                    if (item.ReportKey == "PIARAT")
                    {

                        if (pianoRateale != null)
                        {
                            foreach (var rata in pianoRateale.Rate)
                            {
                                if (dto.Dettaglio.All(itemDettaglio => itemDettaglio.IdConto != rata.ID))
                                {
                                    var dettaglioDTO = new ImpostazioneReportDettaglioDTO
                                    {
                                        IdConto = rata.ID,
                                        Conto = rata.Descrizione,
                                        DescrizioneImporto = "Importo",
                                        ColumnType = ColumnTypeEnum.Conto,
                                        PrintPage = 1,
                                        OrdineConto = rata.Progressivo,
                                        Width = 80f,
                                        WidthMillesimi = 50f,
                                        FontStyle = "Bold"
                                    };

                                    dto.Dettaglio.Add(dettaglioDTO);
                                }
                            }
                        }

                        addColumnConto(dto, -30);
                        addColumnConto(dto, -20);
                        addColumnConto(dto, -10);

                        addColumn(ColumnTypeEnum.OrdineUnita, dto, -100, false);
                        addColumn(ColumnTypeEnum.Nominativo, dto, -90, false);
                        addColumn(ColumnTypeEnum.TipoUnita, dto, -80, true);
                        addColumn(ColumnTypeEnum.Interno, dto, -70, true);
                        addColumn(ColumnTypeEnum.Piano, dto, -60, true);
                        addColumn(ColumnTypeEnum.Subalterno, dto, -50, true);
                        addColumn(ColumnTypeEnum.ProprietaConduzione, dto, -40, false);
                    }

                    if (item.ReportKey == "RICECO")
                    {
                        addColumn(ColumnTypeEnum.Descrizione, dto, 10, false, null, 250);
                        addColumn(ColumnTypeEnum.Importo, dto, 20, false, null, 110);
                    }

                    if (item.ReportKey.StartsWith("RIP"))
                    {
                        
                        if (conti != null)
                        {
                            foreach (var conto in conti)
                            {
                                if (dto.Dettaglio.All(itemDettaglio => itemDettaglio.IdConto != conto.ID))
                                {
                                    var dettaglioDTO = new ImpostazioneReportDettaglioDTO
                                    {
                                        IdConto = conto.ID,
                                        Conto = conto.Descrizione,
                                        DescrizioneImporto = "Importo",
                                        DescrizioneMillesimi = "Mill.",
                                        ColumnType = ColumnTypeEnum.Conto,
                                        PrintPage = 1,
                                        OrdineConto = conto.Ordine,
                                        Width = 80f,
                                        WidthMillesimi = 50f
                                    };

                                    if (conto.IsSpesePersonali)
                                        dettaglioDTO.HideMillesimi = true;

                                    dto.Dettaglio.Add(dettaglioDTO);
                                }
                            }
                        }

                        addColumnConto(dto, 9990);
                        addColumnConto(dto, 9991);
                        addColumnConto(dto, 9992);
                        addColumnConto(dto, 9993);
                        addColumnConto(dto, 9994);
                        addColumnConto(dto, 9995);
                        addColumnConto(dto, 9996);
                        addColumnConto(dto, 9997);

                        addColumn(ColumnTypeEnum.OrdineUnita, dto, -100, false);
                        addColumn(ColumnTypeEnum.Nominativo, dto, -90, false);
                        addColumn(ColumnTypeEnum.TipoUnita, dto, -80, true);
                        addColumn(ColumnTypeEnum.Interno, dto, -70, true);
                        addColumn(ColumnTypeEnum.Piano, dto, -60, true);
                        addColumn(ColumnTypeEnum.Subalterno, dto, -50, true);
                        addColumn(ColumnTypeEnum.ProprietaConduzione, dto, -40, false);
                        addColumn(ColumnTypeEnum.MillesimiProprieta, dto, -30, true);
                    }

                    if (item.ReportKey.StartsWith("BIL"))
                    {
                        addColumn(ColumnTypeEnum.CodiceConto, dto, 10, false);
                        addColumn(ColumnTypeEnum.DescrizioneConto, dto, 20, false);
                        addColumn(ColumnTypeEnum.DataFattura, dto, 30, true);
                        addColumn(ColumnTypeEnum.NumeroFattura, dto, 40, true);
                        addColumn(ColumnTypeEnum.Protocollo, dto, 50, true);
                        addColumn(ColumnTypeEnum.DataPagamento, dto, 60, true);
                        addColumn(ColumnTypeEnum.DataVersamentoRitenuta, dto, 70, true);

                        addColumn(ColumnTypeEnum.Fornitore, dto, 80, true);
                        addColumn(ColumnTypeEnum.Importo, dto, 90, false);
                        addColumn(ColumnTypeEnum.ImportoProprieta, dto, 100, true);
                        addColumn(ColumnTypeEnum.ImportoConduzione, dto, 110, true);
                        addColumn(ColumnTypeEnum.Totale, dto, 120, false);

                        addColumn(ColumnTypeEnum.ImportoConsuntivoAnnoPrecedente, dto, 130, true);
                        addColumn(ColumnTypeEnum.ImportoPreventivoAnnoPrecedente, dto, 140, true);
                        addColumn(ColumnTypeEnum.ImportoScostamentoAnnoPrecedente, dto, 150, true);
                    }

                    if (item.ReportKey.StartsWith("REGCONT"))
                    {
                        addColumn(ColumnTypeEnum.NumeroRiga, dto, 10, false);
                        addColumn(ColumnTypeEnum.Data, dto, 20, false);
                        addColumn(ColumnTypeEnum.Descrizione, dto, 30, false);
                        addColumn(ColumnTypeEnum.TipoDocumento, dto, 40, false, "Documento");
                        addColumn(ColumnTypeEnum.NumeroDocumento, dto, 50, false, "Documento");
                        addColumn(ColumnTypeEnum.DataDocumento, dto, 60, false, "Documento");
                        addColumn(ColumnTypeEnum.NumeroProtocollo, dto, 70, false, "Documento");

                        addColumn(ColumnTypeEnum.ImportoCassaDare, dto, 80, false, "Cassa");
                        addColumn(ColumnTypeEnum.ImportoCassaAvere, dto, 90, false, "Cassa");
                        addColumn(ColumnTypeEnum.ImportoCassaSaldo, dto, 100, false, "Cassa");

                        // Una colonna per ogni Banca
                        if (banche != null)
                        {
                            var index = 100;
                            foreach (var banca in banche.OrderBy(b => b.DataValidita.GetValueOrDefault()))
                            {
                                index = index + 10;
                                addColumnBanca(dto, banca, index, daoFactory);
                            }
                        }

                    }

                    if (item.ReportKey.StartsWith("PERSRI"))
                    {
                        addColumn(ColumnTypeEnum.CodiceConto, dto, 10, false, null, 60);
                        addColumn(ColumnTypeEnum.DescrizioneConto, dto, 20, false, null, 310);

                        addColumn(ColumnTypeEnum.MillesimiProprieta, dto, 30, false, null, 80, "Mill.");
                        addColumn(ColumnTypeEnum.Importo, dto, 40, false, null, 100);
                        addColumn(ColumnTypeEnum.ImportoProprieta, dto, 50, true);
                        addColumn(ColumnTypeEnum.ImportoConduzione, dto, 60, true);
                        addColumn(ColumnTypeEnum.Totale, dto, 70, false, null, 100);
                    }

                    dto.Dettaglio = dto.Dettaglio.OrderBy(itemDettaglio => itemDettaglio.OrdineConto).ToList();

                    return dto; 
                }

                return new ImpostazioneReportDTO();
            }

            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nella lettura delle impostazioni di report - {0} - id:{1}", ex, Utility.GetMethodDescription(), item.ID);
                throw;
            }
        }
        private bool insert(ImpostazioneReportDTO dto, out ImpostazioniReport item)
        {
            var daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);
            item = null;
            try
            {
                item = new ImpostazioniReport(daoFactory.GetAziendaDao().GetById(_info.Azienda, false))
                {
                    TipoLogo = dto.TipoLogo,
                    ReportKey = dto.ReportKey,
                    DefaultFont = new FontType()
                };

                item.DefaultFont.Name = dto.FontName;
                item.DefaultFont.Size = dto.FontSize;
                item.DefaultFont.Style = dto.FontStyle;

                item.RowHeight = dto.RowHeight;
                item.BorderInsideGroup = dto.BorderInsideGroup;

                daoFactory.GetImpostazioniReportDao().SaveOrUpdate(item);
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nel salvataggio delle impostazioni di report - {0} - id:{1}", ex, Utility.GetMethodDescription(), dto.ID);
                throw;
            }
            return true;
        }
        private bool update(ImpostazioneReportDTO dto, out ImpostazioniReport item)
        {
            bool result;
            item = null;
            var daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);

            try
            {
                if (dto.IdCondominio == null)
                    item = daoFactory.GetImpostazioniReportDao().Find(dto.ID, false);
                else
                {
                    item = daoFactory.GetImpostazioniReportDao().GetByReportCondominio(dto.ReportKey, dto.IdCondominio.GetValueOrDefault());
                    if (item == null)
                        item = daoFactory.GetImpostazioniReportDao().GetByReportAzienda(dto.ReportKey, _info.Azienda);
                }

                if (item != null && item.Azienda == null)
                {
                    var azienda = daoFactory.GetAziendaDao().Find(_info.Azienda, false);
                    item = (ImpostazioniReport)item.Clone();
                    item.Azienda = azienda;
                    if (dto.IdCondominio != null)
                        item.Condominio = daoFactory.GetCondominioDao().Find(dto.IdCondominio.Value, false);
                }
                else if (item != null && item.Condominio == null && dto.IdCondominio != null)
                {
                    var azienda = daoFactory.GetAziendaDao().Find(_info.Azienda, false);
                    item = (ImpostazioniReport)item.Clone();
                    item.Azienda = azienda;
                    item.Condominio = daoFactory.GetCondominioDao().Find(dto.IdCondominio.Value, false);
                }
                else if (item == null)
                {
                    var azienda = daoFactory.GetAziendaDao().Find(_info.Azienda, false);
                    item = new ImpostazioniReport(azienda);
                    if (dto.IdCondominio != null)
                        item.Condominio = daoFactory.GetCondominioDao().Find(dto.IdCondominio.Value, false);
                }

                // Condizione necessare per il controllo del fatto che sul DB ho una versione uguale o più vecchia
                if (dto.Version == item.Version)
                {
                    item.Descrizione = dto.Descrizione;
                    item.DefaultFont = new FontType
                    {
                        Name = dto.FontName,
                        Size = dto.FontSize,
                        Style = dto.FontStyle,
                    };

                    item.CaptionFont = null;
                    if (!string.IsNullOrEmpty(dto.CaptionFontName) || dto.CaptionFontStyle != null || dto.CaptionFontSize != null)
                    {
                        item.CaptionFont = new FontType { Name = dto.CaptionFontName };
                        if (dto.CaptionFontSize != null && dto.CaptionFontSize.GetValueOrDefault() > 0)
                            item.CaptionFont.Size = dto.CaptionFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.CaptionFontStyle))
                            item.CaptionFont.Style = dto.CaptionFontStyle;
                    }

                    item.HeaderFont = null;
                    if (!string.IsNullOrEmpty(dto.HeaderFontName) || dto.HeaderFontStyle != null || dto.HeaderFontSize != null)
                    {
                        item.HeaderFont = new FontType { Name = dto.HeaderFontName };
                        if (dto.HeaderFontSize != null && dto.HeaderFontSize.GetValueOrDefault() > 0)
                            item.HeaderFont.Size = dto.HeaderFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.HeaderFontStyle))
                            item.HeaderFont.Style = dto.HeaderFontStyle;
                    }

                    item.TotaleFont = null;
                    if (!string.IsNullOrEmpty(dto.TotaleFontName) || dto.TotaleFontStyle != null || dto.TotaleFontSize != null)
                    {
                        item.TotaleFont = new FontType { Name = dto.TotaleFontName };
                        if (dto.TotaleFontSize != null && dto.TotaleFontSize.GetValueOrDefault() > 0)
                            item.TotaleFont.Size = dto.TotaleFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.TotaleFontStyle))
                            item.TotaleFont.Style = dto.TotaleFontStyle;
                    }

                    item.ArrotondamentiFont = null;
                    if (!string.IsNullOrEmpty(dto.ArrotondamentiFontName) || dto.ArrotondamentiFontStyle != null || dto.ArrotondamentiFontSize != null)
                    {
                        item.ArrotondamentiFont = new FontType { Name = dto.ArrotondamentiFontName };
                        if (dto.ArrotondamentiFontSize != null && dto.ArrotondamentiFontSize.GetValueOrDefault() > 0)
                            item.ArrotondamentiFont.Size = dto.ArrotondamentiFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.ArrotondamentiFontStyle))
                            item.ArrotondamentiFont.Style = dto.ArrotondamentiFontStyle;
                    }

                    item.PageInfoFont = null;
                    if (!string.IsNullOrEmpty(dto.PageInfoFontName) || dto.PageInfoFontStyle != null || dto.PageInfoFontSize != null)
                    {
                        item.PageInfoFont = new FontType { Name = dto.PageInfoFontName };
                        if (dto.PageInfoFontSize != null && dto.PageInfoFontSize.GetValueOrDefault() > 0)
                            item.PageInfoFont.Size = dto.PageInfoFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.PageInfoFontStyle))
                            item.PageInfoFont.Style = dto.PageInfoFontStyle;
                    }

                    item.MillesimiFont = null;
                    if (!string.IsNullOrEmpty(dto.MillesimiFontName) || dto.MillesimiFontStyle != null || dto.MillesimiFontSize != null)
                    {
                        item.MillesimiFont = new FontType { Name = dto.MillesimiFontName };
                        if (dto.MillesimiFontSize != null && dto.MillesimiFontSize.GetValueOrDefault() > 0)
                            item.MillesimiFont.Size = dto.MillesimiFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.MillesimiFontStyle))
                            item.MillesimiFont.Style = dto.MillesimiFontStyle;
                    }

                    item.RiepilogoFont = null;
                    if (!string.IsNullOrEmpty(dto.RiepilogoFontName) || dto.RiepilogoFontStyle != null || dto.RiepilogoFontSize != null)
                    {
                        item.RiepilogoFont = new FontType { Name = dto.RiepilogoFontName };
                        if (dto.RiepilogoFontSize != null && dto.RiepilogoFontSize.GetValueOrDefault() > 0)
                            item.RiepilogoFont.Size = dto.RiepilogoFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.RiepilogoFontStyle))
                            item.RiepilogoFont.Style = dto.RiepilogoFontStyle;
                    }

                    item.ImportoRiepilogoFont = null;
                    if (!string.IsNullOrEmpty(dto.ImportoRiepilogoFontName) || dto.ImportoRiepilogoFontStyle != null || dto.ImportoRiepilogoFontSize != null)
                    {
                        item.ImportoRiepilogoFont = new FontType { Name = dto.ImportoRiepilogoFontName };
                        if (dto.ImportoRiepilogoFontSize != null && dto.ImportoRiepilogoFontSize.GetValueOrDefault() > 0)
                            item.ImportoRiepilogoFont.Size = dto.ImportoRiepilogoFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.ImportoRiepilogoFontStyle))
                            item.ImportoRiepilogoFont.Style = dto.ImportoRiepilogoFontStyle;
                    }

                    item.LogoSize = null;
                    if (dto.LogoHeight != null && dto.LogoWidth != null)
                    {
                        item.LogoSize = new SizeMeasure { Height = dto.LogoHeight.Value, Width = dto.LogoWidth.Value };
                    }

                    item.LogoLocation = null;
                    if(dto.LogoLocationX != null && dto.LogoLocationY != null)
                    {
                        item.LogoLocation = new LocationPoint
                        {
                            LocationX = dto.LogoLocationX.Value,
                            LocationY = dto.LogoLocationY.Value
                        };
                    }

                    item.ReportSize = null;
                    if (dto.ReportHeight != null && dto.ReportWidth != null)
                    {
                        item.ReportSize = new SizeMeasure { Height = dto.ReportHeight.Value, Width = dto.ReportWidth.Value};
                    }

                    #region Legenda Unità Immobiliare
                    
                    item.LegendaUnitaCaptionFont = null;
                    if (!string.IsNullOrEmpty(dto.LegendaUnitaCaptionFontName) || dto.LegendaUnitaCaptionFontStyle != null || dto.LegendaUnitaCaptionFontSize != null)
                    {
                        item.LegendaUnitaCaptionFont = new FontType { Name = dto.LegendaUnitaCaptionFontName };
                        if (dto.LegendaUnitaCaptionFontSize != null && dto.LegendaUnitaCaptionFontSize.GetValueOrDefault() > 0)
                            item.LegendaUnitaCaptionFont.Size = dto.LegendaUnitaCaptionFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.LegendaUnitaCaptionFontStyle))
                            item.LegendaUnitaCaptionFont.Style = dto.LegendaUnitaCaptionFontStyle;
                    }

                    item.LegendaUnitaHeaderFont = null;
                    if (!string.IsNullOrEmpty(dto.LegendaUnitaHeaderFontName) || dto.LegendaUnitaHeaderFontStyle != null || dto.LegendaUnitaHeaderFontSize != null)
                    {
                        item.LegendaUnitaHeaderFont = new FontType { Name = dto.LegendaUnitaHeaderFontName };
                        if (dto.LegendaUnitaHeaderFontSize != null && dto.LegendaUnitaHeaderFontSize.GetValueOrDefault() > 0)
                            item.LegendaUnitaHeaderFont.Size = dto.LegendaUnitaHeaderFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.LegendaUnitaHeaderFontStyle))
                            item.LegendaUnitaHeaderFont.Style = dto.LegendaUnitaHeaderFontStyle;
                    }

                    item.LegendaUnitaTabellaFont = null;
                    if (!string.IsNullOrEmpty(dto.LegendaUnitaTabellaFontName) || dto.LegendaUnitaTabellaFontStyle != null || dto.LegendaUnitaTabellaFontSize != null)
                    {
                        item.LegendaUnitaTabellaFont = new FontType { Name = dto.LegendaUnitaTabellaFontName };
                        if (dto.LegendaUnitaTabellaFontSize != null && dto.LegendaUnitaTabellaFontSize.GetValueOrDefault() > 0)
                            item.LegendaUnitaTabellaFont.Size = dto.LegendaUnitaTabellaFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.LegendaUnitaTabellaFontStyle))
                            item.LegendaUnitaTabellaFont.Style = dto.LegendaUnitaTabellaFontStyle;
                    }

                    item.LegendaUnitaCaptionBackColor = dto.LegendaUnitaCaptionBackColor;

                    item.LegendaUnitaCodiceWidth = dto.LegendaUnitaCodiceWidth;
                    item.LegendaUnitaDescrizioneWidth = dto.LegendaUnitaDescrizioneWidth;
                    item.LegendaUnitaTipoWidth = dto.LegendaUnitaTipoWidth;
                    item.LegendaUnitaInternoWidth = dto.LegendaUnitaInternoWidth;
                    item.LegendaUnitaSubalternoWidth = dto.LegendaUnitaSubalternoWidth;

                    #endregion Legenda Unità Immobiliare

                    item.TipoLogo = dto.TipoLogo;
                    item.ReportKey = dto.ReportKey;
                    item.Descrizione = dto.Descrizione;
                    item.PosizioneLogo = dto.PosizioneLogo;
                    item.PaperKind = dto.PaperKind;
                    item.Landscape = dto.Landscape;
                    item.CellPadding = dto.CellPadding;
                    item.CaptionBackColor = dto.CaptionBackColor;
                    item.HeaderBackColor = dto.HeaderBackColor;
                    item.TotaleBackColor = dto.TotaleBackColor;
                    item.CaptionRowHeight = dto.CaptionRowHeight;
                    item.CaptionTopMargin = dto.CaptionTopMargin;
                    item.CaptionLeftMargin = dto.CaptionLeftMargin;
                    item.HeaderRowHeight = dto.HeaderRowHeight;
                    item.TotaleRowHeight = dto.TotaleRowHeight;
                    item.ArrotondamentiRowHeight = dto.ArrotondamentiRowHeight;
                    item.CaptionAlignment = dto.CaptionAlignment;
                    item.HeaderAlignment = dto.HeaderAlignment;
                    item.BorderColor = dto.BorderColor;
                    item.DescrizioneContoCompleta = dto.DescrizioneContoCompleta;
                    item.StabilePageBreak = dto.StabilePageBreak;
                    item.ScalaPageBreak = dto.ScalaPageBreak;
                    item.StabileTotali = dto.StabileTotali;
                    item.ScalaTotali = dto.ScalaTotali;
                    item.MultiPage = dto.MultiPage;
                    item.MultiPageOrdered = dto.MultiPageOrdered;
                    item.RowHeight = dto.RowHeight;
                    item.BorderInsideGroup = dto.BorderInsideGroup;
                    item.RiepilogoText = dto.RiepilogoText;
                    item.PrintTotale = dto.PrintTotale;

                    item.OrdineUnitaAllRows = dto.OrdineUnitaAllRows;

                    item.RiepilogoTopMargin = dto.RiepilogoTopMargin;
                    item.RiepilogoLeftMargin = dto.RiepilogoLeftMargin;
                    item.RiepilogoRtf = dto.RiepilogoRtf;

                    item.IndirizzoDestinatarioTopMargin = dto.IndirizzoDestinatarioTopMargin;
                    item.IndirizzoDestinatarioLeftMargin = dto.IndirizzoDestinatarioLeftMargin;
                    item.IndirizzoDestinatarioRtf = dto.IndirizzoDestinatarioRtf;

                    item.IndirizzoPerConoscenzaTopMargin = dto.IndirizzoPerConoscenzaTopMargin;
                    item.IndirizzoPerConoscenzaLeftMargin = dto.IndirizzoPerConoscenzaLeftMargin;
                    item.IndirizzoPerConoscenzaRtf = dto.IndirizzoPerConoscenzaRtf;

                    item.TestoLetteraTopMargin = dto.TestoLetteraTopMargin;
                    item.TestoLetteraLeftMargin = dto.TestoLetteraLeftMargin;
                    item.TestoLetteraRtf = dto.TestoLetteraRtf;
                    item.TestoLetteraWidth = dto.TestoLetteraWidth;

                    item.TestoUnitaImmobiliareRtf = dto.TestoUnitaImmobiliareRtf;
                    item.TestoUnitaImmobiliareTopMargin = dto.TestoUnitaImmobiliareTopMargin;
                    item.TestoUnitaImmobiliareLeftMargin = dto.TestoUnitaImmobiliareLeftMargin;

                    item.FirmaLetteraTopMargin = dto.FirmaLetteraTopMargin;
                    item.FirmaLetteraLeftMargin = dto.FirmaLetteraLeftMargin;
                    item.FirmaLetteraRtf = dto.FirmaLetteraRtf;

                    item.NoteBorder = dto.NoteBorder;
                    item.NoteWidth = dto.NoteWidth;
                    item.NotePadding = dto.NotePadding;
                    item.NoteTopMargin = dto.NoteTopMargin;
                    item.NoteLeftMargin = dto.NoteLeftMargin;

                    item.SottoContoTotali = dto.SottoContoTotali;
                    item.DettaglioPersonali = dto.DettaglioPersonali;

                    item.HeaderContoBackColor = dto.HeaderContoBackColor;
                    item.TotaleContoBackColor = dto.TotaleContoBackColor;
                    item.HeaderSottoContoBackColor = dto.HeaderSottoContoBackColor;
                    item.TotaleSottoContoBackColor = dto.TotaleSottoContoBackColor;
                    item.TotaleStabileBackColor = dto.TotaleStabileBackColor;
                    item.TotaleScalaBackColor = dto.TotaleScalaBackColor;

                    item.OrdineStampaMovimenti = dto.OrdineStampaMovimenti;
                    item.NumeroColonne = dto.NumeroColonne;
                    item.DirezioneColonne = dto.DirezioneColonne;
                    item.FitToPage = dto.FitToPage;
                    item.DateTimeFormat = dto.DateTimeFormat;

                    item.OrdineStampaContoSottoconto = dto.OrdineStampaContoSottoconto;
                    item.LimitePagamenti = dto.LimitePagamenti;
                    item.TemplateFatturePagate = dto.TemplateFatturePagate;

                    if ((dto.TopMargin != null || dto.BottomMargin != null || dto.LeftMargin != null || dto.RightMargin != null) && item.ReportMargin == null)
                        item.ReportMargin = new MarginSize();
                    if(dto.TopMargin != null)
                        item.ReportMargin.Top = dto.TopMargin.Value;
                    if (dto.BottomMargin != null)
                        item.ReportMargin.Bottom = dto.BottomMargin.Value;
                    if (dto.LeftMargin != null)
                        item.ReportMargin.Left = dto.LeftMargin.Value;
                    if (dto.RightMargin != null)
                        item.ReportMargin.Right = dto.RightMargin.Value;

                    #region Bilancio Annuale

                    item.HeaderContoFont = null;
                    if (!string.IsNullOrEmpty(dto.HeaderContoFontName) || dto.HeaderContoFontStyle != null || dto.HeaderContoFontSize != null)
                    {
                        item.HeaderContoFont = new FontType { Name = dto.HeaderContoFontName };
                        if (dto.HeaderContoFontSize != null && dto.HeaderContoFontSize.GetValueOrDefault() > 0)
                            item.HeaderContoFont.Size = dto.HeaderContoFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.HeaderContoFontStyle))
                            item.HeaderContoFont.Style = dto.HeaderContoFontStyle;
                    }

                    item.TotaleContoFont = null;
                    if (!string.IsNullOrEmpty(dto.TotaleContoFontName) || dto.TotaleContoFontStyle != null || dto.TotaleContoFontSize != null)
                    {
                        item.TotaleContoFont = new FontType { Name = dto.TotaleContoFontName };
                        if (dto.TotaleContoFontSize != null && dto.TotaleContoFontSize.GetValueOrDefault() > 0)
                            item.TotaleContoFont.Size = dto.TotaleContoFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.TotaleContoFontStyle))
                            item.TotaleContoFont.Style = dto.TotaleContoFontStyle;
                    }

                    item.HeaderSottoContoFont = null;
                    if (!string.IsNullOrEmpty(dto.HeaderSottoContoFontName) || dto.HeaderSottoContoFontStyle != null || dto.HeaderSottoContoFontSize != null)
                    {
                        item.HeaderSottoContoFont = new FontType { Name = dto.HeaderSottoContoFontName };
                        if (dto.HeaderSottoContoFontSize != null && dto.HeaderSottoContoFontSize.GetValueOrDefault() > 0)
                            item.HeaderSottoContoFont.Size = dto.HeaderSottoContoFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.HeaderSottoContoFontStyle))
                            item.HeaderSottoContoFont.Style = dto.HeaderSottoContoFontStyle;
                    }

                    item.TotaleSottoContoFont = null;
                    if (!string.IsNullOrEmpty(dto.TotaleSottoContoFontName) || dto.TotaleSottoContoFontStyle != null || dto.TotaleSottoContoFontSize != null)
                    {
                        item.TotaleSottoContoFont = new FontType { Name = dto.TotaleSottoContoFontName };
                        if (dto.TotaleSottoContoFontSize != null && dto.TotaleSottoContoFontSize.GetValueOrDefault() > 0)
                            item.TotaleSottoContoFont.Size = dto.TotaleSottoContoFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.TotaleSottoContoFontStyle))
                            item.TotaleSottoContoFont.Style = dto.TotaleSottoContoFontStyle;
                    }

                    item.TotaleStabileFont = null;
                    if (!string.IsNullOrEmpty(dto.TotaleStabileFontName) || dto.TotaleStabileFontStyle != null || dto.TotaleStabileFontSize != null)
                    {
                        item.TotaleStabileFont = new FontType { Name = dto.TotaleStabileFontName };
                        if (dto.TotaleStabileFontSize != null && dto.TotaleStabileFontSize.GetValueOrDefault() > 0)
                            item.TotaleStabileFont.Size = dto.TotaleStabileFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.TotaleStabileFontStyle))
                            item.TotaleStabileFont.Style = dto.TotaleStabileFontStyle;
                    }

                    item.TotaleScalaFont = null;
                    if (!string.IsNullOrEmpty(dto.TotaleScalaFontName) || dto.TotaleScalaFontStyle != null || dto.TotaleScalaFontSize != null)
                    {
                        item.TotaleScalaFont = new FontType { Name = dto.TotaleScalaFontName };
                        if (dto.TotaleScalaFontSize != null && dto.TotaleScalaFontSize.GetValueOrDefault() > 0)
                            item.TotaleScalaFont.Size = dto.TotaleScalaFontSize.Value;
                        if (!string.IsNullOrEmpty(dto.TotaleScalaFontStyle))
                            item.TotaleScalaFont.Style = dto.TotaleScalaFontStyle;
                    }

                    #endregion Bilancio Annuale

                    foreach (var impostazioneReportDettaglioDTO in dto.Dettaglio)
                    {
                        var impostazioneDettaglio = daoFactory.GetImpostazioniReportDettaglioDao().Find(impostazioneReportDettaglioDTO.ID, false);
                        if (impostazioneDettaglio == null || item.ID == 0)
                            impostazioneDettaglio = new ImpostazioniReportDettaglio(item);

                        impostazioneDettaglio.ColumnType = impostazioneReportDettaglioDTO.ColumnType;
                        if (impostazioneReportDettaglioDTO.IdConto != null)
                        {
                            if (item.ReportKey != "PIARAT")
                            {
                                impostazioneDettaglio.Conto = daoFactory.GetContoDao().Find(impostazioneReportDettaglioDTO.IdConto.Value, false);
                                if (impostazioneDettaglio.Conto != null)
                                    impostazioneDettaglio.WidthMillesimi = impostazioneReportDettaglioDTO.WidthMillesimi;
                            }
                            else
                            {
                                impostazioneDettaglio.PianoRatealeDettaglio = daoFactory.GetPianoRatealeDettaglioDao().Find(impostazioneReportDettaglioDTO.IdConto.Value, false);
                            }
                        }

                        if (impostazioneReportDettaglioDTO.IdBanca != null)
                            impostazioneDettaglio.Banca = daoFactory.GetDatiBancariCondominiDao().Find(impostazioneReportDettaglioDTO.IdBanca.Value, false);

                        impostazioneDettaglio.Nome = impostazioneReportDettaglioDTO.Conto;
                        impostazioneDettaglio.Hidden = impostazioneReportDettaglioDTO.Hidden;
                        impostazioneDettaglio.OrdineConto = impostazioneReportDettaglioDTO.OrdineConto;
                        impostazioneDettaglio.PrintPage = impostazioneReportDettaglioDTO.PrintPage;
                        impostazioneDettaglio.Width = impostazioneReportDettaglioDTO.Width;
                        impostazioneDettaglio.DescrizioneImporto = impostazioneReportDettaglioDTO.DescrizioneImporto;
                        impostazioneDettaglio.DescrizioneMillesimi = impostazioneReportDettaglioDTO.DescrizioneMillesimi;
                        impostazioneDettaglio.HideMillesimi = impostazioneReportDettaglioDTO.HideMillesimi;
                        impostazioneDettaglio.GroupName = impostazioneReportDettaglioDTO.GroupName;

                        impostazioneDettaglio.Font = new FontType
                        {
                            Name = impostazioneReportDettaglioDTO.FontName,
                            Style = impostazioneReportDettaglioDTO.FontStyle,
                            Size = impostazioneReportDettaglioDTO.FontSize.GetValueOrDefault()
                        };

                        impostazioneDettaglio.MillesimiFont = new FontType
                        {
                            Name = impostazioneReportDettaglioDTO.MillesimiFontName,
                            Style = impostazioneReportDettaglioDTO.MillesimiFontStyle,
                            Size = impostazioneReportDettaglioDTO.MillesimiFontSize.GetValueOrDefault()
                        };
                    }

                    daoFactory.GetImpostazioniReportDao().SaveOrUpdate(item);

                    result = true;
                }
                else
                {
                    // Eccezione: Sul db c'è qualche cosa di più nuovo.

                    _log.ErrorFormat("Errore nel salvataggio delle impostazioni di report - id:{0} - il dato sul db è più recente di quello che si vuole salvare", dto.ID);
                    result = false;
                }
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nel salvataggio della lettura delle impostazioni di report - {0} - id:{1}", ex, Utility.GetMethodDescription(), dto.ID);
                throw;
            }

            return result;
        }