0

Please would someone able to explain to me why this application isn't showing out its operation , i am quit new to programing and everything i have the done on this app is due to help from sites like this. but now i am stuck.

attached the is zip file of the payroll app

code written

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

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        
        
        string name;
        int employeeNumber;
        double hours;
        const double hourlyWage = 8.5;
        double gross;
        double tax;
        double insurance;
        double deduction;
        double Net;
        

        private void btnCompute_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageB.Text = "Enter Name";
            }
            else if (txtPNumber.Text.Length < 6)
            {
                MessageB.Text = "Enter Employee Number";
            }
            else if (txtHoursWork.Text == "")
            {
                MessageB.Text = "Enter Hours";
            }
            else if (btnCompute.Text == "Compute")
            {
                name = txtName.Text;
                employeeNumber = Convert.ToInt32(txtPNumber.Text);
                hours = Convert.ToDouble(txtHoursWork.Text);
                gross = hours * hourlyWage;
                txtGrossPay.Text = "£" + Convert.ToString(gross);
                tax = gross / 100 * 20;

                txtIncomeTax.Text = "£" + Convert.ToString(tax);

                insurance = gross / 100 * 7;

                txtNI.Text = "£" + Convert.ToString(insurance);
                deduction = tax + insurance;
                txtTotalDeduction.Text = "£" + Convert.ToString(deduction);
                Net = gross - tax - insurance;
                txtNetPay.Text = "£" + Convert.ToString(Net);


                

                



            }
            else
            {
                txtName.Text = "";
                txtPNumber.Text = "";
                txtHoursWork.Text = "";
                txtGrossPay.Text = "";
                txtIncomeTax.Text = "";
                txtNI.Text = "";
                txtTotalDeduction.Text = "";
                btnCompute.Text = "Compute";

                

            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }
      
    }
}

thanks in advance for your help.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by __avd
0

Use simple If statements instead of If..else..if.

private void btnCompute_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageB.Text = "Enter Name";
                return;
            }
           if (txtPNumber.Text.Length < 6)
            {
                MessageB.Text = "Enter Employee Number";
                return;
            }
             if (txtHoursWork.Text == "")
            {
                MessageB.Text = "Enter Hours";
                return;
            }
             if (btnCompute.Text == "Compute")
            {
                name = txtName.Text; 
              .....
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.