jj 07.12 1

This commit is contained in:
JenneJ 2016-12-07 12:10:08 +01:00
parent 481e767a99
commit 1f154675a2
2 changed files with 79 additions and 60 deletions

View File

@ -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
'

View File

@ -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 lat = -1 And lon = -1 Then
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 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