This commit is contained in:
Jonathan Jenne
2021-08-06 16:21:28 +02:00
parent eeb8ac9472
commit 50c1e86219
16 changed files with 547 additions and 187 deletions

View File

@@ -15,16 +15,18 @@ Public Class frmMain
Public LogConfig As LogConfig
Public Logger As Logger
Public ConfigManager As ConfigManager(Of Config)
Public DocumentLoader As DocumentLoader
Public Database As MSSQLServer
Public FileLoader As FileLoader
Public DocumentLoader As DocumentLoader
Public GridBuilder As GridBuilder
Public Winline As WinLineInfo
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
txtVersion.Caption = String.Format(txtVersion.Caption, Application.ProductVersion)
LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "EDI Document Importer")
ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath, Application.CommonAppDataPath, Application.StartupPath)
ConfigManager.Save()
Logger = LogConfig.GetLogger()
' If ConnectionString does not exist, show SQL Config Form
@@ -44,10 +46,21 @@ Public Class frmMain
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
Database = New MSSQLServer(LogConfig, oConnectionString)
Winline = New WinLineInfo(LogConfig, Database)
Winline.LoadMandators()
' Load WinLine Data
Winline.Mandators.Clear()
Winline.LoadMandators()
Winline.LoadEconomicYears()
For Each oMandator In Winline.Mandators
Winline.LoadAccounts(oMandator)
Next
' Load data for UI Fields
cmbMandator.Properties.DataSource = Winline.Mandators
cmbCustomer.Properties.DataSource = Winline.Mandators
cmbCustomer.Properties.DataSource = Winline.Accounts
cmbDeliveryAddress.Properties.DataSource = Winline.Accounts
cmbYears.Properties.Items.AddRange(Winline.Years)
cmbYears.SelectedItem = Now.Year
' Initialize Grids
GridBuilder = New GridBuilder(New List(Of GridView) From {GridViewFiles, GridViewPositions})
@@ -56,8 +69,7 @@ Public Class frmMain
WithReadOnlyOptions(GridViewFiles)
' Construct classes related to the xml data
FileLoader = New FileLoader(LogConfig, ConfigManager.Config)
DocumentLoader = New DocumentLoader(LogConfig)
DocumentLoader = New DocumentLoader(LogConfig, ConfigManager.Config)
Catch ex As Exception
Logger.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
@@ -66,9 +78,9 @@ Public Class frmMain
Private Sub btnLoadDocuments_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnLoadDocuments.ItemClick
Try
If FileLoader.LoadFiles() = True Then
GridControlFiles.DataSource = FileLoader.Files
txtFilesLoaded.Caption = $"{FileLoader.Files.Count} Dokumente geladen"
If DocumentLoader.LoadFiles() = True Then
GridControlFiles.DataSource = DocumentLoader.Files
txtFilesLoaded.Caption = $"{DocumentLoader.Files.Count} Dokumente geladen"
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
@@ -76,7 +88,7 @@ Public Class frmMain
End Sub
Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged
Dim oFile As FileInfo = GridViewFiles.GetRow(e.FocusedRowHandle)
Dim oFile As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
If oFile Is Nothing Then
Exit Sub
@@ -85,20 +97,21 @@ Public Class frmMain
RichEditXml.LoadDocument(oFile.FullName, DocumentFormat.PlainText)
Try
Dim oResult As Tuple(Of Object, DocumentType) = FileLoader.LoadFile(oFile.FullName)
Select Case oResult.Item2
Select Case oFile.Type
Case DocumentType.Order
ShowDocument(oResult.Item1)
'ShowDocument(oFile.Data)
End Select
Catch ex As Xml.XmlException
Dim oMessage As String = $"Fehler beim Verarbeiten des Dokuments {oFile.Name}:{vbNewLine}{ex.Message}"
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Logger.Error(ex)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
Logger.Error(ex)
End Try
End Sub
@@ -111,10 +124,15 @@ Public Class frmMain
txtBELEGKEY.Text = oHead.BELEGKEY
txtRunningNumber.Text = oHead.Laufnummer
cmbMandator.EditValue = Winline.Mandators.Where(Function(m) m.Id = oHead.Fakt_Kontonummer).SingleOrDefault()
txtOrderIssuer.Text = oHead.Fakt_Ansprechpartner
txtOrderNumber.Text = oHead.AuftragsBestellnummer
dateOrderDate.EditValue = oHead.Datum_AuftragBestellung
cmbMandator.EditValue = Winline.Mandators.
Where(Function(m) m.Id = "SIVT").
SingleOrDefault()
cmbCustomer.EditValue = Winline.Accounts.
Where(Function(m) m.Id = oHead.Fakt_Kontonummer).
SingleOrDefault()
' ====== Position Data ======