Example #1
0
        private void GenerateQuote(object sender, EventArgs e)
        {
            int rushOrderOption;

            //set Rush Day to Value
            if (RushRadioNone.Checked)
            {
                rushOrderOption = 0;
            }
            else if (RushRadioThree.Checked)
            {
                rushOrderOption = 3;
            }
            else if (RushRadioFive.Checked)
            {
                rushOrderOption = 5;
            }
            else if (RushRadioSeven.Checked)
            {
                rushOrderOption = 7;
            }
            else
            {
                rushOrderOption = 0;
            }

            //  TODO: Validate all fields before sending the data so someone can't submit empty/invalid data
            string clientFirstName = CustomerNameInputBox.Text;
            string clientLastName  = LastNameInputBox.Text;
            double width           = double.Parse(DeskWidthInputBox.Text);
            double depth           = double.Parse(DeskDepthtInputBox.Text);
            int    drawers         = int.Parse(NumberOfDrawersInputBox.Text);
            string material        = SurfaceMaterialInputBox.Text;
            //int rushOrderOption = int.Parse(RushOrderInputBox.Text);

            // Scott - I don't think we need to create a Desk object here.  With the way I've currently written the code, I create a desk object on the DisplayQuotes form
            // Desk myDesk = new Desk(width, depth, drawers, material, rushOrderOption);

            DisplayQuoteInfo viewDisplayQuoteForm = new DisplayQuoteInfo(clientFirstName, clientLastName, width, depth, drawers, material, rushOrderOption);

            // Now go back to the View Quote form
            viewDisplayQuoteForm.Tag = this;
            viewDisplayQuoteForm.Show(this);

            // Now close this window
            Hide();
        }
Example #2
0
        // When the person fills in the all the fields and clicks the Generate Quote button, this will run
        private void GenerateQuote(object sender, EventArgs e)
        {
            // Validate First name field
            if (string.IsNullOrWhiteSpace(CustomerNameInputBox.Text))
            {
                MessageBox.Show("Error.  First name is Empty");
            }

            // Validate Last Name Field
            if (string.IsNullOrWhiteSpace(CustomerNameInputBox.Text))
            {
                MessageBox.Show("Error.  Last name is Empty");
            }

            // Validate width Field
            if (string.IsNullOrWhiteSpace(DeskWidthInputBox.Text))
            {
                MessageBox.Show("Error.  Width is Empty");
            }

            // Validate depth Field
            if (string.IsNullOrWhiteSpace(DeskDepthtInputBox.Text))
            {
                MessageBox.Show("Error.  Depth is Empty");
            }

            // Validate depth Field
            if (string.IsNullOrWhiteSpace(NumberOfDrawersInputBox.Text))
            {
                MessageBox.Show("Error.  Number of Drawers is Empty");
            }

            //Check if the material drop down has a value -TS
            if (materialBox.Text == "")
            {
                // Validation message.
                errorProvider1.SetError(materialBox, "Material Selection Required.");
                matRequired.Text = " -Required";
            }

            // If no validation errors, create the quote
            else
            {
                int rushOrderOption;

                //set Rush Day to Value
                if (RushRadioNone.Checked)
                {
                    rushOrderOption = 0;
                }
                else if (RushRadioThree.Checked)
                {
                    rushOrderOption = 3;
                }
                else if (RushRadioFive.Checked)
                {
                    rushOrderOption = 5;
                }
                else if (RushRadioSeven.Checked)
                {
                    rushOrderOption = 7;
                }
                else
                {
                    rushOrderOption = 0;
                }

                // Try block will try to get the data & send it.  Everything will fail if a field is null
                try
                {
                    string clientFirstName = CustomerNameInputBox.Text;
                    string clientLastName  = LastNameInputBox.Text;
                    double width           = double.Parse(DeskWidthInputBox.Text);
                    double depth           = double.Parse(DeskDepthtInputBox.Text);
                    int    drawers         = int.Parse(NumberOfDrawersInputBox.Text);
                    string material        = materialBox.Text;

                    DisplayQuoteInfo viewDisplayQuoteForm = new DisplayQuoteInfo(clientFirstName, clientLastName, width, depth, drawers, material, rushOrderOption);

                    // Now go back to the View Quote form
                    viewDisplayQuoteForm.Tag = this;
                    viewDisplayQuoteForm.Show(this);

                    // Now close this window
                    Hide();
                } catch (Exception)
                {
                    MessageBox.Show("One or more of the fields is empty.  Please fill it in.");
                }
                // Now close this window
                Hide();
            }
        }