118 lines
5.6 KiB
VB.net
118 lines
5.6 KiB
VB.net
Public Class frmStructureNodeConfig
|
|
Dim DT_ENTITIES As DataTable
|
|
Private Shared _Instance As frmStructureNodeConfig = Nothing
|
|
Private setimageNull As Boolean = False
|
|
Public Shared Function Instance() As frmStructureNodeConfig
|
|
If _Instance Is Nothing OrElse _Instance.IsDisposed = True Then
|
|
_Instance = New frmStructureNodeConfig
|
|
End If
|
|
_Instance.BringToFront()
|
|
Return _Instance
|
|
End Function
|
|
Private Sub TBPMO_STRUCTURE_NODES_CONFIGURATIONBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles TBPMO_STRUCTURE_NODES_CONFIGURATIONBindingNavigatorSaveItem.Click
|
|
Save_Config()
|
|
|
|
End Sub
|
|
Private Function Save_Config()
|
|
Try
|
|
Me.TBPMO_STRUCTURE_NODES_CONFIGURATIONBindingSource.EndEdit()
|
|
If DD_DMSDataSet.TBPMO_STRUCTURE_NODES_CONFIGURATION.GetChanges Is Nothing = False Then
|
|
Me.CHANGED_WHOTextBox.Text = Environment.UserName
|
|
TBPMO_STRUCTURE_NODES_CONFIGURATIONTableAdapter.Update(DD_DMSDataSet.TBPMO_STRUCTURE_NODES_CONFIGURATION)
|
|
lblSave.Visible = True
|
|
Else
|
|
lblSave.Visible = False
|
|
End If
|
|
Return True
|
|
Catch ex As Exception
|
|
MsgBox("Error in Saving Configuration:" & vbNewLine & ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
Private Sub frmStructureNodeConfig_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Try
|
|
Me.TBWH_ENTITYTableAdapter.Connection.ConnectionString = MyConnectionString
|
|
Me.TBWH_ENTITYTableAdapter.Fill(Me.DD_DMSDataSet.TBWH_ENTITY, USER_LANGUAGE)
|
|
Me.TBPMO_STRUCTURE_NODES_CONFIGURATIONTableAdapter.Connection.ConnectionString = MyConnectionString
|
|
Me.TBPMO_STRUCTURE_NODES_CONFIGURATIONTableAdapter.Fill(Me.DD_DMSDataSet.TBPMO_STRUCTURE_NODES_CONFIGURATION)
|
|
|
|
Catch ex As Exception
|
|
MsgBox("Error in Loading Configuration:" & vbNewLine & ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub TBPMO_STRUCTURE_NODES_CONFIGURATIONBindingSource_AddingNew(sender As Object, e As System.ComponentModel.AddingNewEventArgs) Handles TBPMO_STRUCTURE_NODES_CONFIGURATIONBindingSource.AddingNew
|
|
DD_DMSDataSet.TBPMO_STRUCTURE_NODES_CONFIGURATION.ADDED_WHOColumn.DefaultValue = Environment.UserName
|
|
End Sub
|
|
|
|
Private Sub btnSelectBackground_Click(sender As Object, e As EventArgs) Handles btnSelectBackground.Click
|
|
Try
|
|
OpenFileDialog1.Filter = "PNG Bilder|*.png"
|
|
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
|
|
Dim path As String = OpenFileDialog1.FileName
|
|
pbBackground.ImageLocation = path
|
|
If Save_Config() = True Then
|
|
' Hintergrund speichern
|
|
Dim image As Bitmap = Nothing
|
|
Dim bimage() As Byte = Nothing
|
|
|
|
If pbBackground.ImageLocation IsNot Nothing Then
|
|
image = CType(Drawing.Image.FromFile(pbBackground.ImageLocation, True), Bitmap)
|
|
bimage = BitmapToByteArray(image)
|
|
Dim sql As String = String.Format("UPDATE TBPMO_STRUCTURE_NODES_CONFIGURATION SET NODE_IMAGE = @Image WHERE GUID = {0}", Me.GUIDTextBox.Text)
|
|
Dim conn As New SqlClient.SqlConnection(MyConnectionString)
|
|
Dim cmd As New SqlClient.SqlCommand(sql, conn)
|
|
cmd.Parameters.Add("@Image", SqlDbType.VarBinary).Value = bimage
|
|
conn.Open()
|
|
cmd.ExecuteNonQuery()
|
|
conn.Close()
|
|
End If
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox("Error in Setting NodeImage:" & vbNewLine & ex.Message)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Sub btnResetBackground_Click(sender As Object, e As EventArgs) Handles btnResetBackground.Click
|
|
Try
|
|
Me.setimageNull = True
|
|
pbBackground.ImageLocation = Nothing
|
|
pbBackground.Image = Nothing
|
|
Dim sql As String = String.Format("UPDATE TBPMO_STRUCTURE_NODES_CONFIGURATION SET NODE_IMAGE = NULL WHERE GUID = {0}", Me.GUIDTextBox.Text)
|
|
If ClassDatabase.Execute_non_Query(sql) = True Then
|
|
setimageNull = False
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox("Error in Deleting NodeImage:" & vbNewLine & ex.Message)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Sub TBPMO_STRUCTURE_NODES_CONFIGURATIONBindingSource_CurrentChanged(sender As Object, e As EventArgs) Handles TBPMO_STRUCTURE_NODES_CONFIGURATIONBindingSource.CurrentChanged
|
|
Load_image()
|
|
End Sub
|
|
Sub Load_Image()
|
|
If GUIDTextBox.Text <> "" Then
|
|
Try
|
|
pbBackground.ImageLocation = Nothing
|
|
pbBackground.Image = Nothing
|
|
Dim sql = "SELECT NODE_IMAGE FROM TBPMO_STRUCTURE_NODES_CONFIGURATION WHERE GUID = " & GUIDTextBox.Text
|
|
Dim img = ClassDatabase.Execute_Scalar(sql)
|
|
' Hintergrundbild unwandeln und anzeigen
|
|
If Not IsDBNull(img) Then
|
|
Dim bimage() As Byte = img
|
|
Dim image = ByteArrayToBitmap(bimage)
|
|
Me.pbBackground.Image = image
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox("Error in Getting NodeImage:" & vbNewLine & ex.Message)
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub frmStructureNodeConfig_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
|
Load_Image()
|
|
End Sub
|
|
End Class |