WIP
This commit is contained in:
@@ -10,6 +10,7 @@ Imports DigitalData.Controls.SQLConfig
|
||||
Imports DigitalData.GUIs.Common
|
||||
Imports EDIDocumentImport.DocumentInfo
|
||||
Imports EDIDocumentImport.DocumentPositions
|
||||
Imports DevExpress.XtraEditors
|
||||
|
||||
Public Class frmMain
|
||||
Public LogConfig As LogConfig
|
||||
@@ -26,7 +27,6 @@ Public Class frmMain
|
||||
|
||||
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
|
||||
@@ -45,7 +45,7 @@ Public Class frmMain
|
||||
' Initialize Database
|
||||
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
|
||||
Database = New MSSQLServer(LogConfig, oConnectionString)
|
||||
Winline = New WinLineInfo(LogConfig, Database)
|
||||
Winline = New WinLineInfo(LogConfig, Database, ConfigManager.Config)
|
||||
|
||||
' Load WinLine Data
|
||||
Winline.Mandators.Clear()
|
||||
@@ -64,12 +64,10 @@ Public Class frmMain
|
||||
|
||||
' Initialize Grids
|
||||
GridBuilder = New GridBuilder(New List(Of GridView) From {GridViewFiles, GridViewPositions})
|
||||
GridBuilder.
|
||||
WithDefaults().
|
||||
WithReadOnlyOptions(GridViewFiles)
|
||||
GridBuilder.WithDefaults()
|
||||
|
||||
' Construct classes related to the xml data
|
||||
DocumentLoader = New DocumentLoader(LogConfig, ConfigManager.Config)
|
||||
DocumentLoader = New DocumentLoader(LogConfig, ConfigManager.Config, Database, Winline)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
|
||||
@@ -83,28 +81,34 @@ Public Class frmMain
|
||||
txtFilesLoaded.Caption = $"{DocumentLoader.Files.Count} Dokumente geladen"
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
|
||||
Dim oMessage = ex.Message
|
||||
|
||||
If ex.InnerException IsNot Nothing Then
|
||||
oMessage &= vbNewLine & vbNewLine & ex.InnerException.Message
|
||||
End If
|
||||
|
||||
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged
|
||||
Dim oFile As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
|
||||
Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
|
||||
|
||||
If oFile Is Nothing Then
|
||||
If oDocument Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
RichEditXml.LoadDocument(oFile.FullName, DocumentFormat.PlainText)
|
||||
RichEditXml.LoadDocument(oDocument.FullName, DocumentFormat.PlainText)
|
||||
|
||||
Try
|
||||
Select Case oFile.Type
|
||||
Select Case oDocument.Type
|
||||
Case DocumentType.Order
|
||||
'ShowDocument(oFile.Data)
|
||||
ShowDocument(oDocument, oDocument.Data, oDocument.DataOriginal)
|
||||
|
||||
End Select
|
||||
|
||||
Catch ex As Xml.XmlException
|
||||
Dim oMessage As String = $"Fehler beim Verarbeiten des Dokuments {oFile.Name}:{vbNewLine}{ex.Message}"
|
||||
Dim oMessage As String = $"Fehler beim Verarbeiten des Dokuments {oDocument.Name}:{vbNewLine}{ex.Message}"
|
||||
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
|
||||
Logger.Error(ex)
|
||||
|
||||
@@ -115,34 +119,83 @@ Public Class frmMain
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub ShowDocument(pDocument As Orders.MESOWebService)
|
||||
' ====== Head Data ======
|
||||
|
||||
Dim oHead As Orders.MESOWebServiceEXIMVRG_ordersT025 = pDocument.Items.
|
||||
Private Sub ShowDocument(pDocument As Document, pData As Orders.MESOWebService, pDataOriginal As Orders.MESOWebService)
|
||||
Dim oHead As Orders.MESOWebServiceEXIMVRG_ordersT025 = pData.Items.
|
||||
Where(Function(i) TypeOf i Is Orders.MESOWebServiceEXIMVRG_ordersT025).
|
||||
FirstOrDefault()
|
||||
|
||||
Dim oHeadOriginal As Orders.MESOWebServiceEXIMVRG_ordersT025 = pDataOriginal.Items.
|
||||
Where(Function(i) TypeOf i Is Orders.MESOWebServiceEXIMVRG_ordersT025).
|
||||
FirstOrDefault()
|
||||
|
||||
Dim oPositions As List(Of Orders.MESOWebServiceEXIMVRG_ordersT026) = pData.Items.
|
||||
Where(Function(i) TypeOf i Is Orders.MESOWebServiceEXIMVRG_ordersT026).
|
||||
Select(Of Orders.MESOWebServiceEXIMVRG_ordersT026)(Function(i) i).
|
||||
ToList()
|
||||
|
||||
Dim oPositionsOriginal As List(Of Orders.MESOWebServiceEXIMVRG_ordersT026) = pDataOriginal.Items.
|
||||
Where(Function(i) TypeOf i Is Orders.MESOWebServiceEXIMVRG_ordersT026).
|
||||
Select(Of Orders.MESOWebServiceEXIMVRG_ordersT026)(Function(i) i).
|
||||
ToList()
|
||||
|
||||
' ====== Head Data ======
|
||||
|
||||
' Original, Unreplaced Data
|
||||
txtCustomerGLN.Text = oHeadOriginal.Fakt_Kontonummer
|
||||
txtDeliveryAddressGLN.Text = oHeadOriginal.Lief_Kontonummer
|
||||
|
||||
' Regular Data from EDI
|
||||
txtBELEGKEY.Text = oHead.BELEGKEY
|
||||
txtRunningNumber.Text = oHead.Laufnummer
|
||||
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).
|
||||
|
||||
Dim oMandator = Winline.Mandators.
|
||||
Where(Function(m) m.Id = pDocument.Mandator.Id).
|
||||
SingleOrDefault()
|
||||
|
||||
If oMandator Is Nothing Then
|
||||
cmbMandator.ErrorText = "Dieses Feld muss ausgefüllt werden!"
|
||||
cmbMandator.EditValue = Nothing
|
||||
Else
|
||||
cmbMandator.EditValue = oMandator
|
||||
End If
|
||||
|
||||
If oHead.Fakt_Kontonummer = oHeadOriginal.Fakt_Kontonummer Then
|
||||
cmbCustomer.ErrorText = "Dieses Feld muss ausgefüllt werden!"
|
||||
cmbCustomer.EditValue = Nothing
|
||||
Else
|
||||
cmbCustomer.EditValue = Winline.Accounts.
|
||||
Where(Function(oAccount) oAccount.Id = oHead.Fakt_Kontonummer And oAccount.Mandator = cmbMandator.EditValue).
|
||||
SingleOrDefault()
|
||||
End If
|
||||
|
||||
If oHead.Lief_Kontonummer = oHeadOriginal.Lief_Kontonummer Then
|
||||
cmbDeliveryAddress.ErrorText = "Dieses Feld muss ausgefüllt werden!"
|
||||
cmbDeliveryAddress.EditValue = Nothing
|
||||
Else
|
||||
cmbDeliveryAddress.EditValue = Winline.Accounts.
|
||||
Where(Function(oAccount) oAccount.Id = oHead.Lief_Kontonummer And oAccount.Mandator = cmbMandator.EditValue).
|
||||
SingleOrDefault()
|
||||
End If
|
||||
|
||||
' TODO
|
||||
'cmbMandator.EditValue = Winline.Mandators.
|
||||
' Where(Function(m) m.Id = "SIVT").
|
||||
' SingleOrDefault()
|
||||
'cmbCustomer.EditValue = Winline.Accounts.
|
||||
' Where(Function(oAccount) oAccount.Id = oHead.Fakt_Kontonummer And oAccount.Mandator = cmbMandator.EditValue).
|
||||
' SingleOrDefault()
|
||||
|
||||
' ====== Position Data ======
|
||||
|
||||
Dim oPositions As List(Of Orders.MESOWebServiceEXIMVRG_ordersT026) = pDocument.Items.
|
||||
Where(Function(i) TypeOf i Is Orders.MESOWebServiceEXIMVRG_ordersT026).
|
||||
Select(Of Orders.MESOWebServiceEXIMVRG_ordersT026)(Function(i) i).
|
||||
ToList()
|
||||
|
||||
Dim oPositionList As New List(Of OrderPosition)
|
||||
For Each oPosition In oPositions
|
||||
Dim oPositionOriginal = oPositionsOriginal.
|
||||
Where(Function(p) p.Zeilennummer = oPosition.Zeilennummer).
|
||||
SingleOrDefault()
|
||||
|
||||
oPositionList.Add(New OrderPosition With {
|
||||
.ArticleNumber = oPosition.Artikelnummer,
|
||||
.RowNumber = oPosition.Zeilennummer,
|
||||
@@ -151,24 +204,28 @@ Public Class frmMain
|
||||
.EDIPrice = oPosition.Einzelpreis,
|
||||
.WinLinePrice = 0,
|
||||
.Price = 0,
|
||||
.Amount = oPosition.Menge_bestellt
|
||||
.Amount = oPosition.Menge_bestellt,
|
||||
.EuropeanArticleNumber = oPositionOriginal.Artikelnummer
|
||||
})
|
||||
Next
|
||||
|
||||
LoadViewAndColumns(GridViewPositions, DocumentType.Order)
|
||||
GridControlPositions.DataSource = oPositionList
|
||||
End Sub
|
||||
GridViewPositions.BestFitColumns()
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub LoadViewAndColumns(pView As GridView, pDocumentType As DocumentType)
|
||||
Dim oColumns As List(Of GridColumn)
|
||||
|
||||
' Create columns list depending on DocumentType
|
||||
Select Case pDocumentType
|
||||
Case DocumentType.Order
|
||||
oColumns = New List(Of GridColumn) From {
|
||||
ColumnRowNumber,
|
||||
ColumnArticleNumber,
|
||||
ColumnArticleNumberVendor,
|
||||
ColumnEuropeanArticleNumber,
|
||||
ColumnArticleDescription,
|
||||
ColumnEDIPrice,
|
||||
ColumnWinLinePrice,
|
||||
@@ -179,15 +236,29 @@ Public Class frmMain
|
||||
oColumns = New List(Of GridColumn)
|
||||
End Select
|
||||
|
||||
' Reset the grid
|
||||
pView.GridControl.DataSource = Nothing
|
||||
pView.GridControl.ForceInitialize()
|
||||
|
||||
' Add and adjust columns
|
||||
pView.Columns.AddRange(oColumns.ToArray())
|
||||
pView.BestFitColumns()
|
||||
|
||||
' Set columns readonly that need it
|
||||
Dim oReadOnlyColumns = oColumns.
|
||||
Except(DocumentPositions.WritableColumns).
|
||||
ToList()
|
||||
|
||||
For Each oColumn As GridColumn In GridViewPositions.Columns
|
||||
If oReadOnlyColumns.Contains(oColumn) Then
|
||||
oColumn.OptionsColumn.ReadOnly = True
|
||||
oColumn.OptionsColumn.AllowEdit = False
|
||||
Else
|
||||
oColumn.Caption &= " *"
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
||||
Process.Start(ConfigManager.Config.InputDirectory)
|
||||
End Sub
|
||||
@@ -208,4 +279,16 @@ Public Class frmMain
|
||||
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
|
||||
MsgBox("Mach et!")
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem8_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem8.ItemClick
|
||||
Process.Start(LogConfig.LogDirectory)
|
||||
End Sub
|
||||
|
||||
Private Sub cmbAccount_Validating(sender As BaseEdit, e As System.ComponentModel.CancelEventArgs) Handles cmbCustomer.Validating, cmbDeliveryAddress.Validating
|
||||
If sender.EditValue Is Nothing Then
|
||||
sender.ErrorText = "Dieses Feld muss ausgefüllt werden!"
|
||||
Else
|
||||
sender.ErrorText = ""
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user