// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // public EmployeeNavigatorTDS.EmployeeNavigatorDataTable GetNavigator() { employeeNavigator = (EmployeeNavigatorTDS.EmployeeNavigatorDataTable)Session["employeeNavigatorNewDummy"]; if (employeeNavigator == null) { employeeNavigator = ((EmployeeNavigatorTDS.EmployeeNavigatorDataTable)Session["employeeNavigator"]); } return employeeNavigator; }
protected void AddNewEmptyFix(GridView grdNavigator) { if (grdNavigator.Rows.Count == 0) { EmployeeNavigatorTDS.EmployeeNavigatorDataTable dt = new EmployeeNavigatorTDS.EmployeeNavigatorDataTable(); dt.AddEmployeeNavigatorRow(-1, -1, "", "", "", "", "", "", false, false, false, false, "", false, false, 0, 0, 0, 0, 0, 0, false, 0, 0, "", "", "", false, false, -1, -1, -1, -1, 0, ""); Session["employeeNavigatorNewDummy"] = dt; grdNavigator.DataBind(); } // normally executes at all postbacks if (grdNavigator.Rows.Count == 1) { EmployeeNavigatorTDS.EmployeeNavigatorDataTable dt = (EmployeeNavigatorTDS.EmployeeNavigatorDataTable)Session["employeeNavigatorNewDummy"]; if (dt != null) { grdNavigator.Rows[0].Visible = false; grdNavigator.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_RESOURCES_EMPLOYEES_VIEW"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if ((string)Request.QueryString["source_page"] == null) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in employees_navigator2.aspx"); } // Tag Page hdfCompanyId.Value = Session["companyID"].ToString(); hdfResourceType.Value = "Employee"; Session.Remove("employeeNavigatorNewDummy"); // Prepare initial data // ... For odsViewForConditionList.DataBind(); ddlCondition1.DataSourceID = "odsViewForConditionList"; ddlCondition1.DataValueField = "ConditionID"; ddlCondition1.DataTextField = "Name"; ddlCondition1.DataBind(); // Prepare initial data // ... For sortByList odsSortByList.DataBind(); ddlSortBy.DataSourceID = "odsSortByList"; ddlSortBy.DataValueField = "SortID"; ddlSortBy.DataTextField = "Name"; ddlSortBy.DataBind(); // If coming from // ... employees_navigator.aspx or employees_navigator2.aspx if ((Request.QueryString["source_page"] == "employees_navigator.aspx") || (Request.QueryString["source_page"] == "employees_navigator2.aspx")) { RestoreNavigatorState(); employeeNavigatorTDS = (EmployeeNavigatorTDS)Session["employeeNavigatorTDS"]; } // ... employees_edit.aspx, employees_summary.aspx or employees_delete.aspx if ((Request.QueryString["source_page"] == "employees_edit.aspx") || (Request.QueryString["source_page"] == "employees_summary.aspx") || (Request.QueryString["source_page"] == "employees_delete.aspx")) { RestoreNavigatorState(); if (Request.QueryString["update"] == "no") { employeeNavigatorTDS = (EmployeeNavigatorTDS)Session["employeeNavigatorTDS"]; } else { // ... Delete store data Session.Contents.Remove("employeeNavigatorTDS"); // ... Search data with updates employeeNavigatorTDS = SubmitSearch(); // ... store datasets Session["employeeNavigatorTDS"] = employeeNavigatorTDS; } } // ... employees_delete.aspx, employee_summary.aspx or employee_edit.aspx if ((Request.QueryString["source_page"] == "employee_delete.aspx") || (Request.QueryString["source_page"] == "employee_summary.aspx") || (Request.QueryString["source_page"] == "employee_edit.aspx")) { if (employeeNavigatorTDS.EmployeeNavigator.Rows.Count == 0) { string url = "./employees_navigator.aspx?source_page=employees_navigator2.aspx&re_type=" + hdfResourceType.Value + GetNavigatorState() + "&no_results=yes"; Response.Redirect(url); } } Session["employeeNavigatorTDS"] = employeeNavigatorTDS; Session["employeeNavigator"] = employeeNavigatorTDS.EmployeeNavigator; // ... for the total rows if (employeeNavigatorTDS.EmployeeNavigator.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + employeeNavigatorTDS.EmployeeNavigator.Rows.Count; lblTotalRows.Visible = true; } else { lblTotalRows.Visible = false; } } else { // Restore searched data (if any) employeeNavigatorTDS = (EmployeeNavigatorTDS)Session["employeeNavigatorTDS"]; employeeNavigator = employeeNavigatorTDS.EmployeeNavigator; // ... for the total rows if (employeeNavigatorTDS.EmployeeNavigator.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + employeeNavigatorTDS.EmployeeNavigator.Rows.Count; lblTotalRows.Visible = true; } else { lblTotalRows.Visible = false; } } }