diff --git a/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb b/app/DD-Record-Organiser/frmGeodataNavigation.Designer.vb index 6c031a4..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) @@ -164,24 +177,39 @@ 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] ' + '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 ' - 'Button1 + 'btnOpenMap ' - Me.btnOpenMap.Location = New System.Drawing.Point(277, 96) - Me.btnOpenMap.Name = "Button1" - Me.btnOpenMap.Size = New System.Drawing.Size(96, 33) + 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(198, 33) Me.btnOpenMap.TabIndex = 4 - Me.btnOpenMap.Text = "Set on Map" + Me.btnOpenMap.Text = "Auf Karte setzen" Me.btnOpenMap.UseVisualStyleBackColor = True ' 'Label2 @@ -209,7 +237,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 +245,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 ' @@ -234,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() @@ -268,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 a357a93..c572570 100644 --- a/app/DD-Record-Organiser/frmGeodataNavigation.vb +++ b/app/DD-Record-Organiser/frmGeodataNavigation.vb @@ -3,15 +3,19 @@ Imports DevExpress.XtraEditors Imports DevExpress.XtraGrid Imports DevExpress.Utils Imports DevExpress.XtraGrid.Columns +Imports DevExpress.XtraEditors.Repository 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 Return CType(MapControl1.Layers("ImageLayer"), ImageTilesLayer) @@ -24,26 +28,16 @@ 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) 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") @@ -57,13 +51,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 @@ -78,18 +65,21 @@ 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 - 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 + + 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.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 @@ -98,54 +88,90 @@ Public Class frmGeodataNavigation dataProvider.BingKey = BING_KEY 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_ENTITY_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 - - Dim listcheck As List(Of String) = ClassHelper.Return_listcheck(CURRENT_ENTITY_ID) - Dim listdate As List(Of String) = ClassHelper.Return_listdate(CURRENT_ENTITY_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 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() + Dim rowhandle As Integer = grvwMain.FocusedRowHandle + + EntityDataTable = ClassDatabase.Return_Datatable(EntitySql) + LoadItemList() + LoadGridData() + + grvwMain.FocusedRowHandle = rowhandle + End Sub + + + 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 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) + 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 + End Sub + + + Private Sub SetGridFilter(records As List(Of Integer)) Try Dim filter As New List(Of String) @@ -154,7 +180,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) @@ -191,14 +217,18 @@ 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 = 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") Dim LONGITUDE = row.Item("LONGITUDE") - If LATITUDE Is Nothing Or LONGITUDE Is Nothing Then + If IsDBNull(LATITUDE) Or IsDBNull(LONGITUDE) Then e.Appearance.BackColor = Color.Red + e.HighPriority = True End If End If End Sub @@ -207,76 +237,129 @@ 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 + + SaveCurrentPoint() + 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) + SaveCurrentPoint() + End Sub + + + Private Sub SaveCurrentPoint() + 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") - 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 = 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 + 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 + + LoadData() 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 + + 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() diff --git a/app/DD-Record-Organiser/frmWDChangeDoctype.Designer.vb b/app/DD-Record-Organiser/frmWDChangeDoctype.Designer.vb new file mode 100644 index 0000000..6783a30 --- /dev/null +++ b/app/DD-Record-Organiser/frmWDChangeDoctype.Designer.vb @@ -0,0 +1,149 @@ + _ +Partial Class frmWDChangeDoctype + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + Me.OK_Button = New System.Windows.Forms.Button() + Me.Cancel_Button = New System.Windows.Forms.Button() + Me.cmbDokumentart = New System.Windows.Forms.ComboBox() + Me.Label2 = New System.Windows.Forms.Label() + Me.txtFilepath = New System.Windows.Forms.TextBox() + Me.Label1 = New System.Windows.Forms.Label() + Me.Label3 = New System.Windows.Forms.Label() + Me.TextBox1 = New System.Windows.Forms.TextBox() + Me.SuspendLayout() + ' + 'OK_Button + ' + Me.OK_Button.Image = Global.DD_Record_Organiser.My.Resources.Resources.key_go + Me.OK_Button.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.OK_Button.Location = New System.Drawing.Point(12, 152) + Me.OK_Button.Name = "OK_Button" + Me.OK_Button.Size = New System.Drawing.Size(391, 23) + Me.OK_Button.TabIndex = 0 + Me.OK_Button.Text = "Dokumentart ändern" + ' + 'Cancel_Button + ' + Me.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Cancel_Button.Location = New System.Drawing.Point(446, 152) + Me.Cancel_Button.Name = "Cancel_Button" + Me.Cancel_Button.Size = New System.Drawing.Size(124, 23) + Me.Cancel_Button.TabIndex = 1 + Me.Cancel_Button.Text = "Abbrechen" + ' + 'cmbDokumentart + ' + Me.cmbDokumentart.DisplayMember = "DOKUMENTTYPE" + Me.cmbDokumentart.Font = New System.Drawing.Font("Segoe UI Semibold", 9.75!, System.Drawing.FontStyle.Bold) + Me.cmbDokumentart.FormattingEnabled = True + Me.cmbDokumentart.Location = New System.Drawing.Point(12, 70) + Me.cmbDokumentart.Name = "cmbDokumentart" + Me.cmbDokumentart.Size = New System.Drawing.Size(391, 25) + Me.cmbDokumentart.TabIndex = 7 + Me.cmbDokumentart.ValueMember = "DOKUMENTTYPE_ID" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Font = New System.Drawing.Font("Segoe UI Semibold", 9.75!, System.Drawing.FontStyle.Bold) + Me.Label2.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.Label2.Location = New System.Drawing.Point(9, 50) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(188, 17) + Me.Label2.TabIndex = 6 + Me.Label2.Text = "Wählen Sie eine Dokumentart" + ' + 'txtFilepath + ' + Me.txtFilepath.Location = New System.Drawing.Point(12, 26) + Me.txtFilepath.Name = "txtFilepath" + Me.txtFilepath.ReadOnly = True + Me.txtFilepath.Size = New System.Drawing.Size(558, 21) + Me.txtFilepath.TabIndex = 5 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.Label1.Location = New System.Drawing.Point(9, 8) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(58, 13) + Me.Label1.TabIndex = 4 + Me.Label1.Text = "Dateipfad:" + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Font = New System.Drawing.Font("Segoe UI Semibold", 9.75!, System.Drawing.FontStyle.Bold) + Me.Label3.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.Label3.Location = New System.Drawing.Point(12, 98) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(289, 17) + Me.Label3.TabIndex = 8 + Me.Label3.Text = "oder geben sie eine Dokumentart manuell ein:" + ' + 'TextBox1 + ' + Me.TextBox1.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.TextBox1.Location = New System.Drawing.Point(12, 118) + Me.TextBox1.Name = "TextBox1" + Me.TextBox1.Size = New System.Drawing.Size(391, 23) + Me.TextBox1.TabIndex = 9 + ' + 'frmWDChangeDoctype + ' + Me.AcceptButton = Me.OK_Button + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.CancelButton = Me.Cancel_Button + Me.ClientSize = New System.Drawing.Size(585, 182) + Me.Controls.Add(Me.Cancel_Button) + Me.Controls.Add(Me.OK_Button) + Me.Controls.Add(Me.TextBox1) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.cmbDokumentart) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.txtFilepath) + Me.Controls.Add(Me.Label1) + Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "frmWDChangeDoctype" + Me.ShowInTaskbar = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Dokumentart ändern" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents OK_Button As System.Windows.Forms.Button + Friend WithEvents Cancel_Button As System.Windows.Forms.Button + Friend WithEvents cmbDokumentart As System.Windows.Forms.ComboBox + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents txtFilepath As System.Windows.Forms.TextBox + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents TextBox1 As System.Windows.Forms.TextBox + +End Class diff --git a/app/DD-Record-Organiser/frmWDChangeDoctype.resx b/app/DD-Record-Organiser/frmWDChangeDoctype.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/app/DD-Record-Organiser/frmWDChangeDoctype.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file