403 lines
17 KiB
VB.net
403 lines
17 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports DevExpress.Utils
|
|
Imports DevExpress.XtraGrid
|
|
Imports DevExpress.XtraPrinting
|
|
|
|
Public Class frmMonitor
|
|
Dim DT_MONITOR_KONFIG As DataTable
|
|
Dim GRID1_TITLE As String
|
|
Dim GRID2_TITLE As String
|
|
Dim GRID2_SQL As String
|
|
Dim GRID3_TITLE As String
|
|
Dim GRID3_SQL As String
|
|
Dim GRID4_TITLE As String
|
|
Dim GRID4_SQL As String
|
|
Private _ActiveGrid As GridControl = Nothing
|
|
Private _frmDocView As frmDocView 'You need a reference to Form1
|
|
Dim FormShown As Boolean = False
|
|
Private Sub GridView1_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridView1.FocusedRowChanged
|
|
If FormShown = False Then Exit Sub
|
|
Load_Detail()
|
|
|
|
End Sub
|
|
Sub Load_Detail()
|
|
Try
|
|
Dim oDocID = GridView1.GetFocusedRowCellValue(GridView1.Columns("DocID"))
|
|
If IsNothing(oDocID) Then
|
|
Exit Sub
|
|
End If
|
|
Dim oDocPath
|
|
Try
|
|
oDocPath = GridView1.GetFocusedRowCellValue(GridView1.Columns("FULL_FILE_PATH"))
|
|
Catch ex As Exception
|
|
LOGGER.Warn($"Error getting DocPath in Monitor: {ex.Message}")
|
|
End Try
|
|
Dim oDetailSQL = GRID2_SQL
|
|
oDetailSQL = oDetailSQL.Replace("@DocID", oDocID)
|
|
oDetailSQL = oDetailSQL.ToLower.Replace("@idbobjid", oDocID)
|
|
Dim oDT2 As DataTable = ClassDatabase.Return_Datatable(oDetailSQL)
|
|
If Not IsNothing(oDT2) Then
|
|
GridView2.Columns.Clear()
|
|
GridControl2.DataSource = oDT2
|
|
End If
|
|
If DT_MONITOR_KONFIG.Rows.Count > 2 Then
|
|
oDetailSQL = GRID3_SQL
|
|
oDetailSQL = oDetailSQL.Replace("@DocID", oDocID)
|
|
oDetailSQL = oDetailSQL.ToLower.Replace("@idbobjid", oDocID)
|
|
Dim oDT3 As DataTable = ClassDatabase.Return_Datatable(oDetailSQL)
|
|
If Not IsNothing(oDT3) Then
|
|
GridView3.Columns.Clear()
|
|
GridControl3.DataSource = oDT3
|
|
End If
|
|
If DT_MONITOR_KONFIG.Rows.Count = 4 Then
|
|
oDetailSQL = GRID4_SQL
|
|
oDetailSQL = oDetailSQL.Replace("@DocID", oDocID)
|
|
oDetailSQL = oDetailSQL.ToLower.Replace("@idbobjid", oDocID)
|
|
Dim oDT4 As DataTable = ClassDatabase.Return_Datatable(oDetailSQL)
|
|
If Not IsNothing(oDT4) Then
|
|
GridView4.Columns.Clear()
|
|
GridControl4.DataSource = oDT4
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If BarButtonItem3.Caption <> "DocView aktivieren" And oDocPath <> "" Then
|
|
If Not Application.OpenForms().OfType(Of frmValidator).Any Then
|
|
frmDocView.Show()
|
|
_frmDocView = frmDocView
|
|
End If
|
|
_frmDocView.LoadFile(oDocPath)
|
|
|
|
End If
|
|
|
|
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error GridView1.FocusedRowChanged:")
|
|
End Try
|
|
End Sub
|
|
Private Sub frmMonitor_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
Load_Grid_Data()
|
|
|
|
Select Case DT_MONITOR_KONFIG.Rows.Count
|
|
Case 2
|
|
LoadGrid1Layout()
|
|
LoadGrid2Layout()
|
|
SplitContainerControl1.SplitterPosition = CONFIG.Config.MonitorSplitter1_Distance
|
|
Case 3
|
|
LoadGrid1Layout()
|
|
LoadGrid2Layout()
|
|
LoadGrid3Layout()
|
|
SplitContainerControl1.SplitterPosition = CONFIG.Config.MonitorSplitter1_Distance
|
|
SplitContainerControl2.SplitterPosition = CONFIG.Config.MonitorSplitter2_Distance
|
|
Case 4
|
|
LoadGrid1Layout()
|
|
LoadGrid2Layout()
|
|
LoadGrid3Layout()
|
|
LoadGrid4Layout()
|
|
SplitContainerControl1.SplitterPosition = CONFIG.Config.MonitorSplitter1_Distance
|
|
SplitContainerControl2.SplitterPosition = CONFIG.Config.MonitorSplitter2_Distance
|
|
SplitContainerControl3.SplitterPosition = CONFIG.Config.MonitorSplitter3_Distance
|
|
End Select
|
|
|
|
End Sub
|
|
Sub Load_Grid_Data()
|
|
Try
|
|
FormShown = False
|
|
Dim oSQL = "SELECT * FROM TBPM_MONITOR_KONFIG"
|
|
DT_MONITOR_KONFIG = ClassDatabase.Return_Datatable(oSQL)
|
|
If Not IsNothing(DT_MONITOR_KONFIG) Then
|
|
If DT_MONITOR_KONFIG.Rows.Count >= 1 Then
|
|
oSQL = DT_MONITOR_KONFIG.Rows(0).Item("GRID_SQL")
|
|
GridView1.Columns.Clear()
|
|
Dim oDTGRID1 As DataTable = ClassDatabase.Return_Datatable(oSQL)
|
|
GridControl1.DataSource = oDTGRID1
|
|
|
|
GRID1_TITLE = DT_MONITOR_KONFIG.Rows(0).Item("GRID_TITLE")
|
|
GridView1.ViewCaption = GRID1_TITLE
|
|
Try
|
|
'GridView1.Columns.Item("FULL_FILE_PATH").Visible = False
|
|
Catch ex As Exception
|
|
LOGGER.Info($"Attention: No Column FULL_FILE_PATH in GridView1")
|
|
End Try
|
|
Select Case DT_MONITOR_KONFIG.Rows.Count
|
|
Case 2
|
|
SplitContainerControl2.Collapsed = True
|
|
Case 3
|
|
SplitContainerControl3.Collapsed = True
|
|
Case Else
|
|
SplitContainerControl2.Collapsed = False
|
|
SplitContainerControl3.Collapsed = False
|
|
End Select
|
|
If DT_MONITOR_KONFIG.Rows.Count > 1 Then
|
|
GRID2_TITLE = DT_MONITOR_KONFIG.Rows(1).Item("GRID_TITLE")
|
|
GRID2_SQL = DT_MONITOR_KONFIG.Rows(1).Item("GRID_SQL")
|
|
GridView2.ViewCaption = GRID2_TITLE
|
|
Select Case DT_MONITOR_KONFIG.Rows.Count
|
|
Case 3
|
|
GRID3_TITLE = DT_MONITOR_KONFIG.Rows(2).Item("GRID_TITLE")
|
|
GRID3_SQL = DT_MONITOR_KONFIG.Rows(2).Item("GRID_SQL")
|
|
GridView3.ViewCaption = GRID3_TITLE
|
|
Case 4
|
|
GRID3_TITLE = DT_MONITOR_KONFIG.Rows(3).Item("GRID_TITLE")
|
|
GRID3_SQL = DT_MONITOR_KONFIG.Rows(3).Item("GRID_SQL")
|
|
GridView3.ViewCaption = GRID3_TITLE
|
|
GRID4_TITLE = DT_MONITOR_KONFIG.Rows(3).Item("GRID_TITLE")
|
|
GRID4_SQL = DT_MONITOR_KONFIG.Rows(3).Item("GRID_SQL")
|
|
GridView4.ViewCaption = GRID4_TITLE
|
|
End Select
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in Load_Grid_Data:")
|
|
End Try
|
|
End Sub
|
|
Sub LoadGrid1Layout()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid1.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
If File.Exists(xml) Then
|
|
GridView1.RestoreLayoutFromXml(xml, OptionsLayoutBase.FullLayout)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while restoring layout 1: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub LoadGrid2Layout()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid2.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
If File.Exists(xml) Then
|
|
GridView2.RestoreLayoutFromXml(xml, OptionsLayoutBase.FullLayout)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while restoring layout 2: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub LoadGrid3Layout()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid3.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
If File.Exists(xml) Then
|
|
GridView3.RestoreLayoutFromXml(xml, OptionsLayoutBase.FullLayout)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while restoring layout 3: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub LoadGrid4Layout()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid4.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
If File.Exists(xml) Then
|
|
GridView4.RestoreLayoutFromXml(xml, OptionsLayoutBase.FullLayout)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while restoring layout 4: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Sub SaveGrid1layout()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid1.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
GridView1.SaveLayoutToXml(xml, OptionsLayoutBase.FullLayout)
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while saving Grid1Layout: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub RemoveLayout()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid1.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
IO.File.Delete(xml)
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while saving RemoveLayout1: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub SaveGrid2layout()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid2.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
GridView2.SaveLayoutToXml(xml, OptionsLayoutBase.FullLayout)
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while saving Grid2Layout: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub RemoveLayout2()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid2.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
IO.File.Delete(xml)
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while saving RemoveLayout2: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub SaveGrid3layout()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid3.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
GridView3.SaveLayoutToXml(xml, OptionsLayoutBase.FullLayout)
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while saving Grid3Layout: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub RemoveLayout3()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid3.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
IO.File.Delete(xml)
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while saving RemoveLayout3: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub SaveGrid4layout()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid4.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
GridView4.SaveLayoutToXml(xml, OptionsLayoutBase.FullLayout)
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while saving Grid4Layout: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
Sub RemoveLayout4()
|
|
Try
|
|
Dim Filename As String = String.Format("DevExpressGridViewMonitor_UserLayout_Grid4.xml")
|
|
Dim xml As String = System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
|
|
IO.File.Delete(xml)
|
|
Catch ex As Exception
|
|
LOGGER.Error(ex)
|
|
LOGGER.Info("Error while saving RemoveLayout4: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub frmMonitor_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|
Select Case DT_MONITOR_KONFIG.Rows.Count
|
|
Case 2
|
|
SaveGrid1layout()
|
|
SaveGrid2layout()
|
|
Case 3
|
|
SaveGrid1layout()
|
|
SaveGrid2layout()
|
|
SaveGrid3layout()
|
|
CONFIG.Config.MonitorSplitter1_Distance = SplitContainerControl1.SplitterPosition
|
|
CONFIG.Config.MonitorSplitter2_Distance = SplitContainerControl2.SplitterPosition
|
|
|
|
Case 4
|
|
SaveGrid1layout()
|
|
SaveGrid2layout()
|
|
SaveGrid3layout()
|
|
SaveGrid4layout()
|
|
CONFIG.Config.MonitorSplitter1_Distance = SplitContainerControl1.SplitterPosition
|
|
CONFIG.Config.MonitorSplitter2_Distance = SplitContainerControl2.SplitterPosition
|
|
CONFIG.Config.MonitorSplitter3_Distance = SplitContainerControl3.SplitterPosition
|
|
End Select
|
|
CONFIG.Save()
|
|
Try
|
|
_frmDocView.Close()
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub frmMonitor_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
|
FormShown = True
|
|
Load_Detail()
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
|
Dim oActiveGrid = GetActiveGridControl()
|
|
|
|
If oActiveGrid IsNot Nothing Then
|
|
|
|
|
|
XtraSaveFileDialog1.FileName = oActiveGrid.Name & ".xlsx"
|
|
XtraSaveFileDialog1.DefaultExt = ".xlsx"
|
|
|
|
If XtraSaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
|
|
Dim oOptions As New XlsxExportOptions() With {
|
|
.ExportMode = XlsxExportMode.SingleFile
|
|
}
|
|
oActiveGrid.ExportToXlsx(XtraSaveFileDialog1.FileName, oOptions)
|
|
End If
|
|
Else
|
|
MessageBox.Show("Bitte wählen Sie eine Tabelle aus, die Sie exportieren möchten", Text, MessageBoxButtons.OK)
|
|
End If
|
|
End Sub
|
|
Private Function GetActiveGridControl() As GridControl
|
|
If _ActiveGrid Is Nothing Then
|
|
Return Nothing
|
|
End If
|
|
|
|
Return _ActiveGrid
|
|
End Function
|
|
|
|
Private Sub GridControl1_Enter(sender As Object, e As EventArgs) Handles GridControl1.Enter, GridControl1.Enter, GridControl2.Enter, GridControl3.Enter, GridControl4.Enter
|
|
_ActiveGrid = sender
|
|
End Sub
|
|
|
|
Private Sub frmMonitor_HelpButtonClicked(sender As Object, e As CancelEventArgs) Handles Me.HelpButtonClicked
|
|
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
|
|
If BarButtonItem3.Caption = "DocView aktivieren" Then
|
|
BarButtonItem3.Caption = "DocView deaktivieren"
|
|
BarButtonItem3.Down = True
|
|
Dim oDocPath
|
|
Try
|
|
oDocPath = GridView1.GetFocusedRowCellValue(GridView1.Columns("FULL_FILE_PATH"))
|
|
Catch ex As Exception
|
|
LOGGER.Warn($"Error getting DocPath in Monitor: {ex.Message}")
|
|
End Try
|
|
If oDocPath <> "" Then
|
|
If Not Application.OpenForms().OfType(Of frmValidator).Any Then
|
|
frmDocView.Show()
|
|
_frmDocView = frmDocView
|
|
End If
|
|
_frmDocView.LoadFile(oDocPath)
|
|
Me.SendToBack()
|
|
End If
|
|
Else
|
|
BarButtonItem3.Caption = "DocView aktivieren"
|
|
BarButtonItem3.Down = False
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
|
|
Select Case DT_MONITOR_KONFIG.Rows.Count
|
|
Case 2
|
|
RemoveLayout()
|
|
RemoveLayout2()
|
|
Case 3
|
|
RemoveLayout()
|
|
RemoveLayout2()
|
|
RemoveLayout3()
|
|
Case 4
|
|
RemoveLayout()
|
|
RemoveLayout2()
|
|
RemoveLayout3()
|
|
RemoveLayout4()
|
|
End Select
|
|
Load_Grid_Data()
|
|
End Sub
|
|
End Class |