231 lines
7.7 KiB
VB.net
231 lines
7.7 KiB
VB.net
Imports System.Windows.Documents
|
|
Imports VERAG_PROG_ALLGEMEIN
|
|
|
|
Public Class usrCntlDatenarchiv
|
|
|
|
|
|
Dim DatenarchivBind As cEasyBinding
|
|
Public table
|
|
Public BIND_DB
|
|
Private EditRow As Integer = -1
|
|
Sub New(table, BIND_DB)
|
|
Me.table = table
|
|
Me.BIND_DB = BIND_DB
|
|
InitializeComponent()
|
|
End Sub
|
|
|
|
|
|
Private Sub usrCntlDatenarchiv_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
|
|
loaddgv()
|
|
|
|
'cboPartnersystem.Items.Clear()
|
|
Dim distinctDT As DataTable = DatenarchivBind.bindingdataTable.DefaultView.ToTable(True, "Param_system")
|
|
|
|
cboPartnersystem.Items.Add(New MyListItem("", ""))
|
|
For Each d As DataRow In distinctDT.Rows
|
|
If Not cboPartnersystem.Items.Contains(d.Item(0)) Then cboPartnersystem.Items.Add(d.Item(0))
|
|
Next
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub btnSuche_Click(sender As Object, e As EventArgs) Handles btnSuche.Click
|
|
Me.Cursor = Cursors.WaitCursor
|
|
|
|
loaddgv()
|
|
|
|
Me.Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Function getAPIList() As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
|
|
|
|
Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
|
|
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Param_system", cboPartnersystem._value))
|
|
|
|
Return list
|
|
|
|
End Function
|
|
|
|
Function getDatenarchivwhere() As String
|
|
|
|
Dim sqlstr = " and Param_testsystem = " & IIf(cbxTestsystem.Checked, "1 ", "0 ")
|
|
If cboPartnersystem._value <> "" Then sqlstr &= " And [Param_system] = '" & cboPartnersystem._value & "'"
|
|
|
|
Return sqlstr
|
|
End Function
|
|
|
|
|
|
Private Sub DataGridView_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView.CellDoubleClick
|
|
Me.Cursor = Cursors.WaitCursor
|
|
Dim tmprowindex As Integer = e.RowIndex
|
|
If DataGridView.Columns(e.ColumnIndex).Name = "open" Then
|
|
|
|
If DataGridView.CurrentRow.Cells("Param_value").Value IsNot DBNull.Value AndAlso DataGridView.CurrentRow.Cells("Param_value").Value.ToString.StartsWith("\\") Then
|
|
Process.Start(DataGridView.CurrentRow.Cells("Param_value").Value)
|
|
End If
|
|
Else
|
|
|
|
End If
|
|
Me.Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Private Sub cboPartnersystem_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPartnersystem.SelectedIndexChanged
|
|
btnSuche_Click(sender, e)
|
|
End Sub
|
|
|
|
|
|
Public Sub loaddgv()
|
|
|
|
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = cbxTestsystem.Checked
|
|
|
|
Try
|
|
DatenarchivBind = New cEasyBinding(BIND_DB)
|
|
|
|
|
|
Dim sqlstr As String = ""
|
|
Dim TopMax = If(IsNumeric(txtMaxSrch.Text), " TOP " & txtMaxSrch.Text, "")
|
|
|
|
|
|
DatenarchivBind.initBinding("SELECT " & TopMax & " [Param_name],[Param_value], [Param_system] FROM " & table & " WHERE 1 = 1 " & getDatenarchivwhere(), table)
|
|
|
|
DataGridView.DataSource = DatenarchivBind.bindingdataTable
|
|
|
|
|
|
With DataGridView
|
|
|
|
If .RowCount = 0 Then Me.Cursor = Cursors.Default : Exit Sub
|
|
.RowHeadersVisible = False
|
|
.ReadOnly = False
|
|
'.SelectionMode = DataGridViewSelectionMode.FullRowSelect
|
|
.MultiSelect = False
|
|
|
|
|
|
For Each cc As DataGridViewColumn In .Columns
|
|
If cc.Name.ToLower.Contains("param_") Then
|
|
cc.HeaderText = cc.Name.Replace("Param_", "")
|
|
If cc.Name.ToLower.Contains("value") Then
|
|
cc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
|
|
Else
|
|
cc.Width = 200
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
|
|
lblErgebnis.Text = "Ergebnisse: " & .RowCount
|
|
|
|
|
|
If .Columns("open") Is Nothing Then
|
|
|
|
Dim c As New DataGridViewImageColumn
|
|
c.Name = "open" : c.HeaderText = "open"
|
|
c.Image = New Bitmap(1, 1)
|
|
c.Width = 40 : c.DefaultCellStyle.Padding = New Padding(2) : c.DefaultCellStyle.BackColor = Color.White
|
|
c.DefaultCellStyle.Tag = "open"
|
|
.Columns.Add(c)
|
|
|
|
End If
|
|
|
|
For Each r As DataGridViewRow In .Rows
|
|
|
|
If r.Cells("Param_value").Value IsNot DBNull.Value AndAlso r.Cells("Param_value").Value <> "" Then
|
|
Dim path As New System.IO.DirectoryInfo(r.Cells("Param_value").Value)
|
|
|
|
If path.Exists Then
|
|
DirectCast(r.Cells("open"), DataGridViewImageCell).Value = My.Resources.search
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
|
|
End With
|
|
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnSave.Click
|
|
|
|
If DataGridView.Columns.Count = 0 Or DataGridView.SelectedRows.Count = 0 Then 'alles gelöscht oder markierte Zeile gelöscht
|
|
DatenarchivBind.updateBinding()
|
|
Exit Sub
|
|
End If
|
|
|
|
If DataGridView.CurrentRow.Cells("Param_name").ToString <> "" AndAlso DataGridView.CurrentRow.Cells("Param_value").ToString <> "" AndAlso DataGridView.CurrentRow.Cells("Param_system").ToString <> "" AndAlso EditRow >= 0 Then
|
|
DatenarchivBind.updateBinding()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub DataGridView_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView.EditingControlShowing
|
|
EditRow = DataGridView.CurrentRow.Index
|
|
End Sub
|
|
|
|
Private Sub DataGridView_SelectionChanged(sender As Object, e As EventArgs) Handles DataGridView.SelectionChanged
|
|
If EditRow >= 0 Then
|
|
Dim new_row As Integer = EditRow
|
|
EditRow = -1
|
|
DataGridView.CurrentCell = DataGridView.Rows(new_row).Cells(
|
|
DataGridView.CurrentCell.ColumnIndex)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
|
|
Dim jahr As Integer = 2026
|
|
Dim zupruefendeDokumente As String = " select top(100000) * from [tblDatenarchiv_Collection] where Year(coll_date) = " & jahr & " and coll_archiv = 0 and isnull(coll_pfad,'') <> '' order by coll_date desc "
|
|
|
|
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
Dim Datenarchiv_DOKS As DataTable = SQL.loadDgvBySql(zupruefendeDokumente, "FMZOLL")
|
|
Dim dtFehlendeDOKS = Datenarchiv_DOKS.Clone()
|
|
|
|
|
|
If Datenarchiv_DOKS.Rows.Count > 0 Then
|
|
For Each r As DataRow In Datenarchiv_DOKS.Rows
|
|
|
|
If r.Item("coll_pfad") <> "" Then
|
|
If Not System.IO.File.Exists(r.Item("coll_pfad")) Then
|
|
dtFehlendeDOKS.ImportRow(r)
|
|
lblfehlendeDokumente.Text = "fehlende Doks.: " & dtFehlendeDOKS.Rows.Count
|
|
Me.Refresh()
|
|
If dtFehlendeDOKS.Rows.Count >= 10000 Then Exit For
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
Next
|
|
|
|
|
|
If dtFehlendeDOKS.Rows.Count > 0 Then
|
|
|
|
MsgBox("Es existieren " & dtFehlendeDOKS.Rows.Count & " Datenarchiv-Datensätze, die kein zugeordnetes Dokument besitzen!")
|
|
VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dtFehlendeDOKS,,,,, True,,, True)
|
|
|
|
|
|
If vbYes = MsgBox("Sollen diese Datenarchiveinträge gelöscht werden?", vbYesNo) Then
|
|
|
|
End If
|
|
|
|
|
|
Else
|
|
|
|
MsgBox("Es wurden keine fehlenden Dokumente gefunden!")
|
|
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
End Class
|