add button for Price calculation

This commit is contained in:
Jonathan Jenne
2022-02-28 11:59:10 +01:00
parent f80ea96f8a
commit 7f817ffce1
3 changed files with 66 additions and 30 deletions

View File

@@ -1,6 +1,5 @@
Imports System.IO
Imports System.Net.Http
Imports DevExpress.Utils.Behaviors.Common
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraReports.UI
@@ -15,8 +14,7 @@ Imports MultiTool.Shared.Winline
Imports MultiTool.Shared.Winline.Entities
Imports MultiTool.Shared.Constants
Imports MultiTool.Shared.Exceptions
Imports Document = MultiTool.Shared.Documents.Document
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports MultiTool.Shared.Documents.Document
Public Class frmImportMain
Public LogConfig As LogConfig
@@ -131,7 +129,10 @@ Public Class frmImportMain
Dim oRow As DataRow = oView.GetFocusedDataRow()
EditRow(oRow, oView)
Dim oModifiedRow = EditRow(oRow, oView)
If oModifiedRow IsNot Nothing Then
ReloadRow(oModifiedRow)
End If
End Sub
Private Sub btnEditRow_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnEditRow.ItemClick
@@ -143,10 +144,13 @@ Public Class frmImportMain
Exit Sub
End If
EditRow(oRow, oView)
Dim oModifiedRow = EditRow(oRow, oView)
If oModifiedRow IsNot Nothing Then
ReloadRow(oModifiedRow)
End If
End Sub
Private Sub EditRow(pRow As DataRow, pView As GridView)
Private Function EditRow(pRow As DataRow, pView As GridView) As DocumentRow
Try
Dim oColumns = pView.Columns.Select(Function(c) c.FieldName).ToList()
Dim oDocumentRow = CurrentDocument.Rows.
@@ -164,22 +168,19 @@ Public Class frmImportMain
Winline,
oTemplateTable
)
If oForm.ShowDialog() = DialogResult.OK Then
Dim oModifiedRow = oForm.DocumentRow
Dim oIndex = CurrentDocument.Rows.IndexOf(oModifiedRow)
CurrentDocument.Rows.Item(oIndex) = oModifiedRow
LoadDocument(CurrentDocument)
' Refresh Files to update Row color
GridViewFiles.RefreshData()
Return oForm.DocumentRow
Else
Return Nothing
End If
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Detailzeilen)
Return Nothing
End Try
End Sub
End Function
Private Sub btnLoadFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnLoadFiles.ItemClick
@@ -570,7 +571,15 @@ Public Class frmImportMain
txtCurrentFile.Caption = String.Format(My.Resources.frmImportMainExtra.Aktuelle_Datei___0_, pDocument.FileName)
CurrentDocument = pDocument
SetDocumentButtonsEnabled(True)
If CurrentDocument.HasErrors = True Then
btnCalculatePrices.Enabled = False
Else
btnCalculatePrices.Enabled = True
End If
Catch ex As Exception
SetDocumentButtonsEnabled(False)
Logger.Error(ex)
@@ -578,6 +587,17 @@ Public Class frmImportMain
End Try
End Sub
Private Sub ReloadRow(pRow As DocumentRow)
Dim oModifiedRow = pRow
Dim oIndex = CurrentDocument.Rows.IndexOf(oModifiedRow)
CurrentDocument.Rows.Item(oIndex) = oModifiedRow
LoadDocument(CurrentDocument)
' Refresh Files to update Row color
GridViewFiles.RefreshData()
End Sub
Private Sub LoadFiles()
Try
BeginLoadingUI()
@@ -604,6 +624,8 @@ Public Class frmImportMain
End Try
End Sub
Private Async Function TransferFile(pDocument As Document, Optional pIsTest As Boolean = False) As Task(Of Boolean)
' Check for errors and abort
If pDocument.HasErrors = True Then
@@ -699,7 +721,7 @@ Public Class frmImportMain
End Sub
Private Sub TryOpenFile(pPath As String, pDisplayName As String)
If File.Exists(pPath) Then
If IO.File.Exists(pPath) Then
Process.Start(pPath)
Else
Dim oMessage = String.Format(My.Resources.frmImportMainExtra._0__nicht_konfiguriert_oder_nicht_gefunden, pDisplayName)
@@ -733,5 +755,18 @@ Public Class frmImportMain
btnEditRow.Enabled = pEnabled
End Sub
Private Sub btnCalculatePrices_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnCalculatePrices.ItemClick
Dim oCurrentMandator As Mandator = TryCast(lookupMandator.EditValue, Mandator)
If oCurrentMandator Is Nothing Then
MsgBox(My.Resources.frmImportMainExtra.Bitte_wählen_Sie_einen_Mandanten_aus__bevor_Sie_fortfahren, MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
Dim oNewDocument = DocumentLoader.MaybeApplyPriceFunctions(CurrentDocument, oCurrentMandator, CurrentTemplate)
DocumentLoader.ReplaceDocument(oNewDocument)
LoadDocument(oNewDocument)
End Sub
#End Region
End Class