Beispiel #1
0
        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();
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public DisplayQuote(DeskQuote quote, object tag)
 {
     InitializeComponent();
     _quote    = quote;
     _mainMenu = (MainMenu)tag;
 }