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

@ -55,6 +55,7 @@ Partial Class frmImportMain
Me.BarButtonItem1 = New DevExpress.XtraBars.BarButtonItem()
Me.btnDebugExportReport = New DevExpress.XtraBars.BarButtonItem()
Me.btnEditRow = New DevExpress.XtraBars.BarButtonItem()
Me.btnCalculatePrices = New DevExpress.XtraBars.BarButtonItem()
Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroup4 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
@ -86,7 +87,6 @@ Partial Class frmImportMain
Me.WorkspaceManager1 = New DevExpress.Utils.WorkspaceManager(Me.components)
Me.BehaviorManager = New DevExpress.Utils.Behaviors.BehaviorManager(Me.components)
Me.SplashScreenManager = New DevExpress.XtraSplashScreen.SplashScreenManager(Me, GetType(Global.MultiTool.Form.frmWaitForm), True, True)
Me.btnCalculatePrices = New DevExpress.XtraBars.BarButtonItem()
CType(Me.SplitContainerMain, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.SplitContainerMain.Panel1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainerMain.Panel1.SuspendLayout()
@ -373,6 +373,14 @@ Partial Class frmImportMain
Me.btnEditRow.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.editquery
Me.btnEditRow.Name = "btnEditRow"
'
'btnCalculatePrices
'
resources.ApplyResources(Me.btnCalculatePrices, "btnCalculatePrices")
Me.btnCalculatePrices.Enabled = False
Me.btnCalculatePrices.Id = 36
Me.btnCalculatePrices.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.bo_sale
Me.btnCalculatePrices.Name = "btnCalculatePrices"
'
'RibbonPage1
'
Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup1, Me.RibbonPageGroup4, Me.RibbonPageGroup3, Me.RibbonPageGroup7})
@ -600,13 +608,6 @@ Partial Class frmImportMain
'
Me.SplashScreenManager.ClosingDelay = 500
'
'btnCalculatePrices
'
resources.ApplyResources(Me.btnCalculatePrices, "btnCalculatePrices")
Me.btnCalculatePrices.Id = 36
Me.btnCalculatePrices.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.bo_sale
Me.btnCalculatePrices.Name = "btnCalculatePrices"
'
'frmImportMain
'
resources.ApplyResources(Me, "$this")

View File

@ -935,6 +935,12 @@
<data name="&gt;&gt;btnEditRow.Type" xml:space="preserve">
<value>DevExpress.XtraBars.BarButtonItem, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;btnCalculatePrices.Name" xml:space="preserve">
<value>btnCalculatePrices</value>
</data>
<data name="&gt;&gt;btnCalculatePrices.Type" xml:space="preserve">
<value>DevExpress.XtraBars.BarButtonItem, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;RibbonPage1.Name" xml:space="preserve">
<value>RibbonPage1</value>
</data>
@ -1055,12 +1061,6 @@
<data name="&gt;&gt;SplashScreenManager.Type" xml:space="preserve">
<value>DevExpress.XtraSplashScreen.SplashScreenManager, DevExpress.XtraEditors.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;btnCalculatePrices.Name" xml:space="preserve">
<value>btnCalculatePrices</value>
</data>
<data name="&gt;&gt;btnCalculatePrices.Type" xml:space="preserve">
<value>DevExpress.XtraBars.BarButtonItem, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>frmImportMain</value>
</data>

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