// ////////////////////////////////////////////////////////////////////////
        // INITIAL EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                EmployeeGateway employeeGatewayManager = new EmployeeGateway();
                int employeeIdNow = employeeGatewayManager.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));
                employeeGatewayManager.LoadByEmployeeId(employeeIdNow);

                if (!employeeGatewayManager.GetIsVacationsManager(employeeIdNow))
                {
                    // Security check
                    if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_REPORTS"]))
                    {
                        Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                    }
                }

                // Validate query string
                if ((string)Request.QueryString["source_page"] == null)
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in vacations_summary_report.aspx");
                }

                EmployeeInformationPayVacationDaysInformationList employeeInformationPayVacationDaysInformationList = new EmployeeInformationPayVacationDaysInformationList();
                employeeInformationPayVacationDaysInformationList.Load();
                ddlYear.DataSource = employeeInformationPayVacationDaysInformationList.Table;
                ddlYear.DataValueField = "Year";
                ddlYear.DataTextField = "Year";
                ddlYear.DataBind();

                try
                {
                    ddlYear.SelectedValue = DateTime.Now.Year.ToString();
                }
                catch
                {
                }

                // Register delegates
                this.RegisterDelegates();
            }
            else
            {
                // Register delegates
                this.RegisterDelegates();
            }
        }
        private void LoadVacationsData(int employeeId)
        {
            EmployeeInformationPayVacationDaysInformationList employeeInformationPayVacationDaysInformationList = new EmployeeInformationPayVacationDaysInformationList();
            employeeInformationPayVacationDaysInformationList.LoadByEmployeeId(employeeId);

            if (employeeInformationPayVacationDaysInformationList.Table.Rows.Count > 0)
            {
                ddlYear.DataSource = employeeInformationPayVacationDaysInformationList.Table;
                ddlYear.DataValueField = "Year";
                ddlYear.DataTextField = "Year";
                ddlYear.DataBind();

                if (ddlYear.Items.Contains(new ListItem(DateTime.Now.Year.ToString())))
                {
                    ddlYear.SelectedValue = DateTime.Now.Year.ToString();
                }
                else
                {
                    ddlYear.SelectedIndex = 0;
                }

                int year = Int32.Parse(ddlYear.SelectedValue);

                EmployeeInformationPayVacationDaysInformation employeeInformationPayVacationDaysInformation = new EmployeeInformationPayVacationDaysInformation(employeeInformationTDS);
                employeeInformationPayVacationDaysInformation.LoadByEmployeeIdYear(employeeId, year);

                EmployeeInformationPayVacationDaysInformationGateway employeeInformationPayVacationDaysInformationGateway = new EmployeeInformationPayVacationDaysInformationGateway(employeeInformationTDS);
                if (employeeInformationPayVacationDaysInformationGateway.Table.Rows.Count > 0)
                {
                    tbxMax.Text = employeeInformationPayVacationDaysInformationGateway.GetVacationDays(employeeId, year).ToString();
                    tbxRemaining.Text = employeeInformationPayVacationDaysInformationGateway.GetRemainingPayVacationDays(employeeId, year).ToString();
                    tbxTotalApproved.Text = employeeInformationPayVacationDaysInformationGateway.GetTotalApprovedVacations(employeeId, year).ToString();

                    DateTime startDate = new DateTime(Int32.Parse(ddlYear.SelectedValue), 1, 1);
                    DateTime endDate = new DateTime(Int32.Parse(ddlYear.SelectedValue), 12, 31);

                    EmployeeInformationVacationInformation employeeInformationVacationInformation = new EmployeeInformationVacationInformation(employeeInformationTDS);
                    employeeInformationVacationInformation.LoadByEmployeeIdStartDateEndDate(employeeId, startDate, endDate, Int32.Parse(hdfCompanyId.Value));
                }
            }
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            // Set active toolbar
            mForm6 master = (mForm6)this.Master;
            master.ActiveToolbar = "Resources";

            // Cost information only visible for admin
            tpGeneralData.Visible = true;

            if (!Convert.ToBoolean(Session["sgLFS_RESOURCES_EMPLOYEES_ADMIN"]))
            {
                tpGeneralData.Visible = false;
                tkrpbLeftMenuTools.Items[0].Items[0].Visible = false; // Personnel Agencies
            }

            if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_HOLIDAY_FULL_EDITING"])))
            {
                tkrpbLeftMenuTools.Items[0].Items[1].Visible = false; // Vacations Setup
            }

            // For vacation error message
            EmployeeInformationPayVacationDaysInformationList employeeInformationPayVacationDaysInformationList = new EmployeeInformationPayVacationDaysInformationList();
            employeeInformationPayVacationDaysInformationList.LoadByEmployeeId(Int32.Parse(hdfCurrentEmployeeId.Value));

            if (employeeInformationPayVacationDaysInformationList.Table.Rows.Count < 1)
            {
                lblNoExistVacations.Visible = true;
            }

            // For job costing error message
            int employeeId = Int32.Parse(hdfCurrentEmployeeId.Value);
            EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway(employeeInformationTDS);
            decimal? bourdenFactor = employeeInformationBasicInformationGateway.GetBourdenFactor(employeeId);
            decimal? usHealthBenefitFactor = employeeInformationBasicInformationGateway.GetUSHealthBenefitFactor(employeeId);
            decimal? benefitFactorCad = employeeInformationBasicInformationGateway.GetBenefitFactorCad(employeeId);
            decimal? benefitFactorUsd = employeeInformationBasicInformationGateway.GetBenefitFactorUsd(employeeId);

            if ((!bourdenFactor.HasValue) || (!usHealthBenefitFactor.HasValue) || (!benefitFactorCad.HasValue) || (!benefitFactorUsd.HasValue))
            {
                lblJoxCostingFactorsError.Visible = true;
            }
        }