public double CalculateMonth(double Amount)
    {
        double AnnumSalary = 0;
        int    days = 0, days1 = 0;
        int    months = 0, months1 = 0;
        int    years = 0, years1 = 0;

        DateTime dt1 = Convert.ToDateTime(Pages_Employee_frmMonthlyAttendanceNew.ToDateTime1(txtDateOfJoining.Text));
        DateTime dt2 = Convert.ToDateTime(Pages_Employee_frmMonthlyAttendanceNew.ToDateTime1("31/03/2014"));

        dt1 = dt1.Date;
        dt2 = dt2.Date;

        days = dt2.Day - dt1.Day;
        if (days < 0)
        {
            var newNow = dt2.AddMonths(-1);
            days += (int)(dt2 - newNow).TotalDays;
            dt2   = newNow;
        }
        months = dt2.Month - dt1.Month;
        if (months < 0)
        {
            months += 12;
            dt2     = dt2.AddYears(-1);
        }
        years = dt2.Year - dt1.Year;
        if (years == 0)
        {
            if (months == 0)
            {
                days1 = days;
            }
            else if (days >= 0)
            {
                months1 = months;
                days1   = days;
            }
        }

        int daysInMonth = SalaryCalculationDays(dt1.Month);

        if (days1 == 0)
        {
            AnnumSalary = Amount * months1;
        }
        else
        {
            if ((days1 + 1) == daysInMonth)
            {
                days1       = 0;
                months1     = months1 + 1;
                AnnumSalary = Amount * months1 + (Amount / daysInMonth) * (days1 + 1);
            }
            else
            {
                AnnumSalary = Amount * months1 + (Amount / daysInMonth) * (days1);
            }
        }

        return(AnnumSalary);
    }
    //Allowances Grid
    protected void grdMonthlyAttendanceSummary_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //DataSet ds = new DataSet();
        //ds = objMonthlyAttendanceRegisterManager.GetMonthlyAttendanceRegisterDetails4Grid(Convert.ToString(txtCode.Text).Trim(), Convert.ToInt32(ddlMonth.SelectedValue.ToString().Trim()),Convert.ToInt32(ddlFinYear.SelectedValue.ToString().Trim())) ;
        //if (ds != null && ds.Tables[0].Rows.Count > 0)
        //{
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView drv             = ((DataRowView)e.Row.DataItem);
            Label       lbl_Days        = ((Label)e.Row.FindControl("lbl_Days"));
            Label       lbl_Status      = ((Label)e.Row.FindControl("lbl_Status"));
            TextBox     txt_MarkInTime  = ((TextBox)e.Row.FindControl("txt_MarkInTime"));
            TextBox     txt_MarkOutTime = ((TextBox)e.Row.FindControl("txt_MarkOutTime"));
            CheckBox    chk_Date        = ((CheckBox)e.Row.FindControl("chk_Date"));
            LinkButton  Edit            = ((LinkButton)e.Row.FindControl("lnkEdit"));

            if (Convert.ToString(lbl_Days.Text).Trim() == "WO")
            {
                //chk_Date.Enabled = false;
                chk_Date.ForeColor = System.Drawing.Color.Red;
                lbl_Days.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                // chk_Date.Enabled = true;
                lbl_Days.Visible = false;
            }

            DateTime dt1 = Convert.ToDateTime(Pages_Employee_frmMonthlyAttendanceNew.ToDateTime1(chk_Date.Text));
            DateTime dt2 = Convert.ToDateTime(Pages_Employee_frmMonthlyAttendanceNew.ToDateTime1(DateTime.Now.ToString("dd/MM/yyyy")));

            if (Convert.ToString(chk_Date.Text).Trim() == DateTime.Now.ToString("dd/MM/yyyy"))
            {
                chk_Date.Checked = true;
                //chk_Date.Enabled = false;
                chk_Date.ForeColor     = System.Drawing.Color.Green;
                lblTodayDate.Text      = chk_Date.Text;
                lblTodayDate.Font.Bold = true;
            }
            else if (dt1 < dt2)
            {
                chk_Date.Checked = false;
                //chk_Date.Enabled = false;
                chk_Date.ForeColor = System.Drawing.Color.Blue;



                if (Convert.ToString(txt_MarkInTime.Text).Trim() == "" && Convert.ToString(txt_MarkOutTime.Text).Trim() == "" && lbl_Days.Text != "WO")
                {
                    chk_Date.Checked = false;
                    lbl_Status.Text  = "Absent";
                    if (lbl_Days.Text != "WO")
                    {
                        Edit.Visible     = true;
                        chk_Date.Enabled = true;
                    }
                    else
                    {
                        Edit.Visible = false;
                        //chk_Date.Enabled = false;
                    }
                }
                else if (Convert.ToString(txt_MarkInTime.Text).Trim() != "" && Convert.ToString(txt_MarkOutTime.Text).Trim() != "")
                {
                    chk_Date.Checked = true;
                    //lbl_Status.Text = "Present";
                }
            }
            else if (dt1 > dt2)
            {
                //chk_Date.Enabled = false;
                chk_Date.Checked = false;
            }

            //if (chk_Date.Checked == true && Convert.ToString(chk_Date.Text).Trim() == DateTime.Now.ToString("dd/MM/yyyy"))
            //{
            //    DataSet ds4GetMArkInTime = new DataSet();
            //    ds4GetMArkInTime = objMonthlyAttendanceRegisterManager.GetMonthlyAttendanceRegister4ID(Convert.ToString(txtCode.Text).Trim(), Convert.ToString(lblTodayDate.Text).Trim());

            //    if (ds4GetMArkInTime != null && ds4GetMArkInTime.Tables[0].Rows.Count > 0)
            //    {
            //        txt_MarkInTime.Text = ds4GetMArkInTime.Tables[0].Rows[0]["MarkInTime"].ToString();
            //        txt_MarkOutTime.Text = ds4GetMArkInTime.Tables[0].Rows[0]["MarkOutTime"].ToString();
            //        //lbl_Status.Text = ds4GetMArkInTime.Tables[0].Rows[0]["Status"].ToString();
            //        lbl_Status.Text = "";
            //    }
            //}
            //else
            //{
            //    txt_MarkInTime.Text = "";
            //    txt_MarkOutTime.Text = "";
            //    txt_MarkOutTime.Enabled = false;
            //}
            if (lbl_Status.Text == "Absent")
            {
                Edit.Visible = true;
            }
            else
            {
                Edit.Visible = false;
            }
        }
        //}
        //else
        //{

        //}
    }