private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                // check all the error providers to make sure
                bool success = true;
                foreach (Control c in this.Controls)
                {
                    if (errorProvider1.GetError(c).Length > 0)
                    {
                        success = false;
                    }
                    if (c is ComboBox && string.IsNullOrEmpty(c.Text))
                    {
                        success = false;
                    }
                }

                // okay, run the quote and display the quote view!
                if (success)
                {
                    name     = textBox1.Text;
                    width    = int.Parse(comboBox1.SelectedItem.ToString());
                    depth    = int.Parse(comboBox2.SelectedItem.ToString());
                    drawers  = int.Parse(comboBox3.SelectedItem.ToString());
                    material = comboBox4.SelectedItem.ToString();
                    rushDays = int.Parse(comboBox5.SelectedItem.ToString());
                    DeskQuote quote = new DeskQuote(name, width, depth, drawers, material, rushDays);
                    // get the total
                    quotePrice = quote.CalulateQuote();
                    // write the full quote to file
                    quote.WriteQuote();

                    // head over to the view!
                    DisplayQuoteView view = new DisplayQuoteView(quotePrice, quote);
                    view.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please fix all errors and submit again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception)
            {
                textBox1.Text = "Error";
            }
        }
Esempio n. 2
0
 public DisplayQuoteView(int quotePrice, DeskQuote quote)
 {
     QuotePrice = quotePrice;
     TheQuote   = quote;
     InitializeComponent();
 }