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.

290 lines
11 KiB

Imports System
Imports System.IO
Imports System.Data
Imports System.Data.SqlTypes
Imports System.Data.SqlClient
Imports System.ComponentModel
Imports UtilityLibrary.Win32
Public Class frmDokumenttypbeschreibung
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 RichTextBox1 As RichTextBoxHS
Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
Friend WithEvents FontDialog1 As System.Windows.Forms.FontDialog
Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton
Friend WithEvents RichTextBoxHS1 As EDOKAApp.RichTextBoxHS
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmDokumenttypbeschreibung))
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu()
Me.MenuItem1 = New System.Windows.Forms.MenuItem()
Me.MenuItem2 = New System.Windows.Forms.MenuItem()
Me.MenuItem3 = New System.Windows.Forms.MenuItem()
Me.ToolBar1 = New System.Windows.Forms.ToolBar()
Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton()
Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton()
Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton()
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.FontDialog1 = New System.Windows.Forms.FontDialog()
Me.RichTextBoxHS1 = New EDOKAApp.RichTextBoxHS()
Me.SuspendLayout()
'
'ContextMenu1
'
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem2, Me.MenuItem3})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.Text = "Schriftart..."
'
'MenuItem2
'
Me.MenuItem2.Index = 1
Me.MenuItem2.Text = "Gelb markieren"
'
'MenuItem3
'
Me.MenuItem3.Index = 2
Me.MenuItem3.Text = "&Markierungen löschen"
'
'ToolBar1
'
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1, Me.ToolBarButton2, Me.ToolBarButton3})
Me.ToolBar1.DropDownArrows = True
Me.ToolBar1.ImageList = Me.ImageList1
Me.ToolBar1.Name = "ToolBar1"
Me.ToolBar1.ShowToolTips = True
Me.ToolBar1.Size = New System.Drawing.Size(824, 25)
Me.ToolBar1.TabIndex = 1
'
'ToolBarButton1
'
Me.ToolBarButton1.ImageIndex = 0
'
'ToolBarButton2
'
Me.ToolBarButton2.ImageIndex = 1
Me.ToolBarButton2.Visible = False
'
'ToolBarButton3
'
Me.ToolBarButton3.ImageIndex = 2
'
'ImageList1
'
Me.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
'
'RichTextBoxHS1
'
Me.RichTextBoxHS1.AcceptsTab = True
Me.RichTextBoxHS1.ContextMenu = Me.ContextMenu1
Me.RichTextBoxHS1.Dock = System.Windows.Forms.DockStyle.Fill
Me.RichTextBoxHS1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.RichTextBoxHS1.Location = New System.Drawing.Point(0, 25)
Me.RichTextBoxHS1.Name = "RichTextBoxHS1"
Me.RichTextBoxHS1.Size = New System.Drawing.Size(824, 476)
Me.RichTextBoxHS1.TabIndex = 2
Me.RichTextBoxHS1.Text = ""
'
'frmDokumenttypbeschreibung
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(824, 501)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.RichTextBoxHS1, Me.ToolBar1})
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmDokumenttypbeschreibung"
Me.Text = "Dokumenttypbeschreibung"
Me.ResumeLayout(False)
End Sub
#End Region
Dim m_key As Integer = 0
Property key() As Integer
Get
Return m_key
End Get
Set(ByVal Value As Integer)
m_key = Value
End Set
End Property
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Me.FontDialog1.ShowColor = True
Me.FontDialog1.ShowApply = True
Me.FontDialog1.ShowEffects = True
Me.FontDialog1.ShowDialog()
RichTextBoxHS1.SelectionFont = Me.FontDialog1.Font
RichTextBoxHS1.SelectionColor = Me.FontDialog1.Color
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
RichTextBoxHS1.SelectionBackColor = System.Drawing.Color.Yellow
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
RichTextBoxHS1.BackColorSetWhole(System.Drawing.Color.White)
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Select Case ToolBar1.Buttons.IndexOf(e.Button)
Case 0 'close button
Me.Close()
Case 1
Dim frm As New frmDomainDokumenttyp()
frm.ToSelect = True
frm.TransferKey = 0
frm.Eintragnr = 0
frm.Refresh()
frm.Owner = Me
frm.ShowDialog()
If frm.TransferKey = 0 Then
frm.Dispose()
Exit Sub
End If
Me.RichTextBoxHS1.Clear()
key = frm.TransferKey
frm.Dispose()
Get_From_DB()
Case 2
If Me.key = 0 Then
MsgBox("Sie haben keinen Dokumenttyp ausgewählt.")
Exit Sub
End If
Save_To_DB()
Case Else
End Select
End Sub
Public Function Get_From_DB()
Dim connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select * From dokumenttypbeschreibung where dokumenttypbeschreibungnr=" + Str(key), connection)
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()
Dim dokname As String
dokname = Globals.Applikationsdaten.Rows(Globals.AppldataRow).Item("pfad_temporaer_dokumente") + "tmp.rtf"
Try
connection.ConnectionString = Globals.sConnectionString
connection.Open()
da.Fill(ds, "docbeschreibung")
Dim myRow As DataRow
myRow = ds.Tables(0).Rows(0)
Dim MyData() As Byte
MyData = myRow.Item(1)
Dim K As Long
K = UBound(MyData)
Dim fs As New FileStream(dokname, FileMode.OpenOrCreate, FileAccess.Write)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing
Me.RichTextBoxHS1.LoadFile(dokname)
Me.ToolBar1.Buttons(2).Enabled = True
Catch ex As Exception
Return False
Finally
CB = Nothing
ds = Nothing
da = Nothing
connection.Close()
connection = Nothing
End Try
Return True
End Function
Public Function Save_To_DB()
Dim Connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select * From dokumenttypbeschreibung where dokumenttypbeschreibungnr=" + Str(key), Connection)
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()
Dim dokname As String
dokname = Globals.Applikationsdaten.Rows(Globals.AppldataRow).Item("pfad_temporaer_dokumente") + "tmp.rtf"
Me.RichTextBoxHS1.SaveFile(dokname)
Dim fs As New FileStream(dokname, FileMode.OpenOrCreate, FileAccess.Read)
Dim mydata(fs.Length) As Byte
Try
fs.Read(mydata, 0, fs.Length)
fs.Close()
Connection.ConnectionString = Globals.sConnectionString
Connection.Open()
da.Fill(ds, "docs")
Dim myRow As DataRow
If ds.Tables(0).Rows.Count = 0 Then
' Neues Dokument speichern
myRow = ds.Tables(0).NewRow
myRow.Item(0) = key
myRow.Item(1) = mydata
myRow.Item(2) = Now
myRow.Item(3) = Globals.MitarbeiterNr
ds.Tables(0).Rows.Add(myRow)
da.Update(ds, "docs")
Else
myRow = ds.Tables(0).Rows(0)
myRow.Item(1) = mydata
da.Update(ds, "docs")
End If
Catch ex As Exception
MsgBox(ex.Message)
MyMsg.show_standardmessage(86, MsgBoxStyle.Critical)
Return False
Finally
fs = Nothing
cb = Nothing
ds = Nothing
da = Nothing
Connection.Close()
Connection = Nothing
End Try
Return True
End Function
Private Sub frmDokumenttypbeschreibung_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Get_From_DB()
End Sub
End Class