Exemplo n.º 1
0
		FlowDocument FillFlowDocument(ref FlowDocument doc, Size pageSize)   // Per stampa
			{
			doc.ColumnWidth = doc.MaxPageWidth = pageSize.Width;
			doc.MaxPageHeight = pageSize.Height;

			Section[] sz = new Section[4];


			sz[0] = CreateSectionWithPageBreak();
			PrintTesto(ref sz[0], "OPERAZIONI");                              // Stampa le Operazioni (filtrate)
			Table tOp = new Table();
			Operazione opEmpty = new Operazione();
			TableRowGroup rgOp = new TableRowGroup();
			PrintTitoliTabella(ref tOp, ref rgOp, opEmpty);
			foreach (Operazione op in operazioni.operazioni)
				{
				PrintRigaTabella(ref tOp, ref rgOp, op);
				}
			tOp.RowGroups.Add(rgOp);
			sz[0].Blocks.Add(tOp);
			doc.Blocks.Add(sz[0]);
			
			sz[1] = CreateSectionWithPageBreak();
			PrintTesto(ref sz[1], "CONTI");                                   // Stampa i Conti
			Table tCn = new Table();
			Conto cnEmpty = new Conto();
			TableRowGroup rgCn = new TableRowGroup();
			PrintTitoliTabella(ref tCn, ref rgCn, cnEmpty);
			foreach (Conto cn in operazioni.conti)
				{
				PrintRigaTabella(ref tCn, ref rgCn, cn);
				}
			tCn.RowGroups.Add(rgCn);
			sz[1].Blocks.Add(tCn);
			doc.Blocks.Add(sz[1]);

			sz[2] = CreateSectionWithPageBreak();
			PrintTesto(ref sz[2], "OPERAZIONI STANDARD");                     // Stampa le Operazioni Standard
			Table tOs = new Table();
			OpStandard osEmpty = new OpStandard();
			TableRowGroup rgOs = new TableRowGroup();
			PrintTitoliTabella(ref tOs, ref rgOs, osEmpty);
			foreach (OpStandard os in operazioni.opStandard)
				{
				PrintRigaTabella(ref tOs, ref rgOs, os);
				}
			tOs.RowGroups.Add(rgOs);
			sz[2].Blocks.Add(tOs);
			doc.Blocks.Add(sz[2]);

			#region DA SCRIVERE

			sz[3] = CreateSectionWithPageBreak(true);
			foreach (Conto cnt in operazioni.Conti())
				{
				PrintTesto(ref sz[3], "CONSUNTIVO[" + cnt.numero.ToString() + "]: " + cnt.descrizione);
				List<Consuntivo> lc = operazioni.FindListaConsuntivi(cnt.numero);
				if (lc != null)
					{
					Table tCns = new Table();
					Consuntivo cnsEmpty = new Consuntivo();
					TableRowGroup rgCns = new TableRowGroup();
					PrintTitoliTabella(ref tCns, ref rgCns, cnsEmpty);
					foreach (Consuntivo cns in lc)
						{
						PrintRigaTabella(ref tCns, ref rgCns, cns);
						}
					tCns.RowGroups.Add(rgCns);
					sz[3].Blocks.Add(tCns);
					}
				else
					MessageBox.Show("Nessun consuntivo ["+cnt.numero.ToString()+"]");
				}
			doc.Blocks.Add(sz[3]);
#if false
			PrintPageBreak(ref doc);

			foreach (Conto cnt in operazioni.Conti())
				{
				PrintTesto(ref doc, "CONSUNTIVO[" + cnt.numero + "]: " + cnt.descrizione);

				List<Consuntivo> lc = operazioni.FindListaConsuntivi(cnt.numero);
				if(lc != null)
					{
					Consuntivo nouseCn = new Consuntivo();
					Table tCCn = new Table();
					int ncolCn = nouseCn.Count();
					for (int i = 0; i < ncolCn; i++)
						{
						TableColumn tc = new TableColumn();
						tc.Width = new GridLength(70, GridUnitType.Pixel);
						tCn.Columns.Add(tc);
						}
					var rgCn = new TableRowGroup();

					TableRow rowintCn = new TableRow();
					rowintCn.Background = Brushes.Transparent;
					rowintCn.FontSize = headerSize;
					rowintCn.FontWeight = FontWeights.Bold;
					foreach (string str in nouseCn.Titoli())
						{
						TableCell tc = new TableCell(new Paragraph(new Run(str)));
						tc.BorderBrush = Brushes.Black;
						tc.BorderThickness = new Thickness(0, 1, 0, 1);
						rowintC.Cells.Add(tc);
						}
					rgCn.Rows.Add(rowintCn);

					TableRow rowtypCn = new TableRow();
					rowtypCn.Background = Brushes.Transparent;
					rowtypCn.FontSize = headerSize;
					rowtypCn.FontWeight = FontWeights.Bold;

					rgCn.Rows.Add(rowtypCn);
					foreach (Consuntivo cons in lc)
						{
						TableRow row = new TableRow();
						row.Background = Brushes.Transparent;
						row.FontSize = textSize;
						row.FontWeight = FontWeights.Normal;
						foreach (string str in cons.Valori())
							{
							TableCell tc = new TableCell(new Paragraph(new Run(str)));
							tc.BorderBrush = Brushes.Black;
							tc.BorderThickness = new Thickness(0, 0, 0, 0.5);
							row.Cells.Add(tc);
							}
						rgC.Rows.Add(row);
						}
					tCn.RowGroups.Add(rgC);

					doc.Blocks.Add(tCn);
					}
				}
#endif
			#endregion


			return doc;
			}