Tuesday, 10 December 2013

Salary Sheet For Beginners (Win Form)

Salary Sheet For Beginners (Win Form)



       private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                textBox2.Enabled = true;
            }

            textBox1.MaxLength = 100;
           
          
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            if (textBox2.Text != "")
            {
                textBox3.Enabled = true;
            }

            textBox2.MaxLength = 100;

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            if (textBox3.Text != "")
            {
                textBox4.Enabled = true;
            }

            textBox3.MaxLength = 100;
        }


     

        private void textBox4_Leave(object sender, EventArgs e)
        {
           

            // For Salary >=50000

            double salary = Convert.ToDouble(textBox4.Text);
            if (salary >= 50000)
            {
                double cA1 = salary * 0.2;
                double mA1 = salary * 0.3;
                double hR1 = salary * 0.4;
                double tS1 = (cA1 + mA1 + hR1) + salary;
                double pF1 = salary * 0.1;
                double iT1 = salary * 0.03;
                double nS1 = tS1 - pF1 - iT1;

                textBox5.Text = "20%" + " " + cA1.ToString();
                textBox6.Text = "30%" + " " + mA1.ToString();
                textBox7.Text = "40%" + " " + hR1.ToString();
                textBox8.Text = tS1.ToString();
                textBox11.Text = "10%" + " " +"-" + pF1.ToString();
                textBox9.Text = "3%" +" " +"-" +iT1.ToString();
                textBox10.Text = nS1.ToString();

            }

            // For Salary >=30000 && salary < 50000

            if (salary >= 30000 && salary < 50000 )
            {
                double cA2 = salary * 0.2;
                double mA2 = salary * 0.3;
                double hR2 = salary * 0.4;
                double tS2 = (cA2 + mA2 + hR2) + salary;
                double pF2 = salary * 0.1;
                double iT2 = salary * 0;
                double nS2 = tS2 - pF2 - iT2;

                textBox5.Text = "20%" + " " + cA2.ToString();
                textBox6.Text = "30%" + " " + mA2.ToString();
                textBox7.Text = "40%" + " " + hR2.ToString();
                textBox8.Text = tS2.ToString();
                textBox11.Text = "10%" + " " + "-" + pF2.ToString();
                textBox9.Text = iT2.ToString();
                textBox10.Text = nS2.ToString();

            }

            // For Salary >=25000 salary < 30000

            if (salary <= 250000 && salary < 30000)
            {
                double cA3 = salary * 0.15;
                double mA3 = salary * 0.25;
                double hR3 = salary * 0.3;
                double tS3 = (cA3 + mA3 + hR3) + salary;
                double pF3 = salary * 0.1;
                double iT3 = salary * 0;
                double nS3 = tS3 - pF3 - iT3;

                textBox5.Text = "15%" + " " + cA3.ToString();
                textBox6.Text = "25%" + " " + mA3.ToString();
                textBox7.Text = "30%" + " " + hR3.ToString();
                textBox8.Text = tS3.ToString();
                textBox11.Text = "10%" + " " + "-" + pF3.ToString();
                textBox9.Text = iT3.ToString();
                textBox10.Text = nS3.ToString();

            }

            // For salary <= 20000 && salary < 25000

            if (salary <= 20000 && salary < 25000)
            {
                double cA4 = salary * 0.1;
                double mA4 = salary * 0.2;
                double hR4 = salary * 0.25;
                double tS4 = (cA4 + mA4 + hR4) + salary;
                double pF4 = salary * 0.1;
                double iT4 = salary * 0;
                double nS4 = tS4 - pF4 - iT4;

                textBox5.Text = "10%" + " " + cA4.ToString();
                textBox6.Text = "20%" + " " + mA4.ToString();
                textBox7.Text = "25%" + " " + hR4.ToString();
                textBox8.Text = tS4.ToString();
                textBox11.Text = "10%" + " " + "-" + pF4.ToString();
                textBox9.Text = iT4.ToString();
                textBox10.Text = nS4.ToString();

            }

            // if salary < 20000

            if (salary < 20000)
            {
                double cA5 = 1000;
                double mA5 = 1500;
                double hR5 = 2000;
                double tS5 = (cA5 + mA5 + hR5) + salary;
                double pF5 = salary * 0.1;
                double iT5 = salary * 0;
                double nS5 = tS5 - pF5 - iT5;

                textBox5.Text = cA5.ToString();
                textBox6.Text = mA5.ToString();
                textBox7.Text = hR5.ToString();
                textBox8.Text = tS5.ToString();
                textBox11.Text = "10%" + " " + "-" + pF5.ToString();
                textBox9.Text = iT5.ToString();
                textBox10.Text = nS5.ToString();

            }

            if (textBox4.Text != "")
            {
                textBox1.Clear();
                textBox2.Clear();
                textBox3.Clear();
                textBox2.Enabled = false;
                textBox3.Enabled = false;
            }
            panel1.Visible = true;
        
        }

        private void textBox1_Leave(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                textBox4.Clear();
                textBox4.Enabled = false;
                panel1.Visible = false;
            }
        }

    }

No comments:

Post a Comment