Friday, 20 December 2013

How To Work With Delegates In C# Simple Example For Beginners

How To Work  With Delegates In C# Simple Example For Beginners




   public delegate int mob(int ac);
        public int doubles(int ac)
        {
            return ac * 2;

        }
        public int square(int ac)
        {
            return ac * ac;
        }

    private void Delegate_Btn_Click(object sender, EventArgs e)
        {
            //Delegates//
            mob c = doubles;
            label4.Text = c(20).ToString();

            int cde = 20 + 30;
            label5.Text = cde.ToString();

            mob d = square;
            label6.Text = d(9).ToString();
           //--------------------------//

        }

Wednesday, 18 December 2013

How To Work With Structure In C# Simple Tutorial With Source Code

How To Work With Structure In C# Simple Tutorial With Source Code




         //Structure//
        public struct abc
        {
            public int a, b;
            public void xyz(int x, int y)
            {
                x = a;
                y = b;
            }
        }
        public struct points
        {
            public int x, y;
            public points(int ab, int bc)
            {
                x = ab;
                y = bc;
            }
        }
        public struct btdata
        {
            public int sal;
            public int bonus;
        }



        private void Structure_Btn_Click(object sender, EventArgs e)
        {
            ////Structure
            abc ab;
            ab.a = 7;
            ab.b = 8;
            int c;
            c = ab.a + ab.b;
            label1.Text = c.ToString();
            points st;
            st.x = 5;
            st.y = 10;
            c = st.x * st.y;
            label2.Text = c.ToString();
            btdata data;
            data.sal = 45000;
            data.bonus = 10000;
            c = data.sal + data.bonus;
            label3.Text = c.ToString();
            //----------------------//
        }

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;
            }
        }

    }

Saturday, 7 December 2013

HOW TO MAKE BASIC SALARY IN C# CONSOLE

HOW TO MAKE BASIC SALARY IN C# CONSOLE



        static void Main(string[] args)
        {
                 // variables

            again:
       

            int salary, ca, ma, hr, total_aln, aln_per, pf,it, it_per, total, net;

            it = 0;
            it_per = 0;
            pf = 0;
            Boolean check = false;

            //input salary
            Console.WriteLine();
            Console.Write("Enter Basic Salary: ");
            salary = Convert.ToInt32(Console.ReadLine());

            // CODE TO CHECK NUMERIC SALARY //

            ///////////////////////////////////////////

                // calculation
                if (salary > 25000)
                {

                    ca = 40;
                    ma = 50;
                    hr = 60;
                    it = 3;
                    it_per = 3 * salary / 100;

                    total_aln = ca + ma + hr;

                    aln_per = total_aln * salary / 100;

                }

                else if (salary > 15000)
                {
                    ca = 30;
                    ma = 40;
                    hr = 50;

                    total_aln = ca + ma + hr;

                    aln_per = total_aln * salary / 100;
                }

                else
                {

                    check = true;
                    ca = 500;
                    ma = 500;
                    hr = 500;


                    aln_per = ca + ma + hr;

                }

                total = salary + aln_per;

                net = total - it_per;

                ///////////////////////////////////////////////////////

                Console.WriteLine();


                // Output Result

                Console.WriteLine("Basic \t CA \t MA \t HR \t Total \t Income Tax \t PF \t Net Salary");

                Console.WriteLine();

                if (check == false)
                {

                    Console.WriteLine(salary + "\t " + ca + "%\t " + ma + "% \t " + hr + "% \t " + total + " \t " + it + "%\t \t " + pf + " \t " + net);

                }


                else
                {

                    Console.WriteLine(salary + "\t " + ca + " \t " + ma + "  \t " + hr + "  \t " + total + " \t " + it + "%\t \t " + pf + " \t " + net);

                }

            // again calculate

            correct:
            Console.WriteLine();
            Console.WriteLine("Calculate Again ? Y/N");

            String again_check = Convert.ToString(Console.ReadLine());

            if (again_check == "y" || again_check == "Y")

            {

            goto again;
            }


            else if (again_check == "n" || again_check == "N")
            {

                Environment.Exit(0);
            }

            else

            {
                   goto correct;
            }

                Console.Read();
        }
   

Sunday, 1 December 2013