jj 07.12 2

This commit is contained in:
JenneJ
2016-12-07 12:57:28 +01:00
parent 1f154675a2
commit 9aaadf7921

View File

@@ -10,9 +10,11 @@ Public Class frmGeodataNavigation
Private BING_KEY As String = "hQUTlqLLK70bETnonpfi~0jx1pIAq1yQ7gXqbIyzKrg~Au-Tewbty8afAxdbNilSv4JlU7qwU-fQKu0ouH9e1uJmpIyVdA3jugVEWMdy1Rbt" Private BING_KEY As String = "hQUTlqLLK70bETnonpfi~0jx1pIAq1yQ7gXqbIyzKrg~Au-Tewbty8afAxdbNilSv4JlU7qwU-fQKu0ouH9e1uJmpIyVdA3jugVEWMdy1Rbt"
Private EntityId As Integer = Nothing Private EntityId As Integer = Nothing
Private EntitySql As String = Nothing Private EntitySql As String = Nothing
Private Grid As GridControl = Nothing Private EntityDataTable As DataTable = Nothing
Private ConstructorMain_Grid As GridControl = Nothing
Private CurrentPoint As GeoPoint = Nothing Private CurrentPoint As GeoPoint = Nothing
#Region "MAP CONTROL" #Region "MAP CONTROL"
Private ReadOnly Property ImageLayer() As ImageTilesLayer Private ReadOnly Property ImageLayer() As ImageTilesLayer
Get Get
@@ -32,10 +34,10 @@ Public Class frmGeodataNavigation
Dim items As New List(Of MapCustomElementEx) Dim items As New List(Of MapCustomElementEx)
' Datensätze mit Lat,Lon Werten laden ' Datensätze mit Lat,Lon Werten laden
Dim dt As DataTable = ClassDatabase.Return_Datatable(Me.EntitySql) Dim rows As DataRow() = EntityDataTable.Select("LATITUDE IS NOT NULL AND LONGITUDE IS NOT NULL")
' PushPins ' PushPins
For Each row As DataRow In dt.Rows For Each row As DataRow In rows
Dim lat As Double = row.Item("LATITUDE") Dim lat As Double = row.Item("LATITUDE")
Dim lon As Double = row.Item("LONGITUDE") Dim lon As Double = row.Item("LONGITUDE")
@@ -63,7 +65,7 @@ Public Class frmGeodataNavigation
storage.Items.AddRange(items.ToArray()) storage.Items.AddRange(items.ToArray())
VectorLayer.Data = storage VectorLayer.Data = storage
tsLabelRecordCount.Text = String.Format("{0} Elemente gefunden", items.Count) tsLabelRecordCount.Text = String.Format("{0} Elemente mit Koordinaten gefunden", items.Count)
MapControl1.ZoomToFitLayerItems() MapControl1.ZoomToFitLayerItems()
End Sub End Sub
@@ -75,22 +77,9 @@ Public Class frmGeodataNavigation
InitializeComponent() InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
Me.Grid = gridControl Me.ConstructorMain_Grid = gridControl
Me.EntityId = EntityId 'Me.EntityId = EntityId
Me.EntitySql = String.Format("SELECT T.*, T1.LATITUDE, T1.LONGITUDE from VWTEMP_PMO_FORM{0} T,TBPMO_RECORD_GEODATA T1 WHERE T.[Record-ID] = T1.RECORD_ID", Me.EntityId) 'Me.EntitySql = String.Format("SELECT T.*, T1.LATITUDE, T1.LONGITUDE from VWTEMP_PMO_FORM{0} T,TBPMO_RECORD_GEODATA T1 WHERE T.[Record-ID] = T1.RECORD_ID", Me.EntityId)
End Sub
Private Sub frmGeodataNavigation_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Try
Dim gridView As Views.Grid.GridView = Me.Grid.FocusedView
gridView.ActiveFilterString = Nothing
Catch ex As Exception
MsgBox("Error in frmGeodataNavigation_FormClosing: " & vbNewLine & ex.Message)
End Try
End Sub
Private Sub LoadGridData()
End Sub End Sub
Private Sub frmGeodataNavigation_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub frmGeodataNavigation_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@@ -99,12 +88,33 @@ Public Class frmGeodataNavigation
dataProvider.BingKey = BING_KEY dataProvider.BingKey = BING_KEY
ImageLayer.DataProvider = dataProvider ImageLayer.DataProvider = dataProvider
LoadItemList() EntitySql = Get_Grid_Sql(CURRENT_CONSTRUCTOR_ID, CURRENT_FORM_ID, CURRENT_CONSTRUCTOR_DETAIL_ID, frmConstructor_Main.GridType.Grid, USER_GUID, String.Empty, False, 1, 0, GridControlGeo, grvwMain, True)
LoadData()
Dim sql = Get_Grid_Sql(CURRENT_CONSTRUCTOR_ID, CURRENT_FORM_ID, CURRENT_CONSTRUCTOR_DETAIL_ID, frmConstructor_Main.GridType.Grid, USER_GUID, String.Empty, False, 1, 0, GridControlGeo, grvwMain, True) Catch ex As Exception
If Not IsNothing(sql) Then MsgBox("Error while loading GeoData: " & vbNewLine & ex.Message)
Dim DT_GEO As DataTable = ClassDatabase.Return_Datatable(sql) End Try
GridControlGeo.DataSource = DT_GEO End Sub
Private Sub frmGeodataNavigation_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Try
Dim gridView As Views.Grid.GridView = Me.ConstructorMain_Grid.FocusedView
gridView.ActiveFilterString = Nothing
Catch ex As Exception
MsgBox("Error in frmGeodataNavigation_FormClosing: " & vbNewLine & ex.Message)
End Try
End Sub
Private Sub LoadData()
EntityDataTable = ClassDatabase.Return_Datatable(EntitySql)
LoadItemList()
LoadGridData()
End Sub
Private Sub LoadGridData()
If Not IsNothing(EntityDataTable) Then
GridControlGeo.DataSource = EntityDataTable
End If End If
Dim listcheck As List(Of String) = ClassHelper.Return_listcheck(CURRENT_FORM_ID) Dim listcheck As List(Of String) = ClassHelper.Return_listcheck(CURRENT_FORM_ID)
@@ -154,11 +164,10 @@ Public Class frmGeodataNavigation
grvwMain.Columns("Record-ID").Visible = False grvwMain.Columns("Record-ID").Visible = False
grvwMain.Columns("Form-ID").Visible = False grvwMain.Columns("Form-ID").Visible = False
grvwMain.Columns("ROW_COLOR").Visible = False grvwMain.Columns("ROW_COLOR").Visible = False
Catch ex As Exception
MsgBox("Error while loading GeoData: " & vbNewLine & ex.Message)
End Try
End Sub End Sub
Private Sub SetGridFilter(records As List(Of Integer)) Private Sub SetGridFilter(records As List(Of Integer))
Try Try
Dim filter As New List(Of String) Dim filter As New List(Of String)
@@ -167,7 +176,7 @@ Public Class frmGeodataNavigation
filter.Add(String.Format("[Record-Id] = {0}", id)) filter.Add(String.Format("[Record-Id] = {0}", id))
Next Next
Dim gridView As Views.Grid.GridView = Me.Grid.FocusedView Dim gridView As Views.Grid.GridView = Me.ConstructorMain_Grid.FocusedView
gridView.ActiveFilterString = String.Join(" OR ", filter.ToArray()) gridView.ActiveFilterString = String.Join(" OR ", filter.ToArray())
Catch ex As Exception Catch ex As Exception
MsgBox("Error in SetGridFilter: " & vbNewLine & ex.Message) MsgBox("Error in SetGridFilter: " & vbNewLine & ex.Message)
@@ -204,6 +213,10 @@ Public Class frmGeodataNavigation
End Sub End Sub
Private Sub grvwMain_RowStyle(sender As Object, e As Views.Grid.RowStyleEventArgs) Handles grvwMain.RowStyle Private Sub grvwMain_RowStyle(sender As Object, e As Views.Grid.RowStyleEventArgs) Handles grvwMain.RowStyle
If e.RowHandle = DevExpress.XtraGrid.GridControl.AutoFilterRowHandle Then
e.Appearance.BackColor = Color.Orange 'LemonChiffon
End If
If e.RowHandle > 0 Then If e.RowHandle > 0 Then
Dim row As DataRowView = grvwMain.GetRow(e.RowHandle) Dim row As DataRowView = grvwMain.GetRow(e.RowHandle)
Dim LATITUDE = row.Item("LATITUDE") Dim LATITUDE = row.Item("LATITUDE")
@@ -251,10 +264,17 @@ Public Class frmGeodataNavigation
txtLat.Text = SelectedPoint.Latitude txtLat.Text = SelectedPoint.Latitude
txtLon.Text = SelectedPoint.Longitude txtLon.Text = SelectedPoint.Longitude
SaveCurrentPoint()
End If End If
End Sub End Sub
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
SaveCurrentPoint()
End Sub
Private Sub SaveCurrentPoint()
Dim point As GeoPoint = GetCurrentPoint() Dim point As GeoPoint = GetCurrentPoint()
If point Is Nothing Then If point Is Nothing Then
@@ -266,6 +286,9 @@ Public Class frmGeodataNavigation
Dim currentRow As DataRowView = grvwMain.GetFocusedRow() Dim currentRow As DataRowView = grvwMain.GetFocusedRow()
Dim RecordId As Integer = currentRow.Item("Record-ID") Dim RecordId As Integer = currentRow.Item("Record-ID")
Dim geoDataExists As Boolean = ClassDatabase.Execute_Scalar("SELECT RECORD_ID FROM TBPMO_RECORD_GEODATA WHERE RECORD_ID = " & RecordId)
If geoDataExists Then
Dim SQL As String = "UPDATE TBPMO_RECORD_GEODATA SET LATITUDE = @lat, LONGITUDE = @lon, CHANGED_WHO = @who WHERE RECORD_ID = @recordid" Dim SQL As String = "UPDATE TBPMO_RECORD_GEODATA SET LATITUDE = @lat, LONGITUDE = @lon, CHANGED_WHO = @who WHERE RECORD_ID = @recordid"
Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection(MyConnectionString) Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection(MyConnectionString)
Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(SQL, conn) Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(SQL, conn)
@@ -278,8 +301,25 @@ Public Class frmGeodataNavigation
conn.Open() conn.Open()
cmd.ExecuteNonQuery() cmd.ExecuteNonQuery()
conn.Close() conn.Close()
Else
Dim SQL As String = "INSERT INTO TBPMO_RECORD_GEODATA (LATITUDE,LONGITUDE,ADDED_WHO,RECORD_ID) VALUES (@lat,@lon,'@who',@recordid)"
Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection(MyConnectionString)
Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(SQL, conn)
cmd.Parameters.Add("@lat", SqlDbType.Decimal).Value = point.Latitude
cmd.Parameters.Add("@lon", SqlDbType.Decimal).Value = point.Longitude
cmd.Parameters.Add("@who", SqlDbType.VarChar).Value = Environment.UserName
cmd.Parameters.Add("@recordid", SqlDbType.Int).Value = RecordId
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End If
' Markierte Zeile speichern, um diese beim neu laden wieder zu setzen
Dim rowhandle As Integer = grvwMain.FocusedRowHandle
LoadData()
grvwMain.FocusedRowHandle = rowhandle
Catch ex As Exception Catch ex As Exception
MsgBox("Error while saving Coordinates: " & vbNewLine & ex.Message) MsgBox("Error while saving Coordinates: " & vbNewLine & ex.Message)