//Initializes the form and inserts the quote values public DisplayOrder(Desk newDesk, DeskOrder newOrder) { InitializeComponent(); dateDisplayBox.Text = newOrder.quoteDate.ToString(); nameDisplayBox.Text = newOrder.firstName + " " + newOrder.lastName; widthDisplayBox.Text = newDesk.width.ToString() + "in."; depthDisplayBox.Text = newDesk.depth.ToString() + "in."; drawersDisplayBox.Text = newDesk.numDrawers.ToString(); surfaceDisplayBox.Text = newDesk.surface.ToString(); speedDisplaybox.Text = newOrder.rushDays; totalDisplayBox.Text = "$" + newOrder.quote.ToString() + ".00"; }
//DeskOrderQuote constructer public DeskOrderQuote(Desk newDesk, DeskOrder newOrder) { quoteDate = newOrder.quoteDate.ToString(); lastName = newOrder.lastName; firstName = newOrder.firstName; width = newDesk.width; depth = newDesk.depth; numDrawers = newDesk.numDrawers; surface = newDesk.surface.ToString(); rushDays = newOrder.rushDays; quote = newOrder.quote; }
//This calculates the cost of the desk using the users inputs; it also verifies that all the text boxes are completed; and it activates the "Submit" button. private void calculate_Click(object sender, EventArgs e) { //Gets all the values from the form firstName = firstNameBox.Text; lastName = lastNameBox.Text; surface = surfaceBox.Text; rushDays = rushDaysBox.Text; quoteDate = quoteDatePicker.Value; rush = rushButton.Checked; submitButton.Enabled = true; submitButton.BackColor = System.Drawing.SystemColors.Control; firstNameBox.BackColor = SystemColors.Window; lastNameBox.BackColor = SystemColors.Window; widthBox.BackColor = SystemColors.Window; depthBox.BackColor = SystemColors.Window; drawerBox.BackColor = SystemColors.Window; surfaceBox.BackColor = SystemColors.Window; rushDaysBox.BackColor = SystemColors.Window; //Prompts user if required box are empty. try { if (firstName == String.Empty) { firstNameBox.BackColor = Color.LightSalmon; MessageBox.Show("Please enter a first name."); firstNameBox.Focus(); } else if (lastName == String.Empty) { lastNameBox.BackColor = Color.LightSalmon; MessageBox.Show("Please enter a last name."); lastNameBox.Focus(); } else if (widthBox.Text == String.Empty) { widthBox.BackColor = Color.LightSalmon; MessageBox.Show("Please enter a valid desk width value."); widthBox.Focus(); } else if (depthBox.Text == String.Empty) { depthBox.BackColor = Color.LightSalmon; MessageBox.Show("Please enter a valid desk depth value."); depthBox.Focus(); } else if (drawerBox.Text == String.Empty) { drawerBox.BackColor = Color.LightSalmon; MessageBox.Show("Please enter a valid number of drawers."); drawerBox.Focus(); } else if (surfaceBox.Text == "Materials") { surfaceBox.BackColor = Color.LightSalmon; MessageBox.Show("Please select a surface material."); surfaceBox.Focus(); } else if (rush == true && rushDays == "Standard") { rushDaysBox.BackColor = Color.LightSalmon; MessageBox.Show("Please select your desired rush speed option."); rushDaysBox.Focus(); } else { //The submit button is enabled submitButton.Enabled = true; submitButton.BackColor = System.Drawing.Color.DarkSeaGreen; //An instance of Desk is created and required values a passed. newDesk = new Desk(width, depth, numDrawers, surface); //An instance of DeskOrder is created and required values a passed. newOrder = new DeskOrder(newDesk, firstName, lastName, rushDays, quoteDate); //The Calculated price of the quote is inserted into the form. priceBox.Text = "$" + newOrder.quote.ToString() + ".00"; } } catch (Exception) { throw; } }