-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmSearchGazetteer.vb
87 lines (65 loc) · 2.67 KB
/
frmSearchGazetteer.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Imports System.Data.SQLite
Public Class frmSearchGazetteer
Dim objGridRef As GridRef = New GridRef
Private Sub butClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butClose.Click
strGR = ""
Me.Close()
End Sub
Private Sub butSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butSearch.Click
Dim dblEast As Double
Dim dblNorth As Double
Dim dr As DataRow
Dim dtInput As DataTable = New DataTable()
Dim daSQLite As SQLiteDataAdapter
Dim db As clsDB = New clsDB
'Select Town from the OS50k Gaz view
Dim strSQL As String = "Select east as x, north as y, def_nam as name from os50kgaz where def_nam like ?"
'MessageBox.Show(strSQL)
Dim com As SQLiteCommand = New SQLiteCommand(strSQL, db.conGazetteer)
com.Parameters.AddWithValue("place", txtSearch.Text.Replace("*", "%"))
Dim dtTowns As DataTable = New DataTable()
'daSQLite = New SQLiteDataAdapter(strSQL, db.conGazetteer)
daSQLite = New SQLiteDataAdapter(com)
daSQLite.Fill(dtTowns)
'Add the Towns to the list
lvLocations.Items.Clear()
For Each dr In dtTowns.Rows
dblEast = dr.Item("x")
dblNorth = dr.Item("y")
Dim item As ListViewItem = lvLocations.Items.Add(dr.Item("name"))
item.SubItems.Add(objGridRef.EN2Monad(dblEast, dblNorth))
Next
lvLocations.Update()
db.Dispose()
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
objGridRef.MakePrefixArrays()
End Sub
Private Sub butUse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butUse.Click
If lvLocations.SelectedItems.Count > 0 Then
strGR = lvLocations.SelectedItems(0).SubItems(1).Text
Else
strGR = ""
End If
Me.Close()
End Sub
Private strGR As String
Public ReadOnly Property GR() As String
Get
Return strGR
End Get
End Property
Private Sub txtSearch_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSearch.KeyPress
If e.KeyChar = Convert.ToChar(Keys.Enter) Then
butSearch_Click(Nothing, Nothing)
e.Handled = True
End If
End Sub
Private Sub frmSearchGazetteer_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
txtSearch.Focus()
txtSearch.SelectAll()
End Sub
End Class