public DisplayQuote(DeskQuote deskQuote) { InitializeComponent(); labelClientNameOutput.Text = deskQuote.CustomerName.ToString(); labelWidthOutput.Text = deskQuote.Desk.Width.ToString(); labelDepthOutput.Text = deskQuote.Desk.Depth.ToString(); labelMaterialOutput.Text = deskQuote.Desk.SurfaceMaterial.ToString(); labelRushDaysOutput.Text = deskQuote.ShippingType.ToString(); labelDrawersOutput.Text = deskQuote.Desk.NumberOfDrawers.ToString(); labelPriceOutput.Text = deskQuote.QuotePrice.ToString(); labelDateOutput.Text = deskQuote.QuoteDate.ToString(); }
//write to json file public void AddNewQuoteToFile(DeskQuote newDeskQuote) { string fileName = "quotes.json"; List <DeskQuote> quotesList; if (File.Exists(fileName)) { quotesList = JsonConvert.DeserializeObject <List <DeskQuote> >(File.ReadAllText(fileName)); } else { quotesList = new List <DeskQuote>(); } quotesList.Add(newDeskQuote); string convertedJson = JsonConvert.SerializeObject(quotesList, Formatting.Indented); File.WriteAllText(fileName, convertedJson); }