jj 02.12.16 frmGeodataSelect
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
Imports DevExpress.XtraMap
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DevExpress.Utils
|
||||
Imports DevExpress.XtraGrid.Columns
|
||||
|
||||
Public Class frmGeodataNavigation
|
||||
|
||||
@@ -7,6 +10,7 @@ Public Class frmGeodataNavigation
|
||||
Private EntityId As Integer = Nothing
|
||||
Private EntitySql As String = Nothing
|
||||
Private Grid As GridControl = Nothing
|
||||
Private CurrentPoint As GeoPoint = Nothing
|
||||
|
||||
Private ReadOnly Property ImageLayer() As ImageTilesLayer
|
||||
Get
|
||||
@@ -85,7 +89,7 @@ Public Class frmGeodataNavigation
|
||||
gridView.ActiveFilterString = Nothing
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in frmGeodataNavigation_FormClosing: " & vbNewLine & ex.Message)
|
||||
End Try
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub frmGeodataNavigation_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
@@ -101,6 +105,42 @@ Public Class frmGeodataNavigation
|
||||
Dim DT_GEO As DataTable = ClassDatabase.Return_Datatable(sql)
|
||||
GridControlGeo.DataSource = DT_GEO
|
||||
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)
|
||||
|
||||
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
|
||||
|
||||
' 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
|
||||
@@ -147,21 +187,96 @@ Public Class frmGeodataNavigation
|
||||
End Class
|
||||
|
||||
Private Sub XtraTabControl1_TabIndexChanged(sender As Object, e As EventArgs) Handles XtraTabControl1.TabIndexChanged
|
||||
|
||||
|
||||
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
|
||||
Dim row As DataRowView = grvwMain.GetRow(e.RowHandle)
|
||||
Dim LATITUDE = row.Item("LATITUDE")
|
||||
Dim LONGITUDE = row.Item("LONGITUDE")
|
||||
|
||||
If LATITUDE Is Nothing Or LONGITUDE Is Nothing Then
|
||||
e.Appearance.BackColor = Color.Red
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub grvwMain_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles grvwMain.FocusedRowChanged
|
||||
'TODO: Load LatLon in Splitter2
|
||||
|
||||
Dim currentRow As DataRowView = grvwMain.GetFocusedRow()
|
||||
Dim lat As Decimal = currentRow.Item("LATITUDE")
|
||||
Dim lon As Decimal = currentRow.Item("LONGITUDE")
|
||||
Dim lat, lon As Decimal
|
||||
|
||||
txtLat.Text = lat
|
||||
txtLon.Text = lon
|
||||
Try
|
||||
lat = currentRow.Item("LATITUDE")
|
||||
lon = currentRow.Item("LONGITUDE")
|
||||
Catch ex As InvalidCastException
|
||||
lat = -1
|
||||
lon = -1
|
||||
End Try
|
||||
|
||||
If lat = -1 And lon = -1 Then
|
||||
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
|
||||
|
||||
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()
|
||||
|
||||
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
|
||||
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)
|
||||
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")
|
||||
|
||||
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)
|
||||
|
||||
cmd.Parameters.Add("@lat", SqlDbType.Decimal).Value = lat
|
||||
cmd.Parameters.Add("@lon", SqlDbType.Decimal).Value = lon
|
||||
cmd.Parameters.Add("@who", SqlDbType.VarChar).Value = Environment.UserName
|
||||
cmd.Parameters.Add("@recordid", SqlDbType.Int).Value = RecordId
|
||||
|
||||
conn.Open()
|
||||
cmd.ExecuteNonQuery()
|
||||
conn.Close()
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox("Error while saving Coordinates: " & vbNewLine & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user