Make it possible to delete rows

This commit is contained in:
Jonathan Jenne
2021-11-04 11:43:26 +01:00
parent c6622ccbbc
commit 437569919f
10 changed files with 976 additions and 810 deletions

View File

@@ -31,10 +31,10 @@ Public Class frmImportMain
Private GridLoader As GridLoader
Private GridBuilder As GridBuilder
Private CurrentSchemaName As String
Private CurrentSchema As Schema
Private CurrentDocument As Document
Private CurrentSchemaName As String = Nothing
Private CurrentSchema As Schema = Nothing
Private CurrentGrid As GridControl = Nothing
Private CurrentDocument As Document = Nothing
Public Sub New()
InitializeComponent()
@@ -140,6 +140,10 @@ Public Class frmImportMain
CurrentSchema = SchemaLoader.GetSchemaFromFile(CurrentSchemaName)
Grids = CreateGridsAndColumns(CurrentSchema)
For Each oGrid As GridControl In Grids
AddHandler oGrid.GotFocus, AddressOf Grid_Focus
Next
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Winline_Daten)
Finally
@@ -148,6 +152,9 @@ Public Class frmImportMain
End Try
End Sub
Private Sub Grid_Focus(sender As GridControl, e As EventArgs)
CurrentGrid = sender
End Sub
Private Function CreateGridsAndColumns(pSchema As Schemas.Schema) As List(Of GridControl)
Dim oGrids As New List(Of GridControl)
@@ -155,30 +162,26 @@ Public Class frmImportMain
For Each oTable In pSchema.Tables
If oTableCounter = 0 Then
Dim oGrid = GridLoader.GetGridFromElement(oTable)
Dim oGrid = GridLoader.GetGridFromElement(GridControl1, oTable)
AddHandler oGrid.DoubleClick, AddressOf Grid_MouseDoubleClick
SplitContainerGrids1.Panel1.Controls.Add(oGrid)
oGrids.Add(oGrid)
End If
If oTableCounter = 1 Then
Dim oGrid = GridLoader.GetGridFromElement(oTable)
Dim oGrid = GridLoader.GetGridFromElement(GridControl2, oTable)
AddHandler oGrid.DoubleClick, AddressOf Grid_MouseDoubleClick
SplitContainerGrids1.Panel2.Controls.Add(oGrid)
oGrids.Add(oGrid)
End If
If oTableCounter = 2 Then
Dim oGrid = GridLoader.GetGridFromElement(oTable)
Dim oGrid = GridLoader.GetGridFromElement(GridControl3, oTable)
AddHandler oGrid.DoubleClick, AddressOf Grid_MouseDoubleClick
SplitContainerGrids2.Panel1.Controls.Add(oGrid)
oGrids.Add(oGrid)
End If
If oTableCounter = 3 Then
Dim oGrid = GridLoader.GetGridFromElement(oTable)
Dim oGrid = GridLoader.GetGridFromElement(GridControl4, oTable)
AddHandler oGrid.DoubleClick, AddressOf Grid_MouseDoubleClick
SplitContainerGrids2.Panel2.Controls.Add(oGrid)
oGrids.Add(oGrid)
End If
@@ -296,6 +299,10 @@ Public Class frmImportMain
Try
Dim oDatasources As New Dictionary(Of String, DataTable)
For Each oGrid In Grids
oGrid.DataSource = Nothing
Next
' List of Root Elements in XML
For Each oRow In pDocument.Rows
Dim oGrid As GridControl = Grids.
@@ -314,6 +321,7 @@ Public Class frmImportMain
oDatasources.Add(oRow.Name, oTable)
oGrid.DataSource = Nothing
oGrid.DataSource = oTable
End If
@@ -440,5 +448,31 @@ Public Class frmImportMain
oForm.ShowDialog()
End Sub
Private Sub btnRemoveRow_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnRemoveRow.ItemClick
If CurrentGrid Is Nothing Then
Exit Sub
End If
Dim oMessage As String = "Wollen Sie die ausgewählte Zeile wirklich löschen?"
If MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.Yes Then
' Get GUID of currently selected row
Dim oView As GridView = CurrentGrid.FocusedView
Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle)
Dim oGuid = oRow.Row.Item("GUID")
' Get currently selected document
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oNewRows = oDocument.Rows.
Where(Function(r) r.Id.ToString <> oGuid).
ToList()
oDocument.Rows = oNewRows
Dim oIndex = DocumentLoader.Files.IndexOf(oDocument)
DocumentLoader.Files.Item(oIndex) = oDocument
lookupMandator.EditValue = oDocument.Mandator
LoadDocument(oDocument)
End If
End Sub
End Class