private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            textBox1.Text = DateTime.Now.ToString("dd/MM/yyyy");
            string  status="", salary="";
            string joinD = "";
            double curPayment =0.00;
            string q1 ="select empName,salary,status,joinDate from employeeInfo where empID='"+comboBox1.Text+"'";
            string q2 = "select sum(currentPayment) from empPayment where empID='" + comboBox1.Text + "'";
            SqlCommand cmd = new SqlCommand(q1, aa);

            try
            {
                aa.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while(dr.Read())
                {
                    textBox6.Text = dr.GetValue(0).ToString();
                    salary = dr.GetValue(1).ToString();
                    textBox7.Text = dr.GetValue(1).ToString();
                    status = dr.GetValue(2).ToString();
                    joinD = dr.GetValue(3).ToString();
                }

                dr.Close();
                SqlCommand cmd2 = new SqlCommand(q2, aa);
                SqlDataReader dr2 = cmd2.ExecuteReader();
                string curPtemp = "";
                while (dr2.Read())
                {

                        curPtemp = dr2.GetValue(0).ToString();

                }

                if (curPtemp != "")
                {
                    curPayment = Convert.ToDouble(curPtemp);

                }
                else
                {
                    curPayment = 0.00;
                }
                dr2.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "errror!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                aa.Close();
            }
            //salary calculation
            string[] s = status.Split(' ');

               // MessageBox.Show(s[0] + "\t" + s[1]);

            if (s[0] == "Inactive")
            {
                label12.Text = "Inactive";
                string activeDate = joinD;

                DateTime jdate = Convert.ToDateTime(activeDate);
                DateTime currentdate = Convert.ToDateTime(s[1].ToString());
                DateDifference dateDifference = new DateDifference(jdate, currentdate);

                string DiffDate = dateDifference.ToString();
              //  MessageBox.Show(DiffDate);
                string[] sDD = DiffDate.Split('/');
                int yy = Convert.ToInt32(sDD[0]);
                int mm = Convert.ToInt32(sDD[1]);
                int dd = Convert.ToInt32(sDD[2]);
                //if (dd != 0)
                //{
                //    mm += 1;
                //}
                int totalMonth = (yy * 12) + mm;
                textBox8.Text = totalMonth.ToString();

                double totalSal = totalMonth * Convert.ToDouble(salary);
                double dueSal = totalSal - curPayment;
                textBox2.Text = dueSal.ToString();
            }
            else if (s[0] == "Active")
            {
                label12.Text = "Active";
                string activeDate = s[1].ToString();

                DateTime jdate = Convert.ToDateTime(activeDate);
                DateTime currentdate = DateTime.Now;
                DateDifference dateDifference = new DateDifference(jdate,currentdate);

                string DiffDate = dateDifference.ToString();
                string[] sDD = DiffDate.Split('/');
                int yy = Convert.ToInt32(sDD[0]);
                int mm = Convert.ToInt32(sDD[1]);
                int dd = Convert.ToInt32(sDD[2]);
                //if (dd != 0)
                //{
                //    mm += 1;
                //}
                int totalMonth = (yy * 12) + mm;
                textBox8.Text = totalMonth.ToString();

                double totalSal = totalMonth * Convert.ToDouble(salary);
                double dueSal = totalSal - curPayment;
                textBox2.Text = dueSal.ToString();
            }
            else
            {
                MessageBox.Show("Error to receive data.try again..........", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            string date = "11/01/1991";
            DateTime dt = Convert.ToDateTime(date);
            DateTime dt2 = Convert.ToDateTime("07/03/2013");
            DateDifference dateDifference = new DateDifference(dt, dt2);

            MessageBox.Show(dateDifference.ToString());
        }