Exemplo n.º 1
0
        public DisplayQuote(DeskQuote NewDeskQuote)
        {
            InitializeComponent();
            _deskQuote = NewDeskQuote;

            numWidth.Value          = NewDeskQuote.Desk.Width;
            numDepth.Value          = NewDeskQuote.Desk.Depth;
            txtSurfaceMaterial.Text = NewDeskQuote.Desk.SurfaceMaterial.ToString();
            numDrawers.Value        = NewDeskQuote.Desk.NumberOfDrawers;
            txtShippingMethod.Text  = NewDeskQuote.ShippingType.ToString();
            txtCustName.Text        = NewDeskQuote.CustomerName.ToString();
            txtPrice.Text           = NewDeskQuote.QuotePrice.ToString();
        }
Exemplo n.º 2
0
        //gets the new quote and adds it to the new file
        private void AddQuoteToFile(DeskQuote deskQuote)
        {
            List <DeskQuote> deskQuotes = new List <DeskQuote>();

            if (!File.Exists(@"quotes.json"))
            {
                deskQuotes.Add(deskQuote);
                var list = JsonConvert.SerializeObject(deskQuotes);
                File.WriteAllText(@"quotes.json", JsonConvert.SerializeObject(deskQuotes));
            }
            else
            {
                using (StreamReader reader = new StreamReader(@"quotes.json"))
                {
                    string allQuotes = reader.ReadToEnd();
                    deskQuotes = JsonConvert.DeserializeObject <List <DeskQuote> >(allQuotes);
                }
                deskQuotes.Add(deskQuote);
                var list = JsonConvert.SerializeObject(deskQuotes);
                File.WriteAllText(@"quotes.json", list);
            }
        }