// ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Store navigator state
                StoreNavigatorState();

                hdfUpdate.Value = "yes";
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();

                tbxDescription.Text = Server.UrlDecode(Request.QueryString["subject"].ToString());
                ViewState["refId"] = Request.QueryString["refId"].ToString();
                ViewState["projectId"] = Request.QueryString["project_id"].ToString();
                ViewState["libraryCategoriesId"] = Request.QueryString["library_categories_id"].ToString();

                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"];
                projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"];

                if (Session["lfsLibraryTDS"] != null)
                {
                    libraryTDS = (LibraryTDS)Session["lfsLibraryTDS"];
                }
                else
                {
                    libraryTDS = new LibraryTDS();
                }

                Session["lfsProjectTDS"] = projectTDS;
            }
            else
            {
                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"];
                projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"];

                if (Session["lfsLibraryTDS"] != null)
                {
                    libraryTDS = (LibraryTDS)Session["lfsLibraryTDS"];
                }
                else
                {
                    libraryTDS = new LibraryTDS();
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                hdfUpdate.Value = "yes";
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();

                tbxDescription.Text = Server.UrlDecode(Request.QueryString["subject"].ToString());
                ViewState["refId"] = Request.QueryString["refId"].ToString();
                ViewState["unitId"] = Request.QueryString["unit_id"].ToString();
                ViewState["libraryCategoriesId"] = Request.QueryString["library_categories_id"].ToString();

                unitInformationTDS = (UnitInformationTDS)Session["unitInformationTDS"];

                if (Session["libraryTDSForUnits"] != null)
                {
                    libraryTDSForUnits = (LibraryTDS)Session["libraryTDSForUnits"];
                }
                else
                {
                    libraryTDSForUnits = new LibraryTDS();
                }
            }
            else
            {
                unitInformationTDS = (UnitInformationTDS)Session["unitInformationTDS"];

                if (Session["libraryTDSForUnits"] != null)
                {
                    libraryTDSForUnits = (LibraryTDS)Session["libraryTDSForUnits"];
                }
                else
                {
                    libraryTDSForUnits = new LibraryTDS();
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                hdfUpdate.Value = "no";

                libraryTDSForServicesManagerTool = new LibraryTDS();
                serviceRequestsManagerToolTDS = (ServiceRequestsManagerToolTDS)Session["serviceRequestsManagerToolTDS"];

                Session["libraryTDSForServicesManagerTool"] = libraryTDSForServicesManagerTool;

                ViewState["serviceId"] = int.Parse(Request.QueryString["service_id"].ToString());
            }
            else
            {
                libraryTDSForServicesManagerTool = (LibraryTDS)Session["libraryTDSForServicesManagerTool"];
                serviceRequestsManagerToolTDS = (ServiceRequestsManagerToolTDS)Session["serviceRequestsManagerToolTDS"];
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                hdfUpdate.Value = "no";

                libraryTDSForUnits = new LibraryTDS();
                unitInformationTDS = (UnitInformationTDS)Session["unitInformationTDS"];

                Session["libraryTDSForUnits"] = libraryTDSForUnits;

                ViewState["unitId"] = int.Parse(Request.QueryString["unit_id"].ToString());
            }
            else
            {
                libraryTDSForUnits = (LibraryTDS)Session["libraryTDSForUnits"];
                unitInformationTDS = (UnitInformationTDS)Session["unitInformationTDS"];
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_UNITS_VIEW"]) && (Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_UNITS_EDIT"]) || Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_UNITS_COMMENTS"]))))
                {
                    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["unit_id"] == null) || ((string)Request.QueryString["unit_type"] == null) || ((string)Request.QueryString["unit_state"] == null) || ((string)Request.QueryString["active_tab"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in units_edit.aspx");
                }

                // Tag Page
                hdfUnitId.Value = Request.QueryString["unit_id"].ToString();
                hdfUnitType.Value = Request.QueryString["unit_type"].ToString();
                hdfUnitState.Value = Request.QueryString["unit_state"].ToString();
                hdfActiveTab.Value = Request.QueryString["active_tab"].ToString();
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();

                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int unitId = Int32.Parse(hdfUnitId.Value.Trim());

                aceManufacturer.ContextKey = hdfCompanyId.Value;

                // ... For Owner country
                CountryList countryList = new CountryList();
                countryList.LoadAndAddItem(-1, "(Select a country)");
                ddlOwnerCountry.DataSource = countryList.Table;
                ddlOwnerCountry.DataValueField = "CountryID";
                ddlOwnerCountry.DataTextField = "Name";
                ddlOwnerCountry.DataBind();

                // ... For License country
                ddlLicenseCountry.DataSource = countryList.Table;
                ddlLicenseCountry.DataValueField = "CountryID";
                ddlLicenseCountry.DataTextField = "Name";
                ddlLicenseCountry.DataBind();

                Session.Remove("unitsChecklistRulesTempDummy");
                Session.Remove("unitsServicesTempDummy");
                Session.Remove("unitsInspectionsTempDummy");
                Session.Remove("unitsNotesTempDummy");
                Session.Remove("unitCostsDummy");
                Session.Remove("unitCostsExceptionsDummy");
                Session.Remove("costIdSelected");

                // ... units_navigator2.aspx
                if (Request.QueryString["source_page"] == "units_navigator2.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedUnits"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];

                        unitInformationTDS = new UnitInformationTDS();
                        unitsChecklistRulesTemp = new UnitInformationTDS.ChecklistDetailsDataTable();
                        unitsServicesTemp = new UnitInformationTDS.ServiceDetailsDataTable();
                        unitsInspectionsTemp = new UnitInformationTDS.InspectionDetailsDataTable();
                        unitsNotesTemp = new UnitInformationTDS.NoteInformationDataTable();

                        UnitInformationUnitDetails unitInformationUnitDetails = new UnitInformationUnitDetails(unitInformationTDS);
                        unitInformationUnitDetails.LoadByUnitId(unitId, companyId);

                        UnitInformationInspectionDetails unitInformationInspectionDetailsForEdit = new UnitInformationInspectionDetails(unitInformationTDS);
                        unitInformationInspectionDetailsForEdit.LoadByUnitId(unitId, companyId);

                        UnitInformationNoteDetails unitInformationNoteDetailsForEdit = new UnitInformationNoteDetails(unitInformationTDS);
                        unitInformationNoteDetailsForEdit.LoadByUnitId(unitId, companyId);

                        UnitInformationCostInformation unitInformationCostInformation = new UnitInformationCostInformation(unitInformationTDS);
                        unitInformationCostInformation.LoadAllByUnitId(unitId, companyId);

                        UnitInformationCostExceptionsInformation unitInformationCostExceptionsInformation = new UnitInformationCostExceptionsInformation(unitInformationTDS);
                        unitInformationCostExceptionsInformation.LoadAllByUnitId(unitId, companyId);

                        // ... For Categories
                        categoriesTDS = new CategoriesTDS();
                        Category category = new Category(categoriesTDS);
                        category.LoadByUnitType(hdfUnitType.Value, int.Parse(hdfCompanyId.Value));

                        // .. For Company Levels
                        companyLevelsTDS = new CompanyLevelsTDS();
                        CompanyLevel companyLevel = new CompanyLevel(companyLevelsTDS);
                        companyLevel.Load(int.Parse(hdfCompanyId.Value));
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabUnits"];

                        // Restore datasets
                        unitInformationTDS = (UnitInformationTDS)Session["unitInformationTDS"];
                        unitsChecklistRulesTemp = (UnitInformationTDS.ChecklistDetailsDataTable)Session["unitsChecklistRulesTemp"];
                        unitsServicesTemp = (UnitInformationTDS.ServiceDetailsDataTable)Session["unitsServicesTemp"];
                        unitsInspectionsTemp = (UnitInformationTDS.InspectionDetailsDataTable)Session["unitsInspectionsTemp"];
                        unitsNotesTemp = (UnitInformationTDS.NoteInformationDataTable)Session["unitsNotesTemp"];
                        categoriesTDS = (CategoriesTDS)Session["categoriesTDSForUnits"];
                        companyLevelsTDS = (CompanyLevelsTDS)Session["companyLevelsTDS"];
                    }

                    arrayCategoriesSelectedForEdit = new ArrayList();
                    arrayCompanyLevelsSelectedForEdit = new ArrayList();
                    Session["arrayCategoriesSelectedForEdit"] = arrayCategoriesSelectedForEdit;
                    Session["arrayCompanyLevelsSelectedForEdit"] = arrayCompanyLevelsSelectedForEdit;

                    // Store dataset
                    Session["unitInformationTDS"] = unitInformationTDS;
                    Session["unitsChecklistRulesTemp"] = unitsChecklistRulesTemp;
                    Session["unitsServicesTemp"] = unitsServicesTemp;
                    Session["unitsInspectionsTemp"] = unitsInspectionsTemp;
                    Session["unitsNotesTemp"] = unitsNotesTemp;
                    Session["categoriesTDSForUnits"] = categoriesTDS;
                    Session["companyLevelsTDS"] = companyLevelsTDS;
                }

                // ... units_summary.aspx or units_edit.aspx
                if ((Request.QueryString["source_page"] == "units_summary.aspx") || (Request.QueryString["source_page"] == "units_edit.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // Restore dataset
                    unitInformationTDS = (UnitInformationTDS)Session["unitInformationTDS"];
                    unitsChecklistRulesTemp = (UnitInformationTDS.ChecklistDetailsDataTable)Session["unitsChecklistRulesTemp"];
                    unitsServicesTemp = (UnitInformationTDS.ServiceDetailsDataTable)Session["unitsServicesTemp"];
                    unitsInspectionsTemp = (UnitInformationTDS.InspectionDetailsDataTable)Session["unitsInspectionsTemp"];
                    unitsNotesTemp = (UnitInformationTDS.NoteInformationDataTable)Session["unitsNotesTemp"];
                    categoriesTDS = (CategoriesTDS)Session["categoriesTDSForUnits"];
                    companyLevelsTDS = (CompanyLevelsTDS)Session["companyLevelsTDS"];

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedUnits"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];

                        if (ViewState["update"].ToString().Trim() == "yes")
                        {
                            UnitInformationUnitDetails unitInformationUnitDetails = new UnitInformationUnitDetails(unitInformationTDS);
                            unitInformationUnitDetails.LoadByUnitId(unitId, companyId);

                            UnitInformationInspectionDetails unitInformationInspectionDetailsForEdit = new UnitInformationInspectionDetails(unitInformationTDS);
                            unitInformationInspectionDetailsForEdit.LoadByUnitId(unitId, companyId);

                            UnitInformationNoteDetails unitInformationNoteDetailsForEdit = new UnitInformationNoteDetails(unitInformationTDS);
                            unitInformationNoteDetailsForEdit.LoadByUnitId(unitId, companyId);

                            UnitInformationCostInformation unitInformationCostInformation = new UnitInformationCostInformation(unitInformationTDS);
                            unitInformationCostInformation.LoadAllByUnitId(unitId, companyId);

                            UnitInformationCostExceptionsInformation unitInformationCostExceptionsInformation = new UnitInformationCostExceptionsInformation(unitInformationTDS);
                            unitInformationCostExceptionsInformation.LoadAllByUnitId(unitId, companyId);

                            // Store dataset
                            Session["unitInformationTDS"] = unitInformationTDS;
                        }
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabUnits"];
                    }

                    arrayCategoriesSelectedForEdit = new ArrayList();
                    arrayCompanyLevelsSelectedForEdit = new ArrayList();
                    Session["arrayCategoriesSelectedForEdit"] = arrayCategoriesSelectedForEdit;
                    Session["arrayCompanyLevelsSelectedForEdit"] = arrayCompanyLevelsSelectedForEdit;
                }

                // ... units_add.aspx
                if (Request.QueryString["source_page"] == "units_add.aspx")
                {
                    ViewState["update"] = "yes";

                    unitInformationTDS = new UnitInformationTDS();
                    unitsChecklistRulesTemp = new UnitInformationTDS.ChecklistDetailsDataTable();
                    unitsServicesTemp = new UnitInformationTDS.ServiceDetailsDataTable();
                    unitsInspectionsTemp = new UnitInformationTDS.InspectionDetailsDataTable();
                    unitsNotesTemp = new UnitInformationTDS.NoteInformationDataTable();

                    UnitInformationUnitDetails unitInformationUnitDetails = new UnitInformationUnitDetails(unitInformationTDS);
                    unitInformationUnitDetails.LoadByUnitId(unitId, companyId);

                    UnitInformationNoteDetails unitInformationNoteDetailsForEdit = new UnitInformationNoteDetails(unitInformationTDS);
                    unitInformationNoteDetailsForEdit.LoadByUnitId(unitId, companyId);

                    // ... For Categories
                    categoriesTDS = new CategoriesTDS();
                    Category category = new Category(categoriesTDS);
                    category.LoadByUnitType(hdfUnitType.Value, int.Parse(hdfCompanyId.Value));

                    // .. For Company Levels
                    companyLevelsTDS = new CompanyLevelsTDS();
                    CompanyLevel companyLevel = new CompanyLevel(companyLevelsTDS);
                    companyLevel.Load(int.Parse(hdfCompanyId.Value));

                    arrayCategoriesSelectedForEdit = new ArrayList();
                    arrayCompanyLevelsSelectedForEdit = new ArrayList();
                    Session["arrayCategoriesSelectedForEdit"] = arrayCategoriesSelectedForEdit;
                    Session["arrayCompanyLevelsSelectedForEdit"] = arrayCompanyLevelsSelectedForEdit;

                    // Store dataset
                    Session["unitInformationTDS"] = unitInformationTDS;
                    Session["unitsChecklistRulesTemp"] = unitsChecklistRulesTemp;
                    Session["unitsServicesTemp"] = unitsServicesTemp;
                    Session["unitsInspectionsTemp"] = unitsInspectionsTemp;
                    Session["unitsNotesTemp"] = unitsNotesTemp;
                    Session["categoriesTDSForUnits"] = categoriesTDS;
                    Session["companyLevelsTDS"] = companyLevelsTDS;
                }

                // ... For Library
                if (Session["libraryTDSForUnits"] != null)
                {
                    libraryTDSForUnits = (LibraryTDS)Session["libraryTDSForUnits"];
                }
                else
                {
                    libraryTDSForUnits = new LibraryTDS();
                }

                Session["costIdSelected"] = 0;
                grdCostsExceptions.ShowFooter = false;
                string filterOptions = string.Format("CostID = {0} AND Deleted = {1}", 0, 0);
                odsCostsExceptions.FilterExpression = filterOptions;

                // Set initial tab
                int activeTabUnits = Int32.Parse(hdfActiveTab.Value);
                tcDetailedInformation.ActiveTabIndex = activeTabUnits;

                // ... ... Make panels visible
                MakePanelsVisible();

                // ... ... Data for current unit
                LoadUnitData(companyId);
            }
            else
            {
                // Restore datasets
                unitInformationTDS = (UnitInformationTDS)Session["unitInformationTDS"];
                unitsChecklistRulesTemp = (UnitInformationTDS.ChecklistDetailsDataTable)Session["unitsChecklistRulesTemp"];
                unitsServicesTemp = (UnitInformationTDS.ServiceDetailsDataTable)Session["unitsServicesTemp"];
                unitsInspectionsTemp = (UnitInformationTDS.InspectionDetailsDataTable)Session["unitsInspectionsTemp"];
                unitsNotesTemp = (UnitInformationTDS.NoteInformationDataTable)Session["unitsNotesTemp"];
                categoriesTDS = (CategoriesTDS)Session["categoriesTDSForUnits"];
                companyLevelsTDS = (CompanyLevelsTDS)Session["companyLevelsTDS"];

                arrayCategoriesSelectedForEdit = (ArrayList)Session["arrayCategoriesSelectedForEdit"];
                arrayCompanyLevelsSelectedForEdit = (ArrayList)Session["arrayCompanyLevelsSelectedForEdit"];

                // Set initial tab
                int activeTabUnits = Int32.Parse(hdfActiveTab.Value);
                tcDetailedInformation.ActiveTabIndex = activeTabUnits;

                aceManufacturer.ContextKey = hdfCompanyId.Value;

                if (Session["libraryTDSForUnits"] != null)
                {
                    libraryTDSForUnits = (LibraryTDS)Session["libraryTDSForUnits"];
                }
                else
                {
                    libraryTDSForUnits = new LibraryTDS();
                }

                LoadNotes();
            }
        }
示例#6
0
 /// <summary>
 /// InitData
 /// </summary>
 protected override void InitData()
 {
     _data = new LibraryTDS();
 }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_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["project_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_edit.aspx");
                }

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfProjectId.Value = Request.QueryString["project_id"];
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();
                hdfDataChanged.Value = Request.QueryString["data_changed"];
                hdfDataChangedMessage.Value = "Changes made to this project will not be saved.";

                // Prepare initial data
                Session.Remove("projectNotesDummy");
                Session.Remove("projectServicesDummy");
                Session.Remove("projectTypeOfWorkFunctionClassificationDummy");
                Session.Remove("projectJobClassClassificationDummy");
                Session.Remove("projectBudgetDummy");
                Session.Remove("subcontractorsBudgetDummy");
                Session.Remove("hotelsBudgetDummy");
                Session.Remove("bondingsBudgetDummy");
                Session.Remove("insurancesBudgetDummy");
                Session.Remove("otherCostsBudgetDummy");

                Session["fairWage"] = "None";

                // ... Set initial tab
                if ((string)Session["dialogOpenedProjects"] != "1")
                {
                    hdfActiveTab.Value = Request.QueryString["active_tab"];
                }
                else
                {
                    hdfActiveTab.Value = (string)Session["activeTabProjects"];
                }

                // ... For Library
                if (Session["lfsLibraryTDS"] != null)
                {
                    libraryTDS = (LibraryTDS)Session["lfsLibraryTDS"];
                }
                else
                {
                    libraryTDS = new LibraryTDS();
                }

                // If coming from
                // ... projects2.aspx or project_add.aspx
                if (Request.QueryString["source_page"] == "projects2.aspx" || Request.QueryString["source_page"] == "project_add.aspx")
                {
                    // Store Navigator State, Update control and Origin
                    StoreNavigatorState();
                    ViewState["update"] = "no";
                    ViewState["origin"] = "navigator";

                    // Get Project Id
                    int projectId = int.Parse(hdfProjectId.Value);

                    // ... Attachment control
                    if (Session["fromAttachment"] != null)
                    {
                        if (Session["fromAttachment"].ToString() == "yes")
                        {
                            // Restore dataset
                            projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                            projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"];
                            projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"];
                            projectServices = (ProjectNavigatorTDS.ProjectServiceDataTable)Session["projectServices"];
                            projectJobClassClassification = (ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable)Session["projectJobClassClassification"];
                            projectTypeOfWorkFunctionClassification = (ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable)Session["projectTypeOfWorkFunctionClassification"];
                            projectBudget = (ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable)Session["projectBudget"];
                            unitsBudget = (ProjectNavigatorTDS.ProjectUnitsBudgetDataTable)Session["unitsBudget"];
                            materialsBudget = (ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable)Session["materialsBudget"];
                            subcontractorsBudget = (ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable)Session["subcontractorsBudget"];
                            hotelsBudget = (ProjectNavigatorTDS.ProjectHotelsBudgetDataTable)Session["hotelsBudget"];
                            bondingsBudget = (ProjectNavigatorTDS.ProjectBondingsBudgetDataTable)Session["bondingsBudget"];
                            insurancesBudget = (ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable)Session["insurancesBudget"];
                            otherCostsBudget = (ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable)Session["otherCostsBudget"];
                        }

                        Session.Remove("fromAttachment");
                    }
                    else
                    {
                        // Get dataset
                        projectTDS = new ProjectTDS();
                        projectNavigatorTDS = new ProjectNavigatorTDS();
                        projectNotes = new ProjectNavigatorTDS.ProjectNotesDataTable();
                        projectServices = new ProjectNavigatorTDS.ProjectServiceDataTable();
                        projectTypeOfWorkFunctionClassification = new ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable();
                        projectJobClassClassification = new ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable();
                        projectBudget = new ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable();
                        unitsBudget = new ProjectNavigatorTDS.ProjectUnitsBudgetDataTable();
                        materialsBudget = new ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable();
                        subcontractorsBudget = new ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable();
                        hotelsBudget = new ProjectNavigatorTDS.ProjectHotelsBudgetDataTable();
                        bondingsBudget = new ProjectNavigatorTDS.ProjectBondingsBudgetDataTable();
                        insurancesBudget = new ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable();
                        otherCostsBudget = new ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable();

                        // Get General Data
                        ProjectGateway projectGatewayForLoad = new ProjectGateway(projectTDS);
                        projectGatewayForLoad.LoadByProjectId(projectId);

                        // Get job info
                        ProjectJobInfoGateway projectJobInfoGateway = new ProjectJobInfoGateway(projectNavigatorTDS);
                        projectJobInfoGateway.LoadAllByProjectId(projectId);

                        // Get Sale/Billing/Pricing
                        ProjectSaleBillingPricingGateway projectSaleBillingPricingGatewayForLoad = new ProjectSaleBillingPricingGateway(projectTDS);
                        projectSaleBillingPricingGatewayForLoad.LoadAllByProjectId(projectId);

                        // ... Get Sale/Billing/Pricing - Services
                        ProjectNavigatorProjectService projectNavigatorProjectService = new ProjectNavigatorProjectService(projectNavigatorTDS);
                        projectNavigatorProjectService.LoadAllByProjectId(projectId);
                        projectNavigatorProjectService.UpdateForLoad();

                        // Get Costing Updates
                        ProjectCostingUpdatesGateway projectCostingUpdatesGatewayForLoad = new ProjectCostingUpdatesGateway(projectTDS);
                        projectCostingUpdatesGatewayForLoad.LoadByProjectId(projectId);

                        // Get Project Terms
                        ProjectTermsPOGateway projectTermsPOGatewayForLoad = new ProjectTermsPOGateway(projectTDS);
                        projectTermsPOGatewayForLoad.LoadByProjectId(projectId);

                        // Get Technical
                        ProjectTechnicalGateway projectTechnicalGatewayForLoad = new ProjectTechnicalGateway(projectTDS);
                        projectTechnicalGatewayForLoad.LoadByProjectId(projectId);

                        // Get Engineer Subcontractors
                        ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGatewayForLoad = new ProjectEngineerSubcontractorsGateway(projectTDS);
                        projectEngineerSubcontractorsGatewayForLoad.LoadAllByProjectId(projectId);

                        // ... Get Subcontractors
                        ProjectSubcontractorGateway projectSubcontractorGatewayForLoad = new ProjectSubcontractorGateway(projectTDS);
                        projectSubcontractorGatewayForLoad.LoadAllByProjectId(projectId);

                        // Cost Exceptions
                        // ... Get Type Of Work & Function Classification
                        ProjectNavigatorProjectWorkFunctionFairWage projectNavigatorProjectWorkFunctionFairWage = new ProjectNavigatorProjectWorkFunctionFairWage(projectNavigatorTDS);
                        projectNavigatorProjectWorkFunctionFairWage.LoadAllByProjectId(projectId);

                        // ... Get Job Class Classification
                        ProjectNavigatorProjectJobClassTypeRate projectNavigatorProjectJobClassTypeRate = new ProjectNavigatorProjectJobClassTypeRate(projectNavigatorTDS);
                        projectNavigatorProjectJobClassTypeRate.LoadAllByProjectId(projectId);

                        // Get Budget
                        ProjectNavigatorProjectWorkFunctionBudget projectNavigatorProjectWorkFunctionBudget = new ProjectNavigatorProjectWorkFunctionBudget(projectNavigatorTDS);
                        projectNavigatorProjectWorkFunctionBudget.LoadAllByProjectId(projectId);

                        // Get Units Budget
                        ProjectNavigatorProjectUnitsBudget projectNavigatorProjectUnitsBudget = new ProjectNavigatorProjectUnitsBudget(projectNavigatorTDS);
                        projectNavigatorProjectUnitsBudget.LoadAllByProjectId(projectId);

                        // Get Materials Budget
                        ProjectNavigatorProjectMaterialsBudget projectNavigatorProjectMaterialsBudget = new ProjectNavigatorProjectMaterialsBudget(projectNavigatorTDS);
                        projectNavigatorProjectMaterialsBudget.LoadAllByProjectId(projectId);

                        // Get Subcontractors Budget
                        ProjectNavigatorProjectSubcontractorsBudget projectNavigatorProjectSubcontractorsBudget = new ProjectNavigatorProjectSubcontractorsBudget(projectNavigatorTDS);
                        projectNavigatorProjectSubcontractorsBudget.LoadAllByProjectId(projectId);

                        // Get Hotels Budget
                        ProjectNavigatorProjectHotelsBudget projectNavigatorProjectHotelsBudget = new ProjectNavigatorProjectHotelsBudget(projectNavigatorTDS);
                        projectNavigatorProjectHotelsBudget.LoadAllByProjectId(projectId);

                        // Get Bondings Budget
                        ProjectNavigatorProjectBondingsBudget projectNavigatorProjectBondingsBudget = new ProjectNavigatorProjectBondingsBudget(projectNavigatorTDS);
                        projectNavigatorProjectBondingsBudget.LoadAllByProjectId(projectId);

                        // Get Insurances Budget
                        ProjectNavigatorProjectInsurancesBudget projectNavigatorProjectInsurancesBudget = new ProjectNavigatorProjectInsurancesBudget(projectNavigatorTDS);
                        projectNavigatorProjectInsurancesBudget.LoadAllByProjectId(projectId);

                        // Get Other Costs Budget
                        ProjectNavigatorProjectOtherCostsBudget projectNavigatorProjectOtherCostsBudget = new ProjectNavigatorProjectOtherCostsBudget(projectNavigatorTDS);
                        projectNavigatorProjectOtherCostsBudget.LoadAllByProjectId(projectId);

                        // Get Notes
                        ProjectNavigatorProjectNotes projectNavigatorProjectNotes = new ProjectNavigatorProjectNotes(projectNavigatorTDS);
                        projectNavigatorProjectNotes.LoadAllByProjectId(projectId);

                        // Store dataset
                        Session["lfsProjectTDS"] = projectTDS;
                        Session["projectNavigatorTDS"] = projectNavigatorTDS;
                        Session["projectNotes"] = projectNavigatorTDS.ProjectNotes;
                        Session["projectServices"] = projectNavigatorTDS.ProjectService;
                        Session["projectTypeOfWorkFunctionClassification"] = projectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGE;
                        Session["projectJobClassClassification"] = projectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATE;
                        Session["projectBudget"] = projectNavigatorTDS.ProjectWorkFunctionBudget;
                        Session["unitsBudget"] = projectNavigatorTDS.ProjectUnitsBudget;
                        Session["materialsBudget"] = projectNavigatorTDS.ProjectMaterialsBudget;
                        Session["subcontractorsBudget"] = projectNavigatorTDS.ProjectSubcontractorsBudget;
                        Session["hotelsBudget"] = projectNavigatorTDS.ProjectHotelsBudget;
                        Session["bondingsBudget"] = projectNavigatorTDS.ProjectBondingsBudget;
                        Session["insurancesBudget"] = projectNavigatorTDS.ProjectInsurancesBudget;
                        Session["otherCostsBudget"] = projectNavigatorTDS.ProjectOtherCostsBudget;
                    }

                    //grdNotes.DataBind();
                    //grdServices.DataBind();
                    grdTypeOfWorkFunctionClassification.DataBind();
                    grdJobClassClassification.DataBind();
                    grdBudget.DataBind();
                    /*grdSubcontractorsBudget.DataBind();
                    grdHotelsBudget.DataBind();
                    grdBondingsBudget.DataBind();
                    grdInsurancesBudget.DataBind();*/
                    grdOtherCostsBudget.DataBind();
                }

                // ... project_summary.aspx or project_edit.aspx
                if ((Request.QueryString["source_page"] == "project_summary.aspx") || (Request.QueryString["source_page"] == "project_edit.aspx") || (Request.QueryString["source_page"] == "lm"))
                {
                    // Store Navigator State, update control and origin
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];
                    ViewState["origin"] = Request.QueryString["origin"]; //summary

                    // Restore dataset
                    projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                    projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"];
                    projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"];
                    projectServices = (ProjectNavigatorTDS.ProjectServiceDataTable)Session["projectServices"];
                    projectJobClassClassification = (ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable)Session["projectJobClassClassification"];
                    projectTypeOfWorkFunctionClassification = (ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable)Session["projectTypeOfWorkFunctionClassification"];
                    projectBudget = (ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable)Session["projectBudget"];
                    unitsBudget = (ProjectNavigatorTDS.ProjectUnitsBudgetDataTable)Session["unitsBudget"];
                    materialsBudget = (ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable)Session["materialsBudget"];
                    subcontractorsBudget = (ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable)Session["subcontractorsBudget"];
                    hotelsBudget = (ProjectNavigatorTDS.ProjectHotelsBudgetDataTable)Session["hotelsBudget"];
                    bondingsBudget = (ProjectNavigatorTDS.ProjectBondingsBudgetDataTable)Session["bondingsBudget"];
                    insurancesBudget = (ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable)Session["insurancesBudget"];
                    otherCostsBudget = (ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable)Session["otherCostsBudget"];

                    // Get Project Id
                    int projectId = int.Parse(hdfProjectId.Value);

                    if (ViewState["update"].ToString().Trim() == "yes")
                    {
                        // Get General Data
                        ProjectGateway projectGatewayForLoad = new ProjectGateway(projectTDS);
                        projectGatewayForLoad.LoadByProjectId(projectId);

                        // Get job info
                        ProjectJobInfoGateway projectJobInfoGateway = new ProjectJobInfoGateway(projectNavigatorTDS);
                        projectJobInfoGateway.LoadAllByProjectId(projectId);

                        // Get Sale/Billing/Pricing
                        ProjectSaleBillingPricingGateway projectSaleBillingPricingGatewayForLoad = new ProjectSaleBillingPricingGateway(projectTDS);
                        projectSaleBillingPricingGatewayForLoad.LoadAllByProjectId(projectId);

                        // ... Get Sale/Billing/Pricing - Services
                        ProjectNavigatorProjectService projectNavigatorProjectService = new ProjectNavigatorProjectService(projectNavigatorTDS);
                        projectNavigatorProjectService.LoadAllByProjectId(projectId);
                        projectNavigatorProjectService.UpdateForLoad();

                        // Get Costing Updates
                        ProjectCostingUpdatesGateway projectCostingUpdatesGatewayForLoad = new ProjectCostingUpdatesGateway(projectTDS);
                        projectCostingUpdatesGatewayForLoad.LoadByProjectId(projectId);

                        // Get Project Terms
                        ProjectTermsPOGateway projectTermsPOGatewayForLoad = new ProjectTermsPOGateway(projectTDS);
                        projectTermsPOGatewayForLoad.LoadByProjectId(projectId);

                        // Get Technical
                        ProjectTechnicalGateway projectTechnicalGatewayForLoad = new ProjectTechnicalGateway(projectTDS);
                        projectTechnicalGatewayForLoad.LoadByProjectId(projectId);

                        // Get Engineer Subcontractors
                        ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGatewayForLoad = new ProjectEngineerSubcontractorsGateway(projectTDS);
                        projectEngineerSubcontractorsGatewayForLoad.LoadAllByProjectId(projectId);

                        // ... Get Subcontractors
                        ProjectSubcontractorGateway projectSubcontractorGatewayForLoad = new ProjectSubcontractorGateway(projectTDS);
                        projectSubcontractorGatewayForLoad.LoadAllByProjectId(projectId);

                        // Cost Exceptions
                        // ... Get Type Of Work & Function Classification
                        ProjectNavigatorProjectWorkFunctionFairWage projectNavigatorProjectWorkFunctionFairWage = new ProjectNavigatorProjectWorkFunctionFairWage(projectNavigatorTDS);
                        projectNavigatorProjectWorkFunctionFairWage.LoadAllByProjectId(projectId);

                        // ... Get Job Class Classification
                        ProjectNavigatorProjectJobClassTypeRate projectNavigatorProjectJobClassTypeRate = new ProjectNavigatorProjectJobClassTypeRate(projectNavigatorTDS);
                        projectNavigatorProjectJobClassTypeRate.LoadAllByProjectId(projectId);

                        // Get Budget
                        ProjectNavigatorProjectWorkFunctionBudget projectNavigatorProjectWorkFunctionBudget = new ProjectNavigatorProjectWorkFunctionBudget(projectNavigatorTDS);
                        projectNavigatorProjectWorkFunctionBudget.LoadAllByProjectId(projectId);

                        // Get Units Budget
                        ProjectNavigatorProjectUnitsBudget projectNavigatorProjectUnitsBudget = new ProjectNavigatorProjectUnitsBudget(projectNavigatorTDS);
                        projectNavigatorProjectUnitsBudget.LoadAllByProjectId(projectId);

                        // Get Materials Budget
                        ProjectNavigatorProjectMaterialsBudget projectNavigatorProjectMaterialsBudget = new ProjectNavigatorProjectMaterialsBudget(projectNavigatorTDS);
                        projectNavigatorProjectMaterialsBudget.LoadAllByProjectId(projectId);

                        // Get Subcontractors Budget
                        ProjectNavigatorProjectSubcontractorsBudget projectNavigatorProjectSubcontractorsBudget = new ProjectNavigatorProjectSubcontractorsBudget(projectNavigatorTDS);
                        projectNavigatorProjectSubcontractorsBudget.LoadAllByProjectId(projectId);

                        // Get Hotels Budget
                        ProjectNavigatorProjectHotelsBudget projectNavigatorProjectHotelsBudget = new ProjectNavigatorProjectHotelsBudget(projectNavigatorTDS);
                        projectNavigatorProjectHotelsBudget.LoadAllByProjectId(projectId);

                        // Get Bondings Budget
                        ProjectNavigatorProjectBondingsBudget projectNavigatorProjectBondingsBudget = new ProjectNavigatorProjectBondingsBudget(projectNavigatorTDS);
                        projectNavigatorProjectBondingsBudget.LoadAllByProjectId(projectId);

                        // Get Insurances Budget
                        ProjectNavigatorProjectInsurancesBudget projectNavigatorProjectInsurancesBudget = new ProjectNavigatorProjectInsurancesBudget(projectNavigatorTDS);
                        projectNavigatorProjectInsurancesBudget.LoadAllByProjectId(projectId);

                        // Get Other Costs Budget
                        ProjectNavigatorProjectOtherCostsBudget projectNavigatorProjectOtherCostsBudget = new ProjectNavigatorProjectOtherCostsBudget(projectNavigatorTDS);
                        projectNavigatorProjectOtherCostsBudget.LoadAllByProjectId(projectId);

                        // Get Notes
                        ProjectNavigatorProjectNotes projectNavigatorProjectNotes = new ProjectNavigatorProjectNotes(projectNavigatorTDS);
                        projectNavigatorProjectNotes.LoadAllByProjectId(projectId);

                        //grdNotes.DataBind();
                        //grdServices.DataBind();
                        grdTypeOfWorkFunctionClassification.DataBind();
                        grdJobClassClassification.DataBind();
                        grdBudget.DataBind();
                        /*grdSubcontractorsBudget.DataBind();
                        grdHotelsBudget.DataBind();
                        grdBondingsBudget.DataBind();
                        grdInsurancesBudget.DataBind();*/
                        grdOtherCostsBudget.DataBind();

                        // Store dataset
                        Session["lfsProjectTDS"] = projectTDS;
                        Session["projectNavigatorTDS"] = projectNavigatorTDS;
                        Session["projectNotes"] = projectNavigatorTDS.ProjectNotes;
                        Session["projectServices"] = projectNavigatorTDS.ProjectService;
                        Session["projectTypeOfWorkFunctionClassification"] = projectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGE;
                        Session["projectJobClassClassification"] = projectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATE;
                        Session["projectBudget"] = projectNavigatorTDS.ProjectWorkFunctionBudget;
                        Session["unitsBudget"] = projectNavigatorTDS.ProjectUnitsBudget;
                        Session["materialsBudget"] = projectNavigatorTDS.ProjectMaterialsBudget;
                        Session["subcontractorsBudget"] = projectNavigatorTDS.ProjectSubcontractorsBudget;
                        Session["hotelsBudget"] = projectNavigatorTDS.ProjectHotelsBudget;
                        Session["bondingsBudget"] = projectNavigatorTDS.ProjectBondingsBudget;
                        Session["insurancesBudget"] = projectNavigatorTDS.ProjectInsurancesBudget;
                        Session["otherCostsBudget"] = projectNavigatorTDS.ProjectOtherCostsBudget;
                    }
                }

                // Data for current project
                ProjectGateway projectGateway = new ProjectGateway(projectTDS);

                // ... for project
                int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString());
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")";

                // ... for client
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int currentClientId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString()));
                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadAllByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // Load Data
                LoadData();

                // Store Dataset
                Session["lfsProjectTDS"] = projectTDS;

                //// ... For total cost at services
                //ProjectNavigatorProjectService projectNavigatorProjectServiceForCost = new ProjectNavigatorProjectService(projectNavigatorTDS);
                //tbxTotalCost.Text = Decimal.Round(projectNavigatorProjectServiceForCost.GetTotalCost(), 2).ToString();
            }
            else
            {
                // Restore dataset
                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"];
                projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"];
                projectServices = (ProjectNavigatorTDS.ProjectServiceDataTable)Session["projectServices"];
                projectJobClassClassification = (ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable)Session["projectJobClassClassification"];
                projectTypeOfWorkFunctionClassification = (ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable)Session["projectTypeOfWorkFunctionClassification"];
                projectBudget = (ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable)Session["projectBudget"];
                unitsBudget = (ProjectNavigatorTDS.ProjectUnitsBudgetDataTable)Session["unitsBudget"];
                materialsBudget = (ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable)Session["materialsBudget"];
                subcontractorsBudget = (ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable)Session["subcontractorsBudget"];
                hotelsBudget = (ProjectNavigatorTDS.ProjectHotelsBudgetDataTable)Session["hotelsBudget"];
                bondingsBudget = (ProjectNavigatorTDS.ProjectBondingsBudgetDataTable)Session["bondingsBudget"];
                insurancesBudget = (ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable)Session["insurancesBudget"];
                otherCostsBudget = (ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable)Session["otherCostsBudget"];

                tbxProjectNumber.DataBind();

                if (Session["lfsLibraryTDS"] != null)
                {
                    libraryTDS = (LibraryTDS)Session["lfsLibraryTDS"];
                }
                else
                {
                    libraryTDS = new LibraryTDS();
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_VIEW"]) && Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_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["service_id"] == null) || ((string)Request.QueryString["active_tab"] == null) || ((string)Request.QueryString["dashboard"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in services_edit.aspx");
                }

                // Tag Page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfFmType.Value = "Services";
                hdfServiceId.Value = Request.QueryString["service_id"].ToString();
                hdfActiveTab.Value = Request.QueryString["active_tab"].ToString();
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();
                hdfDashboard.Value = Request.QueryString["dashboard"].ToString();

                // Prepare initial data
                Session.Remove("serviceCostsDummy");
                Session.Remove("serviceNotesDummy");

                // If coming from
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int serviceId = Int32.Parse(hdfServiceId.Value.Trim());
                string fmType = hdfFmType.Value;

                // ... services_navigator2.aspx, services_add_request.aspx, services_manager_tool.aspx
                if ((Request.QueryString["source_page"] == "services_navigator2.aspx") || (Request.QueryString["source_page"] == "services_add_request.aspx") || (Request.QueryString["source_page"] == "services_manager_tool.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedServices"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];

                        serviceInformationTDS = new ServiceInformationTDS();

                        ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS);
                        serviceInformationBasicInformation.LoadByServiceId(serviceId, companyId);

                        ServiceInformationServiceCost serviceInformationServiceCostForEdit = new ServiceInformationServiceCost(serviceInformationTDS);
                        serviceInformationServiceCostForEdit.LoadByServiceId(serviceId, companyId);

                        ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS);
                        serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId);
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabServices"];

                        // Restore datasets
                        serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"];
                    }

                    // ... Store dataset
                    Session["serviceInformationTDS"] = serviceInformationTDS;
                }

                // ... services_summary.aspx or services_edit
                if ((Request.QueryString["source_page"] == "services_summary.aspx") || (Request.QueryString["source_page"] == "services_edit.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // ... Restore dataset
                    serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"];

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedServices"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];

                        if (ViewState["update"].ToString().Trim() == "yes")
                        {
                            ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS);
                            serviceInformationBasicInformation.LoadByServiceId(serviceId, companyId);

                            ServiceInformationServiceCost serviceInformationServiceCostForEdit = new ServiceInformationServiceCost(serviceInformationTDS);
                            serviceInformationServiceCostForEdit.LoadByServiceId(serviceId, companyId);

                            ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS);
                            serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId);

                            // ... Store dataset
                            Session["serviceInformationTDS"] = serviceInformationTDS;
                        }
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabServices"];
                    }
                }

                // Prepare initial data
                lblMissingData.Visible = false;

                // ... Set initial tab
                int activeTab = Int32.Parse(hdfActiveTab.Value);
                tcDetailedInformation.ActiveTabIndex = activeTab;

                // ... For total cost
                ServiceInformationServiceCost serviceInformationServiceCostForTotalCost = new ServiceInformationServiceCost(serviceInformationTDS);
                tbxTotalCost.Text = Decimal.Round(serviceInformationServiceCostForTotalCost.GetTotalCost(serviceId, companyId), 2).ToString();

                // ... Data for current servicew
                LoadServiceData(companyId);

                // Databind
                Page.DataBind();

                ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
                if (serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId).HasValue)
                {
                    try
                    {
                        ddlAssignmentDataAssignToTeamMember.SelectedValue = ((int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId)).ToString();
                    }
                    catch
                    {
                        ddlAssignmentDataAssignToTeamMember.SelectedIndex = 0;
                    }

                    int teamMemberId = (int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId);
                    EmployeeGateway employeeGateway = new EmployeeGateway();
                    employeeGateway.LoadByEmployeeId(teamMemberId);
                    tbxAssignmentDataAssignToTeamMemberReadOnly.Text = employeeGateway.GetLastName(teamMemberId) + " " + employeeGateway.GetFirstName(teamMemberId);
                }

                // For thirds party vendor autocomplete
                aceThirdPartyVendor.ContextKey = serviceId.ToString() + "," + hdfCompanyId.Value;

                // ... For Library
                if (Session["libraryTDSForServices"] != null)
                {
                    libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"];
                }
                else
                {
                    libraryTDSForServices = new LibraryTDS();
                }
            }
            else
            {
                // Restore datasets
                serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"];

                // Set initial tab
                int activeTab = Int32.Parse(hdfActiveTab.Value);
                tcDetailedInformation.ActiveTabIndex = activeTab;

                if (Session["libraryTDSForServices"] != null)
                {
                    libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"];
                }
                else
                {
                    libraryTDSForServices = new LibraryTDS();
                }

                LoadNotes();
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // INITIAL EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                if (Session["dialogOpenedServicesManagerTool"] == null)
                {
                    // Security check
                    if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADD"])) || !(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADMIN"])))
                    {
                        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 services_manager_tool.aspx");
                    }

                    // Tag Page
                    TagPage();

                    // Initialize viewstate variables
                    ViewState["StepFrom"] = "Out";
                    Session.Remove("serviceRequests");
                    Session.Remove("serviceRequestsDummy");
                    Session.Remove("serviceRequestsManagerToolTDS");
                    Session.Remove("serviceCostsDummyManagerTool");
                    Session.Remove("costInformationManagerTool");
                    Session.Remove("serviceNotesDummyManagerTool");
                    Session.Remove("serviceInformationTDSForManagerTool");
                    Session.Remove("libraryTDSForServices");

                    serviceInformationTDS = new ServiceInformationTDS();

                    // If coming from
                    // ... lm or services_navigator.aspx
                    if ((Request.QueryString["source_page"] == "lm") || (Request.QueryString["source_page"] == "services_navigator.aspx") || (Request.QueryString["source_page"] == "services_navigator2.aspx"))
                    {
                        // ... Initialize tables
                        serviceRequestsManagerToolTDS = new ServiceRequestsManagerToolTDS();

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

                        ServiceRequestsManagerToolServiceRequests serviceRequestsManagerToolServiceRequests = new ServiceRequestsManagerToolServiceRequests(serviceRequestsManagerToolTDS);
                        serviceRequestsManagerToolServiceRequests.LoadAll(companyId);

                        // ... Store tables
                        Session["serviceRequestsManagerToolTDS"] = serviceRequestsManagerToolTDS;
                        Session["serviceRequests"] = serviceRequestsManagerToolTDS.ServiceRequests;
                    }

                    // ... For Library
                    if (Session["libraryTDSForServices"] != null)
                    {
                        libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"];
                    }
                    else
                    {
                        libraryTDSForServices = new LibraryTDS();
                    }

                    Session["serviceInformationTDSForManagerTool"] = serviceInformationTDS;

                    // StepSection1In
                    wzServices.ActiveStepIndex = 0;
                    StepBeginIn();
                }
                else
                {
                    if ((string)Session["dialogOpenedServicesManagerTool"] == "1")
                    {
                        // Tag Page
                        hdfCompanyId.Value = Convert.ToInt32(Session["companyID"]).ToString();
                        hdfDashboard.Value = (string)Request.QueryString["dashboard"];

                        hdfSelectedSRId.Value = (string)Session["selecctedServiceID"];

                        // Restore tables
                        serviceRequestsManagerToolTDS = (ServiceRequestsManagerToolTDS)Session["serviceRequestsManagerToolTDS"];
                        serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDSForManagerTool"];

                        // ... For Library
                        if (Session["libraryTDSForServices"] != null)
                        {
                            libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"];
                        }
                        else
                        {
                            libraryTDSForServices = new LibraryTDS();
                        }

                        // StepSection1In
                        wzServices.ActiveStepIndex = 1;
                        StepStepsInformationIn();
                    }
                }
            }
            else
            {
                // Restore tables
                serviceRequestsManagerToolTDS = (ServiceRequestsManagerToolTDS)Session["serviceRequestsManagerToolTDS"];
                serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDSForManagerTool"];

                // ... For Library
                if (Session["libraryTDSForServices"] != null)
                {
                    libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"];
                }
                else
                {
                    libraryTDSForServices = new LibraryTDS();
                }
            }
        }
        protected void PopulateNode(object sender, TreeNodeEventArgs e)
        {
            int companyId = Int32.Parse(Session["companyID"].ToString());
            libraryTDSForServicesManagerTool = (LibraryTDS)Session["libraryTDSForServicesManagerTool"];
            LibraryCategoriesGateway libraryCategoriesGateway = new LibraryCategoriesGateway(libraryTDSForServicesManagerTool);
            TreeNode node = e.Node;

            if (e.Node.Depth == 0)
            {
                libraryCategoriesGateway.LoadAllByParentId(0, companyId);
                foreach (LibraryTDS.LIBRARY_CATEGORIESRow rowLibraryCategories in (LibraryTDS.LIBRARY_CATEGORIESDataTable)libraryCategoriesGateway.Table)
                {
                    TreeNode newNode = new TreeNode(rowLibraryCategories.CATEGORY_NAME, rowLibraryCategories.LIBRARY_CATEGORIES_ID.ToString());
                    if (libraryCategoriesGateway.CountByParentId(rowLibraryCategories.LIBRARY_CATEGORIES_ID, companyId) > 0)
                    {
                        newNode.PopulateOnDemand = true;
                    }
                    node.ChildNodes.Add(newNode);
                }
            }
            else
            {
                int libraryCategoriesId = Int32.Parse(e.Node.Value);
                libraryCategoriesGateway.LoadAllByParentId(libraryCategoriesId, companyId);

                foreach (LibraryTDS.LIBRARY_CATEGORIESRow rowLibraryCategories in (LibraryTDS.LIBRARY_CATEGORIESDataTable)libraryCategoriesGateway.Table)
                {
                    TreeNode newNode = new TreeNode(rowLibraryCategories.CATEGORY_NAME, rowLibraryCategories.LIBRARY_CATEGORIES_ID.ToString());
                    if (libraryCategoriesGateway.CountByParentId(rowLibraryCategories.LIBRARY_CATEGORIES_ID, companyId) > 0)
                    {
                        newNode.PopulateOnDemand = true;
                    }
                    node.ChildNodes.Add(newNode);
                }
            }

            Session["libraryTDSForServicesManagerTool"] = libraryTDSForServicesManagerTool;
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Store navigator state
                StoreNavigatorState();

                hdfUpdate.Value = "no";

                libraryTDS = new LibraryTDS();
                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];

                Session["libraryTDS"] = libraryTDS;
                Session["lfsProjectTDS"] = projectTDS;

                ViewState["projectId"] = int.Parse(Request.QueryString["project_id"].ToString());
            }
            else
            {
                libraryTDS = (LibraryTDS)Session["libraryTDS"];
                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                hdfUpdate.Value = "yes";
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();

                tbxDescription.Text = Server.UrlDecode(Request.QueryString["subject"].ToString());
                ViewState["refId"] = Request.QueryString["refId"].ToString();

                try
                {
                    ViewState["refIdCost"] = Request.QueryString["refIdCost"].ToString();
                }
                catch
                {
                    ViewState["refIdCost"] = 0;
                }

                ViewState["serviceId"] = Request.QueryString["service_id"].ToString();
                ViewState["libraryCategoriesId"] = Request.QueryString["library_categories_id"].ToString();

                if (Request.QueryString["source_page"] == "services_edit.aspx")
                {
                    serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"];
                }
                else
                {
                    serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDSForManagerTool"];
                }

                if (Session["libraryTDSForServices"] != null)
                {
                    libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"];
                }
                else
                {
                    libraryTDSForServices = new LibraryTDS();
                }
            }
            else
            {
                if (Request.QueryString["source_page"] == "services_edit.aspx")
                {
                    serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"];
                }
                else
                {
                    serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDSForManagerTool"];
                }

                if (Session["libraryTDSForServices"] != null)
                {
                    libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"];
                }
                else
                {
                    libraryTDSForServices = new LibraryTDS();
                }
            }
        }