Initial
This commit is contained in:
247
EDOKA/Dokumentmanagement/frmMultiDelete.vb
Normal file
247
EDOKA/Dokumentmanagement/frmMultiDelete.vb
Normal file
@@ -0,0 +1,247 @@
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Public Class frmMultiDelete
|
||||
|
||||
Dim dt As New DataTable
|
||||
Dim returnstring As String = ""
|
||||
|
||||
Dim m_dlist As C1.Win.C1TrueDBGrid.C1TrueDBGrid
|
||||
Property dlist As C1.Win.C1TrueDBGrid.C1TrueDBGrid
|
||||
Get
|
||||
Return m_dlist
|
||||
End Get
|
||||
Set(value As C1.Win.C1TrueDBGrid.C1TrueDBGrid)
|
||||
m_dlist = value
|
||||
End Set
|
||||
End Property
|
||||
Dim m_colrows As C1.Win.C1TrueDBGrid.SelectedRowCollection
|
||||
|
||||
Property ColRows As C1.Win.C1TrueDBGrid.SelectedRowCollection
|
||||
Get
|
||||
Return m_colrows
|
||||
End Get
|
||||
Set(value As C1.Win.C1TrueDBGrid.SelectedRowCollection)
|
||||
m_colrows = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
|
||||
If Trim(Me.txtGrund.Text) = "" Then
|
||||
MsgBox("Bitte Lösch-/Aufhebungsgrund eingeben.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
For Each r As DataRow In dt.Rows
|
||||
If r(0) = "Aufhebung" Then
|
||||
DivFnkt.Insert_Notiz(r("dokumentid"), Me.txtGrund.Text)
|
||||
Dim sth As New Statushandling()
|
||||
sth.set_aufgehoben(r("dokumentid"))
|
||||
sth.Dispose()
|
||||
End If
|
||||
If r(0) = "Löschung" Then
|
||||
deletedok(r("dokumentid"))
|
||||
End If
|
||||
If r(0) = "Löschen" Then
|
||||
deletedok(r("dokumentid"))
|
||||
End If
|
||||
Next
|
||||
Me.Close()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
|
||||
Me.Close()
|
||||
End Sub
|
||||
|
||||
Private Sub frmMultiDelete_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Cursor = Cursors.WaitCursor
|
||||
dt.Rows.Clear()
|
||||
dt.Columns.Clear()
|
||||
Me.cbboxGrund.Items.Clear()
|
||||
Dim gruende As DataTable = Get_Grund()
|
||||
For Each r As DataRow In gruende.Rows
|
||||
cbboxGrund.Items.Add(r("grund").ToString)
|
||||
Next
|
||||
cbboxGrund.SelectedIndex = 0
|
||||
Me.txtGrund.Text = ""
|
||||
|
||||
dt.TableName = "DoksToDelete"
|
||||
dt.Columns.Add("Funktion")
|
||||
dt.Columns.Add("Dokumentid")
|
||||
dt.Columns.Add("Dokumenttypnr")
|
||||
dt.Columns.Add("Partnernr")
|
||||
dt.Columns.Add("Vertraulich")
|
||||
dt.Columns.Add("Bezeichnung")
|
||||
dt.Columns.Add("verantwortlich")
|
||||
dt.Columns.Add("AktivesDokument")
|
||||
For i As Integer = 0 To ColRows.Count - 1
|
||||
Dim r As DataRow = dt.NewRow
|
||||
r(1) = dlist.Columns("dokumentid").CellValue(ColRows(i))
|
||||
r(2) = dlist.Columns("dokumenttypnr").CellValue(ColRows(i))
|
||||
r(3) = dlist.Columns("partnernr").CellValue(ColRows(i))
|
||||
r(4) = dlist.Columns("vertraulich").CellValue(ColRows(i))
|
||||
r(5) = dlist.Columns("bezeichnung").CellValue(ColRows(i))
|
||||
r(6) = dlist.Columns("aktivesdokument").CellValue(ColRows(i))
|
||||
|
||||
r(0) = check_dok(dlist.Columns("dokumenttypnr").CellValue(ColRows(i)), dlist.Columns("partnernr").CellValue(ColRows(i)), dlist.Columns("dokumentid").CellValue(ColRows(i)), dlist.Columns("vertraulich").CellValue(ColRows(i)), dlist.Columns("verantwortlich").CellValue(ColRows(i)), dlist.Columns("aktivesdokument").CellValue(ColRows(i)))
|
||||
|
||||
dt.Rows.Add(r)
|
||||
Next
|
||||
Me.DokList.FetchRowStyles = True
|
||||
Me.DokList.DataSource = dt
|
||||
Me.DokList.DataMember = dt.TableName
|
||||
Me.DokList.Splits(0).DisplayColumns(0).Width = 0
|
||||
Me.DokList.Splits(0).DisplayColumns(1).AutoSize()
|
||||
Me.DokList.Splits(0).DisplayColumns(2).Width = 0
|
||||
Me.DokList.Splits(0).DisplayColumns(3).AutoSize()
|
||||
Me.DokList.Splits(0).DisplayColumns(4).Width = 0
|
||||
Me.DokList.Splits(0).DisplayColumns(5).AutoSize()
|
||||
Me.DokList.Splits(0).DisplayColumns(6).Width = 0
|
||||
Me.DokList.Splits(0).DisplayColumns(7).Width = 0
|
||||
|
||||
Label1.BackColor = Color.LightGray
|
||||
Label5.Text = "Nicht abgeschlossenes Dokument löschen"
|
||||
Label2.BackColor = Color.LightGreen
|
||||
Label6.Text = "Abgeschlossenes Dokument löschen"
|
||||
Label3.BackColor = Color.LightSeaGreen
|
||||
Label7.Text = "Abgeschlossenes Dokument aufheben"
|
||||
Label4.BackColor = Color.LightPink
|
||||
Label8.Text = "Fehlende Berechtigungen um das Dokument zu löschen/aufheben"
|
||||
Cursor = Cursors.Default
|
||||
End Sub
|
||||
|
||||
Private Function check_dok(ByVal dokumenttypnr As String, partnernr As String, dokumentid As String, vertraulich As Integer, ByVal verantwortlich As Integer, aktivesdokument As Integer) As String
|
||||
Dim d As New DataTable
|
||||
Dim dtctm As New DataTable
|
||||
Try
|
||||
d = DivFnkt.Berechtigte_Mitarbeiter(dokumenttypnr, Globals.MitarbeiterNr, partnernr, dokumentid, 0, 0, 0, vertraulich, "")
|
||||
returnstring = ""
|
||||
If d.Rows(0).Item("loeschen") = 1 Then
|
||||
If verantwortlich = Globals.MitarbeiterNr Then returnstring = "Löschen"
|
||||
End If
|
||||
dtctm = get_contextmenu_ber(dokumentid)
|
||||
If dtctm.Rows(0).Item("abschlussstatus") <> 0 Then
|
||||
set_abgeschlossen_menu(vertraulich, dtctm, aktivesdokument)
|
||||
End If
|
||||
|
||||
Return returnstring
|
||||
Catch ex As Exception
|
||||
Return "Fehler"
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
Private Function set_abgeschlossen_menu(ByVal bDokIstVertraulich As Boolean, ByVal dtCTM As DataTable, aktivesdokument As Integer) As String
|
||||
|
||||
Try
|
||||
If dtCTM.Rows(0).Item("aufhebung") <> 0 Then
|
||||
If bDokIstVertraulich = False Then
|
||||
returnstring = "Aufhebung"
|
||||
End If
|
||||
End If
|
||||
If dtCTM.Rows(0).Item("loeschung") <> 0 Then
|
||||
If aktivesdokument = -1 Then
|
||||
returnstring = "Löschung"
|
||||
End If
|
||||
'Me.MenuItem21.Enabled = True
|
||||
End If
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Return ""
|
||||
Finally
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function Get_Grund() As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.sp_get_grund"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
Try
|
||||
scmCmdToExecute.Connection = conn.scoDBConnection
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@grundtyp", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, 99))
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
dtToReturn.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
Private Function get_contextmenu_ber(ByVal dokumentid As String) As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.sp_contextmenu"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
Try
|
||||
scmCmdToExecute.Connection = conn.scoDBConnection
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@mitarbeiternr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.MitarbeiterNr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@dokumentid", SqlDbType.VarChar, 22, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, dokumentid))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@fanummer3", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, ""))
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
dtToReturn.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub deletedok(ByVal DOkumentid As String)
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.SP_Dokument_delete"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = conn.scoDBConnection
|
||||
conn.OpenConnection()
|
||||
Try
|
||||
Dim loeschgrund As String = Me.txtGrund.Text
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@dokumentid", SqlDbType.VarChar, 22, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, DOkumentid))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@mitarbeiter", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.MitarbeiterNr))
|
||||
scmCmdToExecute.Parameters.Add("@loeschgrund", loeschgrund)
|
||||
scmCmdToExecute.ExecuteNonQuery()
|
||||
Dim dt As DataTable
|
||||
Dim sth As New Statushandling()
|
||||
dt = sth.get_coldindex_and_statusnr(Me.DokList.Columns("dokumentid").Text, False, False)
|
||||
Archivfnkt.insert_coldupdate_status(dt, Me.DokList.Columns("dokumentid").Text, "Alt")
|
||||
sth.Dispose()
|
||||
|
||||
Catch ex As Exception
|
||||
Throw New Exception("Dokument_Information_Wert::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
conn.CloseConnection(True)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub DokList_FetchRowStyle(sender As Object, e As C1.Win.C1TrueDBGrid.FetchRowStyleEventArgs) Handles DokList.FetchRowStyle
|
||||
Try
|
||||
If Me.DokList.Columns(0).CellValue(e.Row).ToString = "Fehler" Or Me.DokList.Columns(0).CellValue(e.Row).ToString = "" Then
|
||||
e.CellStyle.BackColor = Color.LightPink
|
||||
End If
|
||||
If Me.DokList.Columns(0).CellValue(e.Row).ToString = "Löschen" Then
|
||||
e.CellStyle.BackColor = Color.LightGray
|
||||
End If
|
||||
If Me.DokList.Columns(0).CellValue(e.Row).ToString = "Löschung" Then
|
||||
e.CellStyle.BackColor = Color.LightGreen
|
||||
End If
|
||||
If Me.DokList.Columns(0).CellValue(e.Row).ToString = "Aufhebung" Then
|
||||
e.CellStyle.BackColor = Color.LightSeaGreen
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub cbboxGrund_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbboxGrund.SelectedIndexChanged
|
||||
Me.txtGrund.Text = Me.cbboxGrund.Text
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user