// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // public ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORDataTable GetSections() { projectSectionsNavigator = (ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORDataTable)Session["projectSectionsNavigatorNewDummy"]; if (projectSectionsNavigator == null) { projectSectionsNavigator = ((ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORDataTable)Session["projectSectionsNavigator"]); } return projectSectionsNavigator; }
protected void AddProjectSectionsNewEmptyFix(GridView grdNavigator) { if (grdSectionsNavigator.Rows.Count == 0) { ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORDataTable dt = new ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORDataTable(); dt.AddLFS_PROJECT_SECTIONS_NAVIGATORRow(-1, "", "", -1, -1, -1, -1, "", "", "", false, false, false, -1, "", false, ""); Session["projectSectionsNavigatorNewDummy"] = dt; grdSectionsNavigator.DataBind(); } // normally executes at all postbacks if (grdSectionsNavigator.Rows.Count == 1) { ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORDataTable dt = (ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORDataTable)Session["projectSectionsNavigatorNewDummy"]; if (dt != null) { grdSectionsNavigator.Rows[0].Visible = false; grdSectionsNavigator.Rows[0].Controls.Clear(); } } }
// //////////////////////////////////////////////////////////////////////// // 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"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if (Request.QueryString["source_page"] == null) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_sections_navigator2.aspx"); } projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; assetsTDS = new AssetsTDS(); lfsAssetsTDS = new LfsAssetsTDS(); workTDS = new WorkTDS(); // Tag page hdfCompanyId.Value = Session["companyID"].ToString(); hdfProjectId.Value = Request.QueryString["project_id"]; hdfDataChanged.Value = Request.QueryString["data_changed"]; hdfDataChangedMessage.Value = "Changes made to this project will not be saved."; ViewState["state"] = Request.QueryString["state"]; ViewState["active_tab"] = Request.QueryString["active_tab"]; ViewState["origin"] = Request.QueryString["origin"]; ViewState["update"] = Request.QueryString["update"]; Session.Remove("projectSectionsNavigatorNewDummy"); Session.Remove("projectSectionsNavigator"); // Prepare initial data lblError.Visible = false; // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); 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.Trim()); int currentClientId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentClientId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId); hdfClientId.Value = projectGateway.GetClientID(int.Parse(hdfProjectId.Value)).ToString(); // Store navigator state at projects navigator StoreNavigatorState(); // ... project_sections_navigator.aspx or project_sections_navigator2.aspx if ((Request.QueryString["source_page"] == "project_sections_navigator.aspx") || (Request.QueryString["source_page"] == "project_sections_navigator2.aspx")) { // Restore navigator state RestoreNavigatorState(); // Restore data projectSectionsNavigatorTDS = (ProjectSectionsNavigatorTDS)Session["lfsProjectSectionsNavigatorTDS"]; projectSectionsNavigator = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; // Store data Session["projectSectionsNavigator"] = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; if (Request.QueryString["update_section"] == "no") { // Restore data projectSectionsNavigatorTDS = (ProjectSectionsNavigatorTDS)Session["lfsProjectSectionsNavigatorTDS"]; projectSectionsNavigator = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; // Store data Session["projectSectionsNavigator"] = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; } else { // ... Delete store data Session.Contents.Remove("lfsProjectSectionsNavigatorTDS"); // ... Search data with updates projectSectionsNavigatorTDS = SubmitSearch(); // ... store datasets Session["lfsProjectSectionsNavigatorTDS"] = projectSectionsNavigatorTDS; Session["projectSectionsNavigator"] = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; } //... for the total rows if (projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR.Rows.Count; lblTotalRows.Visible = true; } else { lblTotalRows.Visible = false; } } } else { // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; projectSectionsNavigatorTDS = (ProjectSectionsNavigatorTDS)Session["lfsProjectSectionsNavigatorTDS"]; assetsTDS = (AssetsTDS)Session["assetsTDS"]; lfsAssetsTDS = (LfsAssetsTDS)Session["lfsAssetsTDS"]; workTDS = (WorkTDS)Session["workTDS"]; // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); 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); // Restore searched data (if any) projectSectionsNavigatorTDS = (ProjectSectionsNavigatorTDS)Session["lfsProjectSectionsNavigatorTDS"]; projectSectionsNavigator = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; //... for the total rows if (projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR.Rows.Count; } else { lblTotalRows.Visible = false; } } }