Exemple #1
0
		public override bool FromString(string str)
			{
			bool ok = false;
			string[] cmp = str.ToString().Split(new char[] { Separatore.field });
			if (cmp.Length == CAMPI)
				{
				Conto tmp = new Conto();
				tmp.numero = Conto.String2IntOrZero(cmp[0]);
				tmp.descrizione = cmp[1];
				tmp.nota = cmp[2];


				foreach (AlertConto ta in Enum.GetValues(typeof(AlertConto)))
					{
					if (cmp[3] == ta.ToString())
						{
						tmp.alert = ta;
						ok = true;
						break;
						}
					
					}

				if (ok)
					{
					this.numero = tmp.numero;
					this.descrizione = tmp.descrizione;
					this.nota = tmp.nota;
					this.alert = tmp.alert;
					}
				}
			return ok;
			}
Exemple #2
0
		/// <summary>
		/// Apre il file indicato
		/// </summary>
		/// <param name="fullfilename">Nome completo di path</param>
		/// <returns></returns>
		public bool Open(string fullfilename)
			{
			bool ret = true;
			readwriteCripted = false;
			readwritePassword = "";
			readStat rstat = readStat.Indefinito;
			status = true;
			try
				{
				using (StreamReader sr = new StreamReader(fullfilename, Encoding.UTF8))
					{
					if (ReadFirstLineAndSetCripted(sr, ref rstat, ref readwritePassword))
						{
						while (sr.Peek() >= 0)
							{
							string rline = ReadLine(sr);
							try
								{
								if (rline == new Operazione().Intestazione())
									rstat = readStat.Operazioni;
								else if (rline == new Conto().Intestazione())
									rstat = readStat.Conti;
								else if (rline == new OpStandard().Intestazione())
									rstat = readStat.OpStandard;
								//else if (rline == Operazioni.intestazioneFile)			// ELIMINARE
								//	rstat = readStat.Intestazione;						// ELIMINARE
								else
									{
									switch (rstat)
										{
										case readStat.Operazioni:
												{
												Operazione op = new Operazione();
												if (op.FromString(rline))
													{
													opVisibili.Add(op);
													}
												else
													{
													throw new Exception("Errore analisi linea: " + rline, new Exception("Errore analisi linea"));
													}
												}
											break;
										case readStat.Conti:
												{
												Conto op = new Conto();
												if (op.FromString(rline))
													{
													cntTotali.Add(op);
													}
												else
													{
													throw new Exception("Errore analisi linea: " + rline, new Exception("Errore analisi linea"));
													}
												}
											break;
										case readStat.OpStandard:
												{
												OpStandard op = new OpStandard();
												if (op.FromString(rline))
													{
													opStdTotali.Add(op);
													}
												else
													{
													throw new Exception("Errore analisi linea: " + rline, new Exception("Errore analisi linea"));
													}
												}
											break;
										case readStat.Intestazione:
											break;
										case readStat.Indefinito:
											throw new Exception("Errore sintattico nel file" + rline, new Exception("Errore sintattico nel file"));
										}
									}
								ret = true;
								}
							catch (Exception ex)
								{
								if (LogAbilitato)
									lstLog.Add("Errore in importazione dati:\n" + ex.ToString());
								ret = false;
								status = false;
								}
							}
						}
					}
				}
			catch (Exception ex)
				{
				if (LogAbilitato)
					lstLog.Add("Errore in lettura file:\n" + ex.ToString());
				ret = false;
				status = false;
				}
			if(ret)
				this.filename = fullfilename;
			return ret;
			}
Exemple #3
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;
			}