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.

663 lines
29 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 frmEDOKA_Import
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 ToolBar1 As System.Windows.Forms.ToolBar
Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
Friend WithEvents GrpJournale As System.Windows.Forms.GroupBox
Friend WithEvents Splitter1 As System.Windows.Forms.Splitter
Friend WithEvents GrpJournalDetail As System.Windows.Forms.GroupBox
Friend WithEvents GrdJournale As C1.Win.C1TrueDBGrid.C1TrueDBGrid
Friend WithEvents GrdJournaldetail As C1.Win.C1TrueDBGrid.C1TrueDBGrid
Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
Friend WithEvents popupjournaldetails As System.Windows.Forms.ContextMenu
Friend WithEvents mnuIndexMutation As System.Windows.Forms.MenuItem
Friend WithEvents MnuDokanzeige As System.Windows.Forms.MenuItem
Friend WithEvents MnuReimport As System.Windows.Forms.MenuItem
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents mnuindexdaten As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmEDOKA_Import))
Me.ToolBar1 = New System.Windows.Forms.ToolBar
Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.GrpJournale = New System.Windows.Forms.GroupBox
Me.GrdJournale = New C1.Win.C1TrueDBGrid.C1TrueDBGrid
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu
Me.mnuindexdaten = New System.Windows.Forms.MenuItem
Me.MenuItem2 = New System.Windows.Forms.MenuItem
Me.Splitter1 = New System.Windows.Forms.Splitter
Me.GrpJournalDetail = New System.Windows.Forms.GroupBox
Me.GrdJournaldetail = New C1.Win.C1TrueDBGrid.C1TrueDBGrid
Me.popupjournaldetails = New System.Windows.Forms.ContextMenu
Me.mnuIndexMutation = New System.Windows.Forms.MenuItem
Me.MnuDokanzeige = New System.Windows.Forms.MenuItem
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MenuItem3 = New System.Windows.Forms.MenuItem
Me.MnuReimport = New System.Windows.Forms.MenuItem
Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
Me.GrpJournale.SuspendLayout()
CType(Me.GrdJournale, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GrpJournalDetail.SuspendLayout()
CType(Me.GrdJournaldetail, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ToolBar1
'
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1, Me.ToolBarButton2})
Me.ToolBar1.DropDownArrows = True
Me.ToolBar1.ImageList = Me.ImageList1
Me.ToolBar1.Location = New System.Drawing.Point(0, 0)
Me.ToolBar1.Name = "ToolBar1"
Me.ToolBar1.ShowToolTips = True
Me.ToolBar1.Size = New System.Drawing.Size(888, 28)
Me.ToolBar1.TabIndex = 0
'
'ToolBarButton1
'
Me.ToolBarButton1.ImageIndex = 0
Me.ToolBarButton1.Name = "ToolBarButton1"
'
'ToolBarButton2
'
Me.ToolBarButton2.ImageIndex = 12
Me.ToolBarButton2.Name = "ToolBarButton2"
'
'ImageList1
'
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
Me.ImageList1.Images.SetKeyName(0, "")
Me.ImageList1.Images.SetKeyName(1, "")
Me.ImageList1.Images.SetKeyName(2, "")
Me.ImageList1.Images.SetKeyName(3, "")
Me.ImageList1.Images.SetKeyName(4, "")
Me.ImageList1.Images.SetKeyName(5, "")
Me.ImageList1.Images.SetKeyName(6, "")
Me.ImageList1.Images.SetKeyName(7, "")
Me.ImageList1.Images.SetKeyName(8, "")
Me.ImageList1.Images.SetKeyName(9, "")
Me.ImageList1.Images.SetKeyName(10, "")
Me.ImageList1.Images.SetKeyName(11, "")
Me.ImageList1.Images.SetKeyName(12, "")
'
'GrpJournale
'
Me.GrpJournale.Controls.Add(Me.GrdJournale)
Me.GrpJournale.Dock = System.Windows.Forms.DockStyle.Top
Me.GrpJournale.Location = New System.Drawing.Point(0, 28)
Me.GrpJournale.Name = "GrpJournale"
Me.GrpJournale.Size = New System.Drawing.Size(888, 248)
Me.GrpJournale.TabIndex = 1
Me.GrpJournale.TabStop = False
Me.GrpJournale.Text = "Import_Journale"
'
'GrdJournale
'
Me.GrdJournale.AllowUpdateOnBlur = False
Me.GrdJournale.AlternatingRows = True
Me.GrdJournale.ContextMenu = Me.ContextMenu1
Me.GrdJournale.Cursor = System.Windows.Forms.Cursors.Default
Me.GrdJournale.Dock = System.Windows.Forms.DockStyle.Fill
Me.GrdJournale.FetchRowStyles = True
Me.GrdJournale.FilterBar = True
Me.GrdJournale.GroupByCaption = "Drag a column header here to group by that column"
Me.GrdJournale.Images.Add(CType(resources.GetObject("GrdJournale.Images"), System.Drawing.Image))
Me.GrdJournale.Location = New System.Drawing.Point(3, 16)
Me.GrdJournale.MultiSelect = C1.Win.C1TrueDBGrid.MultiSelectEnum.None
Me.GrdJournale.Name = "GrdJournale"
Me.GrdJournale.PreviewInfo.Location = New System.Drawing.Point(0, 0)
Me.GrdJournale.PreviewInfo.Size = New System.Drawing.Size(0, 0)
Me.GrdJournale.PreviewInfo.ZoomFactor = 75
Me.GrdJournale.PrintInfo.PageSettings = CType(resources.GetObject("GrdJournale.PrintInfo.PageSettings"), System.Drawing.Printing.PageSettings)
Me.GrdJournale.ScrollTips = True
Me.GrdJournale.Size = New System.Drawing.Size(882, 229)
Me.GrdJournale.TabIndex = 26
Me.GrdJournale.Text = "C1TrueDBGrid1"
Me.GrdJournale.PropBag = resources.GetString("GrdJournale.PropBag")
'
'ContextMenu1
'
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuindexdaten, Me.MenuItem2})
'
'mnuindexdaten
'
Me.mnuindexdaten.Index = 0
Me.mnuindexdaten.Text = "&Inputdatei anzeigen/mutierem"
'
'MenuItem2
'
Me.MenuItem2.Index = 1
Me.MenuItem2.Text = "&Daten für nochmaligen Import bereitstellen"
'
'Splitter1
'
Me.Splitter1.Dock = System.Windows.Forms.DockStyle.Top
Me.Splitter1.Location = New System.Drawing.Point(0, 276)
Me.Splitter1.Name = "Splitter1"
Me.Splitter1.Size = New System.Drawing.Size(888, 3)
Me.Splitter1.TabIndex = 2
Me.Splitter1.TabStop = False
'
'GrpJournalDetail
'
Me.GrpJournalDetail.Controls.Add(Me.GrdJournaldetail)
Me.GrpJournalDetail.Dock = System.Windows.Forms.DockStyle.Fill
Me.GrpJournalDetail.Location = New System.Drawing.Point(0, 279)
Me.GrpJournalDetail.Name = "GrpJournalDetail"
Me.GrpJournalDetail.Size = New System.Drawing.Size(888, 278)
Me.GrpJournalDetail.TabIndex = 3
Me.GrpJournalDetail.TabStop = False
Me.GrpJournalDetail.Text = "Journaldetails"
'
'GrdJournaldetail
'
Me.GrdJournaldetail.AllowUpdate = False
Me.GrdJournaldetail.AllowUpdateOnBlur = False
Me.GrdJournaldetail.AlternatingRows = True
Me.GrdJournaldetail.ContextMenu = Me.popupjournaldetails
Me.GrdJournaldetail.Cursor = System.Windows.Forms.Cursors.Default
Me.GrdJournaldetail.Dock = System.Windows.Forms.DockStyle.Fill
Me.GrdJournaldetail.FetchRowStyles = True
Me.GrdJournaldetail.FilterBar = True
Me.GrdJournaldetail.GroupByCaption = "Drag a column header here to group by that column"
Me.GrdJournaldetail.Images.Add(CType(resources.GetObject("GrdJournaldetail.Images"), System.Drawing.Image))
Me.GrdJournaldetail.ImeMode = System.Windows.Forms.ImeMode.[On]
Me.GrdJournaldetail.Location = New System.Drawing.Point(3, 16)
Me.GrdJournaldetail.MultiSelect = C1.Win.C1TrueDBGrid.MultiSelectEnum.None
Me.GrdJournaldetail.Name = "GrdJournaldetail"
Me.GrdJournaldetail.PreviewInfo.Location = New System.Drawing.Point(0, 0)
Me.GrdJournaldetail.PreviewInfo.Size = New System.Drawing.Size(0, 0)
Me.GrdJournaldetail.PreviewInfo.ZoomFactor = 75
Me.GrdJournaldetail.PrintInfo.PageSettings = CType(resources.GetObject("GrdJournaldetail.PrintInfo.PageSettings"), System.Drawing.Printing.PageSettings)
Me.GrdJournaldetail.ScrollTips = True
Me.GrdJournaldetail.Size = New System.Drawing.Size(882, 259)
Me.GrdJournaldetail.TabIndex = 26
Me.GrdJournaldetail.Text = "C1TrueDBGrid1"
Me.GrdJournaldetail.PropBag = resources.GetString("GrdJournaldetail.PropBag")
'
'popupjournaldetails
'
Me.popupjournaldetails.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuIndexMutation, Me.MnuDokanzeige, Me.MenuItem1, Me.MenuItem3, Me.MnuReimport})
'
'mnuIndexMutation
'
Me.mnuIndexMutation.Index = 0
Me.mnuIndexMutation.Text = "&Indexdaten anzeigen/mutieren"
'
'MnuDokanzeige
'
Me.MnuDokanzeige.Index = 1
Me.MnuDokanzeige.Text = "&Dokument lokal speichern"
'
'MenuItem1
'
Me.MenuItem1.Index = 2
Me.MenuItem1.Text = "Dokument &anzeigen"
Me.MenuItem1.Visible = False
'
'MenuItem3
'
Me.MenuItem3.Index = 3
Me.MenuItem3.Text = "-"
'
'MnuReimport
'
Me.MnuReimport.Index = 4
Me.MnuReimport.Text = "Dokument für den nochmaligen Import &bereitstellen"
'
'SaveFileDialog1
'
Me.SaveFileDialog1.FileName = "doc1"
'
'frmEDOKA_Import
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(888, 557)
Me.Controls.Add(Me.GrpJournalDetail)
Me.Controls.Add(Me.Splitter1)
Me.Controls.Add(Me.GrpJournale)
Me.Controls.Add(Me.ToolBar1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmEDOKA_Import"
Me.ShowInTaskbar = False
Me.Text = "frmEDOKA_Import"
Me.GrpJournale.ResumeLayout(False)
CType(Me.GrdJournale, System.ComponentModel.ISupportInitialize).EndInit()
Me.GrpJournalDetail.ResumeLayout(False)
CType(Me.GrdJournaldetail, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
#Region "Deklarationen"
Dim journaldaten As New DataTable()
Dim journaldetails As New DataTable()
#End Region
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
Load_Data()
Case Else
End Select
End Sub
Private Sub frmEDOKA_Import_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Load_Data()
End Sub
Private Sub Load_Data()
Me.journaldaten = Nothing
Me.journaldaten = get_Journale()
Me.GrdJournale.DataSource = journaldaten
Me.GrdJournale.DataMember = journaldaten.TableName
Update_Details()
DivFnkt.SpaltenTitel_Aktualisieren(Me.GrdJournale, Me.journaldaten, "ImportJournal")
End Sub
#Region "Grid"
Private Sub GrdJournale_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GrdJournale.MouseDown
Me.GrdJournale.Bookmark = Me.GrdJournale.RowContaining(e.Y)
Update_Details()
End Sub
Private Sub Update_Details()
get_Journaldata()
Me.GrdJournaldetail.DataSource = Nothing
Me.GrdJournaldetail.DataMember = Nothing
Dim dt As DataTable
dt = get_Journaldata()
Me.GrdJournaldetail.DataSource = dt
Me.GrdJournaldetail.DataMember = dt.TableName
DivFnkt.SpaltenTitel_Aktualisieren(Me.GrdJournaldetail, dt, "Import_Journaldetail")
End Sub
#End Region
#Region "Datenzugriffe"
Private Function get_Journale() As DataTable
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_edoka_import_get_journale"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
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("sp_edoka_import_get_journale::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Function
Private Function get_Journaldata() As DataTable
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_edoka_import_get_journaldata"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
Try
scmCmdToExecute.Parameters.Add(New SqlParameter("@Journalid", SqlDbType.VarChar, 22, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Me.GrdJournale.Columns(0).Value))
sdaAdapter.Fill(dtToReturn)
Return dtToReturn
Catch ex As Exception
' // some error occured. Bubble it to caller and encapsulate Exception object
Throw New Exception("sp_edoka_import_get_journale::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Function
#End Region
Private Sub GrdJournaldetail_FetchRowStyle(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.FetchRowStyleEventArgs) Handles GrdJournaldetail.FetchRowStyle
If Me.GrdJournaldetail.Columns("Status").CellValue(e.Row) <> "" And _
Me.GrdJournaldetail.Columns("Status").CellValue(e.Row) <> "0" Then
e.CellStyle.ForeColor = Color.Red
End If
End Sub
Private Sub GrdJournale_FetchRowStyle(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.FetchRowStyleEventArgs) Handles GrdJournale.FetchRowStyle
If Me.GrdJournale.Columns("fehlerhaft").CellValue(e.Row) <> 0 Then
e.CellStyle.ForeColor = Color.Red
End If
End Sub
Private Sub mnuIndexMutation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuIndexMutation.Click
Dim f As New frmEdoka_Import_TextEditor()
f.Als_Datei = False
f.xmlstring = Me.GrdJournaldetail.Columns("xml").Value
f.ShowDialog()
If f.DialogResult = DialogResult.OK Then
save_xmlstring(Me.GrdJournaldetail.Columns(1).Value, f.xmlstring)
Me.GrdJournaldetail.Columns("xml").Value = f.xmlstring
End If
End Sub
Private Function save_xmlstring(ByVal eintrag As Integer, ByVal xmlstring As String) As DataTable
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_edoka_import_update_xml"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
Try
scmCmdToExecute.Parameters.Add(New SqlParameter("@eintrag", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, eintrag))
scmCmdToExecute.Parameters.Add(New SqlParameter("@xmlstring", SqlDbType.VarChar, 2048, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, xmlstring))
sdaAdapter.Fill(dtToReturn)
Return dtToReturn
Catch ex As Exception
' // some error occured. Bubble it to caller and encapsulate Exception object
Throw New Exception("sp_edoka_import_update_xml::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Function
Private Function get_journale_connection() As String
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_get_journale_connection"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
Try
scmCmdToExecute.Parameters.Add(New SqlParameter("@connstring", SqlDbType.VarChar, 1024, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, ""))
sdaAdapter.Fill(dtToReturn)
Return scmCmdToExecute.Parameters("@connstring").Value
Catch ex As Exception
' // some error occured. Bubble it to caller and encapsulate Exception object
Throw New Exception("sp_edoka_get_journale_connection::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Function
Private Sub MnuDokanzeige_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnuDokanzeige.Click
Dim conn_journale As String
conn_journale = get_journale_connection()
Dim s As String
s = Get_Doc(Me.GrdJournaldetail.Columns(1).Value, conn_journale)
If s = "" Then
MsgBox("Die Datei konnte nicht gespeichert werden.")
Else
MsgBox("Datei gespeichert als : " + s)
End If
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Dim conn_journale As String
conn_journale = get_journale_connection()
Dim s As String
s = Get_Doc(Me.GrdJournaldetail.Columns(1).Value, conn_journale)
If s = "" Then
MsgBox("Die Datei konnte nicht gespeichert werden.")
Else
Dim i As Integer
i = Shell(s, AppWinStyle.NormalFocus, False)
End If
End Sub
Private Function Get_Doc(ByVal itemid As Integer, ByVal connectionstring As String) As String
Dim connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select * From import_daten where import_data_nr=" + LTrim(Str(itemid)), connection)
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()
Dim Dokumentfilename As String
Dim XMLFilename As String
Dim xmlstring As String
Dim xmlds As New DataSet()
Try
'Connectionstring zur Datenbank
connection.ConnectionString = connectionstring
connection.Open()
da.Fill(ds, "docs")
Dim myRow As DataRow
xmlstring = ds.Tables(0).Rows(0).Item(3)
myRow = ds.Tables(0).Rows(0)
'Indexfile schreiben
XMLFilename = Globals.Applikationsdaten.Rows(Globals.AppldataRow).Item("pfad_temporaer_dokumente") + "tmpxml.xml"
FileOpen(11, XMLFilename, OpenMode.Output)
PrintLine(11, xmlstring)
FileClose(11)
xmlds.ReadXml(XMLFilename)
Dokumentfilename = Globals.Applikationsdaten.Rows(Globals.AppldataRow).Item("pfad_temporaer_dokumente") + xmlds.Tables(0).Rows(0).Item(12)
xmlds.Dispose()
'Dokumentdatei schreiben
Dim MyData() As Byte
MyData = myRow.Item(4)
Dim K As Long
K = UBound(MyData)
Dim fs As New FileStream(Dokumentfilename, FileMode.OpenOrCreate, FileAccess.Write)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing
Return Dokumentfilename
Catch ex As Exception
FileClose(11)
Return ""
Finally
CB = Nothing
ds = Nothing
da = Nothing
connection.Close()
connection = Nothing
End Try
End Function
Private Sub MnuReimport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnuReimport.Click
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_edoka_import_set_reimport"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
Try
scmCmdToExecute.Parameters.Add(New SqlParameter("@eintrag", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Me.GrdJournaldetail.Columns(1).Value))
scmCmdToExecute.Parameters.Add(New SqlParameter("@mitarbeiternr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.MitarbeiterNr))
scmCmdToExecute.Parameters.Add(New SqlParameter("@fnkt", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, 0))
sdaAdapter.Fill(dtToReturn)
Catch ex As Exception
' // some error occured. Bubble it to caller and encapsulate Exception object
Throw New Exception("sp_edoka_import_update_xml::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Sub
Private Sub popupjournaldetails_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles popupjournaldetails.Popup
If Me.GrdJournaldetail.Columns("xml").Value = "" Then
Me.mnuIndexMutation.Enabled = False
Me.MnuReimport.Enabled = False
Me.MnuDokanzeige.Enabled = False
Else
Me.mnuIndexMutation.Enabled = True
Me.MnuReimport.Enabled = True
Me.MnuDokanzeige.Enabled = True
End If
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuindexdaten.Click
Dim conn_journale As String
conn_journale = get_journale_connection()
Dim s As String
s = Get_indexdatei(Me.GrdJournale.Columns(0).Value, conn_journale)
If s = "" Then Exit Sub
Dim XMLSTRING As String
Dim f As New frmEdoka_Import_TextEditor()
f.Als_Datei = True
Dim tr As TextReader
Dim hasdata As Boolean = True
tr = File.OpenText(s)
XMLSTRING = tr.ReadToEnd
f.xmlstring = XMLSTRING
tr.Close()
f.Als_Datei = True
f.ShowDialog()
If f.DialogResult = DialogResult.OK Then
If save_xmlstring_journal(Me.GrdJournale.Columns(0).Value, conn_journale, s, f.xmlstring) = False Then
MsgBox("Die Indexdaten konnten nicht gespeichert werden.", MsgBoxStyle.Exclamation)
End If
End If
End Sub
Private Function Get_indexdatei(ByVal itemid As Integer, ByVal connectionstring As String) As String
Dim connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select * From import_job where import_jobnr=" + LTrim(Str(itemid)), connection)
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()
Dim Dokumentfilename As String
Dim XMLFilename As String
Dim xmlstring As String
Dim xmlds As New DataSet()
Try
'Connectionstring zur Datenbank
connection.ConnectionString = connectionstring
connection.Open()
da.Fill(ds, "docs")
Dim myRow As DataRow
myRow = ds.Tables(0).Rows(0)
Dokumentfilename = Globals.Applikationsdaten.Rows(Globals.AppldataRow).Item("pfad_temporaer_dokumente") + "tmpind.ind"
Dim MyData() As Byte
MyData = myRow.Item(7)
Dim K As Long
K = UBound(MyData)
Dim fs As New FileStream(Dokumentfilename, FileMode.OpenOrCreate, FileAccess.Write)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing
Return Dokumentfilename
Catch ex As Exception
Return ""
Finally
CB = Nothing
ds = Nothing
da = Nothing
connection.Close()
connection = Nothing
End Try
End Function
Private Function save_xmlstring_journal(ByVal itemid As Integer, ByVal connectionstring As String, ByVal filename As String, ByVal xml As String) As Boolean
Dim connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select * From import_job where import_jobnr=" + LTrim(Str(itemid)), connection)
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()
FileOpen(11, filename, OpenMode.Output)
Print(11, xml)
FileClose(11)
Dim fs As New FileStream(filename, FileMode.Open, FileAccess.Read)
Dim mydata(fs.Length) As Byte
fs.Read(mydata, 0, fs.Length)
fs.Close()
Try
connection.ConnectionString = connectionstring
connection.Open()
da.Fill(ds, "docs")
Dim myRow As DataRow
myRow = ds.Tables(0).Rows(0)
myRow.Item(7) = mydata
da.Update(ds, "docs")
Return True
Catch ex As Exception
Return False
Finally
CB = Nothing
ds = Nothing
da = Nothing
connection.Close()
connection = Nothing
End Try
End Function
Private Sub MenuItem2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_edoka_import_set_reimport"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
Try
scmCmdToExecute.Parameters.Add(New SqlParameter("@eintrag", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Me.GrdJournale.Columns(0).Value))
scmCmdToExecute.Parameters.Add(New SqlParameter("@mitarbeiternr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.MitarbeiterNr))
scmCmdToExecute.Parameters.Add(New SqlParameter("@fnkt", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, 1))
sdaAdapter.Fill(dtToReturn)
Catch ex As Exception
' // some error occured. Bubble it to caller and encapsulate Exception object
Throw New Exception("sp_edoka_import_update_xml::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Sub
End Class