180 lines
7.3 KiB
VB.net
180 lines
7.3 KiB
VB.net
Imports DevExpress.XtraEditors
|
|
Imports DevExpress.XtraGrid.Views.Grid
|
|
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
|
|
Imports MultiTool.Shared.Winline.Entities
|
|
|
|
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, Me)
|
|
|
|
' Initialize Database
|
|
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
|
|
Database = New MSSQLServer(LogConfig, oConnectionString)
|
|
|
|
Dim oViews As New List(Of GridView) From {
|
|
GridViewDocuments,
|
|
lookupMandator.Properties.View,
|
|
lookupAccount.Properties.View,
|
|
lookupDocumentKind.Properties.View
|
|
}
|
|
GridBuilder = New GridBuilder(oViews)
|
|
GridBuilder.
|
|
WithDefaults().
|
|
WithReadOnlyOptions().
|
|
WithClipboardHandler()
|
|
|
|
Winline = My.Winline
|
|
FileEx = New DigitalData.Modules.Filesystem.File(LogConfig)
|
|
WebService = New WebServiceData(LogConfig, My.GeneralConfiguration.Webservice, My.GeneralConfiguration)
|
|
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()
|
|
|
|
lookupAccount.Properties.DataSource = Winline.Accounts
|
|
lookupAccount.ForceInitialize()
|
|
lookupAccount.Properties.View.BestFitColumns()
|
|
|
|
lookupDocumentKind.Properties.DataSource = Winline.DocumentKinds
|
|
lookupDocumentKind.ForceInitialize()
|
|
lookupDocumentKind.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
|
|
SearchDocuments()
|
|
End Sub
|
|
|
|
Private Sub WebService_Progress(sender As Object, e As String)
|
|
SplashScreenManager.SetWaitFormDescription(e)
|
|
End Sub
|
|
|
|
Private Sub lookupMandator_EditValueChanged(sender As Object, e As EventArgs) Handles lookupMandator.EditValueChanged
|
|
Dim oMandator As Mandator = lookupMandator.EditValue
|
|
lookupAccount.Properties.DataSource = Winline.Accounts.Where(Function(acc) acc.Mandator.Equals(oMandator))
|
|
lookupDocumentKind.Properties.DataSource = Winline.DocumentKinds.Where(Function(kind) kind.Mandator.Equals(oMandator))
|
|
End Sub
|
|
|
|
Private Sub lookup_Properties_ButtonClick(sender As Object, e As DevExpress.XtraEditors.Controls.ButtonPressedEventArgs) _
|
|
Handles lookupDocumentKind.Properties.ButtonClick, lookupAccount.Properties.ButtonClick
|
|
Dim oLookup As GridLookUpEdit = sender
|
|
If e.Button.Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Clear Then
|
|
oLookup.EditValue = Nothing
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub SearchDocuments()
|
|
Try
|
|
Dim oMandator = lookupMandator.EditValue
|
|
Dim oAccount = lookupAccount.EditValue
|
|
Dim oKind = lookupDocumentKind.EditValue
|
|
Dim oDateRanges = dateDocDate.SelectedRanges
|
|
Dim oShowExported = chkShowExported.Checked
|
|
|
|
If oMandator Is Nothing Then
|
|
FormHelper.ShowWarning("Bitte einen Mandanten auswählen!")
|
|
Exit Sub
|
|
End If
|
|
|
|
If oDateRanges.Count > 1 Then
|
|
FormHelper.ShowWarning("Bitte nur einen Datumsbereich auswählen!")
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oStartDate As Date = Nothing
|
|
Dim oEndDate As Date = Nothing
|
|
If oDateRanges.Count > 0 Then
|
|
Dim oRange = oDateRanges.First()
|
|
oStartDate = oRange.StartDate
|
|
oEndDate = oRange.EndDate
|
|
End If
|
|
|
|
'TODO: Make Document Type configurable
|
|
Dim oDocuments = Winline.GetDocuments(oMandator, CurrentTemplate, WinlineData.DocumentType.Order, New WinlineData.GetDocumentArgs With {
|
|
.Account = oAccount,
|
|
.Kind = oKind,
|
|
.DateFrom = oStartDate,
|
|
.DateTo = oEndDate,
|
|
.ShowExported = oShowExported
|
|
})
|
|
|
|
GridControlDocuments.DataSource = oDocuments
|
|
|
|
txtResults.Caption = String.Format("{0} Ergebnisse", oDocuments.Count)
|
|
|
|
Catch ex As Exception
|
|
FormHelper.ShowError(ex, "Laden der Daten")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Async Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
|
|
Try
|
|
SplashScreenManager.ShowWaitForm()
|
|
|
|
Dim oDocument As Document = GridViewDocuments.GetRow(GridViewDocuments.FocusedRowHandle)
|
|
Dim oMandator As Mandator = lookupMandator.EditValue
|
|
|
|
Await WebService.ExportDocumentFromWinline(oDocument, CurrentTemplate, oMandator)
|
|
|
|
Catch ex As Exception
|
|
FormHelper.ShowError(ex, "Exportieren der Daten")
|
|
|
|
Finally
|
|
SplashScreenManager.CloseWaitForm()
|
|
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub btnOpenInputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenInputDirectory.ItemClick
|
|
FormHelper.TryOpenDirectory(CurrentTemplate.InputDirectory, My.Resources.frmImportMainExtra.Eingangsverzeichnis)
|
|
End Sub
|
|
|
|
Private Sub btnOpenOutputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenOutputDirectory.ItemClick
|
|
FormHelper.TryOpenDirectory(CurrentTemplate.OutputDirectory, My.Resources.frmImportMainExtra.Ausgabeverzeichnis)
|
|
End Sub
|
|
End Class |