private void button2_Click(object sender, EventArgs e) { Desk desk = new Desk((int)widthNumberBox.Value, (int)depthNumberBox.Value, int.Parse(drawerBox.Text), (Desk.SurfaceMaterial)Enum.Parse(typeof(Desk.SurfaceMaterial), materialBox.Text)); DeskQuote quote = new DeskQuote(desk, int.Parse(rushBox.Text), nameBox.Text, DateTime.Now); _writeQuote(quote); DisplayQuote displayQuote = new DisplayQuote(quote, Tag) { Tag = this }; displayQuote.Show(this); Hide(); }
private void _writeQuote(DeskQuote quote) { var jsonFile = @"jsonfile.json"; List <DeskQuote> deskQuotes = new List <DeskQuote>(); if (File.Exists(jsonFile)) { using (StreamReader streamreader = new StreamReader(jsonFile)) { string quotes = streamreader.ReadToEnd(); deskQuotes = JsonConvert.DeserializeObject <List <DeskQuote> >(quotes); } } deskQuotes.Add(quote); string jsonQuote = JsonConvert.SerializeObject(deskQuotes, Formatting.Indented); File.WriteAllText(jsonFile, jsonQuote); }
public DisplayQuote(DeskQuote quote, object tag) { InitializeComponent(); _quote = quote; _mainMenu = (MainMenu)tag; }