1036 lines
51 KiB
VB.net
1036 lines
51 KiB
VB.net
Imports System
|
|
Imports System.ComponentModel
|
|
Imports System.Collections.Generic
|
|
Imports System.Diagnostics
|
|
Imports System.Text
|
|
|
|
Imports DevExpress.ExpressApp
|
|
Imports DevExpress.ExpressApp.Actions
|
|
Imports DevExpress.Persistent.Base
|
|
Imports System.IO
|
|
Imports DevExpress.Xpo
|
|
Imports DevExpress.Data.Filtering
|
|
Imports DevExpress.Persistent.BaseImpl
|
|
Imports DevExpress.ExpressApp.Win.Editors
|
|
Imports Microsoft.VisualBasic
|
|
|
|
Imports DevExpress.ExpressApp.Editors
|
|
Imports DevExpress.XtraGrid.Views.Grid
|
|
Imports DevExpress.Persistent.Validation
|
|
Imports DevExpress.ExpressApp.Reports
|
|
|
|
Imports Gnostice.PDFOne
|
|
Imports System.Globalization
|
|
Imports DevExpress.Utils
|
|
Imports DevExpress.ExpressApp.ConditionalAppearance
|
|
|
|
Public Class C3CTelecomVC
|
|
Inherits DevExpress.ExpressApp.ViewController
|
|
Dim _WaitFormClass As New WaitFormClass
|
|
Private Structure tItems
|
|
Dim Name As String
|
|
Dim FullName As String
|
|
Dim Unit As String
|
|
Dim VAT As String
|
|
Dim FullName_English As String
|
|
Dim Unit_English As String
|
|
End Structure
|
|
Private _ItemNumber As Integer = 100
|
|
Private _aItems(_ItemNumber) As tItems
|
|
Public Sub New()
|
|
MyBase.New()
|
|
InitializeComponent()
|
|
RegisterActions(components)
|
|
End Sub
|
|
Protected Overrides Sub OnActivated()
|
|
MyBase.OnActivated()
|
|
If View.Id = "C3CImportHeader_C3CImportRows_ListView" Then ' -- A beágyazott ListView feletti toolbar
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.Win.SystemModule.OpenObjectController)().Active.SetItemValue("", False)
|
|
End If
|
|
|
|
If View.Id = "C3CImportHeader_C3CGeneratedInvoice_ListView" Then ' -- A beágyazott ListView feletti toolbar
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.Win.SystemModule.OpenObjectController)().Active.SetItemValue("", False)
|
|
End If
|
|
|
|
If View.Id = "C3CInvoicePopup_DetailView" Then
|
|
AddHandler Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DialogController)().AcceptAction.Executing, AddressOf AcceptAction_Executing
|
|
End If
|
|
|
|
If View.Id = "C3CGeneratedInvoice_DocumentFile_ListView" Then
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", False)
|
|
Frame.GetController(Of DevExpress.ExpressApp.Win.SystemModule.OpenObjectController)().Active.SetItemValue("", False)
|
|
End If
|
|
End Sub
|
|
Protected Overrides Sub OnDeActivated()
|
|
MyBase.OnDeactivated()
|
|
If View.Id = "C3CImportHeader_C3CImportRows_ListView" Then ' -- A beágyazott ListView feletti toolbar
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.Win.SystemModule.OpenObjectController)().Active.SetItemValue("", True)
|
|
End If
|
|
|
|
If View.Id = "C3CImportHeader_C3CGeneratedInvoice_ListView" Then ' -- A beágyazott ListView feletti toolbar
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", True)
|
|
Frame.GetController(Of DevExpress.ExpressApp.Win.SystemModule.OpenObjectController)().Active.SetItemValue("", True)
|
|
End If
|
|
|
|
If View.Id = "C3CInvoicePopup_DetailView" Then
|
|
RemoveHandler Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DialogController)().AcceptAction.Executing, AddressOf AcceptAction_Executing
|
|
End If
|
|
End Sub
|
|
Private Sub AcceptAction_Executing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
|
|
Validator.RuleSet.ValidateAll(View.ObjectSpace, View.SelectedObjects, DefaultContexts.Save)
|
|
End Sub
|
|
Private Sub Import_Items(openString As FileData)
|
|
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
|
|
Dim _MemoryStream As New MemoryStream
|
|
Dim _StreamReader As StreamReader
|
|
Dim _Line As String
|
|
Dim _sArray As Array
|
|
Dim _index As Integer
|
|
Dim _VAT As VAT
|
|
|
|
For index = 0 To _ItemNumber - 1
|
|
_aItems(index).Name = ""
|
|
Next
|
|
|
|
openString.SaveToStream(_MemoryStream)
|
|
_MemoryStream.Position = 0
|
|
_StreamReader = New StreamReader(_MemoryStream, System.Text.Encoding.Default) ' Esetleg: System.Text.Encoding.GetEncoding(1250)
|
|
_index = 0
|
|
|
|
Do While _StreamReader.Peek <> -1
|
|
_Line = _StreamReader.ReadLine
|
|
_sArray = _Line.Split(";")
|
|
|
|
On Error GoTo CheckError
|
|
|
|
If _sArray.Length > 1 Then
|
|
_aItems(_index).Name = _sArray(0)
|
|
_aItems(_index).FullName = _sArray(4)
|
|
_aItems(_index).FullName_English = _sArray(60)
|
|
_aItems(_index).Unit = _sArray(8)
|
|
_aItems(_index).Unit_English = _sArray(59)
|
|
|
|
Select Case _sArray(13)
|
|
Case "W27" : _aItems(_index).VAT = "27 %"
|
|
Case "W25" : _aItems(_index).VAT = "25 %"
|
|
Case "W0N" : _aItems(_index).VAT = "EU 0"
|
|
Case "W00" : _aItems(_index).VAT = "0 % Export"
|
|
End Select
|
|
|
|
_VAT = _ocur.FindObject(Of VAT)(CriteriaOperator.Parse("ShortName=?", _aItems(_index).VAT))
|
|
If _VAT Is Nothing Then
|
|
Throw New UserFriendlyException("A keresett ÁFA kód nem található, esetleg nem a várt formátumban található az üzleti törzsben.")
|
|
End If
|
|
|
|
_index = _index + 1
|
|
End If
|
|
Loop
|
|
|
|
CheckError:
|
|
|
|
If Err.Number = 9 Then Throw New UserFriendlyException("Hiba történt. Kérem ellenõrizze a bemeneti fájlokat.")
|
|
End Sub
|
|
Private Function GetItembyName(vName As String) As Long
|
|
For _index = 0 To _ItemNumber - 1
|
|
If _aItems(_index).Name = vName Then
|
|
Return _index
|
|
End If
|
|
Next
|
|
|
|
Return -1
|
|
End Function
|
|
Private Sub aC3CTelecomImports_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aC3CTelecomImports.Execute
|
|
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
|
|
Dim _uow As New UnitOfWork(_ocur.Session.DataLayer)
|
|
Dim _C3CImportRows As C3CImportRows = Nothing
|
|
|
|
Dim _C3C As C3CImportHeader = TryCast(View.SelectedObjects(0), C3CImportHeader)
|
|
_C3C.Save()
|
|
View.ObjectSpace.CommitChanges()
|
|
|
|
Dim _C3CImportHeader As C3CImportHeader = _uow.GetObjectByKey(Of C3CImportHeader)(_C3C.Oid)
|
|
|
|
Dim _MemoryStream As New MemoryStream
|
|
Dim _StreamReader As StreamReader
|
|
Dim _C3CImportRows_Collection As New XPCollection(Of C3CImportRows)(_uow, CriteriaOperator.Parse("C3CImportHeader.Oid=?", _C3CImportHeader.Oid))
|
|
Dim _Line As String
|
|
Dim _sArray As Array
|
|
Dim _result As Double = 0
|
|
Dim _prev_result As Double = 0
|
|
Dim _index As Long = 1
|
|
Dim _GUID As Guid
|
|
Dim _Date As Date
|
|
Dim _Szj As String = "SZJ 64.20.18"
|
|
|
|
Import_Items(_C3CImportHeader.FileItems)
|
|
|
|
_uow.Delete(_C3CImportRows_Collection)
|
|
|
|
_C3CImportHeader.FileInvoices.SaveToStream(_MemoryStream)
|
|
_MemoryStream.Position = 0
|
|
_StreamReader = New StreamReader(_MemoryStream, System.Text.Encoding.Default) ' Esetleg: System.Text.Encoding.GetEncoding(1250)
|
|
Do While _StreamReader.Peek <> -1
|
|
_Line = _StreamReader.ReadLine
|
|
_sArray = _Line.Split(";")
|
|
|
|
If _sArray.Length > 1 Then
|
|
|
|
If (_result <> _prev_result) Or _sArray(0) = "0" Then
|
|
_C3CImportRows = New C3CImportRows(_uow)
|
|
_C3CImportRows.C3CImportHeader = _C3CImportHeader
|
|
_C3CImportRows.RowIndex = _index
|
|
_index = _index + 1
|
|
_GUID = Guid.NewGuid
|
|
_Date = Format(GetSQLTime(_ocur.Session), "yyyy-MM-dd")
|
|
'_Date = Convert.ToDateTime(GetSQLTime(_ocur.Session))
|
|
'_Date = _Date.Date
|
|
If Double.TryParse(_sArray(2), _result) Then
|
|
If _result < 200000 Then
|
|
_result = 200000 + _result
|
|
End If
|
|
End If
|
|
|
|
_C3CImportRows.Col01 = _result
|
|
_C3CImportRows.Col02 = _sArray(16) & ";" & _sArray(3)
|
|
_C3CImportRows.Col03 = Replace(_sArray(17), ".", ",")
|
|
_C3CImportRows.Col04 = _Date
|
|
_C3CImportRows.Col05 = _Date.AddDays(Convert.ToInt16(_sArray(18)))
|
|
_C3CImportRows.Col06 = _Date.AddDays(Convert.ToInt16(_sArray(18)))
|
|
_C3CImportRows.Col07 = _GUID.ToString
|
|
_C3CImportRows.Col08 = "H"
|
|
|
|
_prev_result = _result
|
|
_C3CImportRows.Save()
|
|
End If
|
|
|
|
If _sArray(0) <> "0" Then
|
|
If Convert.ToInt16(_sArray(0)) Mod 2 = 1 Then 'Páratlan azonosítójú sor.
|
|
_C3CImportRows = New C3CImportRows(_uow)
|
|
_C3CImportRows.C3CImportHeader = _C3CImportHeader
|
|
_C3CImportRows.RowIndex = _index
|
|
_index = _index + 1
|
|
_C3CImportRows.Col01 = _Szj
|
|
_C3CImportRows.Col02 = _aItems(Me.GetItembyName(_sArray(29))).FullName & " " & vbNewLine & _aItems(Me.GetItembyName(_sArray(29))).FullName_English
|
|
Double.TryParse(_sArray(32), _C3CImportRows.Col03)
|
|
_C3CImportRows.Col04 = _aItems(Me.GetItembyName(_sArray(29))).Unit & "/" & _aItems(Me.GetItembyName(_sArray(29))).Unit_English
|
|
_C3CImportRows.Col05 = Replace(_sArray(36), ".", ",")
|
|
_C3CImportRows.Col06 = _aItems(Me.GetItembyName(_sArray(29))).VAT
|
|
Else 'Páros azonosítójú sor.
|
|
_C3CImportRows.Col02 = _C3CImportRows.Col02 & " " & vbNewLine + _sArray(39)
|
|
_C3CImportRows.Col07 = _GUID.ToString
|
|
_C3CImportRows.Col08 = "R"
|
|
_C3CImportRows.Save()
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
Loop
|
|
_C3CImportHeader.Save()
|
|
_uow.CommitChanges()
|
|
|
|
Dim _C3CImportRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("C3CImportRows")
|
|
Dim _ListView As ListView = TryCast(_C3CImportRows_ListEditor.ListView, ListView)
|
|
|
|
Dim _GridListEditor As GridListEditor = TryCast(_ListView.Editor, GridListEditor)
|
|
|
|
Dim _columnInfo = _GridListEditor.FindColumn("RowIndex")
|
|
_columnInfo.SortIndex = 0
|
|
_columnInfo.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending
|
|
_GridListEditor.GridView.BestFitColumns()
|
|
|
|
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.RefreshController).RefreshAction.DoExecute()
|
|
End Sub
|
|
Private Sub aC3CCreateInvoice_CustomizePopupWindowParams(sender As System.Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aC3CCreateInvoice.CustomizePopupWindowParams
|
|
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
|
|
Dim _C3CImportHeader_old As C3CImportHeader = TryCast(View.SelectedObjects(0), C3CImportHeader)
|
|
_C3CImportHeader_old.Save()
|
|
_ocur.CommitChanges()
|
|
|
|
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace()
|
|
Dim _C3CImportHeader As C3CImportHeader = _onew.GetObjectByKey(Of C3CImportHeader)(TryCast(View.SelectedObjects(0), C3CImportHeader).Oid)
|
|
'Dim _PaymentOption As PaymentOption = TryCast(View.SelectedObjects(0), C3CImportHeader).PaymentOption ' Értéket átveszek röptiben, mert ha nincs mentés akkor a régi mentett értéket veszi át...
|
|
Dim _C3CInvoicePopup As New C3CInvoicePopup(_onew.Session)
|
|
|
|
'If Not _C3CImportHeader_old.Equals(_C3CImportHeader) Then 'Ha _C3CImportHeader_old különbözik _C3CImportHeader akkor figyelmeztetés. Csak akkor legyen save, ha biztosan jó ez így.
|
|
' Dim _result As Windows.Forms.DialogResult = Windows.Forms.MessageBox.Show("A fejléc adatai megváltoztak. Biztosan ezekkel az adatokkal kíván számlát készíteni?", _
|
|
' "Kérdés", Windows.Forms.MessageBoxButtons.YesNo, _
|
|
' Windows.Forms.MessageBoxIcon.Question, _
|
|
' Windows.Forms.MessageBoxDefaultButton.Button1)
|
|
' If _result = Windows.Forms.DialogResult.No Then
|
|
' Exit Sub 'Exceptiont dob. Miért?
|
|
' Else
|
|
' _C3CImportHeader_old.Save()
|
|
' _ocur.CommitChanges()
|
|
' End If
|
|
'End If
|
|
|
|
'If _C3CImportHeader.PaymentOption.PayMode = 1 Then
|
|
' _C3CInvoicePopup.IsRequiredBankInformation = True
|
|
'Else
|
|
' _C3CInvoicePopup.IsRequiredBankInformation = False
|
|
'End If
|
|
_C3CInvoicePopup.CustomersFrom = _C3CImportHeader.CustomersFrom
|
|
e.View = Application.CreateDetailView(_onew, _C3CInvoicePopup, False)
|
|
End Sub
|
|
Private Sub aC3CCreateInvoice_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aC3CCreateInvoice.Execute
|
|
'Számla készítése a megadott táblázat alapján
|
|
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
|
|
|
|
'Dim _nf As NumberFormatInfo = New NumberFormatInfo
|
|
'Dim _DecimalSeparator As String = _nf.NumberDecimalSeparator
|
|
'Dim _GroupSeparator As String = _nf.NumberGroupSeparator
|
|
|
|
'_nf.NumberDecimalSeparator = ","
|
|
'_nf.NumberGroupSeparator = " "
|
|
|
|
Dim _C3CImportHeader As C3CImportHeader = TryCast(View.SelectedObjects(0), C3CImportHeader)
|
|
Dim _C3CInvoicePopup As C3CInvoicePopup = TryCast(e.PopupWindow.View.SelectedObjects(0), C3CInvoicePopup)
|
|
Dim _C3CGeneratedInvoice As C3CGeneratedInvoice
|
|
Dim _C3CTelecomInvoiceType As C3CTelecomInvoiceType = Nothing
|
|
Dim _InvoiceHeader As InvoiceHeader = Nothing
|
|
Dim _InvoiceRows As InvoiceRows
|
|
Dim _C3CImportRows As C3CImportRows
|
|
Dim _Customers As Customers
|
|
Dim _index As Int16 = 0
|
|
Dim _period As String = ""
|
|
Dim _NG As NumberGenerator
|
|
|
|
Dim _CustomsTariffs As CustomsTariffs
|
|
Dim _Units As Units
|
|
|
|
|
|
For Each _GeneratedInv As C3CGeneratedInvoice In _C3CImportHeader.C3CGeneratedInvoice
|
|
If _GeneratedInv.InvoiceHeader.IsProforma Then
|
|
|
|
_ocur.Delete(_GeneratedInv.InvoiceHeader.InvoiceRows)
|
|
_ocur.Delete(_GeneratedInv.InvoiceHeader) 'Biztos, hogy nem kellene inkább stornózni???
|
|
Else
|
|
Throw New UserFriendlyException("Csak proforma számlák generálhatóak újra.")
|
|
End If
|
|
Next
|
|
_ocur.Delete(_C3CImportHeader.C3CGeneratedInvoice)
|
|
|
|
|
|
_C3CImportHeader.C3CImportRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending))
|
|
_WaitFormClass.InitWork(1, 1, _C3CImportHeader.C3CImportRows.Count)
|
|
For Each _C3CImportRows In _C3CImportHeader.C3CImportRows
|
|
_WaitFormClass.DoWork()
|
|
If _C3CImportRows.Col08 = "H" Then
|
|
'Try
|
|
_Customers = _ocur.FindObject(Of Customers)(CriteriaOperator.Parse("CustomerNumber=?", _C3CImportRows.Col01))
|
|
'Catch ex As Exception
|
|
'Throw New UserFriendlyException("A számlázásra kiválasztott ügyfél nem található az ügyféltörzsben.")
|
|
'End Try
|
|
|
|
_period = _C3CImportRows.Col02.Substring(4)
|
|
|
|
On Error GoTo CheckError
|
|
|
|
'-------------FEJLÉC LÉTREHOZÁSA-----------------------------------------------------------------------------------
|
|
_C3CTelecomInvoiceType = _ocur.FindObject(Of C3CTelecomInvoiceType)(CriteriaOperator.Parse("CurrencyName.ShortName=?", _C3CImportRows.Col02.Substring(0, 3)))
|
|
|
|
_InvoiceHeader = _ocur.CreateObject(Of InvoiceHeader)()
|
|
_InvoiceHeader.IsProforma = True
|
|
_InvoiceHeader.IsEditable = False
|
|
_InvoiceHeader.CustomersFrom = _C3CImportHeader.CustomersFrom
|
|
_InvoiceHeader.InvoiceType = _C3CTelecomInvoiceType.InvoiceType
|
|
If _InvoiceHeader.InvoiceType.NumberGeneratorProforma IsNot Nothing Then
|
|
_NG = _InvoiceHeader.InvoiceType.NumberGeneratorProforma
|
|
_InvoiceHeader.DocumentNumberProforma = _NG.GetNewNumber(_NG)
|
|
End If
|
|
_InvoiceHeader.Customers = _Customers
|
|
_InvoiceHeader.DateCreated = _C3CImportRows.Col04
|
|
_InvoiceHeader.DateExecution = _C3CImportRows.Col05
|
|
_InvoiceHeader.DatePayment = _C3CImportRows.Col06
|
|
_InvoiceHeader.Description = _C3CInvoicePopup.Description
|
|
'_InvoiceHeader.BankInformation = _ocur.GetObjectByKey(Of BankInformation)(_C3CInvoicePopup.BankInformation.Oid)
|
|
_InvoiceHeader.CurrencyName = _ocur.FindObject(Of CurrencyName)(CriteriaOperator.Parse("ShortName=?", _C3CImportRows.Col02.Substring(0, 3)))
|
|
_InvoiceHeader.InvoicePeriod = _C3CImportRows.Col02.Substring(4)
|
|
|
|
Dim _NI As New NumberFormatInfo
|
|
Dim s As String = _NI.NumberDecimalSeparator
|
|
Dim _array = Split(_C3CImportRows.Col03, ",")
|
|
|
|
_InvoiceHeader.CurrencyRate = _array(0) + _array(1) / 10 ^ (_array(1).Length)
|
|
_InvoiceHeader.PaymentOption = _C3CTelecomInvoiceType.PaymentOption
|
|
_InvoiceHeader.BankInformation = _C3CTelecomInvoiceType.BankInformation
|
|
|
|
'-- Próbaszámla miatt el kell menteni a tényleges adatokat --------------------------------------------------------
|
|
_InvoiceHeader.Saved_Customers_Name = _Customers.FullName.ToString()
|
|
_InvoiceHeader.Saved_Customers_Address_Country = _Customers.Address1.Country.ToString
|
|
_InvoiceHeader.Saved_Customers_Address_ZipPostal = _Customers.Address1.ZipPostal.ToString
|
|
_InvoiceHeader.Saved_Customers_Address_Street = _Customers.Address1.Street.ToString
|
|
_InvoiceHeader.Saved_Customers_Address_City = _Customers.Address1.City.ToString
|
|
_InvoiceHeader.Saved_Customers_Address_StateProvince = _Customers.Address1.StateProvince.ToString
|
|
_InvoiceHeader.Saved_Customers_VATNumber = _Customers.VATNumber.ToString
|
|
_InvoiceHeader.Saved_Customers_VATNumberEU = _Customers.VATNumberEU.ToString
|
|
|
|
_InvoiceHeader.Saved_CustomersFrom_Name = _C3CImportHeader.CustomersFrom.FullName.ToString()
|
|
_InvoiceHeader.Saved_CustomersFrom_Address_Country = _C3CImportHeader.CustomersFrom.Address1.Country.ToString
|
|
_InvoiceHeader.Saved_CustomersFrom_Address_ZipPostal = _C3CImportHeader.CustomersFrom.Address1.ZipPostal.ToString
|
|
_InvoiceHeader.Saved_CustomersFrom_Address_Street = _C3CImportHeader.CustomersFrom.Address1.Street.ToString
|
|
_InvoiceHeader.Saved_CustomersFrom_Address_City = _C3CImportHeader.CustomersFrom.Address1.City.ToString
|
|
_InvoiceHeader.Saved_CustomersFrom_Address_StateProvince = _C3CImportHeader.CustomersFrom.Address1.StateProvince.ToString
|
|
_InvoiceHeader.Saved_CustomersFrom_VATNumber = _C3CImportHeader.CustomersFrom.VATNumber.ToString
|
|
_InvoiceHeader.Saved_CustomersFrom_VATNumberEU = _C3CImportHeader.CustomersFrom.VATNumberEU.ToString
|
|
|
|
_InvoiceHeader.Saved_CustomersFrom_Bank_ShortName = _C3CTelecomInvoiceType.BankInformation.FullBankAccount.ToString
|
|
_InvoiceHeader.Saved_CustomersFrom_Bank_IBAN = _C3CTelecomInvoiceType.BankInformation.IBAN.ToString
|
|
_InvoiceHeader.Saved_CustomersFrom_Bank_SWIFT = _C3CTelecomInvoiceType.BankInformation.SWIFT.ToString
|
|
_InvoiceHeader.Saved_CustomersFrom_Bank_AccountNumber = _C3CTelecomInvoiceType.BankInformation.AccountNumber.ToString
|
|
|
|
_C3CGeneratedInvoice = _ocur.CreateObject(Of C3CGeneratedInvoice)()
|
|
_C3CGeneratedInvoice.C3CImportHeader = _C3CImportHeader
|
|
_C3CGeneratedInvoice.InvoiceHeader = _InvoiceHeader
|
|
|
|
_index = 0
|
|
'-------------FEJLÉC LÉTREHOZVA------------------------------------------------------------------------------------
|
|
End If
|
|
|
|
If _C3CImportRows.Col08 = "R" Then
|
|
|
|
_InvoiceRows = _ocur.CreateObject(Of InvoiceRows)()
|
|
_InvoiceRows.InvoiceHeader = _InvoiceHeader
|
|
|
|
_InvoiceRows.Controlling = _C3CTelecomInvoiceType.Controlling
|
|
_InvoiceRows.InvoiceRowtype = eInvoiceRowType.FromManual
|
|
_InvoiceRows.VAT = _ocur.FindObject(Of VAT)(CriteriaOperator.Parse("ShortName=?", _C3CImportRows.Col06))
|
|
|
|
_InvoiceRows.ShortName = _C3CImportRows.Col02 'Csak a megjegyzést (2. oszlop) tesszük ide!
|
|
_InvoiceRows.Description = _period 'Idõszak
|
|
'_InvoiceRows.Description = _C3CImportRows.Col02 + " " + vbNewLine + _C3CImportRows.Col01 'Megnevezés + szj szám - javítva lett!!
|
|
_CustomsTariffs = _ocur.FindObject(Of CustomsTariffs)(CriteriaOperator.Parse("CustomsTariffNumber=?", _C3CImportRows.Col01))
|
|
If _CustomsTariffs Is Nothing Then
|
|
_CustomsTariffs = _ocur.CreateObject(Of CustomsTariffs)()
|
|
_CustomsTariffs.CustomsTariffNumber = _C3CImportRows.Col01
|
|
End If
|
|
_InvoiceRows.CustomsTariffs = _CustomsTariffs
|
|
|
|
'Amíg a CustomsTariffs tábla nincs feltöltve, a mezõ értéke mindig nothing lesz. Amennyiben a tábla feltöltésre kerül, le kell ellenõrizni,
|
|
'hogy megfelelõ-e a formátum.
|
|
|
|
_Units = _ocur.FindObject(Of Units)(CriteriaOperator.Parse("ShortName=?", _C3CImportRows.Col04.Substring(0, 2)))
|
|
If _Units Is Nothing Then
|
|
_Units = _ocur.CreateObject(Of Units)()
|
|
_Units.ShortName = _C3CImportRows.Col04.Substring(0, 2)
|
|
_Units.ShortName_Gb = _C3CImportRows.Col04.Substring(3, 4)
|
|
End If
|
|
_InvoiceRows.Units = _Units
|
|
|
|
'If _InvoiceRows.Units Is Nothing Then
|
|
'Throw New UserFriendlyException("A keresett mennyiségegység nem található.")
|
|
'End If
|
|
|
|
_InvoiceRows.QTT = _C3CImportRows.Col03
|
|
If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then
|
|
_InvoiceRows.ListPriceHUF = _C3CImportRows.Col05
|
|
Else
|
|
_InvoiceRows.ListPriceHUF = _C3CImportRows.Col05 * _InvoiceHeader.CurrencyRate
|
|
_InvoiceRows.ListPriceDEV = _C3CImportRows.Col05
|
|
End If
|
|
|
|
_InvoiceRows.RowIndex = _index
|
|
_index = _index + 1
|
|
|
|
_ocur.CommitChanges()
|
|
_InvoiceHeader.RecalculateInvoice(_InvoiceHeader, _ocur)
|
|
End If
|
|
|
|
_ocur.CommitChanges()
|
|
Next
|
|
|
|
_ocur.CommitChanges()
|
|
_WaitFormClass.Finalwork()
|
|
|
|
'_nf.NumberDecimalSeparator = _DecimalSeparator
|
|
'_nf.NumberGroupSeparator = _GroupSeparator
|
|
|
|
Exit Sub
|
|
CheckError:
|
|
If Err.Number = 91 Then Resume Next
|
|
If Err.Number = 13 Then Resume Next
|
|
If Err.Number = 5 Then
|
|
_WaitFormClass.Finalwork()
|
|
Throw New UserFriendlyException(Err.Description)
|
|
'_nf.NumberDecimalSeparator = _DecimalSeparator
|
|
'_nf.NumberGroupSeparator = _GroupSeparator
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub aFinalizeInvoices_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aFinalizeInvoices.Execute
|
|
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
|
|
Dim _C3CGeneratedInvoice As C3CGeneratedInvoice
|
|
Dim _InvoiceVC As New SISBusiness.Module.InvoiceVC
|
|
Dim _C3CImportHeader As C3CImportHeader = TryCast(TryCast(View, ListView).CollectionSource, PropertyCollectionSource).MasterObject
|
|
Dim _DatePayment As Date
|
|
|
|
_WaitFormClass.InitWork(1, 1, _C3CImportHeader.C3CGeneratedInvoice.Count)
|
|
For Each _C3CGeneratedInvoice In _C3CImportHeader.C3CGeneratedInvoice
|
|
_WaitFormClass.DoWork()
|
|
|
|
_DatePayment = _C3CGeneratedInvoice.InvoiceHeader.DatePayment
|
|
_InvoiceVC.FinalizeInvoice(_C3CGeneratedInvoice.InvoiceHeader, View, _ocur)
|
|
_C3CGeneratedInvoice.InvoiceHeader.DatePayment = _DatePayment
|
|
_C3CGeneratedInvoice.InvoiceHeader.Save()
|
|
|
|
Next
|
|
|
|
_ocur.CommitChanges()
|
|
View.Refresh()
|
|
|
|
_WaitFormClass.Finalwork()
|
|
End Sub
|
|
Private Sub aPrintInvoices_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aPrintInvoices.Execute
|
|
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
|
|
Dim _C3CGeneratedInvoice As C3CGeneratedInvoice
|
|
Dim _InvoiceVC As New SISBusiness.Module.InvoiceVC
|
|
Dim _C3CImportHeader As C3CImportHeader = TryCast(TryCast(View, ListView).CollectionSource, PropertyCollectionSource).MasterObject
|
|
Dim _C3CTelecomInvoiceType As C3CTelecomInvoiceType
|
|
Dim _ReportData As ReportData
|
|
Dim _InvoiceHeade_Collection As New List(Of InvoiceHeader)
|
|
Dim _inoperator As InOperator
|
|
|
|
If _C3CImportHeader.C3CGeneratedInvoice.Count > 0 Then
|
|
_C3CTelecomInvoiceType = _ocur.FindObject(Of C3CTelecomInvoiceType)(CriteriaOperator.Parse("CurrencyName=?", _C3CImportHeader.C3CGeneratedInvoice(0).InvoiceHeader.CurrencyName))
|
|
_ReportData = _C3CTelecomInvoiceType.ReportData
|
|
|
|
For Each _C3CGeneratedInvoice In _C3CImportHeader.C3CGeneratedInvoice
|
|
_InvoiceHeade_Collection.Add(_C3CGeneratedInvoice.InvoiceHeader)
|
|
Next
|
|
_inoperator = New InOperator("InvoiceHeader", _InvoiceHeade_Collection)
|
|
|
|
If _ReportData IsNot Nothing Then
|
|
Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_ReportData, _inoperator, True)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub aPrinttoPdfInvoices_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aPrinttoPdfInvoices.Execute
|
|
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
|
|
Dim _C3CGeneratedInvoice As C3CGeneratedInvoice
|
|
Dim _C3CImportHeader As C3CImportHeader = TryCast(TryCast(View, ListView).CollectionSource, PropertyCollectionSource).MasterObject
|
|
Dim _InvoiceHeader As InvoiceHeader
|
|
Dim _FileName As String
|
|
Dim _FileNameOriginalWithAttachments As String
|
|
Dim _FileStream As FileStream
|
|
Dim _StreamReader As StreamReader
|
|
Dim _C3CTelecomInvoiceType As C3CTelecomInvoiceType
|
|
|
|
Dim _NewPdfFileName As String
|
|
|
|
Dim _FN As String
|
|
Dim _SF As FileStream
|
|
Dim _DeletableFileNames As New Collection
|
|
|
|
Dim _DOC As PDFDocument = New PDFDocument("2962-F2F8-23B1-5FD8-F4A3-55DB-7D94-28E9")
|
|
Dim _FA As PDFFileAttachmentAnnot
|
|
|
|
_WaitFormClass.InitWork(1, 1, _C3CImportHeader.C3CGeneratedInvoice.Count)
|
|
For Each _C3CGeneratedInvoice In _C3CImportHeader.C3CGeneratedInvoice
|
|
_WaitFormClass.DoWork()
|
|
_FileName = Nothing
|
|
If _C3CGeneratedInvoice IsNot Nothing Then
|
|
_InvoiceHeader = _C3CGeneratedInvoice.InvoiceHeader
|
|
|
|
If _InvoiceHeader.PrintCopy = 0 Then
|
|
If _InvoiceHeader.PDF_Original Is Nothing Then
|
|
|
|
_InvoiceHeader.PrintCopy = 1
|
|
_C3CTelecomInvoiceType = _ocur.FindObject(Of C3CTelecomInvoiceType)(CriteriaOperator.Parse("CurrencyName.Oid=?", _InvoiceHeader.CurrencyName.Oid))
|
|
_FileName = _InvoiceHeader.GeneratePDFs(_ocur, _InvoiceHeader, False, _C3CTelecomInvoiceType.ReportData)
|
|
End If
|
|
End If
|
|
|
|
If _FileName Is Nothing Then
|
|
|
|
_FileName = Path.GetTempPath & "ORIGINAL" & ".pdf"
|
|
Dim _StreamFile As New FileStream(_FileName, FileMode.Create)
|
|
_InvoiceHeader.PDF_Original.SaveToStream(_StreamFile)
|
|
_StreamFile.Close()
|
|
|
|
End If
|
|
|
|
_DOC.Load(_FileName) 'PdfOne filekezelés kezdete.
|
|
|
|
For Each _C3CGeneratedInvoiceDocuments As C3CGeneratedInvoiceDocuments In _C3CGeneratedInvoice.DocumentFile 'Hozzátesszük az összes csatolandó dokumentumot.
|
|
|
|
_FN = Path.GetTempPath & _C3CGeneratedInvoiceDocuments.File.FileName
|
|
_SF = New FileStream(_FN, FileMode.Create)
|
|
|
|
_C3CGeneratedInvoiceDocuments.File.SaveToStream(_SF)
|
|
_SF.Close()
|
|
|
|
_FA = New PDFFileAttachmentAnnot(_FN, False, False, PDFFileAttachmentIcon.Paperclip)
|
|
_DOC.AddAnnot(_FA)
|
|
|
|
_DeletableFileNames.Add(_FN)
|
|
Next
|
|
|
|
If _InvoiceHeader.Customers IsNot Nothing Then 'Ez lesz a csstolt Pdf neve. Néha előfordul, hogy üres a név...
|
|
|
|
_FileNameOriginalWithAttachments = _InvoiceHeader.Customers.CustomerNumber.ToString & "_" & Replace(_InvoiceHeader.DocumentNumber, "/", "_") & _
|
|
"_" & _InvoiceHeader.DateCreated.Year.ToString & _InvoiceHeader.DateCreated.Month.ToString & _InvoiceHeader.DateCreated.Day.ToString & ".pdf"
|
|
Else
|
|
_FileNameOriginalWithAttachments = "Noname_" & Replace(_InvoiceHeader.DocumentNumber, "/", "_") & _
|
|
"_" & _InvoiceHeader.DateCreated.Year.ToString & _InvoiceHeader.DateCreated.Month.ToString & _InvoiceHeader.DateCreated.Day.ToString & ".pdf"
|
|
End If
|
|
|
|
_NewPdfFileName = Path.GetTempPath & _FileNameOriginalWithAttachments
|
|
|
|
|
|
|
|
_DOC.Save(_NewPdfFileName)
|
|
_DOC.Close()
|
|
For Each _Element As String In _DeletableFileNames 'Kitöröljük a csatolt fájlok elmentett változatait.
|
|
File.Delete(_Element)
|
|
Next
|
|
|
|
_FileStream = New FileStream(_NewPdfFileName, FileMode.Open, FileAccess.Read)
|
|
_StreamReader = New StreamReader(_FileStream)
|
|
_FileStream.Seek(0, SeekOrigin.Begin)
|
|
|
|
_C3CGeneratedInvoice.PdfOriginalWithAttachments = New FileData(_ocur.Session)
|
|
_C3CGeneratedInvoice.PdfOriginalWithAttachments.LoadFromStream(_FileNameOriginalWithAttachments, _FileStream)
|
|
_C3CGeneratedInvoice.PdfOriginalWithAttachments.FileName = _FileNameOriginalWithAttachments
|
|
|
|
_StreamReader.Close()
|
|
_FileStream.Close()
|
|
|
|
File.Delete(_NewPdfFileName)
|
|
File.Delete(_FileName)
|
|
|
|
|
|
_InvoiceHeader.PrintCopy = 2 'Csupán létrehozzuk a másolat file-t is.
|
|
_FileName = _InvoiceHeader.GeneratePDFs(_ocur, _InvoiceHeader, False)
|
|
File.Delete(_FileName)
|
|
|
|
'_C3CGeneratedInvoice.Save()
|
|
_ocur.CommitChanges()
|
|
|
|
End If
|
|
Next
|
|
_WaitFormClass.Finalwork()
|
|
End Sub
|
|
Private Sub aViewOriginalWithAttachment_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aViewOriginalWithAttachment.Execute
|
|
Dim _FN As String
|
|
Dim _SF As FileStream
|
|
Dim _C3CGeneratedInvoice As C3CGeneratedInvoice = View.SelectedObjects(0)
|
|
|
|
If _C3CGeneratedInvoice IsNot Nothing Then
|
|
If _C3CGeneratedInvoice.PdfOriginalWithAttachments IsNot Nothing Then
|
|
_FN = Path.GetTempPath & "OriginalWithAttachments.pdf"
|
|
_SF = New FileStream(_FN, FileMode.Create)
|
|
|
|
_C3CGeneratedInvoice.PdfOriginalWithAttachments.SaveToStream(_SF)
|
|
_SF.Close()
|
|
|
|
Dim _Process As System.Diagnostics.Process = New System.Diagnostics.Process
|
|
_Process.StartInfo.FileName = _FN
|
|
_Process.Start()
|
|
|
|
_Process.WaitForExit()
|
|
File.Delete(_FN)
|
|
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
'Private Sub aPrinttoPdfInvoices_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aPrinttoPdfInvoices.Execute
|
|
'Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
|
|
'Dim _C3CGeneratedInvoice As C3CGeneratedInvoice
|
|
'Dim _InvoiceHeader As InvoiceHeader
|
|
'Dim _FileName As String
|
|
|
|
'Dim _PdfEngine As PDFDocEngine
|
|
'Dim _PdfDocument As Document
|
|
'Dim _PdfStream As Stream
|
|
'Dim _NewPdfFileName As String
|
|
|
|
'Dim _FileStream As FileStream
|
|
'Dim _StreamReader As StreamReader
|
|
|
|
'_C3CGeneratedInvoice = View.SelectedObjects(0)
|
|
'If _C3CGeneratedInvoice IsNot Nothing Then
|
|
' _InvoiceHeader = _C3CGeneratedInvoice.InvoiceHeader
|
|
|
|
' If _InvoiceHeader.PrintCopy = 0 Then
|
|
' If _InvoiceHeader.PDF_Original Is Nothing Then
|
|
|
|
' _PdfEngine = New PDFDocEngine("Domain", "")
|
|
|
|
' _InvoiceHeader.PrintCopy = 1
|
|
' _FileName = _InvoiceHeader.GeneratePDFs(_ocur, _InvoiceHeader, False)
|
|
|
|
' _PdfDocument = _PdfEngine.AddDocument(_FileName)
|
|
|
|
' For Each _C3CGeneratedInvoiceDocuments As C3CGeneratedInvoiceDocuments In _C3CGeneratedInvoice.DocumentFile
|
|
|
|
' _C3CGeneratedInvoiceDocuments.File.SaveToStream(_PdfStream)
|
|
' _PdfDocument.AddAttachedFileFromPDFStream(_PdfStream, _C3CGeneratedInvoiceDocuments.File.FileName, "", False)
|
|
|
|
' Next
|
|
|
|
' _NewPdfFileName = Path.GetTempPath & "OriginalWithAttachments.pdf"
|
|
' _PdfDocument.Save(_NewPdfFileName)
|
|
|
|
' _FileStream = New FileStream(_FileName, FileMode.Open, FileAccess.Read)
|
|
' _StreamReader = New StreamReader(_FileStream)
|
|
' _FileStream.Seek(0, SeekOrigin.Begin)
|
|
|
|
' _C3CGeneratedInvoice.PdfOriginalWithAttachments = New FileData(_ocur.Session)
|
|
' _C3CGeneratedInvoice.PdfOriginalWithAttachments.LoadFromStream("OriginalWithAttachments.pdf", _FileStream)
|
|
' _C3CGeneratedInvoice.PdfOriginalWithAttachments.FileName = "OriginalWithAttachments.pdf"
|
|
|
|
' _StreamReader.Close()
|
|
' _FileStream.Close()
|
|
|
|
' File.Delete(_NewPdfFileName)
|
|
' File.Delete(_FileName)
|
|
|
|
' End If
|
|
' End If
|
|
|
|
' _InvoiceHeader.PrintCopy = 2
|
|
' _FileName = _InvoiceHeader.GeneratePDFs(_ocur, _InvoiceHeader, False)
|
|
' File.Delete(_FileName)
|
|
|
|
'End If
|
|
|
|
|
|
|
|
'Hol vannak a pdfek? Csatolni kellene hozzá a C3CGeneratedInvoice.DocumentFile kollekcióban levő fájlokat...
|
|
'És aztán törölni kell a filestream-ot???
|
|
|
|
|
|
|
|
'Dim _InvoiceVC As New SISBusiness.Module.InvoiceVC
|
|
'Dim _C3CImportHeader As C3CImportHeader = TryCast(TryCast(View, ListView).CollectionSource, PropertyCollectionSource).MasterObject
|
|
|
|
'Dim _ReportData As ReportData
|
|
'Dim _InvoiceHeade_Collection As New List(Of InvoiceHeader)
|
|
|
|
'Dim _inoperator As InOperator
|
|
'Dim _FilePath As String = Path.Combine(Path.GetTempPath(), _C3CImportHeader.ShortName & ".pdf")
|
|
'Dim _Stream As Stream = New FileStream(_FilePath, FileMode.Create)
|
|
'Dim _XafReport As XafReport
|
|
|
|
'Dim _FilterString As String = ""
|
|
'If _C3CImportHeader.C3CGeneratedInvoice.Count > 0 Then
|
|
' _ReportData = _C3CImportHeader.C3CGeneratedInvoice(0).InvoiceHeader.InvoiceType.ReportData
|
|
'End If
|
|
|
|
'For Each _C3CGeneratedInvoice In _C3CImportHeader.C3CGeneratedInvoice
|
|
' If _FilterString = "" Then
|
|
' _FilterString += "'" & _C3CGeneratedInvoice.InvoiceHeader.Oid.ToString & "'"
|
|
' Else
|
|
' _FilterString += ",'" & _C3CGeneratedInvoice.InvoiceHeader.Oid.ToString & "'"
|
|
' End If
|
|
|
|
'Next
|
|
'_XafReport = _ReportData.LoadReport(_ocur)
|
|
'_XafReport.FilterString = "InvoiceHeader.Oid in (" & _FilterString & ")"
|
|
|
|
'If _ReportData IsNot Nothing Then
|
|
' Dim _options As DevExpress.XtraPrinting.PdfExportOptions
|
|
|
|
' _XafReport.ExportToPdf(_Stream)
|
|
' _Stream.Close()
|
|
' Process.Start(_FilePath)
|
|
'End If
|
|
' End Sub
|
|
#Region "pdf"
|
|
'PDF merge
|
|
' Imports org.pdfbox.pdmodel
|
|
'Imports org.pdfbox.util
|
|
'Imports org.pdfbox.pdmodel.interactive.documentnavigation.destination
|
|
'Imports org.pdfbox.pdmodel.interactive.documentnavigation.outline
|
|
'Imports java.util
|
|
'Private Function MergePdfFiles(ByVal pdfFileList As List(Of String), _
|
|
' ByVal outputFileFullName As String) As Boolean
|
|
' Dim result As Boolean = False
|
|
' Dim pdfMerger As PDFMergerUtility = Nothing
|
|
' Dim fileCount As Integer = pdfFileList.Count
|
|
' If fileCount > 1 Then
|
|
' Try
|
|
' 'Instantiate an instance of Pdf Merger Utility
|
|
' pdfMerger = New PDFMergerUtility()
|
|
' With pdfMerger
|
|
' 'Set output destination
|
|
' .setDestinationFileName(outputFileFullName)
|
|
' 'Looping thru the file list and add source to the merger
|
|
' For i As Integer = 0 To fileCount - 1 Step 1
|
|
' .addSource(pdfFileList(i))
|
|
' Next i
|
|
' 'Merge the documents
|
|
' pdfMerger.mergeDocuments()
|
|
' result = True
|
|
' End With
|
|
' Catch ex As Exception
|
|
' WriteToLog("MergePDFFile(" & outputFileFullName & "): " & ex.Message)
|
|
' Return False
|
|
' End Try
|
|
' End If
|
|
' Return result
|
|
'End Function
|
|
'Private Function CreateBookmarkDataTable(ByVal pdfFileList As List(Of String)) As DataTable
|
|
' Dim bookmarkData As New DataTable
|
|
' Dim row As DataRow = Nothing
|
|
' Dim bookmarkTitle As String = String.Empty
|
|
' Dim pageNumber As Integer = 0
|
|
' Try
|
|
' bookmarkData.Columns.Add("BookmarkTitle", GetType(String))
|
|
' bookmarkData.Columns.Add("PageNumber", GetType(Integer))
|
|
' Dim count As Integer = pdfFileList.Count
|
|
' If count > 0 Then
|
|
' For i As Integer = 0 To count - 1 Step 1
|
|
' bookmarkTitle = Path.GetFileNameWithoutExtension(pdfFileList(i))
|
|
' row = bookmarkData.NewRow()
|
|
' row.Item("BookmarkTitle") = bookmarkTitle
|
|
' row.Item("PageNumber") = pageNumber
|
|
' bookmarkData.Rows.Add(row)
|
|
' pageNumber += GetPageCount(pdfFileList(i))
|
|
' Next
|
|
' End If
|
|
' Catch ex As Exception
|
|
' WriteToLog("CreateBookmarkDataTable(): " & ex.Message)
|
|
' Return Nothing
|
|
' End Try
|
|
' Return bookmarkData
|
|
'End Function
|
|
'Private Function GetPageCount(ByVal pdfFile As String) As Integer
|
|
' Dim pageCount As Integer
|
|
' Dim pdfDoc As PDDocument = Nothing
|
|
' Try
|
|
' pdfDoc = PDDocument.load(pdfFile)
|
|
' pageCount = pdfDoc.getNumberOfPages
|
|
' Catch ex As Exception
|
|
' WriteToLog("GetPageCount(" & pdfFile & "): " & ex.Message)
|
|
' Return 0
|
|
' Finally
|
|
' If Not pdfDoc Is Nothing Then
|
|
' pdfDoc.close()
|
|
' End If
|
|
' End Try
|
|
' Return pageCount
|
|
'End Function
|
|
'Private Function AddBookMarks(ByVal pdfFile As String, _
|
|
' ByVal bookmarkTable As DataTable) As Boolean
|
|
' Dim result As Boolean = False
|
|
' Dim PdfDoc As PDDocument = Nothing
|
|
' Dim outFile As String = String.Empty
|
|
' Dim rowCount As Integer = bookmarkTable.Rows.Count
|
|
' Try
|
|
' If rowCount > 0 Then
|
|
' 'Set the output file full path
|
|
' outFile = pdfFile.Replace("temp_", "")
|
|
' 'Load the input pdf file
|
|
' PdfDoc = PDDocument.load(pdfFile)
|
|
' If Not PdfDoc.isEncrypted() Then
|
|
' 'Create new document outline and assign it to the pdf document
|
|
' Dim outline As PDDocumentOutline = New PDDocumentOutline()
|
|
' PdfDoc.getDocumentCatalog().setDocumentOutline(outline)
|
|
' 'Create new outline item for the document outline
|
|
' Dim pagesOutline As PDOutlineItem = New PDOutlineItem()
|
|
' pagesOutline.setTitle("All Pages")
|
|
' outline.appendChild(pagesOutline)
|
|
' 'Get the list of pages in the document
|
|
' Dim pages As List = PdfDoc.getDocumentCatalog().getAllPages()
|
|
' Dim i, pageNumber As Integer
|
|
' Dim row As DataRow = Nothing
|
|
' Dim bookmarkTitle As String = String.Empty
|
|
' 'loop thru the bookmark datatable and add bookmarks to the document accordingly
|
|
' For i = 0 To rowCount - 1 Step 1
|
|
' 'Read the row's data
|
|
' row = bookmarkTable.Rows(i)
|
|
' pageNumber = CInt(row.Item("PageNumber"))
|
|
' bookmarkTitle = CStr(row.Item("BookmarkTitle"))
|
|
' 'Get the page at pageNumber from pages list
|
|
' Dim page As PDPage = CType(pages.get(pageNumber), PDPage)
|
|
' Dim dest As PDPageFitWidthDestination = New PDPageFitWidthDestination()
|
|
' dest.setPage(page)
|
|
' 'Then set bookmark to it
|
|
' Dim bookmark As PDOutlineItem = New PDOutlineItem()
|
|
' bookmark.setDestination(dest)
|
|
' bookmark.setTitle(bookmarkTitle)
|
|
' 'Add this bookmark to the document's outline
|
|
' pagesOutline.appendChild(bookmark)
|
|
' Next i
|
|
' 'Expand the bookmark tree
|
|
' pagesOutline.openNode()
|
|
' outline.openNode()
|
|
' 'Save the the document to a file
|
|
' PdfDoc.save(outFile)
|
|
' result = True
|
|
' Else
|
|
' WriteToLog("Can't add bookmarks to <" & pdfFile & "> because the document is encrypted.")
|
|
' End If
|
|
' Else
|
|
' WriteToLog("Can't add bookmarks to <" & pdfFile & "> because BookmarkTable has no data.")
|
|
' End If
|
|
' Catch ex As Exception
|
|
' WriteToLog("AddBookmarks(" & pdfFile & "): " & ex.Message)
|
|
' Return False
|
|
' Finally
|
|
' If Not PdfDoc Is Nothing Then
|
|
' PdfDoc.close()
|
|
' End If
|
|
' End Try
|
|
' Return result
|
|
'End Function
|
|
#End Region
|
|
|
|
Private Sub aExportPDFtoOutputDirectory_CustomizePopupWindowParams(sender As Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aExportPDFtoOutputDirectory.CustomizePopupWindowParams
|
|
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
|
|
Dim _C3CExportPathPopup As C3CExportPathPopup = _onew.CreateObject(Of C3CExportPathPopup)()
|
|
Dim _C3CGeneratedInvoice As C3CGeneratedInvoice = View.SelectedObjects(0)
|
|
|
|
_C3CExportPathPopup.OutputDirectory = _C3CGeneratedInvoice.C3CImportHeader.OutputDirectory
|
|
e.View = Application.CreateDetailView(_onew, "C3CExportPathPopup_DetailView", False, _C3CExportPathPopup)
|
|
End Sub
|
|
|
|
Private Sub aExportPDFtoOutputDirectory_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aExportPDFtoOutputDirectory.Execute
|
|
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
|
|
Dim _C3CExportPathPopup As C3CExportPathPopup = TryCast(e.PopupWindow.View.SelectedObjects(0), C3CExportPathPopup)
|
|
Dim _C3CGeneratedInvoice As C3CGeneratedInvoice
|
|
|
|
_WaitFormClass.InitWork(1, 1, View.SelectedObjects.Count)
|
|
For Each _C3CGeneratedInvoice In View.SelectedObjects
|
|
_WaitFormClass.DoWork()
|
|
Dim _FileStream As New FileStream(_C3CExportPathPopup.OutputDirectory & "/" & _C3CGeneratedInvoice.PdfOriginalWithAttachments.FileName, FileMode.Create, FileAccess.ReadWrite)
|
|
_C3CGeneratedInvoice.PdfOriginalWithAttachments.SaveToStream(_FileStream)
|
|
_FileStream.Close()
|
|
Next
|
|
_WaitFormClass.Finalwork()
|
|
|
|
End Sub
|
|
End Class
|
|
|
|
#Region "VB6"
|
|
' '/==========================================================================================\
|
|
' '|VERSION: 2 |
|
|
' '|AUTHOR: SISSERVER : ivan.szabo(2010.1.5 11:25) |
|
|
' '|LAST MODIFYING: SISSERVER : ivan.szabo |
|
|
' '|DATE: 2010.2.4 9:58 |
|
|
' '|----------------------------------------DESCRIPTION---------------------------------------|
|
|
' '|3C KFT.-nek import |
|
|
' '| |
|
|
' '\==========================================================================================/
|
|
' Dim clsADO As New clsADO
|
|
' Dim mSQL As String
|
|
' Dim FS As New Scripting.FileSystemObject
|
|
' Dim vF As File
|
|
' Dim sArray() As String
|
|
' Dim TS As String
|
|
' Dim Act_Ügyfélszám As Long
|
|
' Dim Prev_Ügyfélszám As Long
|
|
'ReDim s(1 To SP.MaxCols) As SpreadRecord
|
|
' Dim I As Long
|
|
' Dim clsC As New clsCassa
|
|
' Dim vTempID As Long
|
|
'SP.ReDraw = False
|
|
'SP.MaxRows = 0
|
|
' '-- Ellenõrzések ...
|
|
' 'If FS.FileExists(pathDetails) = False Then
|
|
' ' frmMsgBox.MyMsgBox "Hibás a fájl útvonala !", vbCritical
|
|
' ' Exit Sub
|
|
' 'End If
|
|
'
|
|
' 'If FS.FileExists(pathItems) = False Then
|
|
' ' frmMsgBox.MyMsgBox "Hibás a fájl útvonala !", vbCritical
|
|
' ' Exit Sub
|
|
' 'End If
|
|
'
|
|
' ' 'If FS.FileExists(pathPartners) = False Then
|
|
' ' ' frmMsgBox.MyMsgBox "Hibás a fájl útvonala !", vbCritical
|
|
' ' ' Exit Sub
|
|
' ' 'End If
|
|
|
|
|
|
' '-- Fileok megnyitása ...
|
|
'Me.Import_Items
|
|
|
|
'Open pathDetails For Input As #1
|
|
|
|
' 'Do While Not EOF(1)
|
|
' ' Line Input #1, TS
|
|
' ' sArray = Split(TS, ";")
|
|
' ' If UBound(sArray) <= 0 Then Exit Do
|
|
' ' If StrToDouble(sArray(2)) < 200000 Then
|
|
' ' Act_Ügyfélszám = 200000 + StrToDouble(sArray(2))
|
|
' ' Else
|
|
' ' Act_Ügyfélszám = StrToDouble(sArray(2))
|
|
' ' End If
|
|
|
|
' ' If (Act_Ügyfélszám <> Prev_Ügyfélszám) Or sArray(0) = "0" Then
|
|
' vTempID = clsC.GetTempAlloc
|
|
' FillArray s()
|
|
' s(1).s = Act_Ügyfélszám
|
|
' s(2).s = sArray(16) & ";" & sArray(3)
|
|
' s(3).s = Replace(sArray(17), ".", ","): s(3).AL = 1
|
|
' s(4).s = Format(Now, "yyyy-mm-dd")
|
|
' s(5).s = Format(DateAdd("d", Val(sArray(18)), Now), "yyyy-mm-dd")
|
|
' s(6).s = Format(DateAdd("d", Val(sArray(18)), Now), "yyyy-mm-dd")
|
|
' s(7).s = vTempID
|
|
' s(8).s = "H"
|
|
' For I = 1 To SP.MaxCols
|
|
' s(I).BC = RGB(245, 245, 245)
|
|
' Next I
|
|
' AddToSpreadT s(), SP
|
|
|
|
' Prev_Ügyfélszám = Act_Ügyfélszám
|
|
' End If
|
|
|
|
|
|
' If sArray(0) = "0" Then
|
|
' FillArray s()
|
|
' s(1).s = "SZJ 64.20.18"
|
|
' 's(2).s = sArray(3)
|
|
' End If
|
|
' If (sArray(0) = "1") Or (sArray(0) = "3") Or (sArray(0) = "5") Or (sArray(0) = "7") Then
|
|
' s(2).s = aItems(Me.GetItembyName(sArray(29))).FullName & vbNewLine & aItems(Me.GetItembyName(sArray(29))).FullName_English
|
|
' s(3).s = StrToDouble(sArray(32)): s(3).AL = 1
|
|
' s(4).s = aItems(Me.GetItembyName(sArray(29))).Unit & "/" & aItems(Me.GetItembyName(sArray(29))).Unit_English
|
|
' s(5).s = Replace(sArray(36), ".", ","): s(5).AL = 1
|
|
' s(6).s = aItems(Me.GetItembyName(sArray(29))).VAT
|
|
' End If
|
|
|
|
' If (sArray(0) = "2") Or (sArray(0) = "4") Or (sArray(0) = "6") Or (sArray(0) = "8") Then
|
|
' s(2).s = s(2).s & Chr(13) + Chr(10) + sArray(39)
|
|
' s(7).s = vTempID
|
|
' s(8).s = "R"
|
|
' AddToSpreadT s(), SP
|
|
' End If
|
|
'Loop
|
|
'Close #1
|
|
|
|
'SP.MaxRows = SP.DataRowCnt
|
|
'UseMaxHeight SP
|
|
'SP.ReDraw = True
|
|
|
|
#End Region
|
|
|