public static double bilansPlanowany(Baza baz) { double bil = 0; foreach (PozPlan poz in baz.PozPlanowane) { if (poz.termin.Month == DateTime.Today.Month && poz.termin.Year == DateTime.Today.Year) { bil += poz.wysokość; } } return(bil + bilansRzeczywisty(baz)); }
private void wczytajToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Plik dat|*.dat"; openFileDialog1.Title = "Wczytaj plik budżetu"; openFileDialog1.ShowDialog(); Baza bazpom = baz; baz = WczytZapis.wczytaj(openFileDialog1.FileName); if (baz == null) { MessageBox.Show("Nie udało się wczytać pliku"); baz = bazpom; } refresh(); }
public static void zapisz(Baza baz, String filePath) { Stream stream = null; try { IFormatter formatter = new BinaryFormatter(); stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, baz); } catch (Exception err) { MessageBox.Show(err.Message); } finally { if (null != stream) { stream.Close(); } } }
public static Baza wczytaj(String filePath) { Stream stream = null; Baza baz = null; try { IFormatter formatter = new BinaryFormatter(); stream = new FileStream(filePath, FileMode.Open); baz = (Baza)formatter.Deserialize(stream); } catch (Exception err) { MessageBox.Show(err.Message); } finally { if (null != stream) { stream.Close(); } } return(baz); }
private void oknoGlowne_Load(object sender, EventArgs e) { baz = new Baza(0); refresh(); }
private void nowyBudżetToolStripMenuItem_Click(object sender, EventArgs e) { baz = new Baza(0); refresh(); }