/// <summary>
        /// Save all employee cost exception to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId, int employeeId)
        {
            EmployeeInformationTDS costExceptionsInformationChanges = (EmployeeInformationTDS)Data.GetChanges();

            if (costExceptionsInformationChanges.CostExceptionsInformation.Rows.Count > 0)
            {
                EmployeeInformationCostExceptionsInformationGateway employeeInformationCostExceptionsInformationGateway = new EmployeeInformationCostExceptionsInformationGateway(costExceptionsInformationChanges);

                foreach (EmployeeInformationTDS.CostExceptionsInformationRow row in (EmployeeInformationTDS.CostExceptionsInformationDataTable)costExceptionsInformationChanges.CostExceptionsInformation)
                {
                    // Insert new costs exceptions
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        EmployeeCostHistoryExceptions employeeCostHistoryExceptions = new EmployeeCostHistoryExceptions(null);
                        employeeCostHistoryExceptions.InsertDirect(row.CostID, row.RefID, employeeId, row.Work_, row.UnitOfMeasurement, row.PayRateCad, row.BurdenRateCad, row.TotalCostCad, row.PayRateUsd, row.BurdenRateUsd, row.TotalCostUsd, row.Deleted, row.COMPANY_ID, row.BenefitFactorCad, row.BenefitFactorUsd, row.HealthBenefitUsd);
                    }

                    // Update costs exceptions
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int costId = row.CostID;
                        int refId = row.RefID;
                        bool originalDeleted = row.Deleted;
                        int originalCompanyId = companyId;

                        // original values
                        string originalWork = employeeInformationCostExceptionsInformationGateway.GetWork_Original(costId, refId);
                        string originalUnitOfMeasurement = employeeInformationCostExceptionsInformationGateway.GetUnitOfMeasurementOriginal(costId, refId);
                        decimal originalPayRateCad = employeeInformationCostExceptionsInformationGateway.GetPayRateCadOriginal(costId, refId);
                        decimal originalBurdenRateCad = employeeInformationCostExceptionsInformationGateway.GetBurdenRateCadOriginal(costId, refId);
                        decimal originalTotalCostCad = employeeInformationCostExceptionsInformationGateway.GetTotalCostCadOriginal(costId, refId);
                        decimal originalPayRateUsd = employeeInformationCostExceptionsInformationGateway.GetPayRateUsdOriginal(costId, refId);
                        decimal originalBurdenRateUsd = employeeInformationCostExceptionsInformationGateway.GetBurdenRateUsdOriginal(costId, refId);
                        decimal originalTotalCostUsd = employeeInformationCostExceptionsInformationGateway.GetTotalCostUsdOriginal(costId, refId);
                        decimal originalBenefitFactorCad = employeeInformationCostExceptionsInformationGateway.GetBenefitFactorCadOriginal(costId, refId);
                        decimal originalBenefitFactorUsd = employeeInformationCostExceptionsInformationGateway.GetBenefitFactorUsdOriginal(costId, refId);
                        decimal originalHealthBenefitUsd = employeeInformationCostExceptionsInformationGateway.GetHealthBenefitUsdOriginal(costId, employeeId);

                        // new values
                        string newWork = employeeInformationCostExceptionsInformationGateway.GetWork_(costId, refId);
                        string newUnitOfMeasurement = employeeInformationCostExceptionsInformationGateway.GetUnitOfMeasurement(costId, refId);
                        decimal newPayRateCad = employeeInformationCostExceptionsInformationGateway.GetPayRateCad(costId, refId);
                        decimal newBurdenRateCad = employeeInformationCostExceptionsInformationGateway.GetBurdenRateCad(costId, refId);
                        decimal newTotalCostCad = employeeInformationCostExceptionsInformationGateway.GetTotalCostCad(costId, refId);
                        decimal newPayRateUsd = employeeInformationCostExceptionsInformationGateway.GetPayRateUsd(costId, refId);
                        decimal newBurdenRateUsd = employeeInformationCostExceptionsInformationGateway.GetBurdenRateUsd(costId, refId);
                        decimal newTotalCostUsd = employeeInformationCostExceptionsInformationGateway.GetTotalCostUsd(costId, refId);
                        decimal newBenefitFactorCad = employeeInformationCostExceptionsInformationGateway.GetBenefitFactorCad(costId, refId);
                        decimal newBenefitFactorUsd = employeeInformationCostExceptionsInformationGateway.GetBenefitFactorUsd(costId, refId);
                        decimal newHealthBenefitUsd = employeeInformationCostExceptionsInformationGateway.GetHealthBenefitUsd(costId, employeeId);

                        EmployeeCostHistoryExceptions employeeCostHistoryExceptions = new EmployeeCostHistoryExceptions(null);
                        employeeCostHistoryExceptions.UpdateDirect(costId, refId, employeeId, originalWork, originalUnitOfMeasurement, originalPayRateCad, originalBurdenRateCad, originalTotalCostCad, originalPayRateUsd, originalBurdenRateUsd, originalTotalCostUsd, originalDeleted, originalCompanyId, originalBenefitFactorCad, originalBenefitFactorUsd, originalHealthBenefitUsd, costId, refId, employeeId, newWork, newUnitOfMeasurement, newPayRateCad, newBurdenRateCad, newTotalCostCad, newPayRateUsd, newBurdenRateUsd, newTotalCostUsd, originalDeleted, originalCompanyId, newBenefitFactorCad, newBenefitFactorUsd, newHealthBenefitUsd);
                    }

                    // Deleted costs exceptions
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        EmployeeCostHistoryExceptions employeeCostHistoryExceptions = new EmployeeCostHistoryExceptions(null);
                        employeeCostHistoryExceptions.DeleteDirect(row.CostID, row.RefID, row.COMPANY_ID);
                    }
                }
            }
        }
        protected void grdCostsExceptions_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            // Edit items
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                int refId = Int32.Parse(((Label)e.Row.FindControl("lblExceptionRefIDEdit")).Text.Trim());
                int costId = Int32.Parse(((Label)e.Row.FindControl("lblExceptionCostIDEdit")).Text.Trim());

                EmployeeInformationCostExceptionsInformationGateway employeeInformationCostExceptionsInformationGateway = new EmployeeInformationCostExceptionsInformationGateway(employeeInformationTDS);
                string work_ = employeeInformationCostExceptionsInformationGateway.GetWork_(costId, refId);
                ((DropDownList)e.Row.FindControl("ddlExceptionWork_Edit")).SelectedValue = work_;

                string unitOfMeasurementException = employeeInformationCostExceptionsInformationGateway.GetUnitOfMeasurement(costId, refId);
                ((DropDownList)e.Row.FindControl("ddlExceptionUnitOfMeasurementEdit")).SelectedValue = unitOfMeasurementException;
            }

            // Control value for footer employees
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                // For Material
                ((TextBox)e.Row.FindControl("tbxExceptionBenefitFactorCadNew")).Text = tbxBenefitFactorCad.Text;
                ((TextBox)e.Row.FindControl("tbxExceptionBenefitFactorUsdNew")).Text = tbxBenefitFactorUsd.Text;

                // Validation to add new rows
                if ((tbxBourdenFactor.Text == "") || (tbxUSHealthBenefitFactor.Text == "") || (tbxBenefitFactorCad.Text == "") || (tbxBenefitFactorUsd.Text == ""))
                {
                    ((ImageButton)e.Row.FindControl("ibtnAdd")).Visible = false;
                }
            }

            // Normal rows
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate))))
            {
                // Validation to edit rows
                if ((tbxBourdenFactor.Text == "") || (tbxUSHealthBenefitFactor.Text == "") || (tbxBenefitFactorCad.Text == "") || (tbxBenefitFactorUsd.Text == ""))
                {
                    ((ImageButton)e.Row.FindControl("ibtnEdit")).Visible = false;
                }
                else
                {
                    if (((Label)e.Row.FindControl("lblInDataBase")).Text == "1")
                    {
                        ((ImageButton)e.Row.FindControl("ibtnEdit")).Visible = false;
                    }
                }
            }
        }