public ListWindow(Operazioni operazioni, out List<CheckItem> lst, Operazione op) { InitializeComponent(); lchk = new List<CheckItem>(); foreach (Conto x in operazioni.Conti()) { bool set = false; bool sottrai = false; foreach (int nc in op.Conti()) { if (Math.Abs(nc) == x.numero) { set = true; sottrai = (nc > 0) ? false : true; } } CheckItem tmp = new CheckItem(set, x.numero, sottrai, x.descrizione); lchk.Add(tmp); } dataGrid.AutoGenerateColumns = true; dataGrid.CanUserAddRows = false; dataGrid.CanUserDeleteRows = false; dataGrid.ItemsSource = lchk; lst = lchk; }
public OpEditWindow(ref Operazione op, ref Operazioni ops) { InitializeComponent(); this.op = op; this.ops = ops; this.btCancel.IsCancel = true; this.btOk.IsDefault = true; setText(); }
public bool Check(Operazione op) { bool ok = false; ClearTest(); if (nota != "") test.Add(op.nota.ContainsWithWildcards(nota)); if (DataDa != null) test.Add((op.getData(true) >= data[0])); if (DataA != null) test.Add((op.getData(true) <= data[1])); if (descrizione != "") test.Add(op.descrizione.ContainsWithWildcards(descrizione)); if (ImportoMin != null) test.Add((Math.Abs(op.importo) >= importo[0])); if (ImportoMax != null) test.Add((Math.Abs(op.importo) <= importo[1])); if (Consuntivo != null) test.Add((op.consuntivo == consuntivo)); if (Verificato != null) test.Add((op.verificato == verificato)); if (Tipo != null) test.Add((op.tipo == tipo)); switch(OperatoreLogico) { case Condizione.AND: ok = true; foreach (bool x in test) ok = ok && x; break; case Condizione.OR: ok = false; foreach (bool x in test) ok = ok || x; break; default: ok = false; break; } return ok; }
/// <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; }
/// <summary> /// Inserisce una operazione prima dell'operazione indicata /// </summary> /// <param name="opi"></param> /// <returns></returns> public bool OpInserisciAt(Operazione opi) { bool ok = false; Operazione op = new Operazione(); int indx = opVisibili.IndexOf(opi); if(indx!=-1) { opVisibili.Insert(indx, op); ok = true; } return ok; }
/// <summary> /// Inserisce una operazione alla riga indicata /// </summary> /// <param name="indx"></param> /// <returns></returns> public bool OpInserisciAt(int indx) { bool ok = false; Operazione op = new Operazione(); if ((indx >= 0) && (indx < opVisibili.Count)) { opVisibili.Insert(indx, op); ok = true; } return ok; }
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; }
public override bool FromString(string str) { bool ok = false; bool[] conv = new bool[CAMPI]; for (int i= 0; i < conv.Length; i++) conv[i] = true; string[] cmp = str.ToString().Split(new char[] { Separatore.field }); if (cmp.Length == CAMPI) { Operazione tmp = new Operazione(); tmp.nota = cmp[0]; tmp.data = cmp[1]; tmp.descrizione = cmp[2]; tmp.importo = Operazione.String2DecimalOrZero(cmp[3], out conv[3]); tmp.consuntivo = ((cmp[4] == Operazione.strTrue.ToString()) ? true : false); tmp.verificato = ((cmp[5] == Operazione.strTrue.ToString()) ? true : false); foreach (Operazione.Tipo tp in Enum.GetValues(typeof(Operazione.Tipo))) { if(cmp[6] == tp.ToString()) { tmp.tipo = tp; conv[6] = true; break; } conv[6] = false; } tmp.tipostd = Operazione.String2IntOrZero(cmp[7]); tmp.conti = cmp[8]; ok = true; if (Array.Exists(conv, el => el == false)) { ok = false; } if (ok) { this.nota = tmp.nota; this.data = tmp.data; this.descrizione= tmp.descrizione; this.importo= tmp.importo ; this.consuntivo= tmp.consuntivo ; this.verificato= tmp.verificato ; this.tipo= tmp.tipo; this.tipostd= tmp.tipostd; this.conti= tmp.conti; } } return ok; }