You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
8.1 KiB

Imports System.Data
Imports System.Data.SqlTypes
Imports System.Data.SqlClient
Imports System.ComponentModel
Imports UtilityLibrary.Win32
Public Class frmSetDokVerantwortlicher
Inherits System.Windows.Forms.Form
#Region " Vom Windows Form Designer generierter Code "
Public Sub New()
MyBase.New()
' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
InitializeComponent()
' Initialisierungen nach dem Aufruf InitializeComponent() hinzufügen
End Sub
' Die Form überschreibt den Löschvorgang der Basisklasse, um Komponenten zu bereinigen.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
' Für Windows Form-Designer erforderlich
Private components As System.ComponentModel.IContainer
'HINWEIS: Die folgende Prozedur ist für den Windows Form-Designer erforderlich
'Sie kann mit dem Windows Form-Designer modifiziert werden.
'Verwenden Sie nicht den Code-Editor zur Bearbeitung.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents cbMitarbeiter As System.Windows.Forms.ComboBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.cbMitarbeiter = New System.Windows.Forms.ComboBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(128, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(240, 20)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 23)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Dokument-ID"
'
'cbMitarbeiter
'
Me.cbMitarbeiter.Location = New System.Drawing.Point(128, 56)
Me.cbMitarbeiter.Name = "cbMitarbeiter"
Me.cbMitarbeiter.Size = New System.Drawing.Size(240, 21)
Me.cbMitarbeiter.TabIndex = 4
Me.cbMitarbeiter.Text = "cbmitarbeiter"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(120, 23)
Me.Label2.TabIndex = 5
Me.Label2.Text = "Neuer Verantwortlicher"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(104, 112)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 6
Me.Button1.Text = "&Abbruch"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(192, 112)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 7
Me.Button2.Text = "&OK"
'
'frmSetDokVerantwortlicher
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(384, 158)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1, Me.Label2, Me.cbMitarbeiter, Me.Label1, Me.TextBox1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Name = "frmSetDokVerantwortlicher"
Me.Text = "Dokumentverantwortlichern setzen"
Me.ResumeLayout(False)
End Sub
#End Region
Dim WithEvents mcbmitarbeiter As New MultiComboBox()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub frmSetDokVerantwortlicher_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mcbmitarbeiter = New MultiComboBox(Me.cbMitarbeiter)
fill_mcbmitarbeiter()
End Sub
Private Sub fill_mcbmitarbeiter()
Me.mcbmitarbeiter.DataSource = Nothing
Me.mcbmitarbeiter.Items.Clear()
Me.mcbmitarbeiter.CheckNullValue = False
Me.mcbmitarbeiter.NullValueMessage = MyTxt.gettext(18)
Me.mcbmitarbeiter.DisplayColumnName = "mitarbeiter"
Me.mcbmitarbeiter.ValueColumnName = "mitarbeiternr"
Me.mcbmitarbeiter.Fill_Data(Generic_Select(1), False)
End Sub
Private Function Generic_Select(ByVal typ As Integer) As DataTable
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Select Case typ
Case 1
scmCmdToExecute.CommandText = "dbo.sp_dokverantwortlich_mitarbeiter"
End Select
scmCmdToExecute.CommandType = CommandType.StoredProcedure
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.Connection = conn.scoDBConnection
Try
sdaAdapter.Fill(dtToReturn)
Return dtToReturn
Catch ex As Exception
' // some error occured. Bubble it to caller and encapsulate Exception object
Throw New Exception("Dokumenterstellung::Generic_Select::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i As Integer
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
scmCmdToExecute.CommandText = "dbo.sp_wechsel_verantwortlicher"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.Connection = conn.scoDBConnection
Try
scmCmdToExecute.Parameters.Add(New SqlParameter("@dokumentid", SqlDbType.VarChar, 22, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Me.TextBox1.Text))
scmCmdToExecute.Parameters.Add(New SqlParameter("@verantwortlicher", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Me.mcbmitarbeiter.SelectedValue))
scmCmdToExecute.Parameters.Add(New SqlParameter("@status", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 0))
scmCmdToExecute.Parameters.Add(New SqlParameter("@currentstatus", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 0))
sdaAdapter.Fill(dtToReturn)
i = scmCmdToExecute.Parameters("@status").Value
If i = 1 Then
MsgBox("Ein Dokument mit der ID '" & Me.TextBox1.Text & " existiert nicht")
Else
Dim sth As New Statushandling()
i = scmCmdToExecute.Parameters("@currentstatus").Value
sth.insert_history_status(i, Me.TextBox1.Text, Me.mcbmitarbeiter.SelectedValue)
sth.Dispose()
MsgBox("Der Wechsel des Verantwortlichen wurde erfolgreich durchgeführt.")
End If
Catch ex As Exception
Throw New Exception("Dokumenterstellung::Generic_Select::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Sub
End Class