MultiTool/MultiTool.Form/frmExportMain.vb
2021-12-20 16:39:23 +01:00

96 lines
3.5 KiB
VB.net

Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports MultiTool.Shared
Imports MultiTool.Shared.Templates
Imports MultiTool.Shared.Winline
Public Class frmExportMain
Private ReadOnly LogConfig As LogConfig
Private ReadOnly ConfigManager As ConfigManager(Of Config)
Private ReadOnly CurrentTemplate As Template = Nothing
Private Logger As Logger
Private FormHelper As FormHelper
Private Database As MSSQLServer
Private WebService As WebServiceData
Private Winline As WinlineData
Private GridBuilder As GridBuilder
Private FileEx As DigitalData.Modules.Filesystem.File
Public Sub New(pLogConfig As LogConfig, pConfigManager As ConfigManager(Of Config), pTemplate As Template)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
LogConfig = pLogConfig
ConfigManager = pConfigManager
CurrentTemplate = pTemplate
End Sub
Private Sub frmExportMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Text = String.Format(My.Resources.frmShared._0____WebService_Multitool_für_WinLine, CurrentTemplate.Name)
Logger = LogConfig.GetLogger()
FormHelper = New FormHelper(LogConfig)
' Initialize Database
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
Database = New MSSQLServer(LogConfig, oConnectionString)
GridBuilder = New GridBuilder(GridViewDocuments)
GridBuilder.
WithDefaults().
WithReadOnlyOptions().
WithClipboardHandler()
Winline = My.Winline
FileEx = New DigitalData.Modules.Filesystem.File(LogConfig)
WebService = New WebServiceData(LogConfig, My.GeneralConfiguration.Webservice, My.GeneralConfiguration.OutputWebserviceDirectory)
AddHandler WebService.WebServiceProgress, AddressOf WebService_Progress
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Initialisieren_der_Anwendungs_Daten)
End Try
End Sub
Private Sub frmExportMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
Try
lookupMandator.Properties.DataSource = Winline.Mandators
lookupMandator.ForceInitialize()
lookupMandator.Properties.View.BestFitColumns()
Catch ex As Exception
FormHelper.ShowError(ex, "Initialisierung der Form")
End Try
End Sub
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
Try
Dim oMandator = lookupMandator.EditValue
If oMandator Is Nothing Then
FormHelper.ShowWarning("Bitte einen Mandanten auswählen!")
Exit Sub
End If
'TODO: Make Document Type configurable
Dim oDocuments = Winline.GetDocuments(oMandator, WinlineData.DocumentType.Order)
GridControlDocuments.DataSource = oDocuments
Console.WriteLine()
Catch ex As Exception
FormHelper.ShowError(ex, "Laden der Daten")
End Try
End Sub
Private Sub WebService_Progress(sender As Object, e As String)
Throw New NotImplementedException()
End Sub
End Class