C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 307,174 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,554 people online right now. Registration is fast and FREE... Join Now!




Pat's Auto Parts

 

Pat's Auto Parts, constants

bravo659

5 Nov, 2009 - 08:53 PM
Post #1

New D.I.C Head
*

Joined: 18 May, 2008
Posts: 45

I know this suppose to be an easy task but don't know why I am having so much problem utilizing the constants in calculating the sales tax and hours. The sales tax is for parts only. Below please my code, this is Chapter 6 of the assignment in Visual Studio C# 2008. Please assist me. I also using the calculate in the menu under Edit/Calculate

CODE

namespace PatAutoRepair
{
    public partial class Form1 : Form
    {
        const decimal Labor_Hours = 50.00m; //error:Warning    1    The field 'PatAutoRepair.Form1.Labor_Hours' is assigned but its value is never used    

        const decimal Sales_Tax = .08m; //error: Warning    2    The field 'PatAutoRepair.Form1.Sales_Tax' is assigned but its value is never used    

        public Form1()
        {
            InitializeComponent();
        }

        private void tsslExit_Click(object sender, EventArgs e)
        {
            Application.Exit();

        }

        private void tsslCalculate_Click(object sender, EventArgs e)
        {


            decimal partsDecimal, laborDecimal;
            int Hours, Parts;

            try
            {
                Hours = int.Parse(txtHours.Text);
                Parts = int.Parse(txtParts.Text);
                partsDecimal = decimal.Parse(lblParts.Text);
                laborDecimal = decimal.Parse(lblLabor.Text);
            }
            catch(FormatException)
            {
              
                lblLabor.Text = txtHours.Text;
                lblParts.Text = txtParts.Text;
                lblSub.Text = lblLabor.Text * Labor_Hours + lblParts.Text;
//error: Operator '*' cannot be applied to operands of type 'string' and 'decimal'

                lblTax.Text = Convert.ToInt32(lblSub.Text * Sales_Tax);
//error: Operator '*' cannot be applied to operands of type 'string' and 'decimal'    


            }

        }
        

        private void tsslAbout_Click(object sender, EventArgs e)
        {
            AboutBox1 aboutForm = new AboutBox1();
            aboutForm.ShowDialog();


        }

        private void tsslClear_Click(object sender, EventArgs e)
        {
            txtCustName.Clear();
            txtHours.Clear();
            txtJobNum.Clear();
            txtParts.Clear();
            lblLabor.Text = "";
            lblSub.Text = "";
            lblTax.Text = "";



        }
    }
}


I do appreciate for your help, thanks.

This post has been edited by PsychoCoder: 5 Nov, 2009 - 09:07 PM

User is offlineProfile CardPM
+Quote Post



Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 07:05PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month