Find查找表记录

2015-06-10 11:49:06  访问(1280) 赞(0) 踩(0)

private void buttonFind_Click(object sender, System.EventArgs e)
		{
			listBoxSearchResult.Items.Clear();
			listBoxSearchResult.Visible = false;
			Find find = null;
			Column searchColumn = _searchTable.TableInfo.Columns[comboBoxSearchColumn.SelectedItem.ToString()];
			if ( _refiningTable != null && _refiningTable.IsOpen )
			{
				if (comboBoxRefiningColumn.Items.Count > 0 )
				{
					Column refiningColumn = _refiningTable.TableInfo.Columns[comboBoxRefiningColumn.SelectedItem.ToString()];
					find = new Find(_searchTable, searchColumn, _refiningTable, refiningColumn);
				}
				else
				{
					MessageBox.Show(String.Format("No indexed columns in " + _refiningTable + "."));
					return;
				}

			}
			else
			{
				find = new Find(_searchTable, searchColumn);
			}

			if ( checkBoxUseCloseMatches.Checked )
			{
				find.UseCloseMatches = true;
				find.CloseMatchesMax = int.Parse(textBoxMaxCloseMatches.Text);
			}

			if ( checkBoxAddressNumAfterStreet.Checked )
			{
				find.AddressNumberAfterStreet = true;
			}

			// Do the actual search.
			if ( _refiningTable != null && _refiningTable.IsOpen )
			{
				if (_bSearchIntersection) 
				{
					_result= find.SearchIntersection(textBoxSearchString.Text, textBoxIntersection.Text, textBoxRefiningString.Text);
				} 
				else 
				{
					_result = find.Search(textBoxSearchString.Text, textBoxRefiningString.Text);
				}
			}
			else
			{
				if (_bSearchIntersection) 
				{
					_result= find.SearchIntersection(textBoxSearchString.Text, textBoxIntersection.Text);
				} 
				else 
				{
					_result = find.Search(textBoxSearchString.Text);
				}
			}

			// display label that tells us when multiple matches were found
			labelMultipleMatchesFound.Visible = _result.MultipleMatches;

			if ( _result.ExactMatch 
				&& _result.NameResultCode.Equals(FindNameCode.ExactMatch) 
				&& _result.FoundPoint != null)
			{
				labelSearchResult.Text = "Exact Match";
				showPointOnSearchTableMap(_result.FoundPoint.X, _result.FoundPoint.Y);				
			}
			else if (_result.NameResultCode.Equals(FindNameCode.ExactMatch) 
				&& _result.AddressResultCode.Equals(FindAddressCode.AddressNumNotSpecified))
			{
				labelSearchResult.Text = _result.AddressResultCode.ToString();
				FindAddressRangeEnumerator _enum = _result.GetAddressRangeEnumerator();
				FindAddressRange _findAddressRange;

				listBoxSearchResult.Visible = true;
				while (_enum.MoveNext()) 
				{
					_findAddressRange = _enum.Current;
					listBoxSearchResult.Items.Add(
						String.Format("Address range: [{0} - {1}]", _findAddressRange.BeginRange, _findAddressRange.EndRange));
				}
			}
			else if (_result.NameResultCode.Equals(FindNameCode.ExactMatch) 
				&& _result.MultipleMatches)
			{
				labelSearchResult.Text = _result.NameResultCode.ToString();
				listBoxSearchResult.Visible = true;
				FindCloseMatchEnumerator enumerator = _result.GetCloseMatchEnumerator();
				while ( enumerator.MoveNext() )
				{
					listBoxSearchResult.Items.Add(enumerator.Current.Name);
				}
			}
			else
			{
				labelSearchResult.Text = _result.NameResultCode.ToString();
				if ( find.UseCloseMatches )
				{
					listBoxSearchResult.Visible = true;
					FindCloseMatchEnumerator enumerator = _result.GetCloseMatchEnumerator();
					while ( enumerator.MoveNext() )
					{
						listBoxSearchResult.Items.Add(enumerator.Current.Name);
					}
				}
			}
			find.Dispose();
		}


标签:Find查找表记录 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)