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.
212 lines
6.8 KiB
212 lines
6.8 KiB
Imports System.Drawing
|
|
Imports Syncfusion.Pdf
|
|
|
|
Imports Syncfusion.Pdf.Graphics
|
|
Imports Syncfusion.Pdf.Parsing
|
|
Imports System.Data.SqlClient
|
|
Imports System.Data.SqlDbType
|
|
Imports System.IO
|
|
Imports System
|
|
Imports C1.Win.C1TrueDBGrid
|
|
Imports System.Windows.Forms
|
|
|
|
Public Class Searchform
|
|
Private Sub Searchform_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
|
|
End Sub
|
|
|
|
Public Sub loadpdf(ByVal filename As String)
|
|
PdfViewerControl1.Load(filename)
|
|
End Sub
|
|
|
|
Public Function FindTextinPdf(texttofind As String) As Boolean
|
|
|
|
|
|
Dim IsMatchFound As Boolean
|
|
'Get the occurrences of the target text and location.
|
|
|
|
Dim textSearch As New Dictionary(Of Integer, List(Of RectangleF))()
|
|
Dim gaga As Dictionary(Of Integer, List(Of RectangleF))
|
|
|
|
IsMatchFound = PdfViewerControl1.FindText(texttofind, textSearch)
|
|
|
|
Dim s As String = PdfViewerControl1.FindText(texttofind, textSearch)
|
|
|
|
Return IsMatchFound
|
|
|
|
End Function
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
Me.OpenFileDialog1.ShowDialog()
|
|
|
|
If OpenFileDialog1.FileName <> "" Then
|
|
loadpdf(Me.OpenFileDialog1.FileName)
|
|
Me.TextBox1.Text = OpenFileDialog1.FileName
|
|
Me.TextBox6.Text = Me.TextBox6.Text + 1
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
|
Me.OpenFileDialog1.ShowDialog()
|
|
Me.TextBox2.Text = Me.OpenFileDialog1.FileName
|
|
|
|
If OpenFileDialog1.FileName <> "" Then
|
|
|
|
Dim empfaenger As New DataTable
|
|
Dim ds As New DataSet
|
|
ds.ReadXml(OpenFileDialog1.FileName)
|
|
empfaenger = ds.Tables(0).Copy
|
|
|
|
Dim dataView As New DataView(empfaenger)
|
|
dataView.Sort = " Partnernr desc"
|
|
Dim Empfaenger_sorted As DataTable = dataView.ToTable()
|
|
|
|
|
|
Me.C1TrueDBGrid1.Columns.Clear()
|
|
Me.C1TrueDBGrid1.DataSource = Nothing
|
|
|
|
|
|
Me.C1TrueDBGrid1.DataSource = Empfaenger_sorted
|
|
Me.C1TrueDBGrid1.DataMember = Empfaenger_sorted.TableName
|
|
For i = 0 To Me.C1TrueDBGrid1.Splits(0).DisplayColumns.Count - 1
|
|
Me.C1TrueDBGrid1.Splits(0).DisplayColumns(i).Width = 0
|
|
|
|
Next
|
|
Me.C1TrueDBGrid1.Splits(0).DisplayColumns("Partnernr").Width = 60
|
|
Me.C1TrueDBGrid1.Splits(0).DisplayColumns("Kurzbezeichnung").Width = 150
|
|
Me.C1TrueDBGrid1.Splits(0).DisplayColumns("blkunde").Width = 60
|
|
Me.C1TrueDBGrid1.Splits(0).DisplayColumns("dokumentid").Width = 150
|
|
Me.C1TrueDBGrid1.Splits(0).DisplayColumns("druckjobid").Width = 110
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Button3_Click(sender As Object, e As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
|
|
splitdoc()
|
|
End Sub
|
|
|
|
Function splitdoc()
|
|
Dim loadedDocument As New PdfLoadedDocument(Me.TextBox1.Text)
|
|
|
|
'Create a new PDF document.
|
|
|
|
Dim document As New PdfDocument()
|
|
|
|
Dim startIndex As Integer = 0
|
|
|
|
Dim endIndex As Integer = loadedDocument.Pages.Count - 1
|
|
|
|
'Import all the pages to the new PDF document.
|
|
|
|
document.ImportPageRange(loadedDocument, Me.PdfViewerControl1.CurrentPageIndex - 1, Me.PdfViewerControl1.CurrentPageIndex - 1 + Me.TextBox3.Text - 1)
|
|
|
|
|
|
'Save the document.
|
|
|
|
document.Save(Me.TextBox4.Text + "\" + Me.C1TrueDBGrid1.Columns("Dokumentid").Value + ".pdf")
|
|
|
|
|
|
If FindText(Me.TextBox4.Text + "\" + Me.C1TrueDBGrid1.Columns("Dokumentid").Value + ".pdf", C1TrueDBGrid1.Columns("partnernr").Value) Then
|
|
|
|
Else
|
|
MsgBox("Bitte prüfen, ob es sich um das korrekte Dokument handelt - Zustelladresse konnte nicht überprüft werden")
|
|
End If
|
|
|
|
|
|
|
|
''Close both document instances.
|
|
|
|
loadedDocument.Close(True)
|
|
|
|
document.Close(True)
|
|
|
|
Me.C1TrueDBGrid1.Bookmark = Me.C1TrueDBGrid1.Bookmark + 1
|
|
|
|
|
|
|
|
End Function
|
|
|
|
Private Sub C1TrueDBGrid1_RowColChange(sender As Object, e As RowColChangeEventArgs) Handles C1TrueDBGrid1.RowColChange
|
|
Me.Label5.Text = Me.C1TrueDBGrid1.Columns(1).Value
|
|
'
|
|
If Me.C1TrueDBGrid1.Bookmark < -1 Then
|
|
Me.PdfViewerControl1.GoToPageAtIndex(Me.C1TrueDBGrid1.Bookmark + 1)
|
|
Else
|
|
Me.PdfViewerControl1.GoToPageAtIndex(Me.C1TrueDBGrid1.Bookmark + 1 - ((Me.TextBox6.Text * Me.TextBox5.Text) - Me.TextBox5.Text))
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
|
|
Button4_Click(sender, e)
|
|
|
|
End Sub
|
|
|
|
Private Sub C1TrueDBGrid1_KeyDown(sender As Object, e As KeyEventArgs) Handles C1TrueDBGrid1.KeyDown
|
|
If e.KeyCode = Keys.S Then
|
|
Dim splitter() As String
|
|
splitter = Me.C1TrueDBGrid1.Columns("Kurzbezeichnung").Value.ToString.Split(" ")
|
|
Dim found As Boolean = False
|
|
For i = 0 To splitter.Length - 1
|
|
found = Me.FindTextinPdf(splitter(i))
|
|
If found Then
|
|
MsgBox("Gefunden")
|
|
|
|
Exit Sub
|
|
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Function FindText(filename As String, partnernr As Integer) As Boolean
|
|
Dim dt As New DataTable
|
|
Get_Partnerdata(dt, partnernr)
|
|
Dim f As New Searchform
|
|
|
|
f.loadpdf(filename)
|
|
Dim found As Boolean = False
|
|
|
|
For i As Integer = 0 To 14
|
|
If dt.Rows(0).Item(i).ToString <> "Frau" And dt.Rows(0).Item(i).ToString <> "Herr" And dt.Rows(0).Item(i).ToString <> "" Then
|
|
If f.FindTextinPdf(dt.Rows(0).Item(i)) Then
|
|
Return True
|
|
Exit Function
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
Return False
|
|
End Function
|
|
|
|
Sub Get_Partnerdata(ByRef dt As DataTable, ByVal partnernr As Integer)
|
|
dt.Rows.Clear()
|
|
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
|
Dim conn As New SqlConnection(My.Settings.ConnectionString)
|
|
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
|
scmCmdToExecute.CommandText = "dbo.SP_Partner_Detail"
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
scmCmdToExecute.Connection = conn
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@nrpar00", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, partnernr))
|
|
conn.Open()
|
|
|
|
Try
|
|
sdaAdapter.Fill(dt)
|
|
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
scmCmdToExecute.Dispose()
|
|
sdaAdapter.Dispose()
|
|
conn.Close()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Button6_Click(sender As Object, e As EventArgs)
|
|
|
|
End Sub
|
|
End Class |