public AddQuote(ref FileContext quotesFile, ref FileContext orderPrices) { InitializeComponent(); // Initialize collection of materials and prices using the DesktopMaterial enum materialPrices = new Dictionary <DesktopMaterial, decimal>(); materialPrices.Add(DesktopMaterial.Laminate, MATERIAL_PRICE_LAMINATE); materialPrices.Add(DesktopMaterial.Oak, MATERIAL_PRICE_OAK); materialPrices.Add(DesktopMaterial.Pine, MATERIAL_PRICE_PINE); materialPrices.Add(DesktopMaterial.Rosewood, MATERIAL_PRICE_ROSEWOOD); materialPrices.Add(DesktopMaterial.Veneer, MATERIAL_PRICE_VENEER); // Initialize quotes file and repository this.quotesFile = quotesFile; quoteRepository = new FileRepository <DeskQuote>(quotesFile); // Initialize shipping rates this.orderPrices = orderPrices; orderRepository = new FileRepository <int>(orderPrices); priceList = (List <int>)orderRepository.GetAll(); //Populate the shippingRates dictionary with the values loaded from the text file. shippingRates = new Dictionary <string, decimal[]>(); shippingRates.Add("Normal - 14 Days", new decimal[] { 0, 0, 0 }); shippingRates.Add("Rush - 7 Days", new decimal[] { priceList[6], priceList[7], priceList[8] }); shippingRates.Add("Rush - 5 Days", new decimal[] { priceList[3], priceList[4], priceList[5] }); shippingRates.Add("Rush - 3 Days", new decimal[] { priceList[0], priceList[1], priceList[2] }); // Initialize the collection of NumericUpDowns and MIN, MAX for validation numericUpDownBounds = new Dictionary <string, decimal[]>(); numericUpDownBounds.Add(deskWidth.Name, new decimal[] { Desk.WIDTH_MIN, Desk.WIDTH_MAX }); numericUpDownBounds.Add(deskDepth.Name, new decimal[] { Desk.DEPTH_MIN, Desk.DEPTH_MAX }); numericUpDownBounds.Add(deskDrawerCount.Name, new decimal[] { Desk.DRAWER_MIN, Desk.DRAWER_MAX }); //Initialize the DeskQuote object with basic pricing information. deskQuote = new DeskQuote(PRICE_PER_SQUARE_INCH, PRICE_PER_DRAWER, BASE_PRICE, SURFACE_PRICING_FLOOR); Console.WriteLine(deskQuote.ToString()); // Set basic form fields to current desk values this.customerName.Text = deskQuote.CustomerName; this.deskWidth.Value = deskQuote.Desk.Width; this.deskDepth.Value = deskQuote.Desk.Depth; this.deskDrawerCount.Value = deskQuote.Desk.DrawerCount; // Populate the materials list and set it to current desk value List <DesktopMaterial> materials = new List <DesktopMaterial>(this.materialPrices.Keys); populateComboBox <DesktopMaterial>(materials, this.deskMaterial); this.deskMaterial.SelectedIndex = deskMaterial.FindString(deskQuote.Desk.Material.ToString()); // Populate the shipping method list and default to "normal" List <string> shippingMethodNames = new List <string>(this.shippingRates.Keys); populateComboBox <string>(shippingMethodNames, this.shippingMethod); setShippingMethod(shippingRates.Keys.First(), shippingRates.Values.First()[0]); this.shippingMethod.SelectedIndex = shippingMethod.FindString(deskQuote.Shipping.Key); // Update the quote display based on the initial values updateQuoteDisplay(); // AFter initial field sets, allow dynamic updates performDynamicUpdates = true; }