protected void btnSearch_Click(object sender, EventArgs e) { if (Page.IsValid) { string url = ""; // Delete store data Session.Contents.Remove("jlsNavigatorTDS"); // Get data from DA gateway jlsNavigatorTDS = SubmitSearch(); // Show results if (jlsNavigatorTDS.JlsNavigator.Rows.Count > 0) { // ... Store data Session["jlsNavigatorTDS"] = jlsNavigatorTDS; // ... Go to the results page url = "./jls_navigator2.aspx?source_page=jls_navigator2.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + GetNavigatorState(); } else { // ... Go to the search page url = "./jls_navigator.aspx?source_page=jls_navigator2.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + GetNavigatorState() + "&no_results=yes"; } Response.Redirect(url); } }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_CWP_JUNCTIONLINING_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) || ((string)Request.QueryString["client_id"] == null) || ((string)Request.QueryString["project_id"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in jls_navigator2.aspx"); } // Tag Page hdfCompanyId.Value = Session["companyID"].ToString(); hdfCurrentProjectId.Value = Request.QueryString["project_id"].ToString(); hdfCurrentClientId.Value = Request.QueryString["client_id"].ToString(); // Prepare initial data // ... For sortByList odsSortByList.DataBind(); ddlSortBy.DataSourceID = "odsSortByList"; ddlSortBy.DataValueField = "SortID"; ddlSortBy.DataTextField = "Name"; ddlSortBy.DataBind(); // ... For odsViewForDisplayList.DataBind(); ddlCondition1.DataSourceID = "odsViewForDisplayList"; ddlCondition1.DataValueField = "ConditionID"; ddlCondition1.DataTextField = "Name"; ddlCondition1.DataBind(); // ... for client int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString()); int companyId = Int32.Parse(hdfCompanyId.Value); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadByCompaniesId(currentClientId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId); // ... for project int currentProjectId = Int32.Parse(hdfCurrentProjectId.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 = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // If coming from // ... jls_navigator.aspx or jls_navigator2.aspx if ((Request.QueryString["source_page"] == "jls_navigator.aspx") || (Request.QueryString["source_page"] == "jls_navigator2.aspx")) { RestoreNavigatorState(); jlsNavigatorTDS = (JlsNavigatorTDS)Session["jlsNavigatorTDS"]; } // ... flat_section_jls_edit.aspx, flat_section_jls_summary.aspx or jls_delete.aspx if ((Request.QueryString["source_page"] == "flat_section_jls_edit.aspx") || (Request.QueryString["source_page"] == "flat_section_jls_summary.aspx") || (Request.QueryString["source_page"] == "jls_delete.aspx")) { RestoreNavigatorState(); if (Request.QueryString["update"] == "no") { jlsNavigatorTDS = (JlsNavigatorTDS)Session["jlsNavigatorTDS"]; } else { // ... Delete store data Session.Contents.Remove("jlsNavigatorTDS"); // ... Search data with updates jlsNavigatorTDS = SubmitSearch(); // ... store datasets Session["jlsNavigatorTDS"] = jlsNavigatorTDS; // ... control of existing records if (jlsNavigatorTDS.JlsNavigator.Rows.Count == 0) { string url = "./jls_navigator.aspx?source_page=jls_navigator2.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + GetNavigatorState() + "&no_results=yes"; Response.Redirect(url); } } } // For the grid grdJLNavigator.DataSource = jlsNavigatorTDS.JlsNavigator; grdJLNavigator.DataBind(); // ... for the total rows if (jlsNavigatorTDS.JlsNavigator.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + jlsNavigatorTDS.JlsNavigator.Rows.Count; lblTotalRows.Visible = true; } else { lblTotalRows.Visible = false; } } else { // Restore TDS jlsNavigatorTDS = (JlsNavigatorTDS)Session["jlsNavigatorTDS"]; // ... for the total rows if (jlsNavigatorTDS.JlsNavigator.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + jlsNavigatorTDS.JlsNavigator.Rows.Count; lblTotalRows.Visible = true; } else { lblTotalRows.Visible = false; } } }
/// <summary> /// InitData /// </summary> protected override void InitData() { _data = new JlsNavigatorTDS(); }