Пример #1
0
		private void DisplayResults(int sortColumn, bool ascending)
		{
			grdResults.Columns.Clear();

            pnlError.Visible = false;

			if (_reportManagedItemSort == null)
			{
				try
				{
					_reportManagedItemSort = (Business.ReportManagedItemSort)Context.Items[Common.Names._CNTXT_ReportManagedItemSort];
				}
				catch
				{
				}
			}

			if (_reportManagedItemSort == null)
			{
				//Came directly from ReportSearch.aspx ("Run")
				Business.ManagedItemSearch miSearch = new Kindred.Knect.ITAT.Business.ManagedItemSearch();
                //If this is an 'admin viewer', then do not limit the search results based on security.
                List<string> roles = UserRolesOrAdminViewer();
                Business.SearchResults _searchResults = miSearch.Search(_itatSystem.ID, _report.SearchCriteria, roles);
				_report.DefineTerms(_searchResults);
                _reportManagedItemSort = _report.GetReportManagedItemSort(_searchResults, roles);
				_reportManagedItemSort.Update(_report.ReportTerms, _report.PrimaryTerm, _report.SecondaryTerm, true);
			}
			DataSet dsResults = _reportManagedItemSort.GetDisplay();
			//Add columns to grdResults
			if (_reportManagedItemSort != null)
			{
                if (_reportManagedItemSort.Count == 0)
                {
                    pnlError.Visible = true;
                    litError.Text = "You are receiving no results from your Report as you may not have access to the data or there is no data that meets your criteria";
                }
                else
				{
					Business.ReportManagedItem rmi = _reportManagedItemSort[0];
					foreach (Business.ReportTerm rptTerm in rmi.ReportTerms)
					{
						if (rptTerm.Visible ?? false)
						{
							BoundField fld = new BoundField();
							fld.HeaderText = rptTerm.ColumnHeaderText(_itatSystem.ManagedItemName);
							fld.DataField = rptTerm.Name;
							grdResults.Columns.Add(fld);
						}
					}
					if (sortColumn >= 0)
					{
						dsResults.Tables[0].DefaultView.Sort = string.Format("{0} {1}", dsResults.Tables[0].Columns[sortColumn].ColumnName, ascending ? "ASC" : "DESC");
					}
					grdResults.DataSource = dsResults.Tables[0].DefaultView;
					grdResults.DataBind();
				}
			}
		}
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			((StandardHeader)itatHeader).PageTitle = GetPageName();
			int nSelectedRow = -1;
			if (!IsPostBack)
			{
				_reportManagedItemSort = null;
				try
				{
					//_CNTXT_ReportManagedItemSort is defined if from Report.aspx or could be defined if from ReportSearchResults.aspx 
					_reportManagedItemSort = (Business.ReportManagedItemSort)Context.Items[Common.Names._CNTXT_ReportManagedItemSort];
				}
				catch
				{
				}

				string selectedRow = Request.QueryString[Common.Names._QS_SELECTED_ROW];
				int nTryParse;
				if (int.TryParse(selectedRow, out nTryParse))
				{
					//From Report.aspx or from ReportSearchResults.aspx (in order to correctly display the checkboxes)
					nSelectedRow = nTryParse;
					_searchResults = (Business.SearchResults)Context.Items[Common.Names._CNTXT_SearchResults];
				}
				else
				{
					if (_reportManagedItemSort == null)
					{
						//From ManagedItemSearch.aspx
						_report.SearchCriteria = (Business.SearchCriteria)Context.Items[Common.Names._CNTXT_SearchCriteria];
						Business.ManagedItemSearch miSearch = new Kindred.Knect.ITAT.Business.ManagedItemSearch();
                        //If this is an 'admin viewer', then do not limit the search results based on security.
                        _searchResults = miSearch.Search(_itatSystem.ID, _report.SearchCriteria, UserRolesOrAdminViewer());
						_report.DefineTerms(_searchResults);
					}
					else
					{
						//From Report.aspx
					}
				}
			}
			else
			{
				//Update the selection criteria
				SetVisibility(true);
				//Note - the order is important here. If the same term is used for both, then
				//the second call will 'null out' the first.  So if we call SetSecondary first, then
				//SetPrimary call will null out the SecondaryTerm.
				if (ddlSort1.Items.Count > 0 && ddlSort2.Items.Count > 0)
				{
					string[] sValues1 = ddlSort1.Items[ddlSort1.SelectedIndex].Value.Split(','); ;
					string[] sValues2 = ddlSort2.Items[ddlSort2.SelectedIndex].Value.Split(','); ;

					_report.SetSecondary(ddlSort2.Items[ddlSort2.SelectedIndex].Text, sValues2[1]);
					_report.SetPrimary(ddlSort1.Items[ddlSort1.SelectedIndex].Text, sValues1[1]);
				}
			}
			PopulateForm(nSelectedRow);
		}
		protected void btnContinue_Click(object sender, CommandEventArgs e)
		{
			if (grdTermList.SelectedRows.Count > 0)
			{
				if (_reportManagedItemSort == null)
				{
					//We got to this page from ManagedItemSearch.aspx 
                    _reportManagedItemSort = _report.GetReportManagedItemSort(_searchResults, UserRolesOrAdminViewer());
				}
				else
				{
					//We got to this page from Report.aspx 
				}

				_reportManagedItemSort.Update(_report.ReportTerms, _report.PrimaryTerm, _report.SecondaryTerm, true);

				Context.Items[Common.Names._CNTXT_ReportManagedItemSort] = _reportManagedItemSort;
				SetContextData();
				Server.Transfer("Report.aspx");
			}
			else
			{
				RegisterAlert("You must select at least one term.");
			}
		}
		protected override void LoadViewState(object savedState)
		{
			base.LoadViewState(savedState);
			_dsDropDownSortTerms = (DataSet)ViewState[VIEWSTATE_SORT_TERMS];
			_searchResults = (Business.SearchResults)ViewState[VIEWSTATE_SEARCH_RESULTS];
			_reportManagedItemSort = (Business.ReportManagedItemSort)ViewState[VIEWSTATE_REPORT_MANAGEDITEM_SORT];
		}
Пример #5
0
		protected override void LoadViewState(object savedState)
		{
			base.LoadViewState(savedState);
			_reportManagedItemSort = (Business.ReportManagedItemSort)ViewState[VIEWSTATE_REPORT_MANAGEDITEM_SORT];
		}