protected void btnEstimateTotalLeaveDay_Click(object sender, EventArgs e)
    {
        lblStatutoryHolidayList.Text = string.Empty;
        if (RequestLeaveAppUnit.SelectedValue.Equals("D"))
        {
            DateTime dtFrom, dtTo;

            if (DateTime.TryParse(RequestLeaveAppDateFrom.Value, out dtFrom) && DateTime.TryParse(RequestLeaveAppDateTo.Value, out dtTo))
            {
                int intLeaveCodeID = 0;
                try
                {
                    intLeaveCodeID = Convert.ToInt32(RequestLeaveCodeID.SelectedValue);
                }
                catch
                {
                }

                DateTime[] dateSkipArray = null;
                double     totalDays     = ELeaveApplication.GetEstimatedNumOfLeaveDays(dbConn, CurEmpID, dtFrom, dtTo, intLeaveCodeID, out dateSkipArray);
                // Start 0000201, Ricky So, 2015-05-28
                if (RequestLeaveAppDateFromAM.Visible == true && RequestLeaveAppDateFromAM.SelectedValue == "PM")
                {
                    totalDays -= 0.5;
                }

                if (RequestLeaveAppDateToAM.Visible == true && RequestLeaveAppDateToAM.SelectedValue == "AM")
                {
                    totalDays -= 0.5;
                }

                if (totalDays < 0)
                {
                    totalDays = 0;
                }
                // End 0000201, Ricky So, 2015-05-28

                RequestLeaveDays.Text = totalDays.ToString();

                if (dateSkipArray.GetLength(0) > 0)
                {
                    lblStatutoryHolidayList.Text = HROne.Common.WebUtility.GetLocalizedString("Date excluded");
                    foreach (DateTime dateSkip in dateSkipArray)
                    {
                        lblStatutoryHolidayList.Text += "<br/>" + dateSkip.ToString("yyyy-MM-dd");
                    }
                }
                LeaveAppDays_TextChanged(sender, e);
            }
        }
        else if (RequestLeaveAppUnit.SelectedValue.Equals("H"))
        {
            LeaveAppTime_TextChanged(sender, e);
        }
        else if (RequestLeaveAppUnit.SelectedValue.Equals("A") || RequestLeaveAppUnit.SelectedValue.Equals("P"))
        {
            RequestLeaveDays.Text = "0.5";
            LeaveAppDays_TextChanged(sender, e);
        }
    }
Esempio n. 2
0
    protected void btnEstimateTotalLeaveDay_Click(object sender, EventArgs e)
    {
        lblStatutoryHolidayList.Text = string.Empty;
        if (LeaveAppUnit.SelectedValue.Equals("D"))
        {
            DateTime dtFrom, dtTo;
            if (DateTime.TryParse(LeaveAppDateFrom.Value, out dtFrom) && DateTime.TryParse(LeaveAppDateTo.Value, out dtTo))
            {
                int intLeaveCodeID = 0;
                try
                {
                    intLeaveCodeID = Convert.ToInt32(LeaveCodeID.SelectedValue);
                }
                catch
                {
                }

                DateTime[] dateSkipArray = null;
                double     totalDays     = ELeaveApplication.GetEstimatedNumOfLeaveDays(dbConn, CurEmpID, dtFrom, dtTo, intLeaveCodeID, out dateSkipArray);
                LeaveAppDays.Text = totalDays.ToString();

                if (dateSkipArray.GetLength(0) > 0)
                {
                    lblStatutoryHolidayList.Text = HROne.Common.WebUtility.GetLocalizedString("Date excluded");
                    foreach (DateTime dateSkip in dateSkipArray)
                    {
                        lblStatutoryHolidayList.Text += "<br/>" + dateSkip.ToString("yyyy-MM-dd");
                    }
                }
                LeaveAppDays_TextChanged(sender, e);
                //double totalDays=Math.Abs(((TimeSpan)dtTo.Subtract(dtFrom)).TotalDays) + 1;

                //DBFilter statutoryHolidayFilter = new DBFilter();
                //statutoryHolidayFilter.add(new Match("StatutoryHolidayDate", "<=", dtFrom < dtTo ? dtTo : dtFrom));
                //statutoryHolidayFilter.add(new Match("StatutoryHolidayDate", ">=", dtFrom < dtTo ? dtFrom : dtTo));
                //statutoryHolidayFilter.add("StatutoryHolidayDate", true);
                //ArrayList statutoryList = EStatutoryHoliday.db.select(dbConn, statutoryHolidayFilter);
                //if (statutoryList.Count > 0)
                //{
                //    lblStatutoryHolidayList.Text = HROne.Common.WebUtility.GetLocalizedString("Statutory Holiday");
                //    foreach (EStatutoryHoliday statHol in statutoryList)
                //    {
                //        lblStatutoryHolidayList.Text += "<br/>" + statHol.StatutoryHolidayDate.ToString("yyyy-MM-dd") + "&nbsp" + statHol.StatutoryHolidayDesc;
                //        totalDays--;
                //    }
                //}
                //LeaveAppDays.Text = totalDays.ToString() ;
            }
        }
        else if (LeaveAppUnit.SelectedValue.Equals("H"))
        {
            LeaveAppTime_TextChanged(sender, e);
        }
        else if (LeaveAppUnit.SelectedValue.Equals("A") || LeaveAppUnit.SelectedValue.Equals("P"))
        {
            LeaveAppDays.Text = "0.5";
            LeaveAppDays_TextChanged(sender, e);
        }
    }