Example #1
0
        public DisplayQuote(Form mainMenu, Desk desk, DeskQuote quote)
        {
            InitializeComponent();
            _mainMenu = mainMenu;
            // Customer Info
            nameLabel.Text     = quote.CustomerName;
            dateLabel.Text     = quote.DateCreated.ToString("dd MMM yyyy");
            shippingLabel.Text = quote.ShippingTime.ToString();

            // Desk Info
            widthLabel.Text    = desk.Width.ToString();
            depthLabel.Text    = desk.Depth.ToString();
            drawersLabel.Text  = desk.NumOfDrawers.ToString();
            materialLabel.Text = desk.SurfaceType.ToString();

            // Quote Price
            priceLabel.Text = "$" + quote.QuotePrice.ToString();
        }
        private void AddQuoteToFile(DeskQuote quote)
        {
            List <DeskQuote> deskQuotes = new List <DeskQuote>();
            var quotesFile = "quotes.json";

            if (File.Exists(quotesFile))
            {
                using (StreamReader reader = new StreamReader(quotesFile))
                {
                    string quotes = reader.ReadToEnd();

                    if (quotes.Length > 0)
                    {
                        deskQuotes = JsonConvert.DeserializeObject <List <DeskQuote> >(quotes);
                    }
                }
            }

            deskQuotes.Add(quote);

            var serializedQuotes = JsonConvert.SerializeObject(deskQuotes);

            File.WriteAllText(quotesFile, serializedQuotes);
        }