/// //////////////////////////////////////////////////////////////////////// /// PUBLIC METHODS /// public TDSLFSRecordForArchiveTool.ARCHIVEDataTable GetArchiveNew() { archiveTool = (TDSLFSRecordForArchiveTool.ARCHIVEDataTable)Session["archiveToolDummy"]; if (archiveTool == null) { archiveTool = (TDSLFSRecordForArchiveTool.ARCHIVEDataTable)Session["archiveTool"]; } return archiveTool; }
/// //////////////////////////////////////////////////////////////////////// /// PRIVATE METHODS /// protected void AddArchiveEmptyFix(GridView grdView) { if (grdView.Rows.Count == 0) { TDSLFSRecordForArchiveTool.ARCHIVEDataTable dt = new TDSLFSRecordForArchiveTool.ARCHIVEDataTable(); dt.AddARCHIVERow(Guid.NewGuid(), -1, "", -1, "", "", "", "", false, false); Session["archiveToolDummy"] = dt; grdView.DataBind(); } // normally executes at all postbacks if (grdView.Rows.Count == 1) { TDSLFSRecordForArchiveTool.ARCHIVEDataTable dt = (TDSLFSRecordForArchiveTool.ARCHIVEDataTable)Session["archiveToolDummy"]; if (dt != null) { grdView.Rows[0].Visible = false; grdView.Rows[0].Controls.Clear(); } } }
protected void btnSubmit_Click(object sender, System.EventArgs e) { if (Page.IsValid && (tbxSearch.Text.Trim() != "")) { //--- Get data from database gateway tdsLfsRecordForArchiveTool = this.SubmitSearch(); Session["tdsLfsRecordForArchiveTool"] = tdsLfsRecordForArchiveTool; archiveTool = tdsLfsRecordForArchiveTool.ARCHIVE; Session["archiveTool"] = archiveTool; //--- Show results if (tdsLfsRecordForArchiveTool.ARCHIVE.DefaultView.Count > 0) { //... Yes results grdArchive2.DataBind(); } else { //.... No results //... Store archive tool state Session["ddlSearchSelectedIndexForAT"] = ddlSearch.SelectedIndex; Session["tbxSearchTextForAT"] = tbxSearch.Text; Session["lblHintVisibleForAT"] = lblHint.Visible; Session["lblHintTextForAT"] = lblHint.Text; //... Go to search page Response.Redirect("archive.aspx?source_page=archive2.aspx&search_results=true"); } } }
/////////////////////////////////////////////////////////////////////////// /// EVENTS /// protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { //--- Security check if (!(Convert.ToBoolean(Session["sgLFS_APP_VIEW"]) && Convert.ToBoolean(Session["sgLFS_APP_ADMIN"]))) { 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 archive.aspx"); } //--- If coming from archive.aspx if (Request.QueryString["source_page"] == "archive.aspx") { //--- Restore archive tool state ddlSearch.SelectedIndex = (int)Session["ddlSearchSelectedIndexForAT"]; tbxSearch.Text = (string)Session["tbxSearchTextForAT"]; lblHint.Visible = (bool)Session["lblHintVisibleForAT"]; lblHint.Text = (string)Session["lblHintTextForAT"]; //--- Restore searched data tdsLfsRecordForArchiveTool = (TDSLFSRecordForArchiveTool)Session["tdsLfsRecordForArchiveTool"]; archiveTool = tdsLfsRecordForArchiveTool.ARCHIVE; Session["archiveTool"] = archiveTool; } } else { //--- Restore searched data (if any) tdsLfsRecordForArchiveTool = (TDSLFSRecordForArchiveTool)Session["tdsLfsRecordForArchiveTool"]; archiveTool = tdsLfsRecordForArchiveTool.ARCHIVE; Session["archiveTool"] = archiveTool; } }