/// <summary>
        /// Save
        /// </summary>
        public void Save()
        {
            VacationsInformationTDS vacationsInformationChanges = (VacationsInformationTDS)Data.GetChanges();

            if (vacationsInformationChanges.RequestsInformation.Rows.Count > 0)
            {
                VacationsInformationRequestsInformationGateway vacationsInformationRequestsInformationGateway = new VacationsInformationRequestsInformationGateway(vacationsInformationChanges);

                foreach (VacationsInformationTDS.RequestsInformationRow row in (VacationsInformationTDS.RequestsInformationDataTable)vacationsInformationChanges.RequestsInformation)
                {
                    int requestId = row.RequestID;
                    int employeeId = row.EmployeeID;
                    bool deleted = row.Deleted;
                    int companyId = row.COMPANY_ID;

                    // original values
                    DateTime originalStartDate = vacationsInformationRequestsInformationGateway.GetStartDateOriginal(requestId);
                    DateTime originalEndDate = vacationsInformationRequestsInformationGateway.GetEndDateOriginal(requestId);
                    double originalTotalPaidVacationDays = vacationsInformationRequestsInformationGateway.GetTotalPaidVacationDaysOriginal(requestId);
                    string originalState = vacationsInformationRequestsInformationGateway.GetStateOriginal(requestId);
                    string originalComments = vacationsInformationRequestsInformationGateway.GetCommentsOriginal(requestId);
                    string originalDetails = vacationsInformationRequestsInformationGateway.GetDetailsOriginal(requestId);
                    string originalRejectReason = vacationsInformationRequestsInformationGateway.GetRejectReasonOriginal(requestId);
                    string originalCancelReason = vacationsInformationRequestsInformationGateway.GetCancelReasonOriginal(requestId);

                    // new values
                    DateTime newStartDate = vacationsInformationRequestsInformationGateway.GetStartDate(requestId);
                    DateTime newEndDate = vacationsInformationRequestsInformationGateway.GetEndDate(requestId);
                    double newTotalPaidVacationDays = vacationsInformationRequestsInformationGateway.GetTotalPaidVacationDays(requestId);
                    string newState = vacationsInformationRequestsInformationGateway.GetState(requestId);
                    string newComments = vacationsInformationRequestsInformationGateway.GetComments(requestId);
                    string newDetails = vacationsInformationRequestsInformationGateway.GetDetails(requestId);
                    string newRejectReason = vacationsInformationRequestsInformationGateway.GetRejectReason(requestId);
                    string newCancelReason = vacationsInformationRequestsInformationGateway.GetCancelReason(requestId);

                    if (newState == "Rejected" || newState == "Cancelled")
                    {
                        VacationsInformationBasicInformationGateway vacationsInformationBasicInformationGateway = new VacationsInformationBasicInformationGateway();
                        vacationsInformationBasicInformationGateway.LoadByEmployeeIdYear(employeeId, originalStartDate.Year, companyId);
                        double oldTotalTakenVacationDays = vacationsInformationBasicInformationGateway.GetTotalVacationDays(employeeId, originalStartDate.Year) - vacationsInformationBasicInformationGateway.GetRemainingPayVacationDays(employeeId, originalStartDate.Year);

                        VacationsEmployeeMaxPaidVacations vacationsEmployeeMaxPaidVacations = new VacationsEmployeeMaxPaidVacations();
                        double newTotalTakenVacationDays = oldTotalTakenVacationDays - originalTotalPaidVacationDays;
                        vacationsEmployeeMaxPaidVacations.UpdateTotalTakenVacationDays(row.StartDate.Year, row.EmployeeID, newTotalTakenVacationDays);
                    }
                    else
                    {
                        if (originalState == newState)
                        {
                            VacationsInformationBasicInformationGateway vacationsInformationBasicInformationGateway = new VacationsInformationBasicInformationGateway();
                            vacationsInformationBasicInformationGateway.LoadByEmployeeIdYear(employeeId, originalStartDate.Year, companyId);
                            double oldTotalTakenVacationDays = vacationsInformationBasicInformationGateway.GetTotalVacationDays(employeeId, originalStartDate.Year) - vacationsInformationBasicInformationGateway.GetRemainingPayVacationDays(employeeId, originalStartDate.Year);

                            VacationsEmployeeMaxPaidVacations vacationsEmployeeMaxPaidVacations = new VacationsEmployeeMaxPaidVacations();
                            double newTotalTakenVacationDays = oldTotalTakenVacationDays + newTotalPaidVacationDays;
                            vacationsEmployeeMaxPaidVacations.UpdateTotalTakenVacationDays(row.StartDate.Year, row.EmployeeID, newTotalTakenVacationDays);
                        }
                    }

                    VacationRequests vacationRequests = new VacationRequests(null);
                    vacationRequests.UpdateDirect(requestId, employeeId, originalStartDate, originalEndDate, originalTotalPaidVacationDays, originalState, originalComments, originalDetails, originalRejectReason, originalCancelReason, deleted, companyId, requestId, employeeId, newStartDate, newEndDate, newTotalPaidVacationDays, newState, newComments, newDetails, newRejectReason, newCancelReason, deleted, companyId);
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Tag page
                // ... for non vacation managers
                EmployeeGateway employeeGatewayManager = new EmployeeGateway();
                int employeeIdNow = employeeGatewayManager.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));
                employeeGatewayManager.LoadByEmployeeId(employeeIdNow);

                if (employeeGatewayManager.GetIsVacationsManager(employeeIdNow))
                {
                    hdfIsVacationManager.Value = "True";
                }
                else
                {
                    hdfIsVacationManager.Value = "False";
                }

                // Security check
                if (hdfIsVacationManager.Value == "False")
                {
                    //if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_EDIT"])))
                    //{
                        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) && ((string)Request.QueryString["vacation_id"] == null) && ((string)Request.QueryString["request_id"] == null) && ((string)Request.QueryString["date_to_show"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in vacations_edit.aspx");
                }

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfVacationId.Value = (string)Request.QueryString["vacation_id"];
                hdfRequestId.Value = (string)Request.QueryString["request_id"];

                int requestId = Int32.Parse(hdfRequestId.Value);
                int companyId = Int32.Parse(hdfCompanyId.Value);

                ViewState["date_to_show"] = (string)Request.QueryString["date_to_show"];
                DateTime dateToShow = DateTime.Parse((string)Request.QueryString["date_to_show"]);

                // Initialize values
                DropDownList ddlVacationsFor = (DropDownList)tkrpbLeftMenuAllVacations.FindItemByValue("nbVacationsForDDL").FindControl("ddlVacationsFor");
                EmployeeList employeeList = new EmployeeList();
                string employeeTypeNow = employeeGatewayManager.GetType(employeeIdNow);
                if (employeeTypeNow.Contains("CA"))
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "CA", -1, "(All)");
                }
                else
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "US", -1, "(All)");
                }
                ddlVacationsFor.DataSource = employeeList.Table;
                ddlVacationsFor.DataValueField = "EmployeeID";
                ddlVacationsFor.DataTextField = "FullName";
                ddlVacationsFor.DataBind();
                ddlVacationsFor.SelectedValue = Session["ddlVacationsForSelectedValue"].ToString();

                // Load Data
                vacationsInformationTDS = new VacationsInformationTDS();
                vacationDaysInformation = new VacationsInformationTDS.DaysInformationDataTable();

                VacationsInformationDaysInformationGateway vacationsInformationDaysInformationGateway = new VacationsInformationDaysInformationGateway(vacationsInformationTDS);
                vacationsInformationDaysInformationGateway.LoadByRequestId(requestId, companyId);

                VacationsInformationRequestsInformationGateway vacationsInformationRequestsInformationGateway = new VacationsInformationRequestsInformationGateway(vacationsInformationTDS);
                vacationsInformationRequestsInformationGateway.LoadByRequestId(requestId, companyId);

                hdfEmployeeId.Value = vacationsInformationRequestsInformationGateway.GetEmployeeID(requestId).ToString();
                int employeeId = Int32.Parse(hdfEmployeeId.Value);

                VacationsInformationBasicInformationGateway vacationsInformationBasicInformationGateway = new VacationsInformationBasicInformationGateway(vacationsInformationTDS);
                vacationsInformationBasicInformationGateway.LoadByEmployeeIdYear(employeeId, dateToShow.Year, companyId);

                Session["vacationsInformationTDS"] = vacationsInformationTDS;
                Session["vacationDaysInformation"] = vacationsInformationTDS.DaysInformation;

                LoadData(employeeId, dateToShow.Year, requestId);

                Page.DataBind();
            }
            else
            {
                vacationsInformationTDS = (VacationsInformationTDS)Session["vacationsInformationTDS"];
                vacationDaysInformation = (VacationsInformationTDS.DaysInformationDataTable)Session["vacationDaysInformation"];
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // AUXILIAR EVENTS
        //
        protected void tkrsVacations_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
        {
            DateTime dateToShowOld = DateTime.Parse((string)ViewState["date_to_show"]);

            ViewState["date_to_show"] = tkrsVacations.SelectedDate.ToString();

            DateTime dateToShowNew = DateTime.Parse((string)ViewState["date_to_show"]);

            if (dateToShowNew.Year != dateToShowOld.Year)
            {
                VacationsInformationBasicInformationGateway vacationsInformationBasicInformationGateway = new VacationsInformationBasicInformationGateway(vacationsInformationTDS);
                vacationsInformationBasicInformationGateway.LoadByEmployeeIdYear(Int32.Parse(hdfEmployeeId.Value), dateToShowNew.Year, Int32.Parse(hdfCompanyId.Value));

                if (vacationsInformationBasicInformationGateway.Table.Rows.Count == 0)
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "The team member don't have max paid day vacations defined in the system. Contact your system administrator.");
                }
                else
                {
                    LoadData(Int32.Parse(hdfEmployeeId.Value), dateToShowNew.Year, Int32.Parse(hdfRequestId.Value));
                }
            }
        }
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS - DATASET
 //
 /// <summary>
 /// LoadByEmployeeIdYear
 /// </summary>
 /// <param name="employeeId">employeeId</param>
 /// <param name="year">year</param>
 /// <param name="companyId">companyId</param>
 public void LoadByEmployeeIdYear(int employeeId, int year, int companyId)
 {
     VacationsInformationBasicInformationGateway vcationsInformationBasicInformationGateway = new VacationsInformationBasicInformationGateway(Data);
     vcationsInformationBasicInformationGateway.LoadByEmployeeIdYear(employeeId, year, companyId);
 }