/// <summary>
        /// Save
        /// </summary>
        public void SaveForEdit(double newTakenDays)
        {
            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);
                    bool originalDeleted = vacationsInformationRequestsInformationGateway.GetDeletedOriginal(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);
                    bool newDeleted = vacationsInformationRequestsInformationGateway.GetDeleted(requestId);

                    VacationsEmployeeMaxPaidVacations vacationsEmployeeMaxPaidVacations = new VacationsEmployeeMaxPaidVacations();
                    vacationsEmployeeMaxPaidVacations.UpdateTotalTakenVacationDays(row.StartDate.Year, row.EmployeeID, newTakenDays);

                    VacationRequests vacationRequests = new VacationRequests(null);
                    vacationRequests.UpdateDirect(requestId, employeeId, originalStartDate, originalEndDate, originalTotalPaidVacationDays, originalState, originalComments, originalDetails, originalRejectReason, originalCancelReason, originalDeleted, companyId, requestId, employeeId, newStartDate, newEndDate, newTotalPaidVacationDays, newState, newComments, newDetails, newRejectReason, newCancelReason, newDeleted, companyId);
                }
            }
        }
        /// <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);
                }
            }
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            // Set active toolbar
            mForm6 master = (mForm6)this.Master;
            master.ActiveToolbar = "LabourHours";

            // for non vacation managers
            if (hdfIsVacationManager.Value == "False")
            {
                // Validate left menu
                tkrpbLeftMenuAllVacations.Visible = false; // All Vacations
                tkrpbLeftMenuMyVacations.Visible = true; // My Vacations

                // Validate Top menu for Admin
                tkrmTop.Items[0].Visible = false; // Edit button

                // Validate reports
                tkrpbLeftMenuReports.Visible = false;
            }
            else
            {
                // Validate reports
                if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_REPORTS"]))
                {
                    tkrpbLeftMenuReports.Visible = false;
                }
            }

            if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_HOLIDAY_FULL_EDITING"])))
            {
                // Validate tools menu
                tkrpbLeftMenuTools.Visible = false;
                //tkrpbLeftMenuTools.Items[2].Visible = false;
                //tkrpbLeftMenuTools.Items[3].Visible = false;
            }

            VacationsInformationRequestsInformationGateway vacationsInformationRequestsInformationGateway = new VacationsInformationRequestsInformationGateway(vacationsInformationTDS);
            string state = vacationsInformationRequestsInformationGateway.GetState(Int32.Parse(hdfRequestId.Value));

            if (state == "Rejected" || state == "Cancelled")
            {
                tkrmTop.Items[0].Visible = false;
            }

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