예제 #1
0
        private Automotive GetService(Automotive myCustomer)        //Method to get service request information
        {
            //declare the varibles for the charges and tax rate
            decimal partCharge;
            decimal laborCharge;
            decimal taxRate;

            //tryparse the part charge, labor charge, and tax  rate
            if (decimal.TryParse(PartChargeTextBox.Text, out partCharge))
            {
                if (decimal.TryParse(LaborChargeTextBox.Text, out laborCharge))
                {
                    if (decimal.TryParse(TaxRateTextBox.Text, out taxRate))
                    {
                        // Get the charges and tax of services
                        myCustomer.GetPartCharge  = partCharge;
                        myCustomer.GetLaborCharge = laborCharge;
                        myCustomer.GetTaxRate     = taxRate;
                    }
                    else
                    {
                        MessageBox.Show("The tax you entered is not right - Retry");
                    }
                }
                else
                {
                    MessageBox.Show("The labor charge you entered is not right - Retry");
                }
            }
            else
            {
                MessageBox.Show("The part charge you entered is not right - Retry");
            }
            return(myCustomer);
        }
예제 #2
0
        private Automotive GetCustomer(Automotive myCustomer)   //Method to get customer infomation
        {
            myCustomer.GetCustomerName    = CusNameInput.Text;
            myCustomer.GetCustomerAddress = CusAddressInput.Text;
            myCustomer.GetCustomerPhone   = CusPhoneInput.Text;

            return(myCustomer);
        }
예제 #3
0
        private Automotive GetCarInfo(Automotive myCustomer)        //Method to get the car information
        {
            int year;

            myCustomer.GetBrand = ShopCarBrandInput.Text;
            myCustomer.GetModel = ShopCarModelInput.Text;
            int.TryParse(ShopCarYearInput.Text, out year);
            myCustomer.GetYear = year;

            return(myCustomer);
        }
예제 #4
0
        private void ChargeButton_Click(object sender, EventArgs e)
        {
            Automotive customer       = new Automotive(); // Create an instance of customer in Automotive class  -- customer
            Automotive customerCar    = new Automotive(); //Create an instance of customer's car -- customerCar
            Automotive customerCharge = new Automotive(); // Create an instance of service charge -- customerCharge

            GetCustomer(customer);                        // Get customer's info
            GetCarInfo(customerCar);                      // Get car's info
            GetService(customerCharge);                   // get service's info

            CustomerList.Add(customer);                   // Add all the customer's info to the customer list for later keeping track
            CustomerCarList.Add(customerCar);             // Add car's info into customerCar list
            ChargesList.Add(customerCharge);              // Add charges into customerCharge list

            // Calculate charges
            ChargeOutputLabel.Text = customerCharge.CalculateCharge(customerCharge.GetPartCharge, customerCharge.GetLaborCharge, customerCharge.GetTaxRate).ToString("c");
        }