Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Open Visual Studio and create a new Window Application Project. Name the Project

ID: 668734 • Letter: O

Question

Open Visual Studio and create a new Window Application Project. Name the Project Lab3. NOTE: Ensure that C# is the programming language selected.

Make sure the form is named ServiceForm. Change the Forms Text property to “Pet Boutique Service Form”.   Re-size the form to Width = 400, Height = 450.

)Setup the applications form as shown in the screen shot above. As you place each of the controls on the form, refer to the following:

Text Boxes:

ownerNameTextBox

ownerPhoneTextBox

petNameTextBox

petDOBTextBox

Radio Buttons:

catRadioButton

dogRadioButton


Labels:

fleaRemovalPriceLabel ($5.00)

shampooPriceLabel ($4.00)

totalFeeLabel (Total Fee:)

priceLabel (will include the total price)

(all separate from the check box labels)
[plus labels for other form controls – with default names used]

Group Boxes:

petOwnerGroupBox

petGroupBox

servicesGroupBox

Check Boxes:

fleaRemovalCheckBox

shampooCheckBox

Buttons:

totalButton

clearButton

quitButton

4.   Add code to the totalButton that will do this following when the user clicks:

Create a Try and Catch block statement to store the code and trap the error if one occurs

Declare a double variable called TotalFee and intialize it to 0

Then set the value of the TotalFee variable to the appropriate value depending on the selected service check-boxes (fleaRemovalCheckBox $5, shampooCheckBox $4)

NOTE:

You will need to convert TotalFee variable to string before assigning it to the priceLabel.

Make sure that if both FleaRemoval and Shampoo are selected, the total fee represents the total amount of $9.

5. Add code to the clearButton button that clears the Owner's Name, Owner's Phone number, Pet's name, and Pet's Date of Birth text-boxes

6.   Add code to the quitButton button that closes the application

7. Run your program to make sure that it works as expected.

8. Close your project and ZIP your entire project file. Then upload your project to CANVAS.

C#

http://prntscr.com/8g8rd8

Explanation / Answer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class ServiceForm : Form
    {
        double totalFee = 0.0;

        public ServiceForm()
        {
            InitializeComponent();
        }

        private void totalbutton_Click(object sender, EventArgs e)
        {
            try
            {
                totalFee = 0;
                if (fleaRemovalCheckBox.Checked == true)
                {
                    totalFee = 5.00;
                }

                if (shampooCheckBox.Checked == true)
                {
                    totalFee += 4.00;
                }

                priceLabel.Text = "$" + totalFee.ToString();

            }
            catch
            {
                  //error occured
            }
        }

        private void clearbutton_Click(object sender, EventArgs e)
        {
            ownerNameTextBox.Clear();
            ownerPhoneTextBox.Clear();
            petNameTextBox.Clear();
            petDOBTextBox.Clear();
        }

        private void quitbutton_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Application.Exit();
        }

      

          
    
    }
}

namespace WindowsFormsApplication1
{
    partial class ServiceForm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.ownerPhoneTextBox = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.ownerNameTextBox = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.label5 = new System.Windows.Forms.Label();
            this.cat = new System.Windows.Forms.RadioButton();
            this.radioButton1 = new System.Windows.Forms.RadioButton();
            this.petDOBTextBox = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.petNameTextBox = new System.Windows.Forms.TextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.groupBox3 = new System.Windows.Forms.GroupBox();
            this.priceLabel = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.label7 = new System.Windows.Forms.Label();
            this.shampooCheckBox = new System.Windows.Forms.CheckBox();
            this.label6 = new System.Windows.Forms.Label();
            this.fleaRemovalCheckBox = new System.Windows.Forms.CheckBox();
            this.totalbutton = new System.Windows.Forms.Button();
            this.clearbutton = new System.Windows.Forms.Button();
            this.quitbutton = new System.Windows.Forms.Button();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.groupBox3.SuspendLayout();
            this.SuspendLayout();
            //
            // groupBox1
            //
            this.groupBox1.Controls.Add(this.ownerPhoneTextBox);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.ownerNameTextBox);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Location = new System.Drawing.Point(12, 12);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(360, 100);
            this.groupBox1.TabIndex = 1;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Pet Owner";
            //
            // ownerPhoneTextBox
            //
            this.ownerPhoneTextBox.Location = new System.Drawing.Point(100, 60);
            this.ownerPhoneTextBox.Name = "ownerPhoneTextBox";
            this.ownerPhoneTextBox.Size = new System.Drawing.Size(134, 20);
            this.ownerPhoneTextBox.TabIndex = 3;
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(25, 63);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(72, 13);
            this.label2.TabIndex = 2;
            this.label2.Text = "Owner Phone";
            //
            // ownerNameTextBox
            //
            this.ownerNameTextBox.Location = new System.Drawing.Point(100, 27);
            this.ownerNameTextBox.Name = "ownerNameTextBox";
            this.ownerNameTextBox.Size = new System.Drawing.Size(134, 20);
            this.ownerNameTextBox.TabIndex = 1;
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(25, 30);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(69, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Owner Name";
            //
            // groupBox2
            //
            this.groupBox2.Controls.Add(this.label5);
            this.groupBox2.Controls.Add(this.cat);
            this.groupBox2.Controls.Add(this.radioButton1);
            this.groupBox2.Controls.Add(this.petDOBTextBox);
            this.groupBox2.Controls.Add(this.label3);
            this.groupBox2.Controls.Add(this.petNameTextBox);
            this.groupBox2.Controls.Add(this.label4);
            this.groupBox2.Location = new System.Drawing.Point(12, 140);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(360, 117);
            this.groupBox2.TabIndex = 2;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Pet";
            //
            // label5
            //
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(40, 96);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(50, 13);
            this.label5.TabIndex = 10;
            this.label5.Text = "Pet Type";
            //
            // cat
            //
            this.cat.AutoSize = true;
            this.cat.Location = new System.Drawing.Point(194, 94);
            this.cat.Name = "cat";
            this.cat.Size = new System.Drawing.Size(85, 17);
            this.cat.TabIndex = 9;
            this.cat.TabStop = true;
            this.cat.Text = "radioButton2";
            this.cat.UseVisualStyleBackColor = true;
            //
            // radioButton1
            //
            this.radioButton1.AutoSize = true;
            this.radioButton1.Location = new System.Drawing.Point(103, 94);
            this.radioButton1.Name = "radioButton1";
            this.radioButton1.Size = new System.Drawing.Size(43, 17);
            this.radioButton1.TabIndex = 8;
            this.radioButton1.TabStop = true;
            this.radioButton1.Text = "dog";
            this.radioButton1.UseVisualStyleBackColor = true;
            //
            // petDOBTextBox
            //
            this.petDOBTextBox.Location = new System.Drawing.Point(103, 61);
            this.petDOBTextBox.Name = "petDOBTextBox";
            this.petDOBTextBox.Size = new System.Drawing.Size(134, 20);
            this.petDOBTextBox.TabIndex = 7;
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(12, 64);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(85, 13);
            this.label3.TabIndex = 6;
            this.label3.Text = "Pet Date of Birth";
            //
            // petNameTextBox
            //
            this.petNameTextBox.Location = new System.Drawing.Point(103, 28);
            this.petNameTextBox.Name = "petNameTextBox";
            this.petNameTextBox.Size = new System.Drawing.Size(134, 20);
            this.petNameTextBox.TabIndex = 5;
            //
            // label4
            //
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(40, 31);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(54, 13);
            this.label4.TabIndex = 4;
            this.label4.Text = "Pet Name";
            //
            // groupBox3
            //
            this.groupBox3.Controls.Add(this.priceLabel);
            this.groupBox3.Controls.Add(this.label8);
            this.groupBox3.Controls.Add(this.label7);
            this.groupBox3.Controls.Add(this.shampooCheckBox);
            this.groupBox3.Controls.Add(this.label6);
            this.groupBox3.Controls.Add(this.fleaRemovalCheckBox);
            this.groupBox3.Location = new System.Drawing.Point(12, 263);
            this.groupBox3.Name = "groupBox3";
            this.groupBox3.Size = new System.Drawing.Size(360, 100);
            this.groupBox3.TabIndex = 3;
            this.groupBox3.TabStop = false;
            this.groupBox3.Text = "Services";
            //
            // priceLabel
            //
            this.priceLabel.AutoSize = true;
            this.priceLabel.Location = new System.Drawing.Point(166, 71);
            this.priceLabel.Name = "priceLabel";
            this.priceLabel.Size = new System.Drawing.Size(34, 13);
            this.priceLabel.TabIndex = 5;
            this.priceLabel.Text = "$0.00";
            //
            // label8
            //
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(97, 71);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(52, 13);
            this.label8.TabIndex = 4;
            this.label8.Text = "Total Fee";
            //
            // label7
            //
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(255, 35);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(34, 13);
            this.label7.TabIndex = 3;
            this.label7.Text = "$4.00";
            //
            // shampooCheckBox
            //
            this.shampooCheckBox.AutoSize = true;
            this.shampooCheckBox.Location = new System.Drawing.Point(169, 34);
            this.shampooCheckBox.Name = "shampooCheckBox";
            this.shampooCheckBox.Size = new System.Drawing.Size(71, 17);
            this.shampooCheckBox.TabIndex = 2;
            this.shampooCheckBox.Text = "Shampoo";
            this.shampooCheckBox.UseVisualStyleBackColor = true;
            //
            // label6
            //
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(111, 35);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(34, 13);
            this.label6.TabIndex = 1;
            this.label6.Text = "$5.00";
            //
            // fleaRemovalCheckBox
            //
            this.fleaRemovalCheckBox.AutoSize = true;
            this.fleaRemovalCheckBox.Location = new System.Drawing.Point(14, 34);
            this.fleaRemovalCheckBox.Name = "fleaRemovalCheckBox";
            this.fleaRemovalCheckBox.Size = new System.Drawing.Size(91, 17);
            this.fleaRemovalCheckBox.TabIndex = 0;
            this.fleaRemovalCheckBox.Text = "Flea Removal";
            this.fleaRemovalCheckBox.UseVisualStyleBackColor = true;
            //
            // totalbutton
            //
            this.totalbutton.Location = new System.Drawing.Point(12, 380);
            this.totalbutton.Name = "totalbutton";
            this.totalbutton.Size = new System.Drawing.Size(68, 20);
            this.totalbutton.TabIndex = 4;
            this.totalbutton.Text = "Total";
            this.totalbutton.UseVisualStyleBackColor = true;
            this.totalbutton.Click += new System.EventHandler(this.totalbutton_Click);
            //
            // clearbutton
            //
            this.clearbutton.Location = new System.Drawing.Point(144, 380);
            this.clearbutton.Name = "clearbutton";
            this.clearbutton.Size = new System.Drawing.Size(68, 20);
            this.clearbutton.TabIndex = 5;
            this.clearbutton.Text = "Clear";
            this.clearbutton.UseVisualStyleBackColor = true;
            this.clearbutton.Click += new System.EventHandler(this.clearbutton_Click);
            //
            // quitbutton
            //
            this.quitbutton.Location = new System.Drawing.Point(281, 380);
            this.quitbutton.Name = "quitbutton";
            this.quitbutton.Size = new System.Drawing.Size(68, 20);
            this.quitbutton.TabIndex = 6;
            this.quitbutton.Text = "Quit";
            this.quitbutton.UseVisualStyleBackColor = true;
            this.quitbutton.Click += new System.EventHandler(this.quitbutton_Click);
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(384, 412);
            this.Controls.Add(this.quitbutton);
            this.Controls.Add(this.clearbutton);
            this.Controls.Add(this.totalbutton);
            this.Controls.Add(this.groupBox3);
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.groupBox1);
            this.Name = "Form1";
            this.Text = "Pet Boutique Service Form";
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.groupBox3.ResumeLayout(false);
            this.groupBox3.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.TextBox ownerPhoneTextBox;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TextBox ownerNameTextBox;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.GroupBox groupBox3;
        private System.Windows.Forms.TextBox petDOBTextBox;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox petNameTextBox;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.RadioButton cat;
        private System.Windows.Forms.RadioButton radioButton1;
        private System.Windows.Forms.Label priceLabel;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.CheckBox shampooCheckBox;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.CheckBox fleaRemovalCheckBox;
        private System.Windows.Forms.Button totalbutton;
        private System.Windows.Forms.Button clearbutton;
        private System.Windows.Forms.Button quitbutton;

    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new ServiceForm());
        }
    }
}