From 1f154675a24013b2524cbfc019428d7bd463202d Mon Sep 17 00:00:00 2001 From: JenneJ Date: Wed, 7 Dec 2016 12:10:08 +0100 Subject: [PATCH 1/4] jj 07.12 1 --- .../frmGeodataNavigation.Designer.vb | 7 +- .../frmGeodataNavigation.vb | 132 ++++++++++-------- 2 files changed, 79 insertions(+), 60 deletions(-) diff --git a/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb b/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb index 6c031a4..94cdd5d 100644 --- a/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb +++ b/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb @@ -164,6 +164,7 @@ Partial Class frmGeodataNavigation Me.grvwMain.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CellSelect Me.grvwMain.OptionsView.ColumnAutoWidth = False Me.grvwMain.OptionsView.EnableAppearanceEvenRow = True + Me.grvwMain.OptionsView.ShowAutoFilterRow = True Me.grvwMain.OptionsView.ShowHorizontalLines = DevExpress.Utils.DefaultBoolean.[True] ' 'btnSave @@ -175,10 +176,10 @@ Partial Class frmGeodataNavigation Me.btnSave.Text = "Save" Me.btnSave.UseVisualStyleBackColor = True ' - 'Button1 + 'btnOpenMap ' Me.btnOpenMap.Location = New System.Drawing.Point(277, 96) - Me.btnOpenMap.Name = "Button1" + Me.btnOpenMap.Name = "btnOpenMap" Me.btnOpenMap.Size = New System.Drawing.Size(96, 33) Me.btnOpenMap.TabIndex = 4 Me.btnOpenMap.Text = "Set on Map" @@ -209,7 +210,6 @@ Partial Class frmGeodataNavigation Me.txtLon.Font = New System.Drawing.Font("Tahoma", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtLon.Location = New System.Drawing.Point(11, 96) Me.txtLon.Name = "txtLon" - Me.txtLon.ReadOnly = True Me.txtLon.Size = New System.Drawing.Size(260, 33) Me.txtLon.TabIndex = 1 ' @@ -218,7 +218,6 @@ Partial Class frmGeodataNavigation Me.txtLat.Font = New System.Drawing.Font("Tahoma", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtLat.Location = New System.Drawing.Point(11, 41) Me.txtLat.Name = "txtLat" - Me.txtLat.ReadOnly = True Me.txtLat.Size = New System.Drawing.Size(260, 33) Me.txtLat.TabIndex = 0 ' diff --git a/app/DD-Record-Organiser/frmGeodataNavigation.vb b/app/DD-Record-Organiser/frmGeodataNavigation.vb index 31ff96f..e36f9e3 100644 --- a/app/DD-Record-Organiser/frmGeodataNavigation.vb +++ b/app/DD-Record-Organiser/frmGeodataNavigation.vb @@ -3,6 +3,7 @@ Imports DevExpress.XtraEditors Imports DevExpress.XtraGrid Imports DevExpress.Utils Imports DevExpress.XtraGrid.Columns +Imports DevExpress.XtraEditors.Repository Public Class frmGeodataNavigation @@ -12,6 +13,7 @@ Public Class frmGeodataNavigation Private Grid As GridControl = Nothing Private CurrentPoint As GeoPoint = Nothing +#Region "MAP CONTROL" Private ReadOnly Property ImageLayer() As ImageTilesLayer Get Return CType(MapControl1.Layers("ImageLayer"), ImageTilesLayer) @@ -24,16 +26,6 @@ Public Class frmGeodataNavigation End Get End Property - Public Sub New(ByRef gridControl As GridControl, ByVal EntityId As Integer) - ' Dieser Aufruf ist für den Designer erforderlich. - InitializeComponent() - - ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. - Me.Grid = gridControl - 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) - End Sub - Private Function CreateItemList() ' Liste für PushPins anlegen 'Dim items As New List(Of MapPushpin) @@ -57,13 +49,6 @@ Public Class frmGeodataNavigation customElement.SelectedFill = Color.White items.Add(customElement) - - 'Dim pushpin As New MapPushpin() - 'pushpin.Location = New GeoPoint(lat, lon) - 'pushpin.Text = row.Item("Record-ID").ToString() - 'pushpin.Information = row.Item("Record-ID") - - 'items.Add(pushpin) Next Return items @@ -82,6 +67,18 @@ Public Class frmGeodataNavigation MapControl1.ZoomToFitLayerItems() End Sub +#End Region + + + Public Sub New(ByRef gridControl As GridControl, ByVal EntityId As Integer) + ' Dieser Aufruf ist für den Designer erforderlich. + InitializeComponent() + + ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. + Me.Grid = gridControl + 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) + End Sub Private Sub frmGeodataNavigation_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing Try @@ -92,6 +89,10 @@ Public Class frmGeodataNavigation End Try End Sub + Private Sub LoadGridData() + + End Sub + Private Sub frmGeodataNavigation_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try Dim dataProvider As New BingMapDataProvider() @@ -109,6 +110,18 @@ Public Class frmGeodataNavigation Dim listcheck As List(Of String) = ClassHelper.Return_listcheck(CURRENT_FORM_ID) Dim listdate As List(Of String) = ClassHelper.Return_listdate(CURRENT_FORM_ID) + Dim CheckBoxEditorForDisplay = New RepositoryItemCheckEdit() + CheckBoxEditorForDisplay.ValueChecked = 1 + CheckBoxEditorForDisplay.ValueUnchecked = 0 + GridControlGeo.RepositoryItems.Add(CheckBoxEditorForDisplay) + + ' Alle Checkbox Spalten durchgehen und CheckBoxEditor zuweisen + For Each col As String In listcheck + If Not IsNothing(grvwMain.Columns(col)) Then + grvwMain.Columns(col).ColumnEdit = CheckBoxEditorForDisplay + End If + Next + For Each col As String In listdate Dim date_edit As New DevExpress.XtraEditors.Repository.RepositoryItemTimeEdit Dim date_column As GridColumn = grvwMain.Columns(col) @@ -191,8 +204,7 @@ Public Class frmGeodataNavigation End Sub Private Sub grvwMain_RowStyle(sender As Object, e As Views.Grid.RowStyleEventArgs) Handles grvwMain.RowStyle - 'TODO: Make Rows without geodata RED - If e.RowHandle <> -1 Then + If e.RowHandle > 0 Then Dim row As DataRowView = grvwMain.GetRow(e.RowHandle) Dim LATITUDE = row.Item("LATITUDE") Dim LONGITUDE = row.Item("LONGITUDE") @@ -207,58 +219,50 @@ Public Class frmGeodataNavigation Dim currentRow As DataRowView = grvwMain.GetFocusedRow() Dim lat, lon As Decimal - Try - lat = currentRow.Item("LATITUDE") - lon = currentRow.Item("LONGITUDE") - Catch ex As InvalidCastException - lat = -1 - lon = -1 - End Try + If currentRow Is Nothing Then + Exit Sub + End If + + If currentRow IsNot Nothing AndAlso Not IsDBNull(currentRow.Item("LATITUDE")) And Not IsDBNull(currentRow.Item("LONGITUDE")) Then + Dim validLat As Boolean = Decimal.TryParse(currentRow.Item("LATITUDE"), lat) + Dim validLon As Boolean = Decimal.TryParse(currentRow.Item("LONGITUDE"), lon) - If lat = -1 And lon = -1 Then + If validLat And validLon Then + txtLat.Text = lat + txtLon.Text = lon + Else + txtLat.Text = String.Empty + txtLon.Text = String.Empty + End If + Else txtLat.Text = String.Empty txtLon.Text = String.Empty - CurrentPoint = Nothing - Else - txtLat.Text = lat - txtLon.Text = lon - CurrentPoint = New GeoPoint(lat, lon) End If End Sub Private Sub btnOpenMap_Click(sender As Object, e As EventArgs) Handles btnOpenMap.Click - Dim lat, lon As Double - Dim point As GeoPoint + Dim point As GeoPoint = GetCurrentPoint() - Try - lat = Double.Parse(txtLat.Text) - lon = Double.Parse(txtLon.Text) - point = New GeoPoint(lat, lon) - Catch ex As Exception - point = Nothing - Finally - Dim frm As New frmGeodataSelect(point) - Dim result = frm.ShowDialog() + Dim frm As New frmGeodataSelect(point) + Dim result = frm.ShowDialog() - If result = Windows.Forms.DialogResult.OK Then - Dim SelectedPoint As GeoPoint = frm.SelectedPoint + If result = Windows.Forms.DialogResult.OK Then + Dim SelectedPoint As GeoPoint = frm.SelectedPoint - txtLat.Text = SelectedPoint.Latitude - txtLon.Text = SelectedPoint.Longitude - CurrentPoint = SelectedPoint - End If - End Try + txtLat.Text = SelectedPoint.Latitude + txtLon.Text = SelectedPoint.Longitude + End If End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click - If CurrentPoint Is Nothing Then - MsgBox("Es wurden keine Koodinaten angegeben!", MsgBoxStyle.Critical) + Dim point As GeoPoint = GetCurrentPoint() + + If point Is Nothing Then + ' TODO: Add Error Mesg Exit Sub End If Try - Dim lat As Decimal = CurrentPoint.Latitude - Dim lon As Decimal = CurrentPoint.Longitude Dim currentRow As DataRowView = grvwMain.GetFocusedRow() Dim RecordId As Integer = currentRow.Item("Record-ID") @@ -266,8 +270,8 @@ Public Class frmGeodataNavigation 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 = lat - cmd.Parameters.Add("@lon", SqlDbType.Decimal).Value = lon + 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 @@ -275,8 +279,24 @@ Public Class frmGeodataNavigation cmd.ExecuteNonQuery() conn.Close() + + Catch ex As Exception MsgBox("Error while saving Coordinates: " & vbNewLine & ex.Message) End Try End Sub + + Private Function GetCurrentPoint() As GeoPoint + Dim lat, lon As Decimal + + Dim validLat As Boolean = Decimal.TryParse(txtLat.Text, lat) + Dim validLon As Boolean = Decimal.TryParse(txtLon.Text, lon) + + If validLat And validLon Then + Return New GeoPoint(lat, lon) + Else + Return Nothing + End If + + End Function End Class \ No newline at end of file From 9aaadf79213284c27a8913716176ccc1cd51d694 Mon Sep 17 00:00:00 2001 From: JenneJ Date: Wed, 7 Dec 2016 12:57:28 +0100 Subject: [PATCH 2/4] jj 07.12 2 --- .../frmGeodataNavigation.vb | 198 +++++++++++------- 1 file changed, 119 insertions(+), 79 deletions(-) diff --git a/app/DD-Record-Organiser/frmGeodataNavigation.vb b/app/DD-Record-Organiser/frmGeodataNavigation.vb index e36f9e3..ce234d2 100644 --- a/app/DD-Record-Organiser/frmGeodataNavigation.vb +++ b/app/DD-Record-Organiser/frmGeodataNavigation.vb @@ -10,9 +10,11 @@ Public Class frmGeodataNavigation Private BING_KEY As String = "hQUTlqLLK70bETnonpfi~0jx1pIAq1yQ7gXqbIyzKrg~Au-Tewbty8afAxdbNilSv4JlU7qwU-fQKu0ouH9e1uJmpIyVdA3jugVEWMdy1Rbt" Private EntityId As Integer = 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 + #Region "MAP CONTROL" Private ReadOnly Property ImageLayer() As ImageTilesLayer Get @@ -32,10 +34,10 @@ Public Class frmGeodataNavigation Dim items As New List(Of MapCustomElementEx) ' 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 - For Each row As DataRow In dt.Rows + For Each row As DataRow In rows Dim lat As Double = row.Item("LATITUDE") Dim lon As Double = row.Item("LONGITUDE") @@ -63,102 +65,109 @@ Public Class frmGeodataNavigation storage.Items.AddRange(items.ToArray()) 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() End Sub #End Region - + Public Sub New(ByRef gridControl As GridControl, ByVal EntityId As Integer) ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. - Me.Grid = gridControl - 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.ConstructorMain_Grid = gridControl + '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) + End Sub + + Private Sub frmGeodataNavigation_Load(sender As Object, e As EventArgs) Handles MyBase.Load + Try + Dim dataProvider As New BingMapDataProvider() + dataProvider.BingKey = BING_KEY + ImageLayer.DataProvider = dataProvider + + 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() + + Catch ex As Exception + MsgBox("Error while loading GeoData: " & vbNewLine & ex.Message) + End Try 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 + 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 LoadGridData() - + Private Sub LoadData() + EntityDataTable = ClassDatabase.Return_Datatable(EntitySql) + LoadItemList() + LoadGridData() End Sub - Private Sub frmGeodataNavigation_Load(sender As Object, e As EventArgs) Handles MyBase.Load - Try - Dim dataProvider As New BingMapDataProvider() - dataProvider.BingKey = BING_KEY - ImageLayer.DataProvider = dataProvider - - LoadItemList() - 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) - If Not IsNothing(sql) Then - Dim DT_GEO As DataTable = ClassDatabase.Return_Datatable(sql) - GridControlGeo.DataSource = DT_GEO - End If + Private Sub LoadGridData() + If Not IsNothing(EntityDataTable) Then + GridControlGeo.DataSource = EntityDataTable + End If - Dim listcheck As List(Of String) = ClassHelper.Return_listcheck(CURRENT_FORM_ID) - Dim listdate As List(Of String) = ClassHelper.Return_listdate(CURRENT_FORM_ID) + Dim listcheck As List(Of String) = ClassHelper.Return_listcheck(CURRENT_FORM_ID) + Dim listdate As List(Of String) = ClassHelper.Return_listdate(CURRENT_FORM_ID) - Dim CheckBoxEditorForDisplay = New RepositoryItemCheckEdit() - CheckBoxEditorForDisplay.ValueChecked = 1 - CheckBoxEditorForDisplay.ValueUnchecked = 0 - GridControlGeo.RepositoryItems.Add(CheckBoxEditorForDisplay) + Dim CheckBoxEditorForDisplay = New RepositoryItemCheckEdit() + CheckBoxEditorForDisplay.ValueChecked = 1 + CheckBoxEditorForDisplay.ValueUnchecked = 0 + GridControlGeo.RepositoryItems.Add(CheckBoxEditorForDisplay) - ' Alle Checkbox Spalten durchgehen und CheckBoxEditor zuweisen - For Each col As String In listcheck - If Not IsNothing(grvwMain.Columns(col)) Then - grvwMain.Columns(col).ColumnEdit = CheckBoxEditorForDisplay - End If - Next + ' Alle Checkbox Spalten durchgehen und CheckBoxEditor zuweisen + For Each col As String In listcheck + If Not IsNothing(grvwMain.Columns(col)) Then + grvwMain.Columns(col).ColumnEdit = CheckBoxEditorForDisplay + End If + Next - For Each col As String In listdate - Dim date_edit As New DevExpress.XtraEditors.Repository.RepositoryItemTimeEdit - Dim date_column As GridColumn = grvwMain.Columns(col) - date_column.DisplayFormat.FormatType = FormatType.DateTime - date_column.DisplayFormat.FormatString = CURRENT_DATE_FORMAT - date_column.OptionsFilter.FilterPopupMode = FilterPopupMode.Date - date_column.ColumnEdit = date_edit - date_column.FilterMode = ColumnFilterMode.Value ' was DisplayText - - date_edit.DisplayFormat.FormatType = FormatType.DateTime - date_edit.DisplayFormat.FormatString = CURRENT_DATE_FORMAT - date_edit.Mask.MaskType = Mask.MaskType.DateTime - date_edit.Mask.EditMask = CURRENT_DATE_FORMAT - date_edit.Mask.UseMaskAsDisplayFormat = True + For Each col As String In listdate + Dim date_edit As New DevExpress.XtraEditors.Repository.RepositoryItemTimeEdit + Dim date_column As GridColumn = grvwMain.Columns(col) + date_column.DisplayFormat.FormatType = FormatType.DateTime + date_column.DisplayFormat.FormatString = CURRENT_DATE_FORMAT + date_column.OptionsFilter.FilterPopupMode = FilterPopupMode.Date + date_column.ColumnEdit = date_edit + date_column.FilterMode = ColumnFilterMode.Value ' was DisplayText + + date_edit.DisplayFormat.FormatType = FormatType.DateTime + date_edit.DisplayFormat.FormatString = CURRENT_DATE_FORMAT + date_edit.Mask.MaskType = Mask.MaskType.DateTime + date_edit.Mask.EditMask = CURRENT_DATE_FORMAT + date_edit.Mask.UseMaskAsDisplayFormat = True - Next + Next - ' Styles for GridControl - grvwMain.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.None - grvwMain.OptionsBehavior.Editable = False - grvwMain.OptionsSelection.EnableAppearanceFocusedCell = False - grvwMain.OptionsSelection.EnableAppearanceFocusedRow = False - grvwMain.OptionsSelection.EnableAppearanceHideSelection = False - - grvwMain.Columns("AddedWhen").DisplayFormat.FormatType = FormatType.DateTime - grvwMain.Columns("AddedWhen").DisplayFormat.FormatString = CURRENT_DATE_FORMAT & " HH:MM:ss" - grvwMain.Columns("ChangedWhen").DisplayFormat.FormatType = FormatType.DateTime - grvwMain.Columns("ChangedWhen").DisplayFormat.FormatString = CURRENT_DATE_FORMAT & " HH:MM:ss" - - grvwMain.Columns("Record-ID").Visible = False - grvwMain.Columns("Form-ID").Visible = False - grvwMain.Columns("ROW_COLOR").Visible = False - Catch ex As Exception - MsgBox("Error while loading GeoData: " & vbNewLine & ex.Message) - End Try + ' Styles for GridControl + grvwMain.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.None + grvwMain.OptionsBehavior.Editable = False + grvwMain.OptionsSelection.EnableAppearanceFocusedCell = False + grvwMain.OptionsSelection.EnableAppearanceFocusedRow = False + grvwMain.OptionsSelection.EnableAppearanceHideSelection = False + + grvwMain.Columns("AddedWhen").DisplayFormat.FormatType = FormatType.DateTime + grvwMain.Columns("AddedWhen").DisplayFormat.FormatString = CURRENT_DATE_FORMAT & " HH:MM:ss" + grvwMain.Columns("ChangedWhen").DisplayFormat.FormatType = FormatType.DateTime + grvwMain.Columns("ChangedWhen").DisplayFormat.FormatString = CURRENT_DATE_FORMAT & " HH:MM:ss" + + grvwMain.Columns("Record-ID").Visible = False + grvwMain.Columns("Form-ID").Visible = False + grvwMain.Columns("ROW_COLOR").Visible = False End Sub + + Private Sub SetGridFilter(records As List(Of Integer)) Try Dim filter As New List(Of String) @@ -167,7 +176,7 @@ Public Class frmGeodataNavigation filter.Add(String.Format("[Record-Id] = {0}", id)) 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()) Catch ex As Exception MsgBox("Error in SetGridFilter: " & vbNewLine & ex.Message) @@ -204,6 +213,10 @@ Public Class frmGeodataNavigation End Sub 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 Dim row As DataRowView = grvwMain.GetRow(e.RowHandle) Dim LATITUDE = row.Item("LATITUDE") @@ -251,10 +264,17 @@ Public Class frmGeodataNavigation txtLat.Text = SelectedPoint.Latitude txtLon.Text = SelectedPoint.Longitude + + SaveCurrentPoint() End If End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click + SaveCurrentPoint() + End Sub + + + Private Sub SaveCurrentPoint() Dim point As GeoPoint = GetCurrentPoint() If point Is Nothing Then @@ -266,20 +286,40 @@ Public Class frmGeodataNavigation Dim currentRow As DataRowView = grvwMain.GetFocusedRow() Dim RecordId As Integer = currentRow.Item("Record-ID") - 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 cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(SQL, conn) + Dim geoDataExists As Boolean = ClassDatabase.Execute_Scalar("SELECT RECORD_ID FROM TBPMO_RECORD_GEODATA WHERE RECORD_ID = " & RecordId) - 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 + If geoDataExists Then + 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 cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(SQL, conn) - conn.Open() - cmd.ExecuteNonQuery() - conn.Close() + 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() + 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 MsgBox("Error while saving Coordinates: " & vbNewLine & ex.Message) From 934732780d5422d64e8a78097fdd7ea5f9a6976d Mon Sep 17 00:00:00 2001 From: JenneJ Date: Wed, 7 Dec 2016 14:39:37 +0100 Subject: [PATCH 3/4] jj 07.12 3 --- .../frmGeodataNavigation.Designer.vb | 41 ++++++++++++++++--- .../frmGeodataNavigation.vb | 35 +++++++++++++--- .../frmGeodataSelect.Designer.vb | 8 +++- app/DD-Record-Organiser/frmGeodataSelect.vb | 36 ++++++++-------- 4 files changed, 90 insertions(+), 30 deletions(-) diff --git a/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb b/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb index 94cdd5d..507db73 100644 --- a/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb +++ b/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb @@ -26,6 +26,7 @@ Partial Class frmGeodataNavigation Dim VectorItemsLayer1 As DevExpress.XtraMap.VectorItemsLayer = New DevExpress.XtraMap.VectorItemsLayer() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmGeodataNavigation)) Me.ToolStrip1 = New System.Windows.Forms.ToolStrip() + Me.btnReload = New System.Windows.Forms.ToolStripButton() Me.StatusStrip1 = New System.Windows.Forms.StatusStrip() Me.tsLabelRecordCount = New System.Windows.Forms.ToolStripStatusLabel() Me.MapControl1 = New DevExpress.XtraMap.MapControl() @@ -35,12 +36,14 @@ Partial Class frmGeodataNavigation Me.SplitContainer1 = New System.Windows.Forms.SplitContainer() Me.GridControlGeo = New DevExpress.XtraGrid.GridControl() Me.grvwMain = New DevExpress.XtraGrid.Views.Grid.GridView() + Me.btnDelete = New System.Windows.Forms.Button() Me.btnSave = New System.Windows.Forms.Button() Me.btnOpenMap = New System.Windows.Forms.Button() Me.Label2 = New System.Windows.Forms.Label() Me.Label1 = New System.Windows.Forms.Label() Me.txtLon = New System.Windows.Forms.TextBox() Me.txtLat = New System.Windows.Forms.TextBox() + Me.ToolStrip1.SuspendLayout() Me.StatusStrip1.SuspendLayout() CType(Me.MapControl1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.XtraTabControl1, System.ComponentModel.ISupportInitialize).BeginInit() @@ -57,12 +60,21 @@ Partial Class frmGeodataNavigation ' 'ToolStrip1 ' + Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.btnReload}) Me.ToolStrip1.Location = New System.Drawing.Point(0, 0) Me.ToolStrip1.Name = "ToolStrip1" Me.ToolStrip1.Size = New System.Drawing.Size(1002, 25) Me.ToolStrip1.TabIndex = 0 Me.ToolStrip1.Text = "ToolStrip1" ' + 'btnReload + ' + Me.btnReload.Image = Global.DD_Record_Organiser.My.Resources.Resources.refresh_16xLG + Me.btnReload.ImageTransparentColor = System.Drawing.Color.Magenta + Me.btnReload.Name = "btnReload" + Me.btnReload.Size = New System.Drawing.Size(81, 22) + Me.btnReload.Text = "Neu laden" + ' 'StatusStrip1 ' Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.tsLabelRecordCount}) @@ -128,6 +140,7 @@ Partial Class frmGeodataNavigation ' 'SplitContainer1.Panel2 ' + Me.SplitContainer1.Panel2.Controls.Add(Me.btnDelete) Me.SplitContainer1.Panel2.Controls.Add(Me.btnSave) Me.SplitContainer1.Panel2.Controls.Add(Me.btnOpenMap) Me.SplitContainer1.Panel2.Controls.Add(Me.Label2) @@ -167,22 +180,36 @@ Partial Class frmGeodataNavigation Me.grvwMain.OptionsView.ShowAutoFilterRow = True Me.grvwMain.OptionsView.ShowHorizontalLines = DevExpress.Utils.DefaultBoolean.[True] ' + 'btnDelete + ' + Me.btnDelete.Image = Global.DD_Record_Organiser.My.Resources.Resources.delete + Me.btnDelete.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.btnDelete.Location = New System.Drawing.Point(379, 96) + Me.btnDelete.Name = "btnDelete" + Me.btnDelete.Size = New System.Drawing.Size(96, 33) + Me.btnDelete.TabIndex = 6 + Me.btnDelete.Text = "Löschen" + Me.btnDelete.UseVisualStyleBackColor = True + ' 'btnSave ' - Me.btnSave.Location = New System.Drawing.Point(379, 96) + Me.btnSave.Image = Global.DD_Record_Organiser.My.Resources.Resources.save_16xLG + Me.btnSave.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.btnSave.Location = New System.Drawing.Point(277, 96) Me.btnSave.Name = "btnSave" Me.btnSave.Size = New System.Drawing.Size(96, 33) Me.btnSave.TabIndex = 5 - Me.btnSave.Text = "Save" + Me.btnSave.Text = "Speichern" Me.btnSave.UseVisualStyleBackColor = True ' 'btnOpenMap ' - Me.btnOpenMap.Location = New System.Drawing.Point(277, 96) + Me.btnOpenMap.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.btnOpenMap.Location = New System.Drawing.Point(277, 41) Me.btnOpenMap.Name = "btnOpenMap" - Me.btnOpenMap.Size = New System.Drawing.Size(96, 33) + Me.btnOpenMap.Size = New System.Drawing.Size(198, 33) Me.btnOpenMap.TabIndex = 4 - Me.btnOpenMap.Text = "Set on Map" + Me.btnOpenMap.Text = "Auf Karte setzen" Me.btnOpenMap.UseVisualStyleBackColor = True ' 'Label2 @@ -233,6 +260,8 @@ Partial Class frmGeodataNavigation Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.Name = "frmGeodataNavigation" Me.Text = "Geodata Navigation" + Me.ToolStrip1.ResumeLayout(False) + Me.ToolStrip1.PerformLayout() Me.StatusStrip1.ResumeLayout(False) Me.StatusStrip1.PerformLayout() CType(Me.MapControl1, System.ComponentModel.ISupportInitialize).EndInit() @@ -267,4 +296,6 @@ Partial Class frmGeodataNavigation Friend WithEvents txtLat As System.Windows.Forms.TextBox Friend WithEvents btnSave As System.Windows.Forms.Button Friend WithEvents btnOpenMap As System.Windows.Forms.Button + Friend WithEvents btnReload As System.Windows.Forms.ToolStripButton + Friend WithEvents btnDelete As System.Windows.Forms.Button End Class diff --git a/app/DD-Record-Organiser/frmGeodataNavigation.vb b/app/DD-Record-Organiser/frmGeodataNavigation.vb index ce234d2..57d27f0 100644 --- a/app/DD-Record-Organiser/frmGeodataNavigation.vb +++ b/app/DD-Record-Organiser/frmGeodataNavigation.vb @@ -106,9 +106,13 @@ Public Class frmGeodataNavigation End Sub Private Sub LoadData() + Dim rowhandle As Integer = grvwMain.FocusedRowHandle + EntityDataTable = ClassDatabase.Return_Datatable(EntitySql) LoadItemList() LoadGridData() + + grvwMain.FocusedRowHandle = rowhandle End Sub @@ -222,8 +226,11 @@ Public Class frmGeodataNavigation Dim LATITUDE = row.Item("LATITUDE") Dim LONGITUDE = row.Item("LONGITUDE") - If LATITUDE Is Nothing Or LONGITUDE Is Nothing Then + Console.WriteLine(LATITUDE.ToString()) + + If IsDBNull(LATITUDE) Or IsDBNull(LONGITUDE) Then e.Appearance.BackColor = Color.Red + e.HighPriority = True End If End If End Sub @@ -316,11 +323,7 @@ Public Class frmGeodataNavigation 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 MsgBox("Error while saving Coordinates: " & vbNewLine & ex.Message) End Try @@ -339,4 +342,26 @@ Public Class frmGeodataNavigation End If End Function + + Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles btnReload.Click + LoadData() + End Sub + + Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click + Try + Dim result As DialogResult = MessageBox.Show("Wollen Sie die Koordinaten für diesen Datensatz löschen?", "Koordinaten löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Question) + + If result = Windows.Forms.DialogResult.Yes Then + Dim currentRow As DataRowView = grvwMain.GetFocusedRow() + Dim RecordId As Integer = currentRow.Item("Record-ID") + Dim sql = "DELETE FROM TBPMO_RECORD_GEODATA WHERE RECORD_ID = " & RecordId + + ClassDatabase.Execute_Scalar(sql) + + LoadData() + End If + Catch ex As Exception + MsgBox("Error while deleting Coordinates:" & vbNewLine & ex.Message) + End Try + End Sub End Class \ No newline at end of file diff --git a/app/DD-Record-Organiser/frmGeodataSelect.Designer.vb b/app/DD-Record-Organiser/frmGeodataSelect.Designer.vb index f045fc6..eb0472e 100644 --- a/app/DD-Record-Organiser/frmGeodataSelect.Designer.vb +++ b/app/DD-Record-Organiser/frmGeodataSelect.Designer.vb @@ -40,7 +40,7 @@ Partial Class frmGeodataSelect 'ToolStrip1 ' Me.ToolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden - Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.btnSave, Me.ToolStripLabel1, Me.ToolStripLabel2, Me.txtLat, Me.ToolStripLabel4, Me.txtLon, Me.tsbtnactivate}) + Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.btnSave, Me.tsbtnactivate, Me.ToolStripLabel2, Me.txtLat, Me.ToolStripLabel4, Me.txtLon, Me.ToolStripLabel1}) Me.ToolStrip1.Location = New System.Drawing.Point(0, 0) Me.ToolStrip1.Name = "ToolStrip1" Me.ToolStrip1.Size = New System.Drawing.Size(934, 25) @@ -49,7 +49,6 @@ Partial Class frmGeodataSelect ' 'btnSave ' - Me.btnSave.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right Me.btnSave.Image = Global.DD_Record_Organiser.My.Resources.Resources.save_16xLG1 Me.btnSave.ImageTransparentColor = System.Drawing.Color.Magenta Me.btnSave.Name = "btnSave" @@ -58,6 +57,7 @@ Partial Class frmGeodataSelect ' 'ToolStripLabel1 ' + Me.ToolStripLabel1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right Me.ToolStripLabel1.Font = New System.Drawing.Font("Segoe UI Semibold", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.ToolStripLabel1.Name = "ToolStripLabel1" Me.ToolStripLabel1.Size = New System.Drawing.Size(146, 22) @@ -65,24 +65,28 @@ Partial Class frmGeodataSelect ' 'ToolStripLabel2 ' + Me.ToolStripLabel2.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right Me.ToolStripLabel2.Name = "ToolStripLabel2" Me.ToolStripLabel2.Size = New System.Drawing.Size(53, 22) Me.ToolStripLabel2.Text = "Latitude:" ' 'txtLat ' + Me.txtLat.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right Me.txtLat.Name = "txtLat" Me.txtLat.Size = New System.Drawing.Size(36, 22) Me.txtLat.Text = "txtLat" ' 'ToolStripLabel4 ' + Me.ToolStripLabel4.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right Me.ToolStripLabel4.Name = "ToolStripLabel4" Me.ToolStripLabel4.Size = New System.Drawing.Size(64, 22) Me.ToolStripLabel4.Text = "Longitude:" ' 'txtLon ' + Me.txtLon.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right Me.txtLon.Name = "txtLon" Me.txtLon.Size = New System.Drawing.Size(40, 22) Me.txtLon.Text = "txtLon" diff --git a/app/DD-Record-Organiser/frmGeodataSelect.vb b/app/DD-Record-Organiser/frmGeodataSelect.vb index dc1efe9..2be8693 100644 --- a/app/DD-Record-Organiser/frmGeodataSelect.vb +++ b/app/DD-Record-Organiser/frmGeodataSelect.vb @@ -29,6 +29,24 @@ Public Class frmGeodataSelect Me.InitializeComponent() End Sub + Private Sub frmGeodataSelect_Load(sender As Object, e As EventArgs) Handles Me.Load + Dim dataProvider As New BingMapDataProvider() + dataProvider.BingKey = BING_KEY + ImageLayer.DataProvider = dataProvider + + Dim storage As New MapItemStorage() + VectorLayer.Data = storage + + If SelectedPoint IsNot Nothing Then + Dim pin = New MapPushpin() + pin.Location = SelectedPoint + ItemStorage.Items.Add(pin) + + txtLat.Text = SelectedPoint.Latitude.ToString() + txtLon.Text = SelectedPoint.Longitude.ToString() + End If + End Sub + Private Sub MapControl1_Click(sender As Object, e As MouseEventArgs) Handles MapControl1.Click If e.Button <> Windows.Forms.MouseButtons.Left Then Exit Sub @@ -53,24 +71,6 @@ Public Class frmGeodataSelect SelectedPoint = point End Sub - Private Sub frmGeodataSelect_Load(sender As Object, e As EventArgs) Handles Me.Load - Dim dataProvider As New BingMapDataProvider() - dataProvider.BingKey = BING_KEY - ImageLayer.DataProvider = dataProvider - - Dim storage As New MapItemStorage() - VectorLayer.Data = storage - - If SelectedPoint IsNot Nothing Then - Dim pin = New MapPushpin() - pin.Location = SelectedPoint - ItemStorage.Items.Add(pin) - - txtLat.Text = SelectedPoint.Latitude.ToString() - txtLon.Text = SelectedPoint.Longitude.ToString() - End If - End Sub - Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click Me.DialogResult = Windows.Forms.DialogResult.OK Me.Close() From 784ec6935842d2d72b37126476d538e13b8fc568 Mon Sep 17 00:00:00 2001 From: JenneJ Date: Wed, 7 Dec 2016 14:40:12 +0100 Subject: [PATCH 4/4] jj 07.12 4 --- app/DD-Record-Organiser/frmGeodataNavigation.vb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/DD-Record-Organiser/frmGeodataNavigation.vb b/app/DD-Record-Organiser/frmGeodataNavigation.vb index 57d27f0..c572570 100644 --- a/app/DD-Record-Organiser/frmGeodataNavigation.vb +++ b/app/DD-Record-Organiser/frmGeodataNavigation.vb @@ -226,8 +226,6 @@ Public Class frmGeodataNavigation Dim LATITUDE = row.Item("LATITUDE") Dim LONGITUDE = row.Item("LONGITUDE") - Console.WriteLine(LATITUDE.ToString()) - If IsDBNull(LATITUDE) Or IsDBNull(LONGITUDE) Then e.Appearance.BackColor = Color.Red e.HighPriority = True