Ejemplo n.º 1
0
        /// <summary>
        /// GetAllCategoryManagers
        /// </summary>
        /// <param name="category">category</param>
        /// <param name="employeeId">employeeId</param>
        /// <returns>All Category Managers</returns>
        public string GetAllCategoryManagers(string category, int employeeId)
        {
            string allCategoryManagers = "";

            EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway();
            employeeInformationBasicInformationGateway.LoadByEmployeeId(employeeId);

            string employeeType = "";

            if (employeeInformationBasicInformationGateway.GetType(employeeId).Contains("CA"))
            {
                employeeType = "%CA";
            }
            else
            {
                employeeType = "%US";
            }

            EmployeeGateway employeeGateway = new EmployeeGateway(Data);
            employeeGateway.LoadApproveManagersByCategoryType(category, employeeType);

            foreach (EmployeeTDS.LFS_RESOURCES_EMPLOYEERow row in (EmployeeTDS.LFS_RESOURCES_EMPLOYEEDataTable)Table)
            {
                if (allCategoryManagers.Length > 0)
                {
                    allCategoryManagers = allCategoryManagers + ", " + row.LastName + " " + row.FirstName;
                }
                else
                {
                    allCategoryManagers = allCategoryManagers + row.LastName + " " + row.FirstName;
                }
            }

            //if (allCategoryManagers[allCategoryManagers.Length-1] == ',')
            //{
            //    allCategoryManagers = allCategoryManagers.Substring(0, allCategoryManagers.Length - 2);
            //}

            return allCategoryManagers;
        }
        private void LoadBasicData(int employeeId)
        {
            EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway(employeeInformationTDS);
            if (employeeInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load employee basic data
                tbxFisrtName.Text = employeeInformationBasicInformationGateway.GetFirstName(employeeId);
                tbxLastName.Text = employeeInformationBasicInformationGateway.GetLastName(employeeId);
                tbxeMail.Text = employeeInformationBasicInformationGateway.GeteMail(employeeId);
                ckbxIsSalesman.Checked = employeeInformationBasicInformationGateway.GetIsSalesman(employeeId);
                ckbxRequestTimesheet.Checked = employeeInformationBasicInformationGateway.GetRequestProjectTime(employeeId);
                ckbxSalaried.Checked = employeeInformationBasicInformationGateway.GetSalaried(employeeId);
                ckbxAssignableSrs.Checked = employeeInformationBasicInformationGateway.GetAssignableSRS(employeeId);
                tbxJobClassType.Text = employeeInformationBasicInformationGateway.GetJobClassType(employeeId);
                tbxCategory.Text = employeeInformationBasicInformationGateway.GetCategory(employeeId);
                tbxPersonalAgency.Text = employeeInformationBasicInformationGateway.GetPersonalAgencyName(employeeId);
                ckbxVacationsManager.Checked = employeeInformationBasicInformationGateway.GetIsVacationsManager(employeeId);
                ckbxApproveTimesheets.Checked = employeeInformationBasicInformationGateway.GetApproveTimesheets(employeeId);
                tbxCrew.Text = employeeInformationBasicInformationGateway.GetCrew(employeeId);

                string type = employeeInformationBasicInformationGateway.GetType(employeeId);
                EmployeeTypeGateway employeeTypeGateway = new EmployeeTypeGateway();
                employeeTypeGateway.LoadByType(type);
                tbxType.Text = employeeTypeGateway.GetDescription(type);

                string state = employeeInformationBasicInformationGateway.GetState(employeeId);
                EmployeeStateGateway employeeStateGateway = new EmployeeStateGateway();
                employeeStateGateway.LoadByState(state);
                tbxState.Text = employeeStateGateway.GetDescription(state);

                // Job costing factors
                decimal? bourdenFactor = employeeInformationBasicInformationGateway.GetBourdenFactor(employeeId);
                if (bourdenFactor.HasValue)
                {
                    tbxBourdenFactor.Text = decimal.Round((decimal)bourdenFactor,1).ToString();
                }

                decimal? usHealthBenefitFactor = employeeInformationBasicInformationGateway.GetUSHealthBenefitFactor(employeeId);
                if (usHealthBenefitFactor.HasValue)
                {
                    tbxUSHealthBenefitFactor.Text = decimal.Round((decimal)usHealthBenefitFactor, 1).ToString();
                }

                decimal? benefitFactorCad = employeeInformationBasicInformationGateway.GetBenefitFactorCad(employeeId);
                if (benefitFactorCad.HasValue)
                {
                    tbxBenefitFactorCad.Text = decimal.Round((decimal)benefitFactorCad, 2).ToString();
                }

                decimal? benefitFactorUsd = employeeInformationBasicInformationGateway.GetBenefitFactorUsd(employeeId);
                if (benefitFactorUsd.HasValue)
                {
                    tbxBenefitFactorUsd.Text = decimal.Round((decimal)benefitFactorUsd, 2).ToString();
                }
            }
        }
        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;
            }
        }
        protected void grdProjectTime_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            // Footer Item
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                EmployeeInformationBasicInformationGateway employeeInformationBasicInformation = new EmployeeInformationBasicInformationGateway();
                employeeInformationBasicInformation.LoadByEmployeeId(Int32.Parse(hdfEmployeeID.Value));
                string jobClassType = employeeInformationBasicInformation.GetJobClassType(Int32.Parse(hdfEmployeeID.Value));

                if (jobClassType != "")
                {
                    try
                    {
                        ((DropDownList)e.Row.FindControl("ddlJobClassTypeFooter")).SelectedValue = jobClassType;
                    }
                    catch
                    {
                    }
                }
            }

            // Edit Item
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                int projectTimeId = Int32.Parse(((Label)e.Row.FindControl("lblProjectTimeIdEdit")).Text.Trim());
                ProjectTimeTempGateway projectTimeTempGateway = new ProjectTimeTempGateway(projectTimeTDS);

                // For Start Time
                string startTime = ""; if (projectTimeTempGateway.GetStartTime(projectTimeId) != "") startTime = projectTimeTempGateway.GetStartTime(projectTimeId);
                if (startTime != "")
                {
                    string[] hoursMin1 = startTime.Split(':');

                    ((DropDownList)e.Row.FindControl("ddlStartTimeHourEdit")).SelectedValue = hoursMin1[0].Trim();
                    ((DropDownList)e.Row.FindControl("ddlStartTimeMinuteEdit")).SelectedValue = hoursMin1[1].Trim();
                }

                // For End Time
                string endTime = ""; if (projectTimeTempGateway.GetEndTime(projectTimeId) != "") endTime = projectTimeTempGateway.GetEndTime(projectTimeId);
                if (endTime != "")
                {
                    string[] endHoursMin1 = endTime.Split(':');

                    ((DropDownList)e.Row.FindControl("ddlEndTimeHourEdit")).SelectedValue = endHoursMin1[0].Trim();
                    ((DropDownList)e.Row.FindControl("ddlEndTimeMinuteEdit")).SelectedValue = endHoursMin1[1].Trim();
                }

                // For Type of work
                string workFunctionConcat = projectTimeTempGateway.GetWorkFunctionConcat(projectTimeId);
                ((DropDownList)e.Row.FindControl("ddlTypeOfWorkFunctionEdit")).SelectedValue = workFunctionConcat;

                // For UnitId
                int? unitId = null; if (projectTimeTempGateway.GetUnitId(projectTimeId).HasValue) unitId = (int)projectTimeTempGateway.GetUnitId(projectTimeId);
                if (unitId.HasValue)
                {
                    ((DropDownList)e.Row.FindControl("ddlUnitEdit")).SelectedValue = ((int)unitId).ToString();
                }

                // For TowedId
                int? towedId = null; if (projectTimeTempGateway.GetTowedUnitId(projectTimeId).HasValue) towedId = (int)projectTimeTempGateway.GetTowedUnitId(projectTimeId);
                if (towedId.HasValue)
                {
                    ((DropDownList)e.Row.FindControl("ddlTowedEdit")).SelectedValue = ((int)towedId).ToString();
                }

                string jobClassType = projectTimeTempGateway.GetJobClassType(projectTimeId);

                if (jobClassType != "")
                {
                    try
                    {
                        ((DropDownList)e.Row.FindControl("ddlJobClassTypeEdit")).SelectedValue = jobClassType;
                    }
                    catch
                    {
                    }
                }
            }
        }
        private void LoadBasicData(int employeeId)
        {
            // Load Data
            EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway(employeeInformationTDS);
            if (employeeInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load employee basic data
                tbxFisrtName.Text = employeeInformationBasicInformationGateway.GetFirstName(employeeId);
                tbxLastName.Text = employeeInformationBasicInformationGateway.GetLastName(employeeId);
                tbxeMail.Text = employeeInformationBasicInformationGateway.GeteMail(employeeId);
                ckbxIsSalesman.Checked = employeeInformationBasicInformationGateway.GetIsSalesman(employeeId);
                ckbxRequestTimesheet.Checked = employeeInformationBasicInformationGateway.GetRequestProjectTime(employeeId);
                ckbxSalaried.Checked = employeeInformationBasicInformationGateway.GetSalaried(employeeId);
                ckbxAssignableSrs.Checked = employeeInformationBasicInformationGateway.GetAssignableSRS(employeeId);
                ddlType.SelectedValue = employeeInformationBasicInformationGateway.GetType(employeeId);
                ddlState.SelectedValue = employeeInformationBasicInformationGateway.GetState(employeeId);
                ddlCategory.SelectedValue = employeeInformationBasicInformationGateway.GetCategory(employeeId);
                ddlPersonalAgency.SelectedValue = employeeInformationBasicInformationGateway.GetPersonalAgencyName(employeeId);
                ckbxVacationsManager.Checked = employeeInformationBasicInformationGateway.GetIsVacationsManager(employeeId);
                ckbxApproveTimesheets.Checked = employeeInformationBasicInformationGateway.GetApproveTimesheets(employeeId);
                if (employeeInformationBasicInformationGateway.GetCrew(employeeId) != "")
                {
                    ddlCrew.SelectedValue = employeeInformationBasicInformationGateway.GetCrew(employeeId);
                }
                else
                {
                    ddlCrew.SelectedIndex = 0;
                }

                if (employeeInformationBasicInformationGateway.GetType(employeeId).Contains("CA"))
                {
                    ProjectTimeJobClassTypeList projectTimeJobClassTypeList = new ProjectTimeJobClassTypeList();
                    projectTimeJobClassTypeList.LoadAndAddItem(1, 3, "");
                    ddlJobClassType.DataSource = projectTimeJobClassTypeList.Table;
                    ddlJobClassType.DataValueField = "JobClassType";
                    ddlJobClassType.DataTextField = "JobClassType";
                    ddlJobClassType.DataBind();
                }
                else
                {
                    ProjectTimeJobClassTypeList projectTimeJobClassTypeList = new ProjectTimeJobClassTypeList();
                    projectTimeJobClassTypeList.LoadAndAddItem(2, 3, "");
                    ddlJobClassType.DataSource = projectTimeJobClassTypeList.Table;
                    ddlJobClassType.DataValueField = "JobClassType";
                    ddlJobClassType.DataTextField = "JobClassType";
                    ddlJobClassType.DataBind();
                }

                ddlJobClassType.SelectedValue = employeeInformationBasicInformationGateway.GetJobClassType(employeeId);

                // Job costing factors
                decimal? bourdenFactor = employeeInformationBasicInformationGateway.GetBourdenFactor(employeeId);
                if (bourdenFactor.HasValue)
                {
                    tbxBourdenFactor.Text = decimal.Round((decimal)bourdenFactor, 1).ToString();
                }

                decimal? usHealthBenefitFactor = employeeInformationBasicInformationGateway.GetUSHealthBenefitFactor(employeeId);
                if (usHealthBenefitFactor.HasValue)
                {
                    tbxUSHealthBenefitFactor.Text = decimal.Round((decimal)usHealthBenefitFactor, 1).ToString();
                }

                decimal? benefitFactorCad = employeeInformationBasicInformationGateway.GetBenefitFactorCad(employeeId);
                if (benefitFactorCad.HasValue)
                {
                    tbxBenefitFactorCad.Text = decimal.Round((decimal)benefitFactorCad, 2).ToString();
                }

                decimal? benefitFactorUsd = employeeInformationBasicInformationGateway.GetBenefitFactorUsd(employeeId);
                if (benefitFactorUsd.HasValue)
                {
                    tbxBenefitFactorUsd.Text = decimal.Round((decimal)benefitFactorUsd, 2).ToString();
                }
            }
        }
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            EmployeeInformationTDS employeeInformationChanges = (EmployeeInformationTDS)Data.GetChanges();

            if (employeeInformationChanges.BasicInformation.Rows.Count > 0)
            {
                EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway(employeeInformationChanges);

                // Update employee
                foreach (EmployeeInformationTDS.BasicInformationRow basicInformationRow in (EmployeeInformationTDS.BasicInformationDataTable)employeeInformationChanges.BasicInformation)
                {
                    // Unchanged values
                    int employeeId = basicInformationRow.EmployeeID;
                    int? loginId = null; if(!basicInformationRow.IsLoginIDNull()) loginId =  basicInformationRow.LoginID;
                    int? contactsId = null; if (!basicInformationRow.IsContactsIDNull()) contactsId = basicInformationRow.ContactsID;
                    string middleInitial = ""; if (!basicInformationRow.IsMiddleInitialNull()) middleInitial = basicInformationRow.MiddleInitial;
                    bool deleted = basicInformationRow.Deleted;
                    decimal? bourdenFactor = null; if (!basicInformationRow.IsBourdenFactorNull()) bourdenFactor = (decimal)basicInformationRow.BourdenFactor;
                    decimal? usHealthBenefitFactor = null; if (!basicInformationRow.IsUSHealthBenefitFactorNull()) usHealthBenefitFactor = (decimal)basicInformationRow.USHealthBenefitFactor;
                    decimal? benefitFactorCad = null; if (!basicInformationRow.IsBenefitFactorCadNull()) benefitFactorCad = (decimal)basicInformationRow.BenefitFactorCad;
                    decimal? benefitFactorUsd = null; if (!basicInformationRow.IsBenefitFactorUsdNull()) benefitFactorUsd = (decimal)basicInformationRow.BenefitFactorUsd;

                    // Original values
                    string originalFirstName = employeeInformationBasicInformationGateway.GetFirstNameOriginal(employeeId);
                    string originalLastName = employeeInformationBasicInformationGateway.GetLastNameOriginal(employeeId);
                    string originalFullName = originalFirstName +  ' ' + originalLastName;
                    string originalType = employeeInformationBasicInformationGateway.GetTypeOriginal(employeeId);
                    string originalState = employeeInformationBasicInformationGateway.GetStateOriginal(employeeId);
                    bool originalIsSalessman = employeeInformationBasicInformationGateway.GetIsSalesmanOriginal(employeeId);
                    bool originalRequestProjectTime = employeeInformationBasicInformationGateway.GetRequestProjectTimeOriginal(employeeId);
                    bool originalSalaried = employeeInformationBasicInformationGateway.GetSalariedOriginal(employeeId);
                    string originalEMail = employeeInformationBasicInformationGateway.GeteMailOriginal(employeeId);
                    bool originalAssignableSrs = employeeInformationBasicInformationGateway.GetAssignableSRSOriginal(employeeId);
                    string originalJobClassType = employeeInformationBasicInformationGateway.GetJobClassTypeOriginal(employeeId);
                    string originalCategory = employeeInformationBasicInformationGateway.GetCategoryOriginal(employeeId);
                    string originalPersonalAgencyName = employeeInformationBasicInformationGateway.GetPersonalAgencyNameOriginal(employeeId);
                    bool originalIsVacationsManager = employeeInformationBasicInformationGateway.GetIsVacationsManagerOriginal(employeeId);
                    bool originalApproveTimesheets = employeeInformationBasicInformationGateway.GetApproveTimesheetsOriginal(employeeId);
                    string originalCrew = employeeInformationBasicInformationGateway.GetCrewOriginal(employeeId);

                    // New variables
                    string newFirstName = employeeInformationBasicInformationGateway.GetFirstName(employeeId);
                    string newLastName = employeeInformationBasicInformationGateway.GetLastName(employeeId);
                    string newFullName = newFirstName + ' ' + newLastName;
                    string newType = employeeInformationBasicInformationGateway.GetType(employeeId);
                    string newState = employeeInformationBasicInformationGateway.GetState(employeeId);
                    bool newIsSalessman = employeeInformationBasicInformationGateway.GetIsSalesman(employeeId);
                    bool newRequestProjectTime = employeeInformationBasicInformationGateway.GetRequestProjectTime(employeeId);
                    bool newSalaried = employeeInformationBasicInformationGateway.GetSalaried(employeeId);
                    string newEMail = employeeInformationBasicInformationGateway.GeteMail(employeeId);
                    bool newAssignableSrs = employeeInformationBasicInformationGateway.GetAssignableSRS(employeeId);
                    string newJobClassType = employeeInformationBasicInformationGateway.GetJobClassType(employeeId);
                    string newCategory = employeeInformationBasicInformationGateway.GetCategory(employeeId);
                    string newPersonalAgencyName = employeeInformationBasicInformationGateway.GetPersonalAgencyName(employeeId);
                    bool newIsVacationsManager = employeeInformationBasicInformationGateway.GetIsVacationsManager(employeeId);
                    bool newApproveTimesheets = employeeInformationBasicInformationGateway.GetApproveTimesheets(employeeId);
                    string newCrew = employeeInformationBasicInformationGateway.GetCrew(employeeId);

                    // ... Update
                    Employee employee = new Employee(null);
                    employee.UpdateDirect(employeeId, loginId, contactsId, originalFullName, originalFirstName, middleInitial, originalLastName, originalType, originalState, originalIsSalessman, originalRequestProjectTime, deleted, originalSalaried, originalEMail, originalAssignableSrs, originalJobClassType, originalCategory, originalPersonalAgencyName, originalIsVacationsManager, originalApproveTimesheets, bourdenFactor, usHealthBenefitFactor, benefitFactorCad, benefitFactorUsd, originalCrew, newFullName, newFirstName, middleInitial, newLastName, newType, newState, newIsSalessman, newRequestProjectTime, deleted, newSalaried, newEMail, newAssignableSrs, newJobClassType, newCategory, newPersonalAgencyName, newIsVacationsManager, newApproveTimesheets,  bourdenFactor, usHealthBenefitFactor, benefitFactorCad, benefitFactorUsd, newCrew);
                }
            }
        }
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// LoadByEmployeeId
 /// </summary>
 /// <param name="employeeId">employeeId</param>              
 /// <param name="companyId">companyId</param>
 public void LoadByEmployeeId(int employeeId, int companyId)
 {
     EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway(Data);
     employeeInformationBasicInformationGateway.LoadByEmployeeId(employeeId);
 }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_VIEW"])))
                {
                    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_all.aspx");
                }

                // Tag page
                int companyId = Int32.Parse(Session["companyID"].ToString());
                hdfCompanyId.Value = companyId.ToString();

                // ... 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";
                }

                // 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();

                //... date_to_show
                if ((string)Request.QueryString["date_to_show"] == null)
                {
                    ViewState["date_to_show"] = DateTime.Now.ToString();
                }
                else
                {
                    ViewState["date_to_show"] = (string)Request.QueryString["date_to_show"];
                }

                // Load vacations
                vacationsInformationTDS = new VacationsInformationTDS();
                vacationsInformation = new VacationsInformationTDS.VacationsInformationDataTable();

                VacationsInformationGateway vacationsInformationGateway = new VacationsInformationGateway(vacationsInformationTDS);

                if (hdfIsVacationManager.Value == "False")
                {
                    EmployeeGateway employeeGateway1 = new EmployeeGateway();
                    ViewState["employee_id"] = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));

                    EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway();
                    employeeInformationBasicInformationGateway.LoadByEmployeeId(Int32.Parse(ViewState["employee_id"].ToString()));

                    string employeeType = employeeInformationBasicInformationGateway.GetType(Int32.Parse(ViewState["employee_id"].ToString()));

                    if (employeeType.Contains("CA"))
                    {
                        ddlWorkingLocation.SelectedValue = "CA";

                    }
                    else
                    {
                        ddlWorkingLocation.SelectedValue = "US";
                    }

                    vacationsInformationGateway.LoadByEmployeeIdEmployeeType(Int32.Parse(ViewState["employee_id"].ToString()), employeeType, companyId);
                }
                else
                {
                    if ((string)Request.QueryString["employee_id"] == null)
                    {
                        ViewState["employee_id"] = "-1";

                        if (employeeTypeNow.Contains("CA"))
                        {
                            ddlWorkingLocation.SelectedValue = "CA";
                        }
                        else
                        {
                            ddlWorkingLocation.SelectedValue = "US";
                        }

                        vacationsInformationGateway.LoadByEmployeeType(employeeTypeNow, companyId);
                    }
                    else
                    {
                        ViewState["employee_id"] = (string)Request.QueryString["employee_id"];

                        EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway();
                        employeeInformationBasicInformationGateway.LoadByEmployeeId(Int32.Parse(ViewState["employee_id"].ToString()));

                        string employeeType = employeeInformationBasicInformationGateway.GetType(Int32.Parse(ViewState["employee_id"].ToString()));

                        if (employeeTypeNow.Contains("CA"))
                        {
                            ddlWorkingLocation.SelectedValue = "CA";
                        }
                        else
                        {
                            ddlWorkingLocation.SelectedValue = "US";
                        }

                        vacationsInformationGateway.LoadByEmployeeIdEmployeeType(Int32.Parse(ViewState["employee_id"].ToString()), employeeType, companyId);

                        ddlVacationsFor.SelectedValue = ViewState["employee_id"].ToString();
                    }
                }

                Session["vacationsInformationTDS"] = vacationsInformationTDS;
                Session["vacationsInformation"] = vacationsInformationTDS.VacationsInformation;

                tkrsVacations.SelectedDate = DateTime.Parse(ViewState["date_to_show"].ToString());
                lblTitle.Text = "Vacations Calendar for " + tkrsVacations.SelectedDate.ToString("MMMM") + " " + tkrsVacations.SelectedDate.Year.ToString();

                // Databind
                Page.DataBind();

                // For Open Vacation event
                if ((Request.Params["__EVENTTARGET"]) == "openVacation")
                {
                    int vacationId = Int32.Parse(Request.Params.Get("__EVENTARGUMENT").ToString()) ;
                    VacationsInformationDaysInformationGateway vacationsInformationDaysInformationGateway = new VacationsInformationDaysInformationGateway();
                    vacationsInformationDaysInformationGateway.LoadByVacationId(vacationId, companyId);
                    int requestId = vacationsInformationDaysInformationGateway.GetRequestID(vacationId);

                    Session["ddlVacationsForSelectedValue"] = ddlVacationsFor.SelectedValue;

                    Response.Redirect("./vacations_summary.aspx?source_page=vacations_all.aspx&vacation_id=" + vacationId.ToString() + "&request_id=" + requestId.ToString() + "&date_to_show=" + ViewState["date_to_show"]);
                }
            }
            else
            {
                vacationsInformationTDS = (VacationsInformationTDS)Session["vacationsInformationTDS"];
                vacationsInformation = (VacationsInformationTDS.VacationsInformationDataTable)Session["vacationsInformation"];

                // For Open Vacation event
                if ((Request.Params["__EVENTTARGET"]) == "openVacation")
                {
                    int vacationId = Int32.Parse(Request.Params.Get("__EVENTARGUMENT").ToString());
                    VacationsInformationDaysInformationGateway vacationsInformationDaysInformationGateway = new VacationsInformationDaysInformationGateway();
                    vacationsInformationDaysInformationGateway.LoadByVacationId(vacationId, Int32.Parse(hdfCompanyId.Value));
                    int requestId = vacationsInformationDaysInformationGateway.GetRequestID(vacationId);

                    DropDownList ddlVacationsFor = (DropDownList)tkrpbLeftMenuAllVacations.FindItemByValue("nbVacationsForDDL").FindControl("ddlVacationsFor");
                    Session["ddlVacationsForSelectedValue"] = ddlVacationsFor.SelectedValue;

                    Response.Redirect("./vacations_summary.aspx?source_page=vacations_all.aspx&vacation_id=" + vacationId.ToString() + "&request_id=" + requestId.ToString() + "&date_to_show=" + ViewState["date_to_show"]);
                }
            }
        }
        protected void grdProjectTime_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                // For Start Time
                if (!string.IsNullOrEmpty(hdfStartTime.Value))
                {
                    string startTime = DateTime.Parse(hdfStartTime.Value).ToString("H:mm");
                    if (startTime != "")
                    {
                        string[] hoursMin1 = startTime.Split(':');
                        ((DropDownList)e.Row.FindControl("ddlStartTimeHourFooter")).SelectedValue = hoursMin1[0].Trim();
                        ((DropDownList)e.Row.FindControl("ddlStartTimeMinuteFooter")).SelectedValue = hoursMin1[1].Trim();
                    }
                }

                // For End Time
                if (!string.IsNullOrEmpty(hdfEndTime.Value))
                {
                    string endTime = DateTime.Parse(hdfEndTime.Value).ToString("H:mm");
                    if (endTime != "")
                    {
                        string[] endHoursMin1 = endTime.Split(':');
                        ((DropDownList)e.Row.FindControl("ddlEndTimeHourFooter")).SelectedValue = endHoursMin1[0].Trim();
                        ((DropDownList)e.Row.FindControl("ddlEndTimeMinuteFooter")).SelectedValue = endHoursMin1[1].Trim();
                    }
                }

                // For Lunch
                string lunch = hdfOffset.Value;
                if (lunch != "")
                {
                    ((DropDownList)e.Row.FindControl("ddlLunchFooter")).SelectedValue = lunch;
                }

                // For Type Of Work
                string workFunctionConcat = hdfWorkFunctionConcat.Value;
                ((DropDownList)e.Row.FindControl("ddlTypeOfWorkFooter")).SelectedValue = workFunctionConcat;

                // For Meals Allowance
                //string isMealsAllowance = hdfIsMealsAllowance.Value;
                //((CheckBox)e.Row.FindControl("ckbxMealsAllowanceFooter")).Checked = Boolean.Parse(isMealsAllowance);

                // For Job Class
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(Int32.Parse(ddlProject.SelectedValue));

                if (projectGateway.GetFairWageApplies(int.Parse(ddlProject.SelectedValue)))
                {
                    int employeeId = Int32.Parse(((DropDownList)e.Row.FindControl("ddlEmployeesFooter")).SelectedValue);

                    EmployeeInformationBasicInformationGateway employeeInformationBasicInformation = new EmployeeInformationBasicInformationGateway();
                    employeeInformationBasicInformation.LoadByEmployeeId(employeeId);
                    string jobClassType = employeeInformationBasicInformation.GetJobClassType(employeeId);

                    if (jobClassType != "")
                    {
                        ((DropDownList)e.Row.FindControl("ddlJobClassTypeFooter")).SelectedValue = jobClassType;
                    }
                }
            }

            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                int teamProjectTimeId = Int32.Parse(((Label)e.Row.FindControl("lblTeamProjectTimeIdEdit")).Text.Trim());
                int detailId = Int32.Parse(((Label)e.Row.FindControl("lblDetailIdEdit")).Text.Trim());
                TeamProjectTime2DetailGateway teamProjectTime2DetailGateway = new TeamProjectTime2DetailGateway(teamProjectTime2TDS);

                // For employee
                int employeeId = 0; if (teamProjectTime2DetailGateway.GetEmployeeId(teamProjectTimeId, detailId) != -1) employeeId = teamProjectTime2DetailGateway.GetEmployeeId(teamProjectTimeId, detailId);
                if (employeeId != -1)
                {
                    ((DropDownList)e.Row.FindControl("ddlEmployeesEdit")).SelectedValue = employeeId.ToString();
                }

                // For Start Time
                string startTime = ""; if (teamProjectTime2DetailGateway.GetStartTime(teamProjectTimeId, detailId) != "") startTime = DateTime.Parse(teamProjectTime2DetailGateway.GetStartTime(teamProjectTimeId, detailId)).ToString("H:mm"); ;
                if (startTime != "")
                {
                    string[] hoursMin1 = startTime.Split(':');
                    ((DropDownList)e.Row.FindControl("ddlStartTimeHourEdit")).SelectedValue = hoursMin1[0].Trim();
                    ((DropDownList)e.Row.FindControl("ddlStartTimeMinuteEdit")).SelectedValue = hoursMin1[1].Trim();
                }

                // For End Time
                string endTime = ""; if (teamProjectTime2DetailGateway.GetEndTime(teamProjectTimeId, detailId) != "") endTime = DateTime.Parse(teamProjectTime2DetailGateway.GetEndTime(teamProjectTimeId, detailId)).ToString("H:mm");;
                if (endTime != "")
                {
                    string[] endHoursMin1 = endTime.Split(':');
                    ((DropDownList)e.Row.FindControl("ddlEndTimeHourEdit")).SelectedValue = endHoursMin1[0].Trim();
                    ((DropDownList)e.Row.FindControl("ddlEndTimeMinuteEdit")).SelectedValue = endHoursMin1[1].Trim();
                }

                // For Type Of Work
                string work_ = teamProjectTime2DetailGateway.GetWork(teamProjectTimeId, detailId);
                string function_ = teamProjectTime2DetailGateway.GetFunction(teamProjectTimeId, detailId);
                ((DropDownList)e.Row.FindControl("ddlTypeOfWorkFunctionEdit")).SelectedValue = work_ + " . " + function_;

                string jobClass = teamProjectTime2DetailGateway.GetJobClassType(teamProjectTimeId, detailId);
                ((DropDownList)e.Row.FindControl("ddlJobClassTypeEdit")).SelectedValue = jobClass;

                // For Unit
                int? unitId = null; if (teamProjectTime2DetailGateway.GetUnitId(teamProjectTimeId, detailId).HasValue) unitId = (int)teamProjectTime2DetailGateway.GetUnitId(teamProjectTimeId, detailId);
                if (unitId.HasValue)
                {
                    ((DropDownList)e.Row.FindControl("ddlUnitEdit")).SelectedValue = ((int)unitId).ToString();
                }

                // For Towed
                int? towedId = null; if (teamProjectTime2DetailGateway.GetTowedUnitId(teamProjectTimeId, detailId).HasValue) towedId = (int)teamProjectTime2DetailGateway.GetTowedUnitId(teamProjectTimeId, detailId);
                if (towedId.HasValue)
                {
                    ((DropDownList)e.Row.FindControl("ddlTowedEdit")).SelectedValue = ((int)towedId).ToString();
                }
            }

            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate))))
            {
                int teamProjectTimeId = Int32.Parse(((Label)e.Row.FindControl("lblTeamProjectTimeId")).Text.Trim());
                int detailId = Int32.Parse(((Label)e.Row.FindControl("lblDetailId")).Text.Trim());
                TeamProjectTime2DetailGateway teamProjectTime2DetailGateway = new TeamProjectTime2DetailGateway(teamProjectTime2TDS);

                // For Start Time
                string startTime = "";
                try
                {
                    if (teamProjectTime2DetailGateway.GetStartTime(teamProjectTimeId, detailId) != "") startTime = DateTime.Parse(teamProjectTime2DetailGateway.GetStartTime(teamProjectTimeId, detailId)).ToString("H:mm"); ;
                }
                catch
                {
                }
                if (startTime != "")
                {
                    ((TextBox)e.Row.FindControl("tbxStartTime")).Text = startTime;
                }

                // For End Time
                string endTime = "";
                try
                {
                    if (teamProjectTime2DetailGateway.GetEndTime(teamProjectTimeId, detailId) != "") endTime = DateTime.Parse(teamProjectTime2DetailGateway.GetEndTime(teamProjectTimeId, detailId)).ToString("H:mm"); ;
                }
                catch
                {
                }
                if (endTime != "")
                {
                    ((TextBox)e.Row.FindControl("tbxEndTime")).Text = endTime;
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // STEP4 - EMPLOYEES - AUXILIAR EVENTS
        //
        protected void ddlEmployeesFooter_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProjectGateway projectGateway = new ProjectGateway();
            projectGateway.LoadByProjectId(Int32.Parse(ddlProject.SelectedValue));

            DropDownList ddlEmployee = (DropDownList)sender;
            int employeeId = Int32.Parse(ddlEmployee.SelectedValue);

            if (projectGateway.GetFairWageApplies(int.Parse(ddlProject.SelectedValue)))
            {
                EmployeeInformationBasicInformationGateway employeeInformationBasicInformation = new EmployeeInformationBasicInformationGateway();
                employeeInformationBasicInformation.LoadByEmployeeId(employeeId);
                string jobClassType = employeeInformationBasicInformation.GetJobClassType(employeeId);

                if (jobClassType != "")
                {
                    ((DropDownList)grdProjectTime.FooterRow.FindControl("ddlJobClassTypeFooter")).SelectedValue = jobClassType;
                }
            }
        }