// ////////////////////////////////////////////////////////////////////////
        // STEP3 - DATA - METHODS
        //
        private void StepDataIn()
        {
            // Set instruction
            mWizard2 master = (mWizard2)this.Master;
            master.WizardInstruction = "Please define global data, it will be applied to your team members on the next step.";

            // Wizard type & step from check
            if ((hdfNewOrTemplate.Value == "New") && ((string)ViewState["StepFrom"] != "Employees"))
            {
                // Prepare initial data
                ddlClient.Enabled = true;
                ddlProject.Enabled = true;

                ProjectTimeWorkList projectTimeWorkList = new ProjectTimeWorkList(new DataSet());
                projectTimeWorkList.LoadAndAddItem("(Select a Type)");
                ddlTypeOfWork.DataSource = projectTimeWorkList.Table;
                ddlTypeOfWork.DataValueField = "Work_";
                ddlTypeOfWork.DataTextField = "Work_";
                ddlTypeOfWork.DataBind();
                ddlTypeOfWork.SelectedIndex = 0;

                ProjectTimeWorkFunctionList projectTimeWorkFunctionList = new ProjectTimeWorkFunctionList(new DataSet());
                projectTimeWorkFunctionList.LoadActiveForAddAndAddItem("(Select a Function)", "-1");
                ddlFunction.DataSource = projectTimeWorkFunctionList.Table;
                ddlFunction.DataValueField = "Function_";
                ddlFunction.DataTextField = "Function_";
                ddlFunction.DataBind();
                ddlFunction.SelectedIndex = 0;
            }
            else
            {
                TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(teamProjectTime2TDS);
                TeamProjectTime2DetailTemp teamProjectTime2DetailTemp = new TeamProjectTime2DetailTemp(teamProjectTime2TDS);

                // Prepare initial data
                if ((string)ViewState["StepFrom"] == "Template")
                {
                    ViewState["teamProjectTimeId"] = Int32.Parse(hdfSelectedIdTemplate.Value);

                    // ... for TeamProjectTime
                    teamProjectTime2Gateway.LoadByTeamProjectTimeId((int)ViewState["teamProjectTimeId"]);

                    // ... for TeamProjectTimeDetailTemp
                    teamProjectTime2DetailTemp.LoadAllByTeamProjectTimeId((int)ViewState["teamProjectTimeId"]);
                }

                // ... for Client
                string companiesId = teamProjectTime2Gateway.GetCompaniesId((int)ViewState["teamProjectTimeId"]).ToString();

                int companyId = Int32.Parse(hdfCompanyId.Value);
                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadAllByCompaniesId(Int32.Parse(companiesId), companyId);

                // ... If Company is active
                bool deleted = companiesGateway.GetDeleted(Int32.Parse(companiesId));

                if (deleted)
                {
                    ddlClient.SelectedIndex = -1;
                }
                else
                {
                    ddlClient.SelectedValue = companiesId;
                }

                if (ddlClient.SelectedValue.Length == 0)
                {
                    odsClient.DataBind();
                    ddlClient.DataSourceID = "odsClient";
                    ddlClient.DataValueField = "COMPANIES_ID";
                    ddlClient.DataTextField = "Name";
                    ddlClient.DataBind();

                    if (deleted)
                    {
                        ddlClient.SelectedIndex = -1;
                    }
                    else
                    {
                        ddlClient.SelectedValue = companiesId;
                    }
                }

                if (!deleted)
                {
                    // ... for project
                    odsProjectsInternalProjectsBallparkProjects.SelectParameters.RemoveAt(2);
                    odsProjectsInternalProjectsBallparkProjects.SelectParameters.Add("ClientId", ddlClient.SelectedValue);
                    odsProjectsInternalProjectsBallparkProjects.Select();
                    odsProjectsInternalProjectsBallparkProjects.DataBind();

                    ddlProject.DataSourceID = "odsProjectsInternalProjectsBallparkProjects";
                    ddlProject.DataValueField = "ProjectID";
                    ddlProject.DataTextField = "NAME";
                    ddlProject.DataBind();

                    try
                    {
                        ddlProject.SelectedValue = teamProjectTime2Gateway.GetProjectId((int)ViewState["teamProjectTimeId"]).ToString();
                    }
                    catch
                    {
                        ddlProject.SelectedIndex = -1;
                    }
                }
                else
                {
                    ddlProject.SelectedIndex = -1;
                }

                // ... for Date
                if ((string)ViewState["StepFrom"] == "Employees")
                {
                    tkrdpDate_.SelectedDate = teamProjectTime2Gateway.GetDate_((int)ViewState["teamProjectTimeId"]);
                }

                // ... for Type of work
                ProjectTimeWorkList projectTimeWorkList = new ProjectTimeWorkList(new DataSet());
                projectTimeWorkList.LoadAndAddItem("(Select a Type)");
                ddlTypeOfWork.DataSource = projectTimeWorkList.Table;
                ddlTypeOfWork.DataValueField = "Work_";
                ddlTypeOfWork.DataTextField = "Work_";
                ddlTypeOfWork.DataBind();

                if (teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"]).ToString() == "")
                {
                    ddlTypeOfWork.SelectedValue = "(Select a Type)";
                }
                else
                {
                    ddlTypeOfWork.SelectedValue = (string)teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"]);
                }

                // ... for function
                ProjectTimeWorkFunctionList projectTimeWorkFunctionList = new ProjectTimeWorkFunctionList(new DataSet());
                if (teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"]).ToString() == "")
                {
                    // ... If there is no type of Work, no function should be loaded
                    projectTimeWorkFunctionList.LoadActiveForAddAndAddItem("(Select a Function)", "-1");
                }
                else
                {
                    projectTimeWorkFunctionList.LoadActiveForAddAndAddItem("(Select a Function)", teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"]));
                }

                ddlFunction.DataSource = projectTimeWorkFunctionList.Table;
                ddlFunction.DataValueField = "Function_";
                ddlFunction.DataTextField = "Function_";
                ddlFunction.DataBind();

                if (teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"]).ToString() == "")
                {
                    ddlFunction.SelectedValue = "(Select a Function)";
                }
                else
                {
                    ddlFunction.SelectedValue = (string)teamProjectTime2Gateway.GetFunction((int)ViewState["teamProjectTimeId"]);
                }

                // ... for working details
                if (!deleted)
                {
                    tbxWorkingDetails.Text = teamProjectTime2Gateway.GetWorkingDetails((int)ViewState["teamProjectTimeId"]);
                }
                else
                {
                    tbxWorkingDetails.Text = "";
                }

                // ... for start time
                if (teamProjectTime2Gateway.GetStartTime((int)ViewState["teamProjectTimeId"]).HasValue)
                {
                    string startTime = ((DateTime)teamProjectTime2Gateway.GetStartTime((int)ViewState["teamProjectTimeId"])).ToString("H:mm");
                    string[] hoursMin1 = startTime.Split(':');
                    ddlStartTimeHour.SelectedValue = hoursMin1[0].Trim();
                    ddlStartTimeMinute.SelectedValue = hoursMin1[1].Trim();
                }

                // ... for end time
                if (teamProjectTime2Gateway.GetEndTime((int)ViewState["teamProjectTimeId"]).HasValue)
                {
                    string endTime = ((DateTime)teamProjectTime2Gateway.GetEndTime((int)ViewState["teamProjectTimeId"])).ToString("H:mm");
                    string[] endHoursMin1 = endTime.Split(':');
                    ddlEndTimeHour.SelectedValue = endHoursMin1[0].Trim();
                    ddlEndTimeMinute.SelectedValue = endHoursMin1[1].Trim();
                }

                // ... for offset
                if (teamProjectTime2Gateway.GetOffset((int)ViewState["teamProjectTimeId"]).HasValue) ddlLunch.SelectedValue = Math.Round(teamProjectTime2Gateway.GetOffset((int)ViewState["teamProjectTimeId"]).Value, 2).ToString();

                // ... for meals country
                if (!deleted)
                {
                    if (teamProjectTime2Gateway.GetMealsCountry((int)ViewState["teamProjectTimeId"]).HasValue)
                    {
                        ddlMealsCountry.SelectedValue = teamProjectTime2Gateway.GetMealsCountry((int)ViewState["teamProjectTimeId"]).Value.ToString();
                    }
                    else
                    {
                        ddlMealsCountry.SelectedIndex = 0;
                    }
                }
                else
                {
                    ddlMealsCountry.SelectedIndex = -1;
                }

                // ... for meals allowance
                //if (teamProjectTime2Gateway.GetMealsAllowance((int)ViewState["teamProjectTimeId"]) > 0) cbxMealsAllowance.Checked = true;

                // ... for fair wage
                if (teamProjectTime2Gateway.GetFairWage((int)ViewState["teamProjectTimeId"])) hdfFairWage.Value = "True";

                // Store datasets
                Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
                template = teamProjectTime2TDS.Template;
                Session["template"] = teamProjectTime2TDS.Template;
            }

            //cbxClearUnitAssigment.Checked = false;
        }
        protected void ddlTypeOfWork_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProjectTimeWorkFunctionList projectTimeWorkFunctionList = new ProjectTimeWorkFunctionList();
            projectTimeWorkFunctionList.LoadActiveForAddAndAddItem("(Select a Function)", ddlTypeOfWork.SelectedValue);
            ddlFunction.DataSource = projectTimeWorkFunctionList.Table;
            ddlFunction.DataValueField = "Function_";
            ddlFunction.DataTextField = "Function_";
            ddlFunction.DataBind();
            ddlFunction.SelectedIndex = 0;

            rfvFunction.Validate();
        }